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
[1,2,3,4,5].each_cons(2).each_with_index do |(a, b), i| | |
p a | |
p b | |
p i | |
end |
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
# connection and profile selection skipped | |
class Pageview | |
extend Legato::Model | |
metrics :pageviews | |
dimensions :pagePath, :date | |
filter :for_path, &lambda { |path| contains(:pagePath, path) } | |
end |
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
def wait_for_notify(&block) | |
io = pg_connection.socket_io | |
while @listening do | |
Celluloid::IO.wait_readable(io) # blocks execution, but unblocks this actor | |
pg_connection.consume_input # fetch any input on this connection | |
# read the NOTIFY messages off the socket | |
while notification = pg_connection.notifies do | |
block.call( |
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
letter | frequency | |
---|---|---|
A | .08167 | |
B | .01492 | |
C | .02782 | |
D | .04253 | |
E | .12702 | |
F | .02288 | |
G | .02015 | |
H | .06094 | |
I | .06966 |
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
import os; path=sublime.packages_path(); (os.makedirs(path) if not os.path.exists(path) else None); window.run_command('exec', {'cmd': ['git', 'clone', 'https://github.com/titoBouzout/SideBarEnhancements', 'SideBarEnhancements'], 'working_dir': path}) | |
import os; path=sublime.packages_path(); window.run_command('exec', {'cmd': ['git', 'checkout', '37429739a0452a2dc36343fb7875ba7fcbeb88a9'], 'working_dir': os.path.join(path, 'SideBarEnhancements')}) |
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
// Added to the bottom of tests/unit/model/errors_test.js | |
var env, store, Person, Dog; | |
module("unit/model/errors - model.save() triggers errors", { | |
setup: function() { | |
Person = DS.Model.extend({ | |
firstName: DS.attr(), | |
lastName: DS.attr() | |
}); |
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
function convertId(id) { | |
if (id == null) return id; | |
id = id.replace(/\"/g, ''); | |
if (id.length != 15) { | |
return null; | |
} | |
var suffix = ""; | |
for (var i = 0; i < 3; i++) { | |
var flags = 0; | |
for (var j = 0; j < 5; j++) { |
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
import sublime_plugin | |
class AlwaysCenterCommand(sublime_plugin.EventListener): | |
def on_modified(self, view): | |
sel = view.sel() | |
region = sel[0] if len(sel) == 1 else None | |
if region != None: | |
view.show_at_center(region) |
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
CREATE OR REPLACE VIEW next_episode_ids AS ( | |
SELECT id, ROW_NUMBER() OVER(PARTITION BY show_id ORDER BY airs_on) AS r | |
FROM episodes | |
WHERE airs_on >= NOW() | |
); | |
CREATE OR REPLACE VIEW next_episodes AS ( | |
SELECT * FROM episodes WHERE id IN ( | |
SELECT id FROM next_episode_ids WHERE r = 1 | |
) |
OlderNewer