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
async.waterfall [ | |
(cb) -> doStuff(cb) | |
(result, cb) -> doOtherStuff(result, cb) | |
(someOtherResult, cb) -> finally(someOtherResult, cb) | |
], (err, res) -> | |
console.log 'res is', res | |
# ᕕ( ᐛ )ᕗ WELP | |
async.waterfall [ |
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
React.renderComponent( | |
<MomentPreviewList data={previewList}/>, | |
document.getElementById('moment-live-feed') | |
) |
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 makeN(n, obj) { | |
// gotta use .apply(null) because Array(n) makes a new empty array of size n and map behaves starngely | |
// Array.apply(null, Array(n)) creates an array of size n with undefined as the value of every item | |
// we can then call map on it to get back an array with n `obj`s. | |
return Array.apply(null, Array(n)).map(function() { return obj; }); | |
} |
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
/** @jsx: React.DOM */ | |
var React = require('react'); | |
var IfThingy = React.createClass({ | |
render: function() { | |
var ifThingy; | |
if (this.props.someVar) { | |
ifThingy = <h1>Some Var Is {this.props.someVar}</h1>; | |
} | |
else { |
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 durp.handler | |
(:require [compojure.core :as cc] | |
[compojure.handler :as handler] | |
[ring.util.response :refer [response]] | |
[ring.middleware.json :as json])) | |
(cc/defroutes app-routes | |
(cc/POST "/user/:user-id" [user-id {:body body}] (response (body)))) | |
(def app |
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
(defn decrement-char-count [char-map character] | |
(let [new-char-map (assoc char-map character (dec (get char-map character 0)))] | |
[(new-char-map character) new-char-map])) | |
(defn make-char-map [string] | |
(reduce (fn [char-map character] (assoc char-map character (inc (get char-map character 0)))) {} (seq string))) | |
(defn permutation? [str1 str2] | |
"return true if str2 can be formed by some permutation of str1, false otherwise" | |
(let [str1-map (make-char-map str1)] |
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
var React = require('react'); | |
var History = require('immutable-history'); | |
// call `render` whenever the cursor changes | |
var state = new History({posts: [], username: 'Jamitron The Terrible'}, render); | |
var App = React.createClass({ | |
render: function() { | |
var postsCursor = this.props.data.cursor(['posts']); | |
return <div> |
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
(defn products-of-ints [nums] | |
"Takes an array of integers and returns an array of integers where the | |
element at each index is the product of all the other elements except the | |
element at that index multiplied." | |
(let [product-of-every-num (reduce * nums)] | |
(map #(/ product-of-every-num %) nums))) |
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
f :: Int -> [Int] -> [Int] | |
f n arr = -- Complete this function | |
concat $ map (makeN n) arr | |
makeN :: Int -> (Int -> [Int]) | |
makeN n = | |
(\x -> map (\i -> x) [1..n]) | |
-- This part handles the Input and Output and can be used as it is. Do not modify this part. |
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
-- see http://learnyouahaskell.com/recursion#quick-sort | |
quicksort' :: (Ord a) => [a] -> [a] | |
quicksort' [] = [] | |
quicksort' (x:xs) = | |
let biggerSorted = quicksort' [a | a <- xs, a > x] | |
smallerSorted = quicksort' [a | a <- xs, a <= x] | |
in smallerSorted ++ [x] ++ biggerSorted |
OlderNewer