Skip to content

Instantly share code, notes, and snippets.

View tomraithel's full-sized avatar
🏠
Working from home

Tom Raithel tomraithel

🏠
Working from home
View GitHub Profile
@tomraithel
tomraithel / gist:4085422
Created November 16, 2012 08:22
SASS - Div with background and flexible main area
$paddingHeight: 50px;
background: transparent url(../img/b2b-content-middle.png) repeat-y;
min-height: 400px;
padding: 30px 30px 0 30px;
margin-bottom: $paddingHeight;
position: relative;
.main-content {
&:before,
&:after {
@tomraithel
tomraithel / gist:4085424
Created November 16, 2012 08:22
JS: regex replace all whitespaces with dash
"asdf a asdfsad".replace(/\s+/g, "-");
@tomraithel
tomraithel / gist:4085430
Created November 16, 2012 08:23
JS: Multiline RegEx to cut out body contents
// .* does not work because it can not handle multi line
var regex = /<body.*?>([\s\S]*)<\/body>/igm;
regex.exec(data);
data = RegExp.$1;
@tomraithel
tomraithel / gist:4085441
Created November 16, 2012 08:25
SUBLIME: Eclipse-like key bindings
[
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+alt+j"], "command": "join_lines" },
{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
{ "keys": ["shift+ctrl+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["ctrl+shift+s"], "command": "save_all" },
{ "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["shift+ctrl+f4"], "command": "close_all" },
@tomraithel
tomraithel / gist:4085444
Created November 16, 2012 08:25
JS: IE7 multiple class fix
(function($) { // jQuery no conflict container
"use strict"; // strict mode on!
new function() { // class container
// map this to that (to use this in anonymous functions)
var that = this;
// fires initial Event...
@tomraithel
tomraithel / gist:4085449
Created November 16, 2012 08:26
RUBY: Copy files from one directory into another
require 'fileutils'
# specify files which should not be copied
dont_copy = ['jquery.languageTags.js']
puts "Copying files from FE to BE folder"
from_dir = "./../FE/templates/global"
to_dir = "./../BE/trunk/htdocs/fileadmin/templates/global"
@tomraithel
tomraithel / gist:4085460
Last active October 12, 2015 20:48
SUBLIME: Create a snippet
<snippet>
<!-- Save this file in ~\Library\Application Support\Sublime Text 2\Packages\User\whatevername.sublime-snippet -->
<content><![CDATA[
<a class="button-lookalike ${1:primary} green" data-iconclass="buttoniconright arrow-right" href="${2:#}">${3:link}</a>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ts.button</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>*.html</scope> -->
</snippet>
@tomraithel
tomraithel / gist:4085463
Created November 16, 2012 08:28
SUBLIME: Eclipse-like key bindings (MAC)
[
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+shift+j"], "command": "join_lines" },
{ "keys": ["super+alt+down"], "command": "duplicate_line" },
{ "keys": ["shift+super+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["super+shift+s"], "command": "save_all" },
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
@tomraithel
tomraithel / gist:4085466
Created November 16, 2012 08:28
JS: normalize a page number to match a valid page in a looping carrousel / slider
_getNormalizedPage: function(page) {
if(page < 0) {
return this.pages.length + (page % this.pages.length)
}
return page % this.pages.length;
}
@tomraithel
tomraithel / gist:4085474
Created November 16, 2012 08:29
SUBLIME: Custom build command
{
"cmd": ["my_custom_bat.bat"],
"encoding": "cp850",
"working_dir": "C:/dev/path-to/batch/",
"variants": [
{
"cmd": ["solve_world_hunger"],
"name": "Solve World Hunger" // Searchable in command pallette
},