Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
shrwnsan / gulpfile-express.js
Last active August 29, 2015 13:56 — forked from mollerse/gulpfile-express.js
Gulpfile configs
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@shrwnsan
shrwnsan / sc-dl-min.js
Last active August 29, 2015 13:55 — forked from duncanbeevers/sc-dl-min.js
Bookmarklet which creates download links on *any* Soundcloud page. Full credit goes to @duncanbeevers, with contributions from @markpiro and @haroldSanchezb -- Last tested on Soundcloud site: 4 Feb 2013 Successful :-)
!function(a){var b,c,d,e=$(".sound"),f=require("config").get("client_id");require("lib/connect").getAuthToken();var i,j,k,l,m,h=require("lib/helpers/conversion-helper");for(b=e.length-1;b>=0;b--){c=$(e[b]);var n="https://soundcloud.com"+(c.find(".soundTitle__title").attr("href")||a.location.pathname);k={url:n,client_id:f},m=function(a){return function(b){var c={client_id:f};l=require("lib/url").stringify({query:c},b.stream_url+".mp3"),d=$(a.find(".sound__soundActions .sc-button-group")[0]),j=d.find(".sc-button:first")[0].className.match(/sc-button-((?:small)|(?:medium))/)[1],i=$('<a class="sc-button sc-button-download sc-button-icon sc-button-responsive">Download</a>').attr({title:"Download this sound ("+h.bytesToMB(b.original_content_size)+")",href:l,download:a.find(".soundTitle__title").first().text()+".mp3"}).addClass("sc-button-"+j),0==a.find(".sc-button-download").length&&d.append(i)}}(c),$.getJSON("http://api.soundcloud.com/resolve.json",k).success(m)}}(window);
@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 July 12, 2024 10:25
Webhost .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')) {