Skip to content

Instantly share code, notes, and snippets.

View andredublin's full-sized avatar
🐝
buzz

Andre Dublin andredublin

🐝
buzz
View GitHub Profile
@andredublin
andredublin / workflow.rb
Created December 19, 2011 22:20
Heroku + Rails Generator
gem("thin")
gem("bcrypt-ruby", version:"~> 3.0.0")
gem("heroku")
gem("gravatar_image_tag")
gem("kaminari")
gem("bourbon", group: 'assets')
gem("annotate", group: 'development', :git => 'git://github.com/ctran/annotate_models.git')
gem("ffaker", group: 'development')
if yes?("Would like to install Zurb Foundation?")
@andredublin
andredublin / gist:1522158
Created December 26, 2011 21:43
Investigate an object with PHP Reflection API
function classData(ReflectionClass $class)
{
$details = "";
$name = $class->getName();
if ($class->isUserDefined())
{
$details .= "$name is user defined\n";
}
if ($class->isInternal())
@andredublin
andredublin / gist:1522162
Created December 26, 2011 21:44
Reflection API Utility to access source of a class
class ReflectionUtil
{
static function getClassSource(ReflectionClass $class)
{
$path = $class->getFileName();
$lines = @file($path);
$from = $class->getStartLine();
$to = $class->getEndLine();
$len = $to-$from+1;
return implode(array_slice($lines, $from-1, $len));
@andredublin
andredublin / gist:1522178
Created December 26, 2011 21:57
Investigate object methods with PHP Reflection API
$my_class = new ReflectionClass('MyClass');
$methods = $my_class->getMethods();
foreach ($methods as $method)
{
print methodData( $method );
print "\n----\n";
}
@andredublin
andredublin / gist:1522183
Created December 26, 2011 22:00
Reflection API Utility to access method source of a class
class ReflectionUtil
{
static function getMethodSource(ReflectionMethod $method)
{
$path = $method->getFileName();
$lines = @file($path);
$from = $method->getStartLine();
$to = $method->getEndLine();
$len = $to-$from+1;
return implode(array_slice( $lines, $from-1, $len));
@andredublin
andredublin / gist:1522191
Created December 26, 2011 22:10
Investigate method arguments with PHP Reflection API
$my_class = new ReflectionClass('MyClass');
$method = $my_class->getMethod("__construct");
$params = $method->getParameters();
foreach ($params as $param)
{
print argData($param);
}
@andredublin
andredublin / simplescroll
Created January 15, 2012 01:13
Sometimes localscroll doesn't work for me, so I made this function to do simply vertical navigation
$navLinks.click(function(event) {
var pos1, pos2, hash, start, end, total, time,
$this = $(this),
offset = $($this.attr('href')).offset().top,
pos1 = $this.offset().top,
hash = event.currentTarget.hash.toString(),
pos2 = $(hash.toString()).offset().top,
$target = $('html, body');
start = parseInt(pos1);
end = parseInt(pos2);
@andredublin
andredublin / separate and group
Created January 19, 2012 18:56
Group values separated by commas from a column
SELECT
SUBSTRING_INDEX(column_name, ',', -1)
AS xxx
FROM table_name
WHERE 1
GROUP BY
SUBSTRING_INDEX(column_name, ',', -1)
ASC
@andredublin
andredublin / delete non-existant records
Created January 19, 2012 19:03
Super quick records deletion in table child that don't exist in table parent
DELETE
FROM table_child
WHERE NOT EXISTS (
SELECT table_parent.id
FROM table_parent
WHERE table_child.id = table_parent.id)
@andredublin
andredublin / custom.css
Created February 8, 2012 13:59
Fork of Darcy's Chrome Dev Tools Skin
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*