Skip to content

Instantly share code, notes, and snippets.

Avatar
💜
Decentralizing

RangerMauve

💜
Decentralizing
View GitHub Profile
@nybblr
nybblr / 1-easy.js
Last active Apr 8, 2021
3 examples of using Async Generators and Async Iteration in JavaScript!
View 1-easy.js
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {
@jarretmoses
jarretmoses / React Native Clear Cache
Last active May 8, 2021
Clearing the Cache of your React Native Project
View React Native Clear Cache
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@MoOx
MoOx / .travis.yml
Last active May 12, 2016
Run tap/tape tests using saucelabs
View .travis.yml
language: node_js
node_js:
- iojs
env:
global:
# https://docs.saucelabs.com/ci-integrations/travis-ci/
# SAUCE_USERNAME
- secure: Daa...
@terinjokes
terinjokes / build.js
Created Feb 18, 2015
Requiring a dynamically created file with Browserify
View build.js
var Browserify = require('browserify');
var Readable = require('stream').Readable;
function stringStream(content) {
var s = new Readable();
s.push(content);
s.push(null);
return s;
}
@gubatron
gubatron / dht-walkthrough.md
Last active Jun 1, 2021
DHT walkthrough notes
View dht-walkthrough.md

DHT Walkthrough Notes

I've put together these notes as I read about DHT's in depth and then learned how the libtorrent implementation based on the Kademlia paper actually works.

What problem does this solve?

400,000,000,000 (400 billion stars), that's a 4 followed by 11 zeros. The number of atoms in the universe is estimated to be around 10^82. A DHT with keys of 160 bits, can have 2^160 possible numbers, which is around 10^48

@jarrodirwin
jarrodirwin / storagePolyfill.js
Last active Jun 9, 2020 — forked from remy/gist:350433
LocalStorage/SessionStorage Polyfill with Safari Private Browsing support.
View storagePolyfill.js
// Refer to https://gist.github.com/remy/350433
try {
// Test webstorage existence.
if (!window.localStorage || !window.sessionStorage) throw "exception";
// Test webstorage accessibility - Needed for Safari private browsing.
localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {
@netgusto
netgusto / pegjs-htmlish.peg
Last active Aug 3, 2018
PEG.js grammar for parsing simple HTML-ish balanced markup language - use it on http://pegjs.majda.cz/online
View pegjs-htmlish.peg
Content = (DocType / Comment / BalancedTag / SelfClosingTag / Text)*
DocType = "<!doctype " doctype:[^>]* ">" {
return {
type: 'DocType',
content: doctype.join('')
};
}
Comment = "<!--" c:(!"-->" c:. {return c})* "-->" {
@jessehattabaugh
jessehattabaugh / gulpfile.js
Last active Aug 23, 2016
Gulp task for changing values in PhoneGap's config.xml file
View gulpfile.js
/* Config - set the right values in the PhoneGap config.xml
******************************************************************************/
gulp.task('config', function () {
return gulp.src([srcDir + '/config.xml'])
.pipe(cheerio({
run: function ($) {
// get the version number from package.json
$('widget').attr('version', require('./package').version);
// in development launch the app with a different html file
@constantology
constantology / process.logger.js
Created Jul 24, 2014
using node's process to emit events to log stuff from anywhere
View process.logger.js
// use like this:
// process.emit( 'app:log', module, arg1, arg2, ..., argN );
var Module = require('module');
function logConsole(method, module) {
var args = [(new Date()).toJSON(), method];
var index = 1;
if (module instanceof Module) {
@staltz
staltz / introrx.md
Last active Jun 14, 2021
The introduction to Reactive Programming you've been missing
View introrx.md