Time Difference between Time.now and 1.day.ago

My app time_zone is set to UTC(default, I didn't change it in config/application.rb). This is what I see in rails console 1.9.3p194 :004 > Time.now => 2014-03-20 14:45:23 -0500 1.9.3p194 :005 > 1.day.ago => Wed, 19 Mar 2014 19:45:48 UTC +00:00

Mysql Left join with condition on column

can you help me with sql query? I have this problem: I have two tables "Join" table: Reservation_has_meal +----------------+ | id_reservation | | id_meal | | pieces | +----------------+ and table with data: Meal +-------------+ | id_meal | | nam

Remove all local git branches

I follow a development process where I create a new local branch for every new feature or story card. When finished I merge the branch into master and then push. What tends to happen over time due to a combination of laziness or forgetfulness, is tha

Maintain i18n resources synchronized

I am looking for an editor/comparator for i18n property files that would help me keep different language files in sync. Basically, something that would compare a bunch a of property files and show which keys are not present in a particular language.

Serializing a datetime

What would be the best way to perform binary serialization of a date/time pair? My best guess so far is to store the number of seconds since the epoch, as returned by the POSIX time() and mktime() functions, and then translate it back to "human reada

Creating a trigger stream with PopUp

I built a triggerField and when i press at it, i want to have a popup, that is appended to the button in the triggerfield(so when i click anywhere else it shall disappear and it shall pop out up to the button when i click at the button just like a da

Insert doubled and mdash; In the SQLite database

I have some text which I need to put in an sqlite database. I do not know how to make sqlite accept the double minus in the text because sqlite treats it as a comment. How can I do it?Are you sure you're putting the string into quotation marks? Like

A: Create a specific tray based on the data range

I am attempting to repeatedly add a "fixed number" to a numeric vector depending on a specified bin size. However, the "fixed number" is dependent on the data range. For instance ; i have a data range 10 to 1010, and I wish to separate

How to write tests with simulacres using f #

I'd like to write F# unit test with mock objects. I'm using NUnit. But unfortunately I couldn't find any examples. Here's an example of the code under test: type ICustomer = interface abstract Id: int with get abstract Name: string with get abstract

java equivalent of python regex

I am new to android development. And now i am struck with a regex pattern. I had tried many things but in vain. I am trying to find the java equivalent of the regular expression "r'\^\d+\~[A-Za-z~ ]+'" which is written in python. Thanks in advan

Index Suggestion for a Table with ID Columns

I have a table whose all columns store ids of other tables (huge tables). CREATE TABLE #mytable ( Table1Id int, Table2Id int, Table3Id int, Table4Id int, Table5Id int, ) Now my select has join to all the tables whose ids are stored in the columns of

pandas DataFrame assign with format

I'm trying to use assign to create a new column in a pandas DataFrame. I need to use something like str.format to have the new column be pieces of existing columns. For instance... import pandas as pd df = pd.DataFrame(np.random.randn(3, 3)) gives me

Process.Start () and the process tree

How can I use Process.Start(), but have the launched process not in the same process tree as the launching process? Consider this sample console application: using System; using System.Diagnostics; using System.Threading; internal class Program { pri

ActionBarCompat: add a separator between menu items

I use ActionBarCompat to add an ActionBar to my Activities. In the ActionBar one can add 3 items which are displayed with an icon. I want to have a separator (vertical line) between the items. I was looking for a layout file where I can add a margin

Connection string to connect to the MySql database?

I am trying to connect MySql database to my forms. I got the connection string my right clicking on my database connection and going to properties. connection.ConnectionString = "server=localhost;user id=root;database=island_dealership;"+ "

Read serial port data in c #

I am trying to read data from the serial port. The data comes off of a scale. I first send a command to start reading the scale. _serialPort.Write("P"); then after waiting for some time I am trying to read using temp2 = _serialPort.ReadLine(); T

How to edit a .xib file outside of xcode?

I have a .xib file. I open it up with textfile or Dashcode or what ever. Say it has 4 buttons on it. All the same but with different titles. My goal is to change the color, font, and background image outside of xcode automatically and then import the

Dynamic columns and records from openxml in sql

I have an xml document that's pretty straightfoward. The only difference is that the elements can change. One time I might have: <data><PersonalInfo> <Person><FirstName>Bob</FirstName><LastName>Smith</LastName><

hang the thread for one second in C

how can I sleep for 1s in a C app? I want to disconnect a socket, so I want to sleep for a second and trigger the timeout. In Java it's Thread.sleep(1000); Thanks a lotThe C specification doesn't really cover threads, so you'll need a platform specif

Php mail does not work perfectly with prospects

I have a problem using PHP to send mail. The mail is received by Outlook correctly, but it does not show the "From" address in the e-mail. $subject = $_POST['message_subject']; $message = $_POST['speaker_description']; $email = $_POST['email'];

What are the alternatives to the IRB?

In the python world, there are a number of alternative python interpreters that add cool additional features. One particularly useful example is bpython, which adds dynamic syntax highlighting, automatically pulls documentation, and displays live aut

How to export data to CSV in PowerShell?

foreach ($computer in $computerlist) { if((Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) { foreach ($file in $REMOVE) { Remove-Item "\\$computer\$DESTINATION\$file" -Recurse Copy-Item E:\Code\powershell\shortcuts\* "\

Can I read the AssemblyFile information in Inno Setup

I would like to read these three values from my application.exe in my Inno Setup script. [assembly: AssemblyCompany("My Company")] [assembly: AssemblyProduct("My Great Application")] [assembly: AssemblyFileVersion("9.3.2")] D

GWT celltable - delete button does not delete table row

I added a buttoncell column to a celltable using the following code: public class CellTableExample implements EntryPoint { private static class Contact { private String address; private String name; public Contact(String name, String address) { super