Skip to content

Instantly share code, notes, and snippets.

Eduardo Lavaque greduan

View GitHub Profile
@greduan
greduan / ruler.txt
Created May 19, 2014
Text ruler that goes up to 80 characters.
View ruler.txt
================================================================================
12345678901234567890123456789012345678901234567890123456789012345678901234567890
| | | | | | | | |
1 10 20 30 40 50 60 70 80
================================================================================
@greduan
greduan / minHash.js
Created Jun 1, 2014
Finds the shortest unique string for a string in an array of strings. Meant to be used with hashes
View minHash.js
/**
* Big thanks to Bruce who figured this out for me. What this function does is
* give you the shortest unique prefix of the strings (hashes) that you give it
* in the array.
*
* Args: {array} hashesArr, {function} callback
* Returns: {array} minHashes, through callback. Something like this:
*
* [ '1c',
* '28d',
View randomArray.js
// returns an array with a random chance of it's contents being more arrays or
// random strings
function randomArray(length) {
if (length == null)
length = 10;
var times = randTo.from1to(length); // amount of initial dirs/files
var result = [];
// make an array of times length
for (var i = 0; i <= times; i++) {
// random chance, hey it's a dir
@greduan
greduan / emacs-journal.txt
Created Aug 11, 2014
The journal I (barely) kept while on my 1 week Emacs challenge
View emacs-journal.txt
Mon Aug 4 11:09:40 2014
Finally got YASnippets working, spent the last half an hour I guess.
Moved some of the snippets I have from Vim. Still not quite sure how it works so
that I just have to press tab after writing the snippets name, without breaking
the tab character which currently outputs 3C3EB0 for some reason...
[Mon Aug 4 14:11:29 2014
Deleted the original character for that "wrong tab" that was appearing.
Emacs rendered it as a square with the following characters in it: "3C3EB0"
@greduan
greduan / colors.sh
Created Sep 4, 2014
Outputs the terminal 16 colors in the foreground (and background)
View colors.sh
#!/bin/bash
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
# This program outputs the 16 colors in the foreground (and background) so that
# you can keep checking those colors when developing a theme.
@greduan
greduan / manifest.json
Last active Aug 29, 2015
Some template files for Chrome extensions
View manifest.json
{
"manifest_version": 2,
"name": "",
"version": "0.0.0",
"description": "",
"icons": {},
"browser_action": {},
View findNearestParent.js
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 };
}
@greduan
greduan / closure.js
Last active Aug 29, 2015
Quick JS file demonstrating closures very simply
View closure.js
var foo = 100;
console.log('first'); //=> 'first'
console.log(foo); //=> 100
(function () {
var foo = 200;
console.log('second'); //=> 'second'
console.log(foo); //=> 200
@greduan
greduan / responsive.css
Created Nov 22, 2014
Simplest thing I've found for responsive sites, works pretty well
View responsive.css
/* 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 */
You can’t perform that action at this time.