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 / PHP: Email.php
Last active December 17, 2015 13:49
PHP: Email
$aResponse = array('success' => false);
$from = $_POST['email'];
$message = $_POST['msg'];
$subject = $_POST['name'];
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
@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 / getDomainName.js
Last active August 1, 2021 13:34
Get complete domain name with protocol and port if available. #js #url From http://stackoverflow.com/questions/6941533/javascript-get-protocol-domain-and-port-from-url
var domain = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : '');
@tahirm
tahirm / mysqldump.sql
Created March 27, 2014 13:44
mysqldump command to dump a remote database in locally. #db #sql #mysql #mysqldump #remote
mysqldump -u USER -p -h dev.incuray.com DATABASE > /path/to/output/file/DATABASE.sql;
@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 / xdebug.sh
Created April 18, 2014 19:42
Install/uninstall xdebug from pecl. #xdebug #apache2 Further notes for installing xdebug on ubuntu. http://ubuntuforums.org/showthread.php?t=525257
# install xdebug using pecl
$ sudo pecl install xdebug
# uninstall xdebug using pecl
$ sudo pecl uninstall xdebug
@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, '');
}