Skip to content

Instantly share code, notes, and snippets.

View samcorcos's full-sized avatar

Sam Corcos samcorcos

View GitHub Profile
web: MIX_ENV=prod mix ecto.migrate && mix.phoneix.server
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)
@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)"
@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
import React from 'react'
let counter = 0
class App extends React.Component {
constructor(props) {
super(props)
this.addOne = this.addOne.bind(this)
}
class App extends React.Component {
static requiredData = [
"username",
"email",
"thumbnail_url"
]
render() {
return(<div></div>)
}
class App extends React.Component {
constructor() {
super()
this.prototypeProperty = {
baz: "qux"
}
}
static staticProperty = {
foo: "bar"
};
class App extends React.Component {
static propTypes {
title: React.PropTypes.string.isRequired
}
render() {
return (<div>{ this.props.title }</div>)
}
}
class App extends React.Component {
render() {
return (<div>{ this.props.title }</div>)
}
}
App.propTypes = {
title: React.PropTypes.string.isRequired
}
import React from 'react'
import { Socket } from 'phoenix'
class App extends React.Component {
componentDidMount() {
this.socket = new Socket('http://localhost:4000/socket')
this.socket.connect()
this.configureChannel("lobby")
}