Skip to content

Instantly share code, notes, and snippets.

View jh3's full-sized avatar
🔥

Joe Hassick jh3

🔥
View GitHub Profile
@jh3
jh3 / helpers.coffee
Last active August 29, 2015 14:03
AngularJS filter of Drupal's truncate_utf8() function
app.filter "truncateText", ->
(string, maxLength, wordsafe = false, addEllipsis = false, minWordsafeLength = 1) ->
ellipsis = ''
maxLength = Math.max(maxLength, 0)
minWordsafeLength = Math.max(minWordsafeLength, 0)
# Remove HTML tags
string = string.replace(/<(?:.|\n)*?>/gm, '')
# No truncation needed, so don't add ellipsis, just return.
@jh3
jh3 / hosts-manager.sh
Created August 26, 2013 01:42
Shell script to manage /etc/hosts. I forget where I found this.
#!/usr/bin/env bash
# Idea and interface taken from https://github.com/macmade/host-manager
path="/etc/hosts"
addusage="Usage: `basename $0` -add host address"
remusage="Usage: `basename $0` -remove host"
case "$1" in
-add)
if [ $# -eq 3 ]; then
if [[ -n $(grep "^$3.*[^A-Za-z0-9\.]$2$" ${path}) ]]; then
@jh3
jh3 / setup-drupal.sh
Created August 26, 2013 01:41
Quickly setup a drupal site for local development
#!/usr/bin/env bash
# For OSX. Assumes you have drush, git, mysql, apache, and Chrome installed.
# Usage: ./setup-drupal.sh cool-app 7
SITE=$1
VERSION=$2
DIR="~/Development/sites/$SITE"

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@jh3
jh3 / drupal-quick-dump.sh
Created November 22, 2012 19:21 — forked from timmillwood/drupal-quick-dump.sh
Script to dump Drupal database structure, but exclude data from massive/unneeded tables.
#!/bin/bash
# usage: drupal-quick-dump user host database
USER="$1"
HOST="$2"
DB="$3"
DATE=`date +%Y%m%d`
# Get User Password
echo "Please provide the password for ${USER} on db ${DB} hosted at ${HOST}:"
@jh3
jh3 / rss-subscribers.sh
Created September 29, 2012 15:50
Bash script to parse Apache log for a count of RSS subscribers and email it to you
#!/bin/bash
# --- Required variables ---
RSS_URI="/rss"
MAIL_TO="your@email.com"
LOG_FILE="/var/log/httpd/access_log"
LOG_DATE_FORMAT="%d/%b/%Y"
# --- Optional customization ---
@jh3
jh3 / android-report.pl
Created September 19, 2012 13:17
Get a monthly report for your Android applications
#!/usr/bin/env perl
# Feed this script an android_report csv file.
# Note: Requires Text::CSV_XS
use strict;
use warnings;
use Text::CSV_XS;
use File::Basename;
@jh3
jh3 / dds.rb
Created March 18, 2012 21:15
Generate a printer friendly DrupalCon Denver schedule
#!/usr/bin/env ruby
# dds.rb -- DrupalCon Denver Schedule
# Create a printer friendly schedule of your DrupalCon Denver sessions
# Usage: ./dds.rb YOURID
# For example: ./dds.rb 34143
require 'nokogiri'
require 'open-uri'
user_id = ARGV[0]
@jh3
jh3 / deploy.rb
Created November 1, 2010 18:32
An example deploy.rb file for drupal-deploy
# Check for drush on your remote server(s)
depend :remote, :command, "drush"
# A couple of custom tasks I use to fix some things. You may add or modify
# anything in this file.
before 'deploy:symlink', 'drupal:symlink:webapp'
after 'deploy:symlink', 'drupal:configure:settings'
after 'deploy:rollback', 'drupal:symlink:webapp'
namespace :drupal do
@jh3
jh3 / Capfile
Created November 1, 2010 18:29
An example Capfile for drupal-deploy
require 'rubygems'
require 'drupal-deploy'
load File.join(File.dirname(__FILE__), 'config', 'lib', 'deploy')
# The name of your Drupal site
set :application, "sandbox"
# The user that will own the files directory
set :web_user, "apache"