Skip to content

Instantly share code, notes, and snippets.

Sublime Text 2 – Useful Shortcuts (Windows)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command prompt
Ctrl+` python console
Ctrl+N new file

Editing

#!/usr/bin/env ruby
class Array
def avg
self.inject(:+).fdiv(self.length)
end
end
g = [5,4,6,5,5,6,7,6,4,234234,2,4,4,3,43]
puts g.avg
package cmsc433.p1;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class SimpleGraph<T> {
HashMap<Node, HashSet<Node>> graph = new HashMap<Node, HashSet<Node>>();
HashMap<T, Node> nodeCache = new HashMap<T, Node>();
#!/usr/bin/env ruby
require 'open-uri'
require 'JSON'
require 'digest/sha2'
require 'pry'
require 'bigdecimal'
require 'bitcoin' # Because I need to cheat every now and then
# Usage:
# gem install pry json ffi ruby-bitcoin

Keybase proof

I hereby claim:

  • I am arthurcolle on github.
  • I am arthurcolle (https://keybase.io/arthurcolle) on keybase.
  • I have a public key whose fingerprint is 3F3E 4B04 E173 8BDD 299E 0B15 18C9 D0D0 9094 2A26

To claim this, I am signing this object:

** (EXIT from #PID<0.80.0>) an exception was raised:
** (FunctionClauseError) no function clause matching in HashDict.dict_delete/2
(elixir) lib/hash_dict.ex:90: HashDict.dict_delete([], "milk")
(elixir) lib/hash_dict.ex:68: HashDict.pop/3
(elixir) lib/agent/server.ex:20: Agent.Server.handle_call/3
(stdlib) gen_server.erl:607: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:639: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
Interactive Elixir (1.1.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
@stochastic-thread
stochastic-thread / gist:60e08655508b3b4b80c5
Created April 26, 2015 07:27
Are these two functions "the same" ?
def delete(bucket, key) do
Agent.get_and_update(bucket, &HashDict.pop(&1, key))
end
vs.
def delete(bucket, key) do
Agent.get_and_update(bucket,
fn dict -> HashDict.pop(dict, key)
end)
@stochastic-thread
stochastic-thread / Quicksort
Created April 27, 2015 05:57
Quicksort in Elixir
defmodule Sorting do
def qsort(list) do
case list do
[] -> []
_ ->
[h|t] = list
qsort(for n <- t, n < h, do: n)
++ [h] ++
qsort(for n <- t, n >= h, do: n)
end
defmodule Thinker.User do
use Thinker.Web, :model
schema "users" do
field :username, :string
timestamps
end
@required_fields ~w(username)
@optional_fields ~w()
defp deps do
[{:phoenix, "~> 0.12"},
{:postgrex, ">= 0.0.0"},
{:ecto, "~> 0.11.2"},
{:phoenix_live_reload, "~> 0.3"},
{:poolboy, "~> 1.5.1", optional: true},
{:exrethinkdb, github: "hamiltop/exrethinkdb", ref: "master"},
{:cowboy, "~> 1.0"},
{:addict, github: "trenpixster/addict", ref: "master"}
]