Ctrl+KB | toggle side bar |
Ctrl+Shift+P | command prompt |
Ctrl+` | python console |
Ctrl+N | new file |
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 | |
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 |
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
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>(); |
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 '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 |
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:
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
** (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) |
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 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) |
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
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 |
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
defmodule Thinker.User do | |
use Thinker.Web, :model | |
schema "users" do | |
field :username, :string | |
timestamps | |
end | |
@required_fields ~w(username) | |
@optional_fields ~w() |
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
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"} | |
] |
OlderNewer