Skip to content

Instantly share code, notes, and snippets.

@flores
flores / clustered google maps markers from sql table
Created April 26, 2011 22:04
clustered google maps markers from sql table
#!/usr/bin/env ruby
# quick and dirty.
# using http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/ to cluster data points
# (prevents slow page loads and timeouts from google)
# i could do this file opens nicer. later.
File.open('/tmp/maps.json','w') {|f| f.write("var data = {maps:[") }
# this too
dataset=`mysql -umyuser mydatabase -e 'SELECT CONCAT(CONCAT("{\'id\':",id,","),CONCAT("\'latitude\':",lat,","),CONCAT("\'longitude\':",\`long\`,"}")) FROM mytable where lat is not NULL' |grep -v CONCAT`
@flores
flores / didn't know sh's "while" could do this...
Created May 4, 2011 22:00
assigning variable names to a space delimited, new-line separated file with sh's "while"
$ while read firstcolumn secondcolumn thirdcolumn; do
> echo -e "First column is $firstcolumn
> Third is $thirdcolumn \n"
> done << EOF
> i like cats
> and pie too
> baby baby yeah
> EOF
First column is i
Third is cats
@flores
flores / gist:975119
Created May 16, 2011 19:21
the world is in /proc/world
box:~# date
Mon May 16 19:14:47 UTC 2011
box:~# cat /proc/sys/xen/independent_wallclock
0
box:~# echo 1 > !$
echo 1 > /proc/sys/xen/independent_wallclock
box:~# ntpdate -s pool.ntp.org
box:~# date
Mon May 16 19:19:21 UTC 2011
this is a test gist for gabe
@flores
flores / wtflog.sh
Created May 20, 2011 07:35
for sporadic wtfs.
#!/usr/bin/env bash
#
# because sometimes a server sporadically acts funny and we're all like wtf.
# date and -+ separated list of general os, system, and network stuff.
echo -e "#!/usr/bin/env bash\n(date; top -n1; ps axfu; iostat; vmstat; df -h; lsof -n -i; netstat -ano; w; echo -e '\n-----------------\n\n') >> /var/log/wtf.log" > /root/wtf.sh
chmod +x /root/wtf.sh
# put it in the crontab.
echo '* * * * * /root/wtf.sh' >> /var/spool/cron/crontabs/root
[root@downoi pacman.d]# pacman -S ruby rubygems
warning: provider package was selected (ruby provides rubygems)
warning: skipping target: rubygems
resolving dependencies...
looking for inter-conflicts...
Targets (2): libffi-3.0.9-1 ruby-1.9.2_p0-4
Total Download Size: 2.82 MB
Total Installed Size: 18.43 MB
@flores
flores / wordpress.vcl
Created June 28, 2011 23:37 — forked from onyxfish/wordpress.vcl
ChicagoNow Varnish configuration (development version)
backend app1 {
.host = "127.0.0.1";
.port = "8000";
}
acl purge {
"127.0.0.1";
"::1";
}
@flores
flores / mysql_grant_checker.pl
Created July 5, 2011 19:09
quick and dirty mysql grant checker
#!/usr/bin/perl -w
use strict;
#die "usage: $0 <mysql_server_hostname>" unless (@ARGV > 0);
#my $server=@ARGV;
#chomp $server;
#my @users=`ssh $server "echo \"select user,host from mysql.user;\" | /usr/bin/mysql"`;
my @users=`echo "select user,host from mysql.user" | /usr/bin/mysql`;
@flores
flores / mysql_tablecheck.pl
Created July 5, 2011 19:19
Really old mysql table checksum script.
#!/usr/bin/perl -w
#########################################
# walks all replicated tables on MySQL
# master and slave. Run with no args
# to see options.
########################################
use strict;
SERVICE=`basename $0`
COMMAND=$1
if [ -z "$SERVICE"] || [ -z "$COMMAND"]; then
echo "usage: `basename $0` <restart|stop|start|status>"
fi
echo "/var/lib/gems/1.8/bin/god $COMMAND $SERVICE"