Skip to content

Instantly share code, notes, and snippets.

View druid628's full-sized avatar

Micah Breedlove druid628

View GitHub Profile
@druid628
druid628 / RemoveDOSlineEndings.sh
Last active October 30, 2019 18:39
Perl 1-Liner to remove dos line endings from a file (all the while backing it up)
#NOTE: ^M -- To get the ^M you must use <CTRL+V><CTRL+M>
#
# $ perl -p -i.bak -e "s/^M//g" <FILENAME>
#
#Creates a <FILENAME>.bak file and removes the DOS line ending (^M)
perl -p -i.bak -e "s/^M//g" <FILENAME>
@druid628
druid628 / busyScript.groovy
Created November 9, 2011 21:01
Inspired by epochBlue's lookBusy Script. Installing grails plugins sure do take a long time :D
#!/usr/bin/groovy
import java.util.Random
def scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent;
def pluginsList = ["spring-security-core", "dojo", "hibernate", "tomcat", "searchable", "spring-social-core", "uploadr"];
def grailsHeading = "Using Java at: /usr/lib/jvm/java-6-openjdk\n" +
"Welcome to Grails 1.3.7 - http://grails.org/\nLicensed under Apache Standard License 2.0\n" +
"Grails home is set to: /usr/share/grails/1.3.7\nBase Directory: ${scriptDir}\nResolving dependencies...\n" +
"Dependencies resolved in 888ms.\nRunning script /usr/share/grails/1.3.7/scripts/InstallPlugin.groovy\n" +
@druid628
druid628 / urlShortCode.php
Created December 2, 2011 16:42
phpUrlShortenMethod
<?PHP
$url = "http://blog.code-grove.net";
echo urlShorten($url);
exit();
function urlShorten($url, $times2Split = 6)
{
$encoded2 = generateHashes($url);
// for testing purposes we're only using the $encoded['md5']
@druid628
druid628 / delicious.groovy
Created December 16, 2011 02:54
Delicious RSS to HTML Converter (groovy)
#!/usr/bin/groovy
/**
* Del.icio.us RSS to HTML converter
* command line groovy script execution 1 required argument
* with 1 optional argument
*
*
* syntax:
* groovy delicious http://feeds.delicious.com/v2/rss/<user>?private=<key>\&count=<count> [ /path/to/output/file ]
* groovy delicious http://feeds.delicious.com/v2/rss/<user>?count=<count> [ /path/to/output/file ]
@druid628
druid628 / f_ck_you.sh
Created February 6, 2013 16:40
Easy way to destroy all data within files inside a given directory
#!/bin/bash
# Gotcha!
if [ $# -ne 1 ]; then
echo "No directory using current."
exit 0
fi
if [ ! -d $1 ]; then
echo "That is not a directory dumbass."
@druid628
druid628 / Shell_n2k
Created February 18, 2013 20:51
handy shell reminders
# Shell need to knows:
${PWD##*/} # current directory name not path cheaper than basename $PWD
@druid628
druid628 / MP3Player.php
Created March 8, 2013 20:16
PHP Traits -- After a discussion about traits and using them as a class within the name space I put together this little gist.
<?PHP
# src/druid628/traittesting/MP3Player.php
namespace druid628\traittesting;
use druid628\traittesting\traits as TRAITS;
class MP3Player
{
use TRAITS\Track
{
@druid628
druid628 / s649.php
Last active December 16, 2015 02:59
who voted what in the senate in S. 649 (Safe Communities, Safe Schools Act of 2013)
<?PHP
$context = stream_context_create(array('http' => array('header' => 'Host: www.govtrack.us')));
$url = 'http://www.govtrack.us/api/v2/vote_voter?vote=113312';
$s649 = json_decode(file_get_contents($url, 0, $context), true);
foreach ($s649['objects'] as $key => $object) {
$name = $object['person']['name'];
$vote = substr($object['option']['value'], 0, 1);
echo "$name -- $vote\n";
}
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@druid628
druid628 / AnnotationDI.php
Last active December 16, 2015 16:29
Annotation based Dependency Injection
<?php
// Based on http://www.php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php#108466
//dependency to inject
class dep {}
class a {
/**
* @inject
* @var dep