I hereby claim:
- I am rockneurotiko on github.
- I am rockneurotiko (https://keybase.io/rockneurotiko) on keybase.
- I have a public key whose fingerprint is 4946 D290 EC2E 817F F126 E0B7 B6AE 2B3F BD58 B1CD
To claim this, I am signing this object:
defmodule StrongParams do | |
def extract(params, allowed_fields, atomize \\ false) | |
def extract(params, allowed_fields, atomize) when not is_list(allowed_fields), | |
do: extract(params, [allowed_fields], atomize) | |
def extract(params, allowed_fields, atomize) | |
when is_map(params) and is_list(allowed_fields) do | |
Enum.reduce(allowed_fields, %{}, fn field, acc -> | |
case extract_field(field, params, atomize) do |
import json | |
class DictSave(dict): | |
def save(self, fpath): | |
with open(fpath, 'w') as f: | |
json.dump(self, f) | |
def load(self, fpath): | |
with open(fpath, 'r') as f: | |
self = json.load(f) | |
return self |
// Part one | |
println(io.StdIn.readLine.foldLeft(0) { | |
case (cur, '(') => cur + 1 | |
case (cur, ')') => cur - 1 | |
case (cur, _) => cur | |
}) | |
// Part two | |
println(io.StdIn.readLine.scanLeft(0) { | |
case (cur, '(') => cur + 1 |
var FIDASHRequests = (function() { | |
"use strict"; | |
// http://stackoverflow.com/questions/1714786/querystring-encoding-of-a-javascript-object | |
var serialize = function serialize(obj) { | |
var str = []; | |
for(var p in obj) | |
if (obj.hasOwnProperty(p)) { | |
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | |
} | |
return str.join("&"); |
I hereby claim:
To claim this, I am signing this object:
import functools | |
def tail_call(func): | |
def _optimize_partial(*args, **kwargs): | |
old_reference = func.__globals__[func.__name__] | |
func.__globals__[func.__name__] = functools.partial(functools.partial, func) | |
to_execute = functools.partial(func, *args, **kwargs) | |
while isinstance(to_execute, functools.partial): |
from typing import List, Tuple | |
def calc_overload(out: List[int], ins: List[int]) -> List[int]: | |
out1, out2 = out[0], out[1] | |
in1, in2 = ins[0], ins[1] | |
if out1 <= in1 < out2 < in2: # Case right overlap: [1, 50] with [32, 60] | |
return [out1, in2] | |
if out1 <= in1 < out2 >= in2: # Case inside: [1, 50] x [20, 40] | |
return [out1, out2] | |
if in1 < out1 < in2: # left overlap and full overlap: 1) [20, 30] x [10,25] and [20, 30] x [10, 40] |
import scala.annotation.tailrec | |
object criba { | |
def basic_get_primes(n: Int): List[Int] = { | |
val primes = List.range(2, n+1) | |
var max = Math.sqrt(n).toInt | |
@tailrec | |
def tal_rec(now: Int, prim: List[Int]): List[Int] = { | |
if(now >= max) prim |