Skip to content

Instantly share code, notes, and snippets.

View ChillyBwoy's full-sized avatar
🕶️
(ノ ˘_˘)ノ ζ|||ζ ζ|||ζ ζ|||ζ

Eugene Cheltsov ChillyBwoy

🕶️
(ノ ˘_˘)ノ ζ|||ζ ζ|||ζ ζ|||ζ
  • 東京都
View GitHub Profile
@ChillyBwoy
ChillyBwoy / gist:6172771
Last active March 29, 2017 14:42 — forked from statico/gist:3172711
How to use a PS3 controller on Mac OS X 10.7 (Lion)

How to use a PS3 controller on Mac OS X 10.7 (Lion)

  1. Open Apple menu -> System Preferences -> Bluetooth and disable Bluetooth on Mac as well as any other nearby Macs or devices which will try to pair with and confuse the controller.

  2. Reset PS3 controller by inserting paperclip into pinhole near L2 button.

  3. Connect PS3 controller to Mac with USB cable.

  4. Enable Bluetooth.

@ChillyBwoy
ChillyBwoy / 2048.clj
Last active March 29, 2017 14:43 — forked from luisgerhorst/2048.clj
Clojure implementation of 2048
(def grid (insert [[nil nil nil nil]
[nil nil nil nil]
[nil nil nil nil]
[nil nil nil nil]]))
;; Grid functions.
(defn move
"Moves all field to the choosen direction, merges fields and inserts field value for random free location. Returns nil if game is over. Returns same grid if move doesn't change the grid."
[grid direction]
@ChillyBwoy
ChillyBwoy / core.cljs
Created May 22, 2014 23:54
Simple particles in ClojureScript
(ns particles.core)
(def display (.getElementById js/document "display"))
(def context (.getContext display "2d"))
(def damping 0.999)
(def max-particles 250)
(def line-width 2)
(def app-state (atom {:width (.-innerWidth js/window)
:height (.-innerHeight js/window)}))
@ChillyBwoy
ChillyBwoy / transducers.coffee
Last active March 30, 2017 14:55
Transducers CoffeeScript
class Reduced
@isReduced = (obj) -> obj instanceof Reduced
constructor: (@wraped) ->
unwrap: -> @wraped
reduce = (collection, fn, seed) ->
@ChillyBwoy
ChillyBwoy / vim-cheatsheet_ru.md
Last active March 29, 2017 14:43 — forked from A/vim-cheatsheet_ru.md
Vim cheatsheet

Конфиги

Навигация

Различные способы перехода в режим вставки

i " вставить текст до курсора
@ChillyBwoy
ChillyBwoy / readme.md
Last active August 1, 2017 19:26
IIFE Parentheses

If you don't care about the return value of the IIFE, it could also be any of the following:

!function(){}();  // => true
~function(){}(); // => -1
+function(){}(); // => NaN
-function(){}();  // => NaN

Let's explore this a bit more.

@ChillyBwoy
ChillyBwoy / multimethod.js
Last active March 29, 2017 14:47
Multimethod in js
function multi(pred) {
const methods = new Map();
const fn = (...args) => {
const f = methods.get(pred(...args));
return f ? f(...args) : null;
};
fn.method = (predKey, methodFn) => {
methods.set(predKey, methodFn);
@ChillyBwoy
ChillyBwoy / fest.pegjs
Created October 20, 2015 10:51
peg.js rules for parsing fest-templates
start =
element
validchar = [0-9a-zA-Z\-_\{\}\.\:\/]
_ = [ \t\r\n]*
tagAttrs =
_ name:validchar+ '="' value:validchar+ '"' _ {
@ChillyBwoy
ChillyBwoy / index.js
Created January 20, 2016 13:55
FizzBuzz
// with array. More more more faster
Array.apply(null, Array(100)).map((_, i) => {
var n = i + 1;
return (n % 3 === 0 && n % 5 === 0 ? 'FizzBuzz' :
(n % 3 === 0 ? 'Fizz' :
(n % 5 === 0 ? 'Buzz' : n)))
});
// with recursion
const fizzBuzz = (size, acc = []) => {
@ChillyBwoy
ChillyBwoy / fn.js
Last active March 29, 2017 14:38
fn with acc
function fibonacci (n) {
const fn = (n, a, b) => n === 0 ? a : fn(n - 1, a + b, a);
return fn(n, 0, 1);
};
function factorial (n) {
const fn = (n, acc) => n === 0 ? acc : fn(n - 1, n * acc);
return fn(n, 1);
}