Skip to content

Instantly share code, notes, and snippets.

qvvg orodio

Block or report user

Report or block orodio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@orodio
orodio / prng.js
Created Mar 3, 2020 — forked from blixt/prng.js
A very simple, seedable JavaScript PRNG.
View prng.js
/**
* Creates a pseudo-random value generator. The seed must be an integer.
*
* Uses an optimized version of the Park-Miller PRNG.
* http://www.firstpr.com.au/dsp/rand31/
*/
function Random(seed) {
this._seed = seed % 2147483647;
if (this._seed <= 0) this._seed += 2147483646;
}
View perf.js
// PTS | 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// ----+----------------------------------------------------
// R1 | t6 t12 t4 t8 t5 t14 t11 t10 t13 t1 t2 t9 t3 t7
// R2 | t6 t4 t14 t13 t11 t10 t12 t1 t8 t5 t2 t9 t3 t7
// R3 | t6 t5 t11 t4 t14 t8 t10 t2 t1 t13 t12 t9 t3 t7
// R4 | t6 t5 t4 t10 t12 t11 t13 t8 t14 t2 t1 t9 t3 t7
// R5 | t6 t13 t11 t2 t10 t5 t12 t14 t8 t1 t4 t9 t3 t7
// R6 | t6 t5 t4 t13 t12 t8 t14 t11 t10 t1 t2 t9 t3 t7
// R7 | t6 t5 t13 t8 t4 t10 t1 t2 t14 t11 t12 t3 t9 t7
// R8 | t6 t5 t11 t14 t8 t4 t13 t10 t12 t1 t2 t3 t9 t7
View dirtyInject.js
const root =
(typeof self === 'object' && self.self === self && self) ||
(typeof global === 'object' && global.global === global && global) ||
(typeof window === 'object' && window.window === window && window) ||
this
root.__RAWR__ = {
onMount: (domNode, props) => {
// ReactDOM.render(<Counter {...props} />, domNode)
domNode.innerHTML = `<div>
View Counter.js
const { GenServer, Ok, Reply, NoReply, Continue } = require("./gen-server")
var counts = {}
function UpdateCount(event) {
if (!(this instanceof UpdateCount)) return new UpdateCount(event)
this.count = event.count
}
const Counter = GenServer({
View keybase.md

Keybase proof

I hereby claim:

  • I am orodio on github.
  • I am qvvg (https://keybase.io/qvvg) on keybase.
  • I have a public key ASBf-wXJ3JAfM4GCCg9M96ZHtraCOzUneZkS_T40Tw2ziAo

To claim this, I am signing this object:

View simon_counter2.js
const foo1 = () => { this.rawr = "rawr" }
function foo2 () { this.rawr = "rawr" }
function moo2 () { this.rawr = "moo" }
function resetRawr () { this.rawr = "rawr" }
function setRawr (value) { this.rawr = value }
const rawrStuff = { moo2: moo2, resetRawr: resetRawr, setRawr: setRawr }
foo1()
View gist:1e1b608f3a533cc2a0a5886e82f8914f
button.addEventListener('click', () => {
Promise.resolve().then(() => console.log('P1'))
console.log('L1')
})
button.addEventListener('click', () => {
Promise.resolve().then(() => console.log('P2'))
console.log('L2')
})
@orodio
orodio / redux.js
Created May 31, 2017
redux with a generator
View redux.js
export const createStore = (reducer, state = {}) => {
let subs = []
const store = (function * () {
while (true) {
const event = yield null
state = reducer(state, event)
subs.forEach(fn => fn(state))
}
})
@orodio
orodio / flux.js
Created May 29, 2017
redux'ish thing with generators and adhoc handlers
View flux.js
const createStore = (state) => {
const noop_handler = state => state
state = state || {}
var handlers = {}
var subs = []
const store = (function * () {
while (true) {
const { type, payload } = yield null
state = (handlers[type] || noop_handler)(state, ...payload)
@orodio
orodio / cmds.md
Created Apr 11, 2017
elixir phoenix mac postgres
View cmds.md
$ mix phoenix.new <NAME>
$ cd <NAME>
$ mix ecto.create

// if postgres errors
  $ brew install postgresql
  $ psql postgres
  postgres=# CREATE ROLE postgres;
  postgres=# ALTER ROLE postgres LOGIN;
You can’t perform that action at this time.