Random stuff that would be useful in making a (much better) Pocket alternative
- readability.js - a JS library that performs text extraction
- goose - a mature content/article extractor in scala
enum MyEnum { | |
/* ... */ | |
} | |
function stringToEnum(str: string): MyEnum | undefined { | |
return new Map(Object.entries(MyEnum)).get(str) | |
} |
# Install ethereum | |
brew tap ethereum/ethereum | |
brew install ethereum | |
# Run a light ethereum node | |
geth --syncmode="light" | |
# Open wallet in light mode (will need to install wallet from github first) | |
open -n /Applications/Ethereum\ Wallet.app --args -node-light |
function rgba (hex, opacity) { | |
return `rgba(${hexToR(hex)}, ${hexToG(hex)}, ${hexToB(hex)}, ${opacity})` | |
} | |
function hexToR (h) {return parseInt((cutHex(h)).substring(0, 2), 16)} | |
function hexToG (h) {return parseInt((cutHex(h)).substring(2, 4), 16)} | |
function hexToB (h) {return parseInt((cutHex(h)).substring(4, 6), 16)} | |
function cutHex (h) {return (h.charAt(0) == "#") ? h.substring(1, 7) : h} |
angular.module('farm4trade') | |
.directive('resizeToFit', | |
function() { | |
return { | |
restrict: 'EA', | |
replace: false, | |
transclude: true, | |
link: function(scope, elem) { | |
var $parent = $(elem[0]), | |
$span = $parent.find('.resize'), |
Random stuff that would be useful in making a (much better) Pocket alternative
var myAPI = { | |
doSomeShit: function (cb) { | |
// Need to preserve the binding of cb, | |
// but you can't do cb.this - there's no way to find out what it's bound to | |
cb.call(cb.this, 'arg1', 'arg2') | |
} | |
}; | |
function MyClass() { | |
this.shitIsDone = false; |
var oldOn = siesta.events.on; | |
siesta.events.on = function (event, fn) { | |
oldOn.call(siesta.events, event, function (e) { | |
$rootScope.$apply(function () { | |
fn(e); | |
}) | |
}); | |
} |
function Something() { | |
_.extend(this, { | |
attr: 1, | |
_extras = {}, | |
__setattr__: function (key, value) { | |
this._extras[key] = value; | |
}, | |
__getattr__: function (key) { | |
return this._extras[key] || 'That attribute doesnt exist yet!'; | |
} |
Car = Collection.model('Car', { | |
id: 'id', | |
attributes: ['colour'], | |
properties: { | |
blah: { | |
get: function () { | |
return this.colour ? this.colour.toUpperCase() : this.colour; | |
}, | |
// Workaround for chrome. |
var LETTERS = 'acdegilmnoprstuw'; | |
/** | |
* The provided hash function with additional logging | |
* @param s | |
* @returns {number} | |
*/ | |
function hash(s) { | |
var h = 7; | |
for (var i = 0; i < s.length; i++) { |