Skip to content

Instantly share code, notes, and snippets.

View chrisma's full-sized avatar

Christoph Matthies chrisma

View GitHub Profile
@chrisma
chrisma / handy_commands.tex
Last active August 29, 2015 14:07
Handy commands for Latex
\newcommand{\enquote}[1]{``#1''} %enquote stuff nicely
\newcommand{\up}[1]{\ensuremath{^{\textrm{\small#1}}}} %Easy way of doing supercripts in text
@chrisma
chrisma / gist:2074bc2d6dbdbbdea138
Created October 26, 2014 20:36
Replace master branch with gh-pages
git branch gh-pages
git checkout gh-pages
git branch -D master
git push origin gh-pages
# Set gh-pages as default branch in admin interface
git push origin :master # delete master
@chrisma
chrisma / js_helpers
Last active August 29, 2015 14:08
Javascript helper functions
function randomPropertyName(obj) {
var keys = Object.keys(obj)
return keys[ keys.length * Math.random() << 0];
}
function randomPropertyValue(obj) {
var keys = Object.keys(obj)
return obj[keys[ keys.length * Math.random() << 0]];
};
@chrisma
chrisma / js_string_helpers
Last active August 29, 2015 14:08
Javascript String helpers
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
String.prototype.title = function(force) {
//'examPLE'.title(); -> 'ExamPLE'
//'examPLE'.title(true); -> 'Example'
return (force ? this.toLowerCase() : this).replace(/(?:^|\s)\S/g, function(s) { return s.toUpperCase(); });
};
@chrisma
chrisma / fixed_height_sticky_footer
Created November 1, 2014 22:52
Favorite fixed height sticky footer
@chrisma
chrisma / rgb_to_hex.js
Created December 1, 2014 20:48
RGB to Hex Javascript
function rgbToHex(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
@chrisma
chrisma / Extract_color_json_from_wikipedia.js
Created December 1, 2014 22:30
Extract information about colors (name, rgb, hex, hsv, hsl) from Wikipedia to JSON.
result = [];
$('.wikitable tbody tr').each(function(){
var color = {};
color['name'] = $(this).find('th').text();
var tds = $(this).find('td');
color['hex'] = tds.first().text();
var rgb = [];
tds.slice(1,4).each(function(){
rgb.push(parseInt($(this).attr('title').replace('/255','')));
});
@chrisma
chrisma / preisvergleich_TShirt_drucken.md
Last active August 29, 2015 14:11
Preisvergleich T-Shirtdruck 09.12.2014

Preisvergleich T-Shirtdruck, Dez 14

Preise für das preiswerteste schwarze T-Shirt in Größe L, Versand nach Deutschland:

Gesamt
Anbieter Preis Versandkosten
@chrisma
chrisma / Reddit_sidebar_bookmarklet.html
Created December 18, 2014 17:44
Bookmarklet for toggling visibility of Reddit sidebar
<a href="javascript:$('div.side').toggle();void 0;">Toggle sidebar</a>
@chrisma
chrisma / unread_in_primary.txt
Created January 26, 2015 14:38
Show unread e-mails in primary inbox in Gmail
category:primary is:unread