Skip to content

Instantly share code, notes, and snippets.

View adeolaawoyemi's full-sized avatar
🏠
Working from home

Adeola Awoyemi adeolaawoyemi

🏠
Working from home
  • Yahoo
  • San Jose, CA
View GitHub Profile
@adeolaawoyemi
adeolaawoyemi / resizeImage.js
Created October 25, 2010 02:22
functions for resizing/scaling images proportionally
function resizeimage(img) {
var max_width = img.parent().width();
var max_height = img.parent().height();
//console.log('max dimensions are: %s x %s', max_width, max_height);
var width = img.width();
var height = img.height();
//console.log('img dimensions are: %s x %s', width, height);
var image = img;
(image.width()/image.parent().width()) > (image.height()/image.parent().height()) ?
image.css({'width':'100%'}) :
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql # run this in terminal
mysql> set global time_zone='UTC';
@adeolaawoyemi
adeolaawoyemi / flush_dns_cache.sh
Created November 9, 2010 11:38
To flush the DNS cache in Mac OS X:-
#!/bin/sh
# type dscacheutil -flushcache in your terminal to flush the DNS resolver cache.
# ex: bash-2.05a$ dscacheutil -flushcache
# Once you run the command your DNS cache (in Mac OS X Leopard) will flush.
dscacheutil -flushcache
@adeolaawoyemi
adeolaawoyemi / perl CPAN Timeouts
Created November 23, 2010 14:30
perl CPAN Timeouts
I started seeing this error when I used CPAN to fetch stuff:
Fetching with LWP:
ftp://ftp.planetmirror.com/pub/perl/CPAN/modules/02packages.details.txt.gz
LWP failed with code[400] message[FTP return code 000]
Fetching with Net::FTP:
ftp://ftp.planetmirror.com/pub/perl/CPAN/modules/02packages.details.txt.gz
Couldn't fetch 02packages.details.txt.gz from ftp.planetmirror.com
Fetching with LWP:
@adeolaawoyemi
adeolaawoyemi / diff_directories.sh
Created November 24, 2010 01:08
find the differences between directories
diff -urb /dir/one /dir/two
@adeolaawoyemi
adeolaawoyemi / random.pl
Created December 10, 2010 15:38
select random window (or item from hash)
#!/opt/local/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @windows = qw/one two three four/;
my %windows = map { $_ => $_ } @windows;
@adeolaawoyemi
adeolaawoyemi / random.rb
Created December 10, 2010 16:24
the ruby way
# Choose random window, the Ruby way ;-)
windows_array = ['one', 'two', 'three', 'four']
windows_hash = Hash[ *windows_array.collect { |v| [ v, v ] }.flatten ]
def get_random_window(wa,wh)
windows_count = wa.length
puts "We have #{windows_count} windows"
chosen = rand(windows_count);
name = wa[chosen]
@adeolaawoyemi
adeolaawoyemi / 001_home_links.pl
Created December 16, 2010 13:08
Perl Selenium tests for Pbx home page links
@adeolaawoyemi
adeolaawoyemi / gist:745959
Created December 18, 2010 00:19
hilight keywords like 'FIXME:', 'TODO:' and 'BUG:' in code
;; hilight some useful keywords
(set-face-background 'font-lock-warning-face "yellow")
(set-face-foreground 'font-lock-warning-face "black")
(add-hook 'font-lock-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 font-lock-warning-face prepend)))))
@adeolaawoyemi
adeolaawoyemi / ping.rb
Created January 18, 2011 14:12
ping a list of servers to know if they are available
# script to ping server for activity
# Author: Adeola Awoyemi ([email protected])
require 'net/http'
require 'uri'
urls = [
'http://www.photobox.co.uk/',
'http://www.idontexist.co.uk/'
]