Skip to content

Instantly share code, notes, and snippets.

@jheth
jheth / table_size.sql
Created November 2, 2015 16:24
MySQL Table Size
SELECT (data_length+index_length)/power(1024,3) tablesize_mb
FROM information_schema.tables
WHERE table_schema='ProposalAgent' and table_name='proposals';
@jheth
jheth / movies.txt
Created November 3, 2015 02:50
Movies
A Perfect Man
Best of Me - Good
Begin Again - Recommend
Celeste and Jesse Forever - Good
a case of you
@jheth
jheth / run_mutant.rb
Created November 9, 2015 02:11
mutant command line
bundle exec mutant --include lib/ --require dynamics_crm --fail-fast --use rspec DynamicsCRM::Client
@jheth
jheth / palindrome
Last active December 12, 2015 00:58
PHP palindrome
<?php
$strings = array("racecar", "bob", "b", "abc", "car", "mom", "diary", null, '');
foreach ($strings as $str) {
if (palindrome($str)) {
print "$str is a palindrome\n";
} else {
print "$str is NOT a palindrome\n";
}
@jheth
jheth / svn-sed-xargs
Last active December 12, 2015 00:58
Look for new or modified files and check them for coding standard violations.
svn status | grep "^[AM]" | sed "s/^. //" | xargs phpcs
@jheth
jheth / ansi-color-control
Last active December 12, 2015 00:58
PHP ANSI Color Control
<?php
echo chr(27) . '[32m' . "This is a green line" . chr(27) . '[0m' . "\n";
echo chr(27) . '[31m' . "This is a red line" . chr(27) . '[0m' . "\n";
function move_right($x) { echo chr(27) . "[{$x}C"; sleep(1); }
function move_left($x) { echo chr(27) . "[{$x}D"; sleep(1); }
function move_up($x) { echo chr(27) . "[{$x}A"; sleep(1); }
@jheth
jheth / phpunit-example
Last active December 12, 2015 00:58
Sample PHP class and PHPUnit test using a dataProvider.
<?php
class StringUtil
{
public function is_palindrome($str)
{
if (!is_string($str)) {
return false;
}
$length = strlen($str);
@jheth
jheth / wget-recursive-fetch
Last active December 12, 2015 02:08
Fetch Rails Guides using wget
wget --recursive --no-clobber --page-requisites --adjust-extension --convert-links --restrict-file-names=unix --domains guides.rubyonrails.org --no-parent http://guides.rubyonrails.org/v2.3.11/
@jheth
jheth / gist:5239103
Created March 25, 2013 17:50
Rails mailer configuration for Google Apps
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => "587",
:domain => "domain.com",
:authentication => :login,
@jheth
jheth / gist:5541976
Created May 8, 2013 17:15
I wanted to capture the redirect location for the visual force salesforce domain. This does just that.
curl = Curl::Easy.http_get('https://tinderbox.na15.visual.force.com')
curl.header_str
http_response, *http_headers = curl.header_str.split(/[\r\n]+/).map(&:strip)
http_headers = Hash[http_headers.flat_map{ |s| s.scan(/^(\S+): (.+)/) }]
http_response # => "HTTP/1.1 200 OK"
http_headers["Location"]