Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / lcs.js
Created November 22, 2014 23:59
LCS algorithm in JS. Prettified version of what can be found here: https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_subsequence#JavaScript
// prettified version of what can be found here:
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_subsequence#JavaScript
function LCS(a, b) {
var m = a.length,
n = b.length,
C = [],
i,
j;
for (i = 0; i <= m; i++) C.push([0]);
@greduan
greduan / responsive.css
Created November 22, 2014 01:10
Simplest thing I've found for responsive sites, works pretty well
/* REMEMBER TO CHANGE THE FONT SIZES FOR YOUR OWN WEBSITE */
/* higher than 900px wide screen */
body {
max-width: 700px;
padding: 0 10px;
margin: 0 auto;
}
/* 900px or smaller width screen */
@greduan
greduan / closure.js
Last active August 29, 2015 14:09
Quick JS file demonstrating closures very simply
var foo = 100;
console.log('first'); //=> 'first'
console.log(foo); //=> 100
(function () {
var foo = 200;
console.log('second'); //=> 'second'
console.log(foo); //=> 200
function findNearestParent(element, parentTag, limit) {
var parent = element.parentElement;
if (limit < 0) {
return { foundIt: false };
}
if (element.tagName.toLowerCase() === parentTag) {
return { element: element, foundIt: true };
}