Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / php5-mods-available-custom.ini
Last active August 29, 2015 14:11
php custom config
cgi.fix_pathinfo = 0;
realpath_cache_size = 256k;
realpath_cache_ttl = 300;
max_execution_time = 120;
max_input_time = 120;
memory_limit = 192M;
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
post_max_size = 30M
upload_max_filesize = 30M
date.timezone = Australia/Sydney
@yusufhm
yusufhm / etc-init-rtorrent.conf
Created December 9, 2014 00:14
Ubuntu upstart script for rtorrent
description "Run a persistent rtorrent within screen"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
env LANG=en_US.utf8
env HOME=/home/ubuntu
setuid ubuntu
setgid ubuntu
@yusufhm
yusufhm / etc-init-btsync.conf
Created December 9, 2014 00:48
Ubuntu upstart script for btsync
# btsync - Bittorent Sync
description "btsync - Keep Bittorent Sync running"
start on filesystem
stop on shutdown
respawn
expect fork
@yusufhm
yusufhm / iptables-firewall.sh
Last active August 29, 2015 14:11
Sample script for iptables firewall rules
#!/bin/bash
#Bridge config
#for f in /proc/sys/net/bridge/bridge-nf-*; do echo 0 > $f; done
#Flush all before applying new rules
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
@yusufhm
yusufhm / drupal-fix-file-permissions.sh
Created January 15, 2015 23:45
Fix Drupal files permissions (credits to James Wilmot)
#!/bin/bash
#
# A script to fix file permissions in the given
# files directory for drupal
#
# Usage:
# - set files directory variable to point at the files
# drupal installation files directory
# - run script
@yusufhm
yusufhm / bash_commands.sh
Last active December 20, 2021 00:15
Bash Commands
#!/usr/bin/env bash
# split strings
GIT_BRANCH="origin/master"
remote=`echo $GIT_BRANCH | cut -d '/' -f 1`
branch=`echo $GIT_BRANCH | cut -d '/' -f 2`
# finding working directory of a process (where $$ is the PID, obtained through `pgrep` or other)
pwdx $$
# or
@yusufhm
yusufhm / etc-init-selenium.conf
Last active August 29, 2015 14:16
Ubuntu upstart script for Selenium
## WARNING: THIS IS CURRENTLY NOT WORKING BECAUSE SELENIUM DOES NOT HAVE
## A DISPLAY IN WHICH TO LAUNCH
description "Selenium Server Standalone"
author "Yusuf"
start on runlevel [2345]
stop on runlevel [!2345]
#Respawn the process if it crashes
@yusufhm
yusufhm / css-fix-aspect-ratio.html
Created April 17, 2015 01:02
CSS fix - aspect ratio
<!-- taken from http://stackoverflow.com/a/12121309/351590 -->
<div class="wrapper">
<div class="main">
This is your div with the specified aspect ratio.
</div>
</div>
<style>
.wrapper {
width: 50%;
/* whatever width you want */
@yusufhm
yusufhm / npm-script.conf
Created September 14, 2015 01:43
NPM Upstart Script
description "Turn `project name` bot into a daemon"
author "Yusuf Hasan Miyan"
start on runlevel [2345]
stop on runlevel [016]
script
echo $$ > /var/run/project-name-bot.pid
chdir /path/to/project-name-bot
exec sudo -u $user /usr/bin/npm start
@yusufhm
yusufhm / mysql.sh
Created September 29, 2015 07:40
mysql command-line
mysql -uroot -ppassw0rd --execute "CREATE DATABASE <db_name>;"