Skip to content

Instantly share code, notes, and snippets.

@greduan
greduan / emacs-journal.txt
Created August 11, 2014 01:08
The journal I (barely) kept while on my 1 week Emacs challenge
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 September 4, 2014 01:57
Outputs the terminal 16 colors in the foreground (and background)
#!/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 / y-combinator.js
Created October 10, 2014 00:10
Y Combinator in JavaScript as shown by Douglas Crockford
// playlist:
// http://youtu.be/ya4UHuXNygM?list=PL7664379246A246CB
// minute:
// http://youtu.be/ya4UHuXNygM?t=1h8m42s
function y(le) {
return (function (f) {
return f(f);
}(function (f) {
return le(function (x) {
@greduan
greduan / manifest.json
Last active August 29, 2015 14:08
Some template files for Chrome extensions
{
"manifest_version": 2,
"name": "",
"version": "0.0.0",
"description": "",
"icons": {},
"browser_action": {},
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 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
@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 / 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]);