Skip to content

Instantly share code, notes, and snippets.

View subhaze's full-sized avatar

Michael Russell subhaze

View GitHub Profile
@subhaze
subhaze / .sublp
Created April 12, 2016 18:08
function to get completions for sublime projects available and open said project in sublime
# Sublime text project completions
function sublp(){
subl --project ~/Sites/**/${1}.sublime-project
}
_sublp()
{
local cur=${COMP_WORDS[COMP_CWORD]}
local list=`ls -1 ~/Sites/**/*sublime-project | cut -d/ -f5`
COMPREPLY=( $(compgen -W "${list}" -- ${cur}) )
@subhaze
subhaze / .site
Created April 12, 2016 14:10
command to quickly cd to a site directory, with autocomplete
site(){
cd ~/Sites/$1
}
_site()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(ls ~/Sites/)" -- $cur) )
}
complete -F _site site
@subhaze
subhaze / jquery-outsideclick.js
Created April 12, 2016 13:23
event to fire when you click outside an element
jQuery.event.special.outsideclick = {
setup: function(data, namespaces, handler){
var $this = $(this);
var namespace = namespaces.join('.');
function _clickHandler(e){
var handleClick = true;
var mouseUsed = 'button' in e;
if(namespace === 'mouse' && !mouseUsed){
handleClick = false;
@subhaze
subhaze / JavaScript NG.sublime-syntax
Last active September 29, 2023 14:58
very start of Angular 2 sublime syntax file
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: JavaScript NG
file_extensions:
- js
- ng.js
scope: source.js.ng
contexts:
main:
<!DOCTYPE html>
<html lang="en">
<body class="container">
<h1>Some Title</h1>
<% if (names.length) { %>
<ul>
<% names.forEach(function(name){ %>
<li><%= name %></li>
@subhaze
subhaze / wp_xml_export_mashup.py
Last active November 11, 2015 18:53
I couldn't find any concrete way of selectively pulling content from an old Wordpress blog (with attachments). So... this python script will take an xml export file of all your Wordpress content and only move over the attachments that are found based on your selective content Wordpress export.
import codecs
from bs4 import BeautifulSoup
soup_all = BeautifulSoup(open('Wordpress_all_content.xml'))
soup_all_items = soup_all.find_all('item')
soup_posts = BeautifulSoup(open('Wordpress_selective_content.xml'))
soup_posts_items = soup_posts.channel.find_all('item')
def match_post(item):
@subhaze
subhaze / _media_mixins_bootstrap.scss
Created May 29, 2015 20:34
mixins to hit specific screen sizes using bootstrap's screen variables
/* Extra small devices (phones, less than 768px) */
/* No media query since this is the default in Bootstrap */
/* Small devices (tablets, 768px and up) */
@media (min-width: $screen-sm-min) { ... }
/* Medium devices (desktops, 992px and up) */
@media (min-width: $screen-md-min) { ... }
/* Large devices (large desktops, 1200px and up) */
@subhaze
subhaze / .htaccess
Last active August 29, 2015 14:07 — forked from bhollis/.htaccess
AddEncoding gzip .gz
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Konqueror
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)\.css$ $1.css.gz [QSA,L]
RewriteRule ^(.*)\.js$ $1.js.gz [QSA,L]
RewriteRule ^(.*)\.html$ $1.html.gz [QSA,L]
@subhaze
subhaze / custom-grid.scss
Last active August 29, 2015 14:06
So... I had to deal with a site that was original based on 16 cols, but, ended up with a few pages that were a mixture of 16 and 12 col layouts...
//Bootstrap 3 grid inception
@mixin new-grid($class, $columns, $grid-gutter-width: $grid-gutter-width){
$i: 1;
$grid-columns: $columns;
@include make-grid-columns($i: 1, $list: ".col-#{$class}-xs-#{$i}, .col-#{$class}-sm-#{$i}, .col-#{$class}-md-#{$i}, .col-#{$class}-lg-#{$i}");
@include make-grid(#{$class}-xs);
@media (min-width: $screen-sm-min) {
@include make-grid(#{$class}-sm);
}
@subhaze
subhaze / jQuery-tap.js
Last active January 23, 2019 16:00
Probably a more sane way to do this, but, here's a x-device click/tap event; It works with event delegation as well.
jQuery.event.special.tap = {
add: function(handleObj){
var $this = $(this);
var touchMoved = false;
var touched = false;
var touchesHandler = function(e){
if(e.type === 'touchstart'){
touchMoved = false;
touched = true;
}else if(e.type === 'touchmove'){