Skip to content

Instantly share code, notes, and snippets.

View shrwnsan's full-sized avatar
🏠
Working from home

shrwnsan

🏠
Working from home
View GitHub Profile
@shrwnsan
shrwnsan / ip-up.nix
Last active January 3, 2016 18:29
To setup a VPN for specific websites, in OS X. Based on this writeup: http://archives.aidanfindlater.com/blog/2010/02/03/use-vpn-for-specific-sites-on-mac-os-x/ Add "ip-up" file/content below to "/etc/ppp". Then "chmod a+x /etc/ppp/ip-up".
#!/bin/bash
#
# Script which handles the routing issues as necessary for pppd.
# When the ppp link comes up, this script is called with the following
# parameters:
# $1 the interface name used by pppd (e.g. ppp3)
# $2 the codey device name
# $3 the codey device speed
# $4 the local IP address for the interface
# $5 the remote IP address
@shrwnsan
shrwnsan / function.php
Created July 30, 2013 07:35
WordPress: Printout enqueued styles and scripts via their $handle.
function my_inspect_styles() {
global $wp_styles;
echo '<!-- Styles: ';
foreach( $wp_styles->queue as $handle ) {
echo $handle . ' | ';
}
echo '-->';
}
function my_inspect_scripts() {
global $wp_scripts;
@shrwnsan
shrwnsan / .htaccess
Last active December 17, 2015 23:49
Make .git files and directory web inaccessible. There's two solutions below for your preference. One redirects to a 404, and the other to domain root. I use a 404. (Based on my Stack Overflow post @ http://j.mp/17fb164)
# Make .git files and directory web inaccessible
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*/)?\.git+ - [R=404,L]
</IfModule>
# Second line of defense (if no mod_rewrite)
RedirectMatch 404 ^(.*/)?\.git+
@shrwnsan
shrwnsan / post-merge
Last active December 17, 2015 22:39
Git: Useful if you are doing dev between multiple machines (e.g. local or dev environments). Based on "Synchronizing a MySQL Database with Git and Git Hooks" > http://ben.kulbertis.org/2011/10/synchronizing-a-mysql-database-with-git-and-git-hooks/ Note: I'm using the following in OSX.
#!/bin/sh
cd /path/to/your/repo/
gunzip -v < [database].sql.gz | mysql -u [mysql_user] -p[mysql_password] [database]
# Note:
# No need to have these comments in the file...
# This file's location @ /path/to/your/repo/.git/hooks/post-merge
# Be sure to make this file executable via:
# sudo chmod +x /path/to/your/repo/.git/hooks/post-merge
@shrwnsan
shrwnsan / .bash_aliases
Last active October 14, 2020 23:21
Dreamhost .dotfiles
# Alias: Files & Folders
alias ls="ls --color=auto"
alias la="ls -aF"
alias lc="ls -lcr"
alias ld="ls -ld"
alias lk="ls -lSr"
alias ll="ls -lF"
alias lla="ls -al"
alias lm="ls -al | more"
alias lr="ls -lR"
@shrwnsan
shrwnsan / com.setdns.txt
Created May 14, 2013 08:56
For efficiently using dnsmasq. Based from http://wizardmode.com/2012/06/apache-php-mysql-dev-on-os-x-lion-with-a-minimum-of-pain/ /Library/LaunchDaemons/com.setdns.plist /usr/local/bin/setdns.sh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.setdns</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/setdns.sh</string>
</array>
@shrwnsan
shrwnsan / functions.php
Created May 7, 2013 12:56
WordPress: Selectively load plugins' styles/JS only for pages/views that needs them
function my_deregister_styles() {
if (!is_page('Contact')) {
wp_deregister_style('contact-form-7');
}
if (!is_single()) {
wp_deregister_style('tfg_style');
}
}
function my_deregister_javascript() {
if (!is_page('Contact')) {
// Note: httpd-vhosts.conf filename just used as an example.
// Add the following line to your apache configuration inside the VirtualDocumentRoot vhost definition
// E.g.
// <VirtualHost *:80>
// ...
// {paste here}
// </VirtualHost>
php_admin_value auto_prepend_file "/Users/USERNAME/Sites/setdocroot.php"
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset