Skip to content

Instantly share code, notes, and snippets.

@Geruhn
Geruhn / addGlobalStyle.js
Created November 25, 2013 16:59
JavaScript: addGlobalStyle(css)
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
@Geruhn
Geruhn / .bash_aliases
Created December 12, 2013 09:45
git init && add && commit
alias "giac"="git init && git add . && git commit -m \"Initial commit\""
@Geruhn
Geruhn / Default (Windows).sublime-keymap
Last active December 29, 2015 12:58
Sublime: Keybinding for [1,1][0,1] cells layout (one big cell in the left column, two halves in the right column) Example: http://twitpic.com/dmrbv8
{
"keys": ["alt+shift+6"],
"command": "set_layout",
"args":
{
"cols": [0.0, 0.45, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells":
[
[0, 0, 1, 2], [1, 0, 2, 1],
@Geruhn
Geruhn / addAnimationListener.js
Created November 26, 2013 13:31
JavaScript: addAnimationListener (addEventListener on Animations with vendorprefixes)
EventTarget.prototype.addAnimationListener = function(type, listener, useCapture, wantsUntrusted) {
//vendors[0][vendorIndex] = vendor-prefixes + vendors[1][vendorIndex] = vendorwrittenInCamelCase
//[[w3c, ff, webkit, Opera, IE],[...]]
var vendors = [['', '', 'webkit', 'o', 'MS'],[false, false, true, false, true]];
var prefix = 'Animation';
var animationTypes = ['Start', 'Iteration', 'End'];
var animationType = false;
for(var i = animationTypes.length - 1; (i >= 0) && !animationType; i--) {
animationType = (type.toLowerCase() === animationTypes[i].toLowerCase()) ? i : false;
}
@Geruhn
Geruhn / add_remove_toggle_Many.js
Created November 25, 2013 17:01
JavaScript: (add|remove|toggle)Many
DOMTokenList.prototype.addMany = function(classes) {
var classes = classes.split(' ');
for (var i = classes.length - 1; i >= 0; i--) {
this.add(classes[i]);
};
};
DOMTokenList.prototype.removeMany = function(classes) {
var classes = classes.split(' ');
for (var i = classes.length - 1; i >= 0; i--) {
@Geruhn
Geruhn / Responsive_Twitter.css
Last active December 28, 2015 08:28
Making Twitter responsive with a greasemonkey script
@media (min-width: 701px) {
.dashboard {
position: fixed;
}
}
@media (max-width: 900px) and (min-width: 701px) {
.wrapper {
width: 100%;
padding: 54px 0px 0px 0px;
@Geruhn
Geruhn / gist:6389735
Last active December 22, 2015 00:29
JavaScript: Custom Each mit Callback Quelle: http://www.sitepoint.com/jquery-vs-raw-javascript-3-events-ajax/
function Each(obj, fn) {
if (obj.length) for (var i = 0, ol = obj.length, v = obj[0]; i < ol && fn(v, i) !== false; v = obj[++i]);
else for (var p in obj) if (fn(obj[p], p) === false) break;
};
<?php
// define the path and name of cached file
$cachefile = 'cached-files/'.date('M-d-Y').'.php';
// define how long we want to keep the file in seconds. I set mine to 5 hours.
$cachetime = 18000;
// Check if the cached file is still fresh. If it is, serve it up and exit.
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
include($cachefile);
exit;
}
@Geruhn
Geruhn / .gitconfig
Last active December 21, 2015 14:28
Git: Standard .gitconfig
[color]
ui = true
[alias]
go = checkout
ci = commit -m
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t