Skip to content

Instantly share code, notes, and snippets.

View albabar's full-sized avatar

Babar Al-Amin albabar

View GitHub Profile
@albabar
albabar / reposition.sql
Last active November 27, 2015 09:24
Reorder a table based on some column.
SELECT x.id,
x.position,
x.title,
x.created_at
FROM (SELECT t.id,
t.title,
t.created_at,
@rownum := @rownum + 1 AS position
FROM posts t
JOIN (SELECT @rownum := 0) r
@albabar
albabar / iterm.sh
Created October 27, 2015 17:02 — forked from sponomarev/command.sh
Remove iTerm2 icon from Dock
# remove
/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
# restore
/usr/libexec/PlistBuddy -c 'Delete :LSUIElement' /Applications/iTerm.app/Contents/Info.plist
@albabar
albabar / Contract Killer.md
Last active September 28, 2015 13:01 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@albabar
albabar / quick-upload.php
Created August 4, 2014 19:32
Sometimes it may be needed to test upload on PHP, if it's working. To make the process quicker, this script would help. Just place it in web server root and make sure current folder is writable.
<!DOCTYPE HTML>
<html>
<head><title>Quick Upload for PHP by Babar</title></head>
<body>
<h1>Quick Upload for PHP by <a href="http://www.babar.im">Babar</a></h1>
<?php
if(isset($_FILES['userfile'][)) {
$uploaddir = dirname(__FILE__) . '/';
@albabar
albabar / aliases
Created July 15, 2014 23:07
Parse email with PHP as they received based on email forwards to PHP. Source: http://ericlondon.com/2010/01/10/configuring-a-server-to-parse-email-via-a-php-script.html and http://badjava.com/node/8
phpscript: "|php -q /usr/local/bin/email.php"
@albabar
albabar / AutoIncrement.php
Created June 5, 2014 10:51
Au Increment in HTML tables, like foreach loops. If you want to use it with loop and want to reset the counter, please reset it outside loop. Made it for laravel blade, is it's pain to assign a variable in blade.
<?php
function increment($reset = false, $l = 0) {
static $i;
if($reset) $i = $l;
else return ++$i;
return $reset;
}
@albabar
albabar / Countries.csv
Created May 6, 2014 10:07
Country List, a list of 244 Countries. Contains Country names, Country ISO codes, CSV, PHP Array and HTML Drop down.
Afghanistan AF
Albania AL
Algeria DZ
American Samoa AS
Andorra AD
Angola AO
Anguilla AI
Antarctica AQ
Antigua and Barbuda AG
Argentina AR
.awesome-bar, .page_aside.article_aside, .main-header, .page_banner, .contributor, .article_meta-data, .article_header__buttons, footer, #disqus_thread, .promo-panel, .related-content, .article__author-bios {display:none;}
.page, .page--primary .page_content > .article {width: 900px}
body {font-family: "Lucida Grande";}
@albabar
albabar / mysql-list-dump.sh
Created March 28, 2014 18:23
List all Database and export/dump them to individual SQL files.
#!/bin/sh
for db in $(mysql -u root -pROOTPASS -e 'show databases' -s --skip-column-names);
do
mysqldump -u root -pROOTPASS $db > $db-$(hostname)-$(date +%F-%s).sql
done
@albabar
albabar / dropbox.init
Created March 27, 2014 16:50
A dropin dropbox init file for Debian/Ubuntu headless Servers.
#!/bin/bash
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: Control the Dropbox daemon.