Skip to content

Instantly share code, notes, and snippets.

View samcorcos's full-sized avatar

Sam Corcos samcorcos

View GitHub Profile
import React from 'react'
let counter = 0
class App extends React.Component {
constructor(props) {
super(props)
this.addOne = this.addOne.bind(this)
}
@samcorcos
samcorcos / collision.js
Last active November 11, 2021 11:27
Algorithm for calculating hash collision probability
const calculate = (n, k) => {
const exponent = (-k * (k - 1)) / (2 * n)
return 1 - Math.E ** exponent
}
// where `n` is the number of possible unique hashes
// where `k` is the number of values created
// calculate(100000, 25) => 0.0029955044966269995 aka 0.29% chance of collision
@samcorcos
samcorcos / crayola.json
Created September 14, 2016 23:31 — forked from jjdelc/crayola.json
Crayola colors in JSON format
[
{
"hex": "#EFDECD",
"name": "Almond",
"rgb": "(239, 222, 205)"
},
{
"hex": "#CD9575",
"name": "Antique Brass",
"rgb": "(205, 149, 117)"
defmodule LearnPhoenix do
use Application
def start(_type, _args) do
...
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: LearnPhoenix.Supervisor]
start_result = Supervisor.start_link(children, opts)
web: MIX_ENV=prod mix ecto.migrate && mix.phoneix.server
@samcorcos
samcorcos / file.js
Last active November 8, 2016 23:31
simple structure
const makesModels = {
"Acura": {
"ILX": {
"years": [
2016,
2015,
2014,
2013,
2012
]
const formatData = data => {
// We're sorting by alphabetically so we need the alphabet
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
// Need somewhere to store our data
const dataBlob = {};
const sectionIds = [];
const rowIds = [];
// Each section is going to represent a letter in the alphabet so we loop over the alphabet
export const makes = {
"makes": [{
"id": "279a091a-32c1-46c7-80d2-b3423320f18f",
"name": "AM General"
}, {
"id": "72cadfa6-e1c0-4507-9bdd-835f93951dd6",
"name": "Acura"
}, {
"id": "02a97e0d-eb73-48e3-898a-567a3c81c0ee",
"name": "Alfa Romeo"
import React from 'react'
import { View, Text, TouchableOpacity, } from 'react-native'
import style from './style'
const pipe = (fns, init) => fns.reduce((acc, fn) => fn(acc), init)
const monthLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
const getDaysInMonth = (month, year) => {
if (month === 1) {
"scripts": {
"start": "node server.js",
"cover": "nyc -x '**/*spec.js' -n 'app' -r text -r html -r lcov npm test",
"test": "mocha --compilers js:babel-register -r babel-polyfill -r whatwg-fetch -r jsdom-global/register -r .test-setup.js -R spec app/**/spec.js app/**/*spec.js app/redux/actions/*spec.js",
"test:watch": "npm test -- --watch",
"prodbuild": "webpack -p --config ./webpack.prod.config.js"
},