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
Flask: | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
if __name__ == "__main__": | |
app.run() |
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 Backbone.RaphaelView extends Backbone.View | |
delegateRaphaelEvents: (elements)-> | |
for name,element of elements | |
@delegateRaphaelElementEvents name, element | |
delegateRaphaelElementEvents: (name, element) -> | |
events = [ | |
"mouseup" | |
"mousedown" | |
"mousemove" | |
"mouseover" |
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
It's a mostly empty database with only 4 records being emitted from the view (with reduce=false) | |
curl -u hamiltop https://hamiltop.cloudant.com/cs360/_design/purchases/_view/most_recent?reduce=false | |
{"total_rows":4,"offset":0,"rows":[ | |
{"id":"22b7dd2f647009d2161c42bb46d6c5e7","key":["Peter",1338416091.0237810612],"value":10}, | |
{"id":"5c7c2731a493d8cfafd036a7a93415fc","key":["Peter",1338416093.9606831074],"value":30}, | |
{"id":"8d2c99d15c9f37e0af0244c643fe7c84","key":["Peter",1338416096.3526899815],"value":22}, | |
{"id":"22b7dd2f647009d2161c42bb46da3b52","key":["Peter",1338416107.6635489464],"value":19} | |
]} |
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
# my goal is for one module (of many) to use https://webcache.foo.com/ in place of /common/ for a set of static assets. | |
#here's what I have: | |
# root __init__.py | |
config.add_static_view('common', 'foo_web.layout:static/', cache_max_age=3600) | |
# my module __init__.py | |
config.add_static_view('https://webcache.foo.com/', 'foo_web.layout:cloudfront/', cache_max_age=3600) | |
config.override_asset( |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
var LastSeen = 1; | |
var waiting = 0; | |
var to_travel = 0; |
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
lib/dm-mongolitedb-adapter.rb | |
1 require 'dm-core' | |
2 require 'dm-core/adapters/abstract_adapter' | |
3 require 'mongolitedb' | |
4 | |
5 module DataMapper | |
6 module Adapters | |
7 class MongoLiteDBAdapter < AbstractAdapter | |
8 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
curl "http://store.apple.com/us/configUpdate/Z0PZ?option.macbookpro_processor_17=065-C1T0&option.macbookpro_storage=065-C1T5&option.macbookpro_usb_superdrive=none&option.apple_thunderbolt_display=none&option.macbook_pro_keyboard_and_os=065-C1TQ&option.iwork_keynote=065-C13G&option.iwork_pages=065-C13D&option.iwork_numbers=065-C13F&option.macbookpro_applecare=none&option.one_to_one=none&option.thunderbolt_to_gigabit_ethernet_adapter=065-C1T6&option.thunderbolt_to_firewire_adapter=065-C1T8&option.vga_adapter=065-C1TC&option.dvi_adapter=none&option.dual_link_dvi_adapter=none&option.magsafe_2_power_adapter_85w=none&option.magsafe_to_magsafe_2_converter=none&option.apple_thunderbolt_cable=none&option.external_storage=none&option.time_capsule=none&option.apple_tv_mac=none&option.printer_offers=none&fcs1=&fcs2=" -H "Cookie: ccl=tBtBE3lJ4LMSEepGlEUjGGOfRSsgiBpkseqQEyb0CJc=; geo=US; s_orientation=%5B%5BB%5D%5D; s_pathLength=homepage%3D1%2Cmac.tab%2Bother%3D1%2Cmacbookpro%3D1%2C; s_invisit_n2_us=3%2C0%2C26; s_vnum_n2_u |
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
curl "http://store.apple.com/us/configUpdate/Z0PZ?option.macbookpro_processor_17=065-C1T0&option.macbookpro_storage=065-C1T5&option.macbookpro_usb_superdrive=none&option.apple_thunderbolt_display=none&option.macbook_pro_keyboard_and_os=065-C1TQ&option.iwork_keynote=065-C13G&option.iwork_pages=065-C13D&option.iwork_numbers=065-C13F&option.macbookpro_applecare=none&option.one_to_one=none&option.thunderbolt_to_gigabit_ethernet_adapter=065-C1T6&option.thunderbolt_to_firewire_adapter=065-C1T8&option.vga_adapter=065-C1TC&option.dvi_adapter=none&option.dual_link_dvi_adapter=none&option.magsafe_2_power_adapter_85w=none&option.magsafe_to_magsafe_2_converter=none&option.apple_thunderbolt_cable=none&option.external_storage=none&option.time_capsule=none&option.apple_tv_mac=none&option.printer_offers=none&fcs1=&fcs2=" -H "Cookie: ccl=tBtBE3lJ4LMSEepGlEUjGGOfRSsgiBpkseqQEyb0CJc=; geo=US; s_orientation=%5B%5BB%5D%5D; s_pathLength=homepage%3D1%2Cmac.tab%2Bother%3D1%2Cmacbookpro%3D1%2C; s_invisit_n2_us=3%2C0%2C26; s_vnum_n2_u |
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
I would like to go from: | |
Bundle.find_by_sql("select bundles.name, bundles.id, if(bundles.max_count > 100, 1, 0) as big from bundles;") | |
to something more like: | |
Bundle.select([:name,:id,"if(bundles.max_count > 100, 1, 0)"]).all | |
That way I could continue to chain on where clauses and such. |
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
Stream.interval(1000) | |
|> Stream.map fn(_) -> get_memory_usage end | |
|> Stream.chunk(60) # group every 60 seconds together | |
|> Stream.map &( {Enum.min(&1), Enum.max(&1)} ) | |
|> Enum.each fn ({min, max) -> | |
send_to_graphite("min_memory_usage", min) | |
send_to_graphite("max_memory_usage", max) | |
end |
OlderNewer