Skip to content

Instantly share code, notes, and snippets.

View Clokze's full-sized avatar

Alexandru Bularca Clokze

  • EveryMatrix
  • Bucharest, Romania
View GitHub Profile
defmodule KVServer.Command do
@doc ~S"""
Parses the given `line` into a command.
## Examples
iex> KVServer.Command.parse "CREATE shopping\r\n"
{:ok, {:create, "shopping"}}
iex> KVServer.Command.parse "CREATE shopping \r\n"
defmodule Math do
def fibonnaci(n, prev \\ 0, current \\ 1)
def fibonnaci(n, _prev, current) when n < 1 do
IO.puts(current)
end
def fibonnaci(n, prev, current) do
fibonnaci(n - 1, current, current + prev)
end
@Clokze
Clokze / math.ex
Last active August 29, 2015 14:23
elixir reduce
defmodule Math do
def sum_list([head|tail], accumulator) do
sum_list(tail, head + accumulator)
end
def sum_list([], accumulator) do
accumulator
end
end
[Nemesis, Ninja Ratter]
Damage Control II
Micro Auxiliary Power Core I
1MN Afterburner II
Medium Shield Extender II
Thermic Dissipation Field II
Kinetic Deflection Amplifier II
Covert Ops Cloaking Device II
Prototype 'Arbalest' Torpedo Launcher, Inferno Torpedo
Prototype 'Arbalest' Torpedo Launcher, Inferno Torpedo
@Clokze
Clokze / keybase.md
Created April 13, 2014 10:12
Keybase proof gist

Keybase proof

I hereby claim:

  • I am arcade on github.
  • I am alexbularca (https://keybase.io/alexbularca) on keybase.
  • I have a public key whose fingerprint is F909 BA7B D56D A6E5 0768 7331 22E9 26E2 0EB5 E562

To claim this, I am signing this object:

http://jsfiddle.net/TheSharpieOne/N7YuP/3/
@Clokze
Clokze / gist:8803231
Created February 4, 2014 13:04
getter/setter
class Person
get = (props) => @::__defineGetter__ name, getter for name, getter of props
set = (props) => @::__defineSetter__ name, setter for name, setter of props
# @property [String] The person name
get name: -> @_name
set name: (@_name) ->
# The persons age
@Clokze
Clokze / fiddle.html
Created December 4, 2013 14:39
JSFiddle stuff
<!DOCTYPE html>
<html>
<head>
<title>foo</title>
<style>
textarea {
width: 100%;
height: 300px;
}
</style>
@Clokze
Clokze / gist:7681927
Created November 27, 2013 19:42
Fibers fibonacci
var Fiber = require('fibers');
// Generator function. Returns a function which returns incrementing
// Fibonacci numbers with each call.
function Fibonacci() {
// Create a new fiber which yields sequential Fibonacci numbers
var fiber = Fiber(function() {
Fiber.yield(0); // F(0) -> 0
var prev = 0, curr = 1;
while (true) {
@Clokze
Clokze / gist:7681880
Created November 27, 2013 19:39
pseudocode of sync wrapper
function readFile (file) {
var f = generator(function () {
fs.readFile(file, function (err, data) {
yield data;
}
}
return f.run();
}