Skip to content

Instantly share code, notes, and snippets.

View jjgonecrypto's full-sized avatar
🔗
Eth wrangling.

j-j.eth jjgonecrypto

🔗
Eth wrangling.
View GitHub Profile
@jjgonecrypto
jjgonecrypto / gist:3987610
Created October 31, 2012 15:19
delete used remote branches
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$' | xargs -I% git push origin :%
@jjgonecrypto
jjgonecrypto / gist:3987615
Created October 31, 2012 15:20
git remove local merged branches
git branch --merged master | grep -v 'master$' | xargs git branch -d
@jjgonecrypto
jjgonecrypto / echoline.sh
Created March 11, 2016 22:23
Echo 5 lines before and after line in a file
#Usage echoline LINE_NUMBER FILE
function echoline() { sed -n "$(($1 - 5)),$(($1 + 5))p" $2; }
@jjgonecrypto
jjgonecrypto / App.js
Last active October 6, 2016 16:08
Navigator in react-native
import Start from './Start'
import NextPage from './NextPage'
const Views = { Start, NextPage }
<Navigator
initialRoute={{ view: 'Start' }}
renderScene={(route, navigator) => {
const SceneComponent = Views[route.view];
return <SceneComponent {...route.props} navigator={navigator} />;
@jjgonecrypto
jjgonecrypto / nodejs6-proxy.md
Last active February 16, 2017 20:55
Create dynamic objects in a nodejs6 REPL with Proxy

#Create dynamic objects in a nodejs6 REPL with Proxy

Nodejs 6.x comes with ES6 Proxy support baked in. Just like Ruby's method-missing (aka ghost methods), you can intercept getters and setters on an object and, like ActiveRecord in Rails, write rich APIs that can take any method or property name you like.

They are particularly fun in a REPL, where you might want to handle undefined variables.

For example, say we started a nodejs REPL via:

@jjgonecrypto
jjgonecrypto / index.html
Last active December 14, 2021 02:04
es6 proxy #jsbench #jsperf (http://jsbench.github.io/#531652a2edfa806a5014558bafe6eb0e) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>es6 proxy #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@jjgonecrypto
jjgonecrypto / grecent.sh
Last active March 28, 2017 16:34
Git show branches with most recent commits
# via http://stackoverflow.com/a/5188364/794170
git for-each-ref --sort=committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))"
@jjgonecrypto
jjgonecrypto / Deferred.js
Last active May 11, 2018 15:21
Migrating to jQuery 3 Promises A+
module.exports = class Deferred {
constructor() {
this._promise = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
}
resolve(value) {
this._resolve(value);
@jjgonecrypto
jjgonecrypto / EOS Smart Contract Development.md
Last active March 3, 2021 14:39
Getting started writing Smart Contracts with EOS

Getting started writing Smart Contracts with EOS

This information has been extrapolated from https://developers.eos.io/eosio-home/docs

Latest version of EOS when writing: 1.4.0

Note: the Developer Portal has a number of older links inside it. Some of the URLs contain older version numbers. For example, if you use the breadcrumbs at the top, things can get confusing as the latest version shows as v1.3.0 which has different C++ syntax due to the latest changes in eosio.cdt )Contract Development Toolkit) https://developers.eos.io/eosio-cpp/v1.3.0/docs/introduction-to-smart-contracts

Environment Setup

@jjgonecrypto
jjgonecrypto / random-split.js
Created December 4, 2018 19:48
Function to split up some given number into a fixed number of parts.
const random = require('random-js')();
// Splits up number into times random parts
const splitter = (number, times) => {
const ran = random.real(0, number);
if (times < 2) {
return [number];
}
const halved = times / 2;
if (times % 2 === 0) {