Skip to content

Instantly share code, notes, and snippets.

View tahirm's full-sized avatar

Tahir tahirm

  • Zürich, Switzerland
View GitHub Profile
@tahirm
tahirm / gist:9643964
Last active August 29, 2015 13:57 — forked from peteymoore/gist:5392815
Simple HTML5 Template #html5 #template
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 Template</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
</body>
@tahirm
tahirm / hack.sh
Last active August 29, 2015 13:57 — forked from erikh/hack.sh
OSX Hacks. #osx
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@tahirm
tahirm / media-query-detection.js
Created April 3, 2014 09:26
Find size and orientation of current media (like media-queries in css). #js #media-query #css From http://stackoverflow.com/questions/7625718/how-to-use-javascript-conditionally-like-css3-media-queries-orientation
function doStuff(){
landscape = window.orientation? window.orientation=='landscape' : true;
if(landscape && window.innerWidth<1900 && window.innerWidth > 768){
//code here
}
}
window.onload=window.onresize=doStuff;
if(window.onorientationchange){
window.onorientationchange=doStuff;
$ git checkout -b <new-branch>
This will leave your current branch as is, create and checkout a new branch and keep all your changes. You can then make a commit with:
$ git add <files>
and commit to your new branch with:
$ git commit
The changes in the working directory and changes staged in index do not belong to any branch yet. This changes where those changes would end in.
@tahirm
tahirm / compress-pdf.sh
Created April 17, 2014 21:18
Compress PDF files in linux. #pdf #linux #compress From http://askubuntu.com/questions/113544/how-to-reduce-pdf-filesize
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
#Leave out the '-dPDFSETTINGS=/screen' setting for better quality, but slightly larger pdfs.
@tahirm
tahirm / trim.js
Created May 15, 2014 12:46
Trim function for strings. If native .trim is available it uses that otherwise trim the string manually. #js #trim #string
//trim string
function trim(str){
return String.prototype.trim ? str.trim() : String(str).replace(/^([\s]*)|([\s]*)$/g, '');
}
@tahirm
tahirm / uri.js
Created May 16, 2014 14:51 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@tahirm
tahirm / regex-and
Created February 5, 2015 16:40
Regex AND functionality. #regex #and Reference: http://stackoverflow.com/questions/3041320/regex-and-operator
String: foobaz
Regex: (?=.*foo)(?=.*baz)