Skip to content

Instantly share code, notes, and snippets.

View apcomplete's full-sized avatar

Alex Padgett apcomplete

View GitHub Profile
@apcomplete
apcomplete / Session.php
Created November 28, 2011 20:12
Native session library for CodeIgniter
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter Native Session Library
*
* @package Session
* @subpackage Libraries
* @category Session
* @author Topic Deisgn
*/
@apcomplete
apcomplete / notes
Created April 4, 2012 18:40
todo.txt notes action
#!/bin/bash
TODOTXT_VERBOSE=0
DEFAULT_NOTES_ACTION="listnotes"
listnotes() {
TODO_LIST_NOTES="ls $TODO_NOTES_DIR | xargs -0 basename | sed -e 's/\.[a-z]\{3\}$//'"
if [ ! -z $TODO_NOTES_PROJECT ]
then
TODO_LIST_NOTES+=" | grep -i $TODO_NOTES_PROJECT"
@apcomplete
apcomplete / gist:3866655
Created October 10, 2012 16:17
Cake watch file
fs = require 'fs'
{exec} = require 'child_process'
util = require 'util'
appFiles = [
{
destination: "path/to/public/scripts/",
join: true
output: "application.js"
files: [
@apcomplete
apcomplete / Backtrace.js
Last active July 21, 2018 08:11
Simple backbone routing without hash URLs
r(function() {
Backtrace = {};
Backtrace.Router = (function() {
Router.prototype.optionalParam = /\((.*?)\)/g;
Router.prototype.namedParam = /:\w+/g;
@apcomplete
apcomplete / gist:5187630
Created March 18, 2013 14:42
bash script for being too lazy to cd into sites directory (with autocompletion)
_sites () {
local client project
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ $prev == "sites" ]
then
COMPREPLY=( $(compgen -W "$(ls /Users/alex/Sites/)" -- $cur) );
else
COMPREPLY=( $(compgen -W "$(ls "/Users/alex/Sites/$prev")" -- $cur));
@apcomplete
apcomplete / gist:5205282
Created March 20, 2013 14:53
jquery.hotspot, plugin for scalable overlaying of clickable hotspots on an image
(function( $ ){
var methods = {
init: function(opts){
var opts = $.extend({
scale: 1
}, opts);
return this.each(function() {
var $this = $(this)
, spots = $this.children('div.hotspot')
, image = $this.children('img')
@apcomplete
apcomplete / app_builder.rb
Last active December 16, 2015 09:49
App Template
client = ask "What's the client name for this project?"
job = ask "What's the job number for this project?"
install_devise = yes? "Do you want to use devise?"
install_rails_admin = yes? "Do you want to use rails_admin?"
gem 'rails-backbone'
gem 'thin'
gem 'capybara', group: [:test,:development]
gem 'rspec-rails', group: [:test,:development]
gem 'faker', group: [:test,:development]
@apcomplete
apcomplete / gist:6800017
Created October 2, 2013 20:26
AppleScript for displaying OSX notifications when receiving a message in Messages without displaying the message text in the notification.
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
tell application "Notifications Scripting"
-- This is required for calling the user notification event handlers. The handlers can be in a different script file.
set event handlers script path to (path to me)
-- The user info parameter is a record. The supported data types are text, integer, real, boolean, date, alias, file and POSIX file.
set dict to {theName:"Notifications Scripting", theVersion:"1.0", theScript:event handlers script path}
display notification "New Message" subtitle "From " & (theBuddy's name as string) message "" sound name "Default" user info dict
@apcomplete
apcomplete / resource.rb
Last active December 29, 2015 03:19
Shared example for request specs
require 'spec_helper'
describe "Scrapbooks" do
context 'beta user' do
before do
@user = FactoryGirl.create :user, :confirmed, roles: [:beta]
@resource = FactoryGirl.create :scrapbook, user: @user
@other_resource = FactoryGirl.create :scrapbook
end
@apcomplete
apcomplete / array_input.coffee
Created March 27, 2014 17:33
Ember easyForm array input using Zurb Foundation
Ember.EasyForm.ArrayInput = Ember.View.extend
classNames: ["row"]
templateName: 'easyForm/array_input'
valueItems: (->
@get('value').map (item) ->
{ value: item }
).property()