-
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.
-
Reset PS3 controller by inserting paperclip into pinhole near L2 button.
-
Connect PS3 controller to Mac with USB cable.
-
Enable Bluetooth.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Reduced | |
@isReduced = (obj) -> obj instanceof Reduced | |
constructor: (@wraped) -> | |
unwrap: -> @wraped | |
reduce = (collection, fn, seed) -> |
i " вставить текст до курсора
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = | |
element | |
validchar = [0-9a-zA-Z\-_\{\}\.\:\/] | |
_ = [ \t\r\n]* | |
tagAttrs = | |
_ name:validchar+ '="' value:validchar+ '"' _ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = []) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |