This file contains hidden or 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
defmodule Project.AppleApi do | |
@moduledoc """ | |
Apple API: https://developer.apple.com/documentation/appstoreserverapi/creating_api_keys_to_use_with_the_app_store_server_api | |
Relies on Confex and having the following configuration in config/config.exs | |
``` | |
config :project, Project.Apple, | |
api_url: {:system, "PROJECT_APPLE_URL", ""}, | |
certificate: {:system, "PROJECT_APPLE_CERTIFICATE", ""}, |
This file contains hidden or 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
const reduce = (array, callback, initialValue) => { | |
let result; | |
for(let i = 0; i < array.length; i++) { | |
result = callback(result || initialValue, array[i], i); | |
} | |
return result; | |
}; |
This file contains hidden or 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
//Example of underscore chaining | |
var users = [ | |
{name: 'John', surname: 'Doe', age: 35}, | |
{name: 'John 2', surname: 'Doe 2', age: 19}, | |
{name: 'John 3', surname: 'Doe 3', age: 28}, | |
{name: 'John 4', surname: 'Doe 4', age: 16}, | |
{name: 'John 5', surname: 'Doe 5', age: 39} | |
]; | |
//Iterate over users and sort them by age, pick first and transform to a sentence |
This file contains hidden or 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
//Some of the examples use spread syntax available via Babel in ES7 proposal. | |
//Live at: https://jsbin.com/zawavekepo/edit?js,console | |
//Arrays, slicing and avoiding mutations | |
const numArray = [10, 20, 30, 40, 50, 60]; | |
const removeAtIndex = (arr, x) => { | |
return [ | |
...arr.slice(0, x), | |
...arr.slice(x + 1) | |
]; |
This file contains hidden or 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
const React = require('react'); | |
const classnames = require('classnames'); | |
const { find, map } = require('lodash'); | |
module.exports = React.createClass({ | |
displayName: 'Select', | |
propTypes: { | |
types: React.PropTypes.arrayOf( | |
React.PropTypes.shape({ |
This file contains hidden or 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
customers = ['CustomerA', 'CustomerB', 'CustomerC'] | |
{div} = React.DOM | |
App = React.createClass | |
render: -> | |
div {}, customers.map (c, i) -> div {key: i, className: ~~new Date()}, c | |
ReactDOM.render( |
This file contains hidden or 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
/* | |
Coding | |
Given an array of positive integers, write a function which returns all the unique pairs which add (equal) up to 100. | |
sample_input = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 50, 51, 49, 50, 51, 49, 51] | |
sample_output = [[1,99], [0,100], [10,90], [51,49], [50,50]] | |
*/ | |
var sample_input = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 50, 51, 49, 50, 51, 49, 51]; | |
var result = getNumbersOf(100, sample_input, true, []); |
This file contains hidden or 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 http = require('http'); | |
function follow(url, cb) { | |
http.get(url, function(res) { | |
res.on('data', function (chunk) { | |
var data = JSON.parse(chunk.toString()); | |
if (!data || !data.follow) { | |
cb(data); | |
return; | |
} |