Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / mysql.sh
Created September 29, 2015 07:40
mysql command-line
mysql -uroot -ppassw0rd --execute "CREATE DATABASE <db_name>;"
@yusufhm
yusufhm / add_to_known_hosts.sh
Created October 1, 2015 23:17
automatically add host key to known_hosts
#!/bin/bash
host=$1
# first remove the host's key if it exists
ssh-keygen -R $host
# then add to the known_hosts file
ssh-keyscan -H $host >> ~/.ssh/known_hosts
@yusufhm
yusufhm / add_remote.sh
Created October 1, 2015 23:40
Add git remote if it does not exist
#!/bin/bash
$remote_name=$1
$remote_url=$2
git ls-remote --exit-code $remote_name &>/dev/null
if [ $? -ne 0 ]; then
git remote add $remote_name $remote_url
fi
@yusufhm
yusufhm / rename_drupal_module.sh
Last active November 23, 2015 03:40
Rename Drupal modules
#!/bin/sh
# Copied from http://whaaat.com/rename-drupal-module-cli
old=$1
new=$2
mv $old $new
cd $new
rename "s/$old/$new/g;" *
perl -pi -w -e "s/$old/$new/g;" *
@yusufhm
yusufhm / ubuntu-set-au-repos.sh
Created December 30, 2015 05:54
ubuntu set au repos
#!/bin/bash
sed -i 's/archive.ubuntu.com/au.archive.ubuntu.com/g' /etc/apt/sources.list
.parent-element {
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
@yusufhm
yusufhm / create_directory_bookmark.sh
Last active March 1, 2016 23:32
Create directory bookmark in zsh
# Create a bookmark using the following command
hash -d -- bookmark_name=/path/to/dir
# Access using
cd ~bookmark_name