Skip to content

Instantly share code, notes, and snippets.

function alphabet() {
let letter =
arguments.length > 0 ?
arguments[0] :
"a";
let next = String.fromCharCode(letter.charCodeAt(0)+1);
return next == "z" ?
next :
letter + alphabet(next);
@frenata
frenata / robot.go
Created April 9, 2017 06:13
Advent of Code 2016 #10, solution with Go and channels
package main
import (
"bufio"
"fmt"
"io"
"os"
"regexp"
"strconv"
)
@frenata
frenata / people.py
Last active April 23, 2017 16:30
no metadata!
from pupa.scrape import Person, Scraper
import lxml.html
import re
import pdb
class IAPersonScraper(Scraper):
jurisdiction = 'ia'
def scrape(self, chamber=None):
@frenata
frenata / GHCi usage
Created October 12, 2017 20:37
Haskell Hashtables!
table = mkHashTable 10
table
|> insert ("bob", "bob metadata")
|> insert ("alice", "alice metadata")
|> delete "bob"
|> search "bob"
import Data.Char
import Data.Monoid
zipRot :: Int -> [a] -> [(a, a)]
zipRot n xs =
let rotXs = (drop n xs) ++ (take n xs)
in zip xs rotXs
captcha :: (Monoid a, Eq a) => Int -> [a] -> a
captcha n xs =
@frenata
frenata / Boilerplate.elm
Created May 4, 2018 13:46
Elm Boilerplate
module Monitor exposing (..)
import Html exposing (..)
{-| Single source of truth
-}
type alias Model =
{ text : String }
@frenata
frenata / http.coco
Created May 26, 2018 17:43
http headers in coconut
import sys
import requests as req
def get(url) =
outputs |> fmap$(print) where:
result = url |> req.get
status = (result
|> .status_code
|> "Status Code: {}".format$())
@frenata
frenata / core.clj
Last active March 28, 2019 20:40
4clojure
(ns for-clj.core)
;; utils
(defn
digits [n base]
(loop [n n b base acc '()]
(let [[q m] ((juxt quot mod) n b)
d (/ (* base m) b)]
(if (> q 0)
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@frenata
frenata / .tmux.conf
Last active February 12, 2020 18:45
set -g default-terminal "screen-256color"
# keybindings
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
unbind C-b
set-option -g prefix `
bind-key ` send-prefix