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.
# Directly copied from eycap-0.5.2 (thanks!)
#
# With these tasks you can:
# - dump your production database and save it in shared_path/db_backups
# - dump your production into your local database (clone_to_local)
#
# Tested and fixed by fjguzman
Capistrano::Configuration.instance(:must_exist).load do
namespace :db do
#!/usr/bin/env perl
# Quick and dirty way of adding a prefix to all tables
# in a sql file
#
# Takes a sql file, duplicates it, and adds whatever
# prefix you pass to all TABLE and INSERT statements
# in the copied file.
#
# Usage: ./dbp.pl example.sql prefix
#!/usr/bin/env ruby
# Answer to part 1 of the Greplin Programming Challenge (http://challenge.greplin.com/)
text = "FourscoreandsevenyearsagoourfthersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwet
# This will search your config/deploy folder for *.rb files
# and add the basename without the extension to :stages.
#
# Now you don't need something like "set :stages, %w(dev prod stage)"
set(:stages) do
Dir[File.join('config', 'deploy') + '/*.rb'].map do |f|
f.match(/[^\/]+?(?=\.[^\/]+$)/)[0]
end
end
@jh3
jh3 / gist:653663
Created October 29, 2010 14:38
.gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@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"
@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 / 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 / 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;