Skip to content

Instantly share code, notes, and snippets.

View adamwalter's full-sized avatar

Adam Walter adamwalter

View GitHub Profile
@adamwalter
adamwalter / ask.sh
Created April 1, 2016 15:27
Bash: General-purpose Yes/No prompt function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# http://djm.me/ask
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@adamwalter
adamwalter / github_repos.rb
Last active March 16, 2016 16:22 — forked from c10b10/github_repos.rb
Clones all the private github repos from a certain organization, including branches, submodules and wiki
#!/usr/bin/env ruby
require "json";
# Change github credentials and organization name
github = {:user => "johndoe", :pass => "password", :org => "twitter"}
repos = `curl --user "#{github[:user]}:#{github[:pass]}" https://api.github.com/orgs/#{github[:org]}/repos\?per_page\=200\&type\=private`
for repo in JSON.load(repos)
puts "\n+++ Starting with " + repo["name"]
%x[git clone #{repo["ssh_url"]}]
@adamwalter
adamwalter / gf-acf-image-attachment-maker.php
Last active September 12, 2015 21:02 — forked from adamplabarge/gf-acf-image-attachment-maker.php
GF-ACF image attachment maker
<?php
/**
* Change the default GF upload path
* https://www.gravityhelp.com/documentation/article/gform_upload_path/
*/
function agw_change_upload_path($path_info, $form_id){
$wp_upload_path = wp_upload_dir();
$path_info["path"] = $wp_upload_path['path'] . '/';
$path_info["url"] = $wp_upload_path['url'] . '/';
@adamwalter
adamwalter / .jshintrc
Last active August 29, 2015 14:26 — forked from sdempsey/.jshintrc
my .jshintrc
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
@adamwalter
adamwalter / functions.php
Last active October 19, 2018 04:05
Tracking WordPress Data in Google Analytics
<?php
/**
* Enqueue ga.js and pass PHP variables into it
*/
function ga_script_enqueuer() {
wp_enqueue_script('ga', get_template_directory_uri() . 'ga.js');
@adamwalter
adamwalter / .bash-custom-cd-with-autocomplete
Last active August 29, 2015 14:05
cd into custom directory with tab autocomplete of its subdirectories
_dirComplete()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(ls ~/public_html/dev/)" -- $cur) )
}
complete -F _dirComplete cddev
cdDev() {
cd ~/public_html/dev/$1
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"csslint": {
{
"browser": true,
"devel": true,
"jquery": true,
"undef": true,
"unused": true
}
@adamwalter
adamwalter / serverLoadMonitor.sh
Last active December 31, 2015 20:29
Monitor script for high server load
#! /bin/sh
#
# Script to send email notification if a server exceeds a specified load average.
#
# Selected load average limit.  If above this number a notification message will be emailed.
NOTIFY="8"
TRUE="1"
# Email address to receive alerts.
// New plugin file:
import sublime, sublime_plugin
class ScopeToClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit):
sublime.set_clipboard(self.view.syntax_name(self.view.sel()[0].b))
// Set key binding:
{ "keys": ["shift+alt+command+p"], "command": "scope_to_clipboard" }