Skip to content

Instantly share code, notes, and snippets.

@theohogberg
theohogberg / random32x.tsx
Created March 25, 2024 21:26
TS: random32 * x hex generator
export const getRandom32x = (x: number = 1): string => {
if (x > 8) x = 8;
const uint32Array = new Uint32Array(x);
crypto.getRandomValues(uint32Array);
return uint32Array.reduce((a: string, v: number) => {
return a + v.toString(16).padStart(8, '0');
}, "");
};

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@proudlygeek
proudlygeek / commands-channel.go
Last active March 31, 2024 03:31
Golang Commands in Goroutines
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {

WHEN TO USE DIRECTIVES, CONTROLLERS, OR SERVICES IN ANGULAR JS

SERVICES

Whenever we want to share data across domains. Additionally, thanks to Angular’s dependency injection system, this is both very easy to do and very clean.

module.service( 'Book', [ '$rootScope', function( $rootScope ) {
 var service = {
@dongyuwei
dongyuwei / phantomjs-netsniff.js
Created September 10, 2012 09:33
phantomjs auto netsniff, create HAR file.
if (!Date.prototype.toISOString) {
Date.prototype.toISOString = function () {
function pad(n) { return n < 10 ? '0' + n : n; }
function ms(n) { return n < 10 ? '00'+ n : n < 100 ? '0' + n : n }
return this.getFullYear() + '-' +
pad(this.getMonth() + 1) + '-' +
pad(this.getDate()) + 'T' +
pad(this.getHours()) + ':' +
pad(this.getMinutes()) + ':' +
pad(this.getSeconds()) + '.' +