Skip to content

Instantly share code, notes, and snippets.

View azizhk's full-sized avatar
:octocat:
Keep git history linear, squash and merge into master.

Aziz Khambati azizhk

:octocat:
Keep git history linear, squash and merge into master.
View GitHub Profile
@toddmotto
toddmotto / gist:6596373
Created September 17, 2013 15:56
Disable Web Security in Chrome Canary to make cross-domain XHR requests (local servers obvs).
open -a Google\ Chrome\ Canary --args --disable-web-security
@joepie91
joepie91 / random.md
Last active July 2, 2024 01:17
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@staltz
staltz / readme.ts
Created April 25, 2018 17:31
callbag-typescript-proof-of-concept
/**
* Callbag loves TypeScript
*
* Copy-paste this into http://www.typescriptlang.org/play/index.html
*/
// A Callbag dynamically receives input of type I
// and dynamically delivers output of type O
type Callbag<I, O> = {
(t: 0, d: Callbag<O, I>): void;
@axemclion
axemclion / PerfLogger.java
Last active August 12, 2023 02:56
React Native Android - Systrace from ReactMarkers
package com.nparashuram;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.bridge.ReactContext;