Skip to content

Instantly share code, notes, and snippets.

View bigandy's full-sized avatar

Andrew Hudson bigandy

View GitHub Profile
@bigandy
bigandy / gist:9400717
Created March 6, 2014 22:04
Sass Element and Modifier Mixins
// Mixins for element and modifier
//elements get appended with "__" and the $name
@mixin e($name) {
@at-root &__#{$name} {
@content;
}
}
//modifiers get appended with "--" and the $name
@bigandy
bigandy / gist:e82df405c02d56e65443
Created November 11, 2014 09:47
Sublime Settings
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/Monokai (SL).tmTheme",
"detect_slow_plugins": true,
"disable_colored_group_labels": true,
"disable_coloured_folder_labels": true,
"disable_formatted_linebreak": true,
"fade_fold_buttons": true,
"folder_exclude_patterns":
@bigandy
bigandy / gist:9be72cc647e7a90543a0
Created November 21, 2014 08:51
Sublime Keybindings
[
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["ctrl+super+w"], "command": "close_all" },
{ "keys": ["super+ctrl+e"], "command": "open_file", "args": {"file": "${project}" } },
// { "keys": ["super+down"], "command": "goto_definition" },
{ "keys": ["super+b"], "command": "toggle_side_bar" },
{
"keys": ["ctrl+alt+left"],
"command": "set_layout",
@bigandy
bigandy / wordpress.sh
Last active August 29, 2015 14:14
New WordPress build script
#!/bin/bash
function newsite {
local email="andrew@electricstudio.co.uk"
local appdir="/Users/andrew/Sites/$1"
local httpd_vhosts="/etc/apache2/extra/httpd-vhosts.conf"
# local input=$1
# local size=${#input}
# local max="8"
local basedir=$PWD
@bigandy
bigandy / resp.php
Last active August 29, 2015 14:17
Resp Images Find strings in string, order independent.
// original HTML, when added to post
<img src="http://boilerplate.dev/wp-content/uploads/2015/03/spiral_01.jpg" alt="spiral_01" width="993" height="1000" class="alignnone size-full wp-image-45" />
// when change the class, order of HTML is changed.
<img class="alignnone wp-image-45 size-full" src="http://boilerplate.dev/wp-content/uploads/2015/03/spiral_01.jpg" alt="spiral_01" width="993" height="1000" />
Need to get:
1. class
i. the number 45 from the end of wp-image-45
@bigandy
bigandy / pwgen-bash-function
Created August 24, 2015 15:32
pwgen Bash Function
pass() {
if [ -n "$1" ]
then
pwgen -sy $1 1 |pbcopy |pbpaste; echo " Has been copied to clipboard"
else
pwgen -sy 40 1 |pbcopy |pbpaste; echo "Has been copied to clipboard"
fi
}
@bigandy
bigandy / var-into-object-fail.php
Created December 15, 2011 14:43
Not working, giving an error. How to insert variable into object???
function year_sum($year) {
return $minutes_cycled_year = $wpdb->get_var($wpdb->prepare("
SELECT SUM($wpdb->postmeta.meta_value)
FROM $wpdb->postmeta, $wpdb->posts
WHERE $wpdb->postmeta.meta_key='exercise-minutes'
AND $wpdb->postmeta.post_id=$wpdb->posts.id
AND year($wpdb->posts.post_date)='$year'
"));
@bigandy
bigandy / rakefile
Created July 27, 2012 08:22
sass rakefile
#rakefile
namespace :sass do
task :sass_environment => :environment do
Sass::Plugin.on_updating_stylesheet { |template, css| puts "Building #{css} from #{template}" }
Sass::Plugin.on_not_updating_stylesheet { |template, css| puts "Skipping #{css}" }
end
desc "Forcefully updates the stylesheets generated by SASS."
@bigandy
bigandy / json-loop.js
Created November 22, 2012 14:19
JSON Milk Check
window.setInterval(function(){
jQuery.getJSON("/api/milk/single_milk/?dev=1",function(data) {
milkAmount = data['result']['milk-amount'];
console.log(milkAmount);
jQuery('#list').html('<h1>'+milkAmount+'</h1>');
});
@bigandy
bigandy / milk-solution.js
Created November 23, 2012 11:53
Solution
setInterval ( getMilk, 1000 );
var old = "";
function getMilk() {
jQuery.getJSON("/api/milk/single_milk/?dev=1",function(data) {
milkAmount = data['result']['milk-amount'];
if(old != milkAmount) {