Skip to content

Instantly share code, notes, and snippets.

@greduan
greduan / initialiseKeys.js
Created May 13, 2015 19:38
recursive func which goes goes through object and finds all .init() funcs and runs them
var initialiseKeys = function initialiseKeys (obj) {
var val
for (var key in obj) {
val = obj[key]
// the key isn't 'init' BUT it's an object we need to explore it
if (key !== 'init' && typeof val === 'object') {
initialiseKeys(val)
// hey the key is 'init' and its value is a function!
} else if (key === 'init' && typeof val === 'function') {
@greduan
greduan / callFuncFromString.js
Created May 13, 2015 21:52
extrapolates a method from an object from string, so 'boop.bap' gets called from the provided context with the provided params
var callFuncFromString = function (funcString, context, params) {
// funcString should be a string like so 'boop.bap', no () at the end
// parameters should be an array of the func's parameters, for .apply()
var layers = funcString.split('.')
layers.forEach(function (val) {
context = context[val]
})
@greduan
greduan / cool-oloo.js
Created July 24, 2015 20:32
What I've been looking for OLOO
var MyClass = {
prototype: {
// prototypal members and methods
},
create: function (options) {
// do stuff with options
return Object.create(MyClass.prototype, options)
},
}
@greduan
greduan / autoexec.cfg
Last active February 18, 2016 18:09
CSGO CFGs
// Launch options:
// -novid -nod3d9ex -threads 4 -high -nojoy
// Commands (aliases)
alias "+jthrow" "+jump; -attack; -attack2"
alias "-jthrow" "-jump"
alias "+bombfind" "+use; gameinstructor_enable 1; cl_clearhinthistory"
alias "-bombfind" "-use; gameinstructor_enable 0; cl_clearhinthistory"
@greduan
greduan / time-estimate
Last active January 5, 2016 00:55
Script to figure out how long you'll take on a ticket, worst case, expected case and best case are provided
#!/usr/bin/env node
if (process.argv.length < 5) {
console.log('usage: time-estimate BEST EXPECTED WORST')
process.exit(0)
}
var best = parseFloat(process.argv[2]),
exp = parseFloat(process.argv[3]),
worst = parseFloat(process.argv[4]),
var uuid = require('node-uuid')
var M = {}
M.BaseModel = Class(M, 'BaseModel').inherits(Krypton.Model)({
primaryKey: 'uuid',
prototype: {
init: function (config) {
@greduan
greduan / init.js
Created March 9, 2016 03:22
Atom: Destroy other items in pane when we open a new item
// We don't need empty panes
if (atom.config.get('core.destroyEmptyPanes')) {
atom.config.set('core.destroyEmptyPanes', true)
}
atom.workspace.onDidOpen(function (event) {
/**
* event = { item, pane, index }
*/
'use strict'
var Promise = require('bluebird'),
ttys = require('ttys'),
readlineSync = require('readline-sync')
module.exports = function () {
return Promise.resolve(readlineSync.question('password: ', { hideEchoBack: true }))
}

Keybase proof

I hereby claim:

  • I am greduan on github.
  • I am greduan (https://keybase.io/greduan) on keybase.
  • I have a public key whose fingerprint is 2F24 E29B 1BE2 A929 5A81 9EDE 99C9 826C 54CF DECB

To claim this, I am signing this object:

@greduan
greduan / unsub-youtube.js
Created September 11, 2017 21:24
Mass unsub from all YT subscriptions
const buttons = document.getElementsByClassName('subscribed-label')
Array.prototype.forEach.call(buttons, b => {
b.click()
const unsub = document.getElementsByClassName('overlay-confirmation-unsubscribe-button')
Array.prototype.forEach.call(unsub, u => u.click())
})