This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT created_on, note_count, sum(note_count) OVER (ORDER BY created_on ASC) | |
FROM ( | |
SELECT date_trunc('day', created_at) AS created_on, count(1) AS note_count | |
FROM notes | |
GROUP BY created_on | |
ORDER BY created_on DESC | |
) AS note_counting; | |
-- WHERE created_on >= '2013-01-01' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dm-core' | |
class BooleanChar < DataMapper::Property::String | |
def primitive?(value) | |
super || value == true || value == false | |
end | |
# prepare for model use | |
def load(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/init/ruby-example-upstart.conf | |
description "Ruby example upstart conf" | |
# change to the user you want to run this ruby script as | |
setuid deploy | |
setgid deploy | |
# This starts upon bootup and stops on shutdown | |
# check runlevel of running system with `runlevel` command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order to to add a new task for Problem 3 in the UI above, I'm hoping for a route that's something like `/problems/3/tasks/new`. This style is, of course, very much like what Rails uses. | |
Below is a cut down version of the router setup I'm using to to try to accomplish this URL structure. It seems strange to have a resource "problem" inside of a resource "problems", but the edit for that problem is ouside the individual problem, but inside of problems (plural). | |
Either way, all of this is structured in such a way as to give me the UI above, and the URL I'd like to use. To couple the UI and the URL together feels like it makes things very brittle in the router, and makes me fight against Embers' conventions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
setup_window | |
end | |
def window | |
@window ||= UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):003:0> pp Wisp.info(File.expand_path('~/Dropbox/Projects/created_or_updated.wsp'));nil | |
{:aggregation_method=>"average", | |
:max_retention=>94608000, | |
:x_files_factor=>0.5, | |
:archives=> | |
[{:offset=>64, | |
:seconds_per_point=>10, | |
:point_count=>241920, | |
:retention=>2419200, | |
:size=>2903040}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
gem 'celluloid-zmq', '0.15.0' | |
require 'celluloid' | |
require 'celluloid/zmq' | |
class Publisher | |
include Celluloid::ZMQ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options = OpenStruct.new({a: 1, b: 2}) | |
# make options[] work in 1.9 like 2.0 | |
unless options.respond_to?(:[]) | |
options.extend(Forwardable) | |
options.def_delegators :@table, :[], :[]= | |
end | |
# now I can do | |
options[:a] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'mail' | |
today = Time.now.strftime('%Y-%m-%d') | |
options = { :address => "smtp.gmail.com", | |
:port => 587, | |
:domain => '<your domain>', | |
:user_name => '<your full email>', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -Ilib | |
require 'pp' | |
require 'oauth2' | |
require 'legato' | |
module OAuth2Helpers | |
def build_client(id, secret) | |
opts = { | |
:authorize_url => 'https://accounts.google.com/o/oauth2/auth', |