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 / 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 / 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
@shrwnsan
shrwnsan / functions.php
Created April 13, 2013 04:23
WordPress: exclude custom post-types from search query results. Note: 'video-camera', 'software-solution','post' are the post types which you want to search replace with you own. Source: http://wordpress.org/support/topic/exclude-custom-post-types-from-search-query-results?replies=6#post-3249786
// search filter
function fb_search_filter($query) {
if ( !$query->is_admin && $query->is_search) {
$query->set('post_type', array('video-camera', 'software-solution','post') ); // id of page or post
}
return $query;
}
add_filter( 'pre_get_posts', 'fb_search_filter' );
@shrwnsan
shrwnsan / twitter.css
Last active December 16, 2015 02:29
Stylebot Chrome-extension CSS. http://stylebot.me/styles/4752
#profile_popup .modal, .profile-card.profile-header, #activity-popup-dialog .modal {
width: 600px;
}
.account-summary .avatar {
top: 0.5em;
}
.activity-popup-users .avatar {
top: 0.9em;
@shrwnsan
shrwnsan / fontawesome-ie7.scss
Last active December 16, 2015 00:09
Font Awesome: For those looking to add support for IE7, and using SASS: 1. Copy-paste https://github.com/FortAwesome/Font-Awesome/blob/master/less/font-awesome-ie7.less 2. Rename to "font-awesome-ie7.scss" 3. Move to your relative /scss folder 4. Find and replace the corresponding snippets between your LESS and SCSS file. Use the included gist a…
@mixin ie7icon($arguments...) {
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = #{$arguments});
}
.icon-music { @include ie7icon('&#xf021;'); }
.icon-search { @include ie7icon('&#xf022;'); }
.icon-envelope { @include ie7icon('&#xf023;'); }
// and so on...