This file contains hidden or 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
| reduce for x <- [1,2,3], | |
| y <- [3,4,5], | |
| {n,m} = {2,3}, | |
| x != 2, | |
| acc: {sum, product} = {0,1} do | |
| {sum + x + y + n + m, product*x*y*n*m} | |
| end |
This file contains hidden or 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
| defmodule ConcatTest do | |
| def append do | |
| 1..10000 |> Enum.reduce([], fn (x, acc) -> | |
| acc ++ [x] | |
| end) | |
| end | |
| def prepend do | |
| 1..10000 |> Enum.reduce([], fn (x, acc) -> | |
| [x] ++ acc | |
| end) |> Enum.reverse |
This file contains hidden or 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
| defmodule Coercion do | |
| defmacro get({:when, _, [path, {:is_integer, _, [{val, _, _}]}]}) do | |
| {path, [{val, :integer}]} | |
| end | |
| defmacro get(route) do | |
| {route, []} | |
| end | |
| end | |
| defmodule Route do |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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( |