Skip to content

Instantly share code, notes, and snippets.

View boogie666's full-sized avatar

Bogdan Bugarschi boogie666

  • Timisoara
View GitHub Profile
@boogie666
boogie666 / click_position.js
Last active May 23, 2018 10:44
Example Transducer for tim.js
// example of get the position of the cursor in a line of a text buffer from a click event
function clickPositionToCharIndex(clickX){
return comp(
map(measureCharWidth),
reductions((a,b) => a + b, 0),
takeWhile(x => x < clickX),
mapIndexed((idx, item) => idx)
);
}
@boogie666
boogie666 / tiny-tiny-lisp.js
Last active April 6, 2018 07:44
128 char lisp interperter
//the interperter
e=(s,c)=>s/s?s:s.trim?c(s):(S=s[0],S=="if"?e(s[1],c)?e(s[2],c):e(s[3],c):S=="f"?a=>e(s[2],n=>s[1]==n?a:c(n)):e(S,c)(e(s[1],c)));
//global ctx
function global_scope(name){
if(name === "log")
return item => console.log(item);
if(name === "+")
return a => b => a + b;
if(name === "<")
@boogie666
boogie666 / arp-lang.js
Last active February 12, 2018 11:56
a really bad, really slow, poorly coded, but turing complete version of a lisp :)
// a basic 'scope' for our language...
// it will never have globals...
// so it will thorw by default.
function ctx(name){
throw name + " is undefined";
}
/**
;; -*- 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
console.log 'fixing keybindigs'
atom.keymaps.keyBindings.forEach (x) ->
if x.keystrokes == 'g ^'
x.keystrokes = 'g shift-6'
x.keystrokeArray = ['g', 'shift-6']
@boogie666
boogie666 / channels.clj
Created July 9, 2017 09:52
core.async difference between pipe and pipeline
(into [] (partition-by #(not= % :spliter)) [1 2 3 4 :spliter 4 3 2 1 :spliter])
;; ^^^^ this is like the base case. output is [[1 2 3 4] [:spliter] [4 3 2 1] [:spliter]]
(def in (chan))
(def out (chan 1 (partition-by #(not= % :spliter))))
(pipe in out)
@boogie666
boogie666 / fizzbuzz.clj
Last active December 5, 2017 00:18
Lazy Functional FizzBuzz in Clojure
(ns fizzbuzz.core)
(defn str-max [a b]
(if (<= (compare a b) 0) b a))
(def fizzes (cycle ["" "" "fizz"]))
(def buzzes (cycle ["" "" "" "" "buzz"]))
(def numbers (sequence (comp (map inc) (map str)) (range)))
@boogie666
boogie666 / html.cljs
Created May 8, 2017 15:58
Parsing Hiccup with clojure spec
(ns test.html
(:require [clojure.spec :as s]
[clojure.string :as string])
(:require-macros [cljs.spec :as s]))
(def non-closing-elements
#{:area :base :br :col :command
:embed :hr :img :input :link
:meta :keygen :param :source
:track :wbr})
@boogie666
boogie666 / screen.sh
Created April 23, 2017 17:15
resolutions
xrandr --newmode 1920x1080_60.00 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode eDP1 1920x1080_60.00
xrandr --output eDP1 --mode 1920x1080_60.00 --rate 60
@boogie666
boogie666 / .proton
Last active September 7, 2017 22:40
Proton config
{
;; Layers you wish to have active
;; To get a list of all available layers, check github.com/dvcrn/proton/tree/master/src/cljs/proton/layers
:layers
[
;; -----------------------------------
;; core layer. Don't remove.
;; -----------------------------------
:core