Skip to content

Instantly share code, notes, and snippets.

View rtanglao's full-sized avatar
😃
you rock :-)

Roland Tanglao rtanglao

😃
you rock :-)
View GitHub Profile
var db = new mongo.Db('mydatabase', new mongo.Server("127.0.0.1", 27017, {}));
db.open(function(e, db) {
get('/', function() {
var $this = this
db.collection('some-collection', function(e, col){
col.find({}, {}, function(e, items) {
items.each(function(err, item) {
sys.puts(sys.inspect(item))
})
@rtanglao
rtanglao / getGastownPhotos.rb
Created September 9, 2010 04:02
get Roland's Gastown's photos
#!/usr/bin/env ruby
require 'json'
require 'net/http'
require 'pp'
require 'Time'
require 'uri'
require 'parseconfig'
flickr_config = ParseConfig.new('flickr.conf').params
api_key = flickr_config['api_key']
@rtanglao
rtanglao / markVancouverpoints.html
Created September 27, 2010 04:26
map with Roland's 21000 geotagged cameraphone photos
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Roland's Vancouver Geotagged Cameraphone Pics</title>
</head>
<body>
<div id="cm-example" style="width: 800px; height: 600px"></div>
<script type="text/javascript" src="http://tile.cloudmade.com/wml/latest/web-maps-lite.js"></script>
<script type="text/javascript" src="vancouver-sample-points.js"></script>
@rtanglao
rtanglao / getAverageColour.rb
Created September 29, 2010 04:23
get average colour of flickr photos from serialized JSON
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'xmlsimple'
require 'pp'
require 'json'
#pp data["variable"][6]["statistic"][0]["rgb"] # or "hex" or "value"
ARGF.each_line do |line|
@rtanglao
rtanglao / sleepyMongooseJSWhereQuery
Created February 24, 2011 03:40
sleepy mongoose JS $where query to find all topics with "comcast" AND "send" and just return the at_sfn url field and sorted by last_active_at
# the trick is to escape any double quotes in the $where queries with "\" i.e %5C
http://localhost:27080/gs/topics/_find?criteria=%7B%22%24where%22%3A%22this.fulltext.indexOf%28%5C%22comcast%5C%22%29%20%21%3D%20-1%20%26%26%20this.fulltext.indexOf%28%5C%22send%5C%22%29%20%21%3D%20-1%22%7D&fields=%7B%22at_sfn%22%3A%221%22%7D&sort=%7B%22last_active_at%22%3A%22-1%22%7D
# or using CURL:
curl -X GET 'http://localhost:27080/gs/topics/_find?criteria=%7B%22%24where%22%3A%22this.fulltext.indexOf%28%5C%22comcast%5C%22%29%20%21%3D%20-1%20%26%26%20this.fulltext.indexOf%28%5C%22send%5C%22%29%20%21%3D%20-1%22%7D&fields=%7B%22at_sfn%22%3A%221%22%7D&sort=%7B%22last_active_at%22%3A%22-1%22%7D'
@rtanglao
rtanglao / tikiToKitsuneWikiSyntax.md
Created March 2, 2011 17:19
how to convert SuMoMo Tiki Wiki kb article content to Kitsune Syntax
  • export PYTHONPATH=/Users/rolandtanglao/Documents/MOZILLA_MESSAGING/KITSUNE/TIKI_TO_KITSUNE_CONVERSION_CODE/pcraciunoiu-kitsune-531b784/apps
  • get the KB article text files as .txt files from Gozer, see bug 6345657
  • for i in *.txt; do cat "$i" | ~/Documents/MOZILLA_MESSAGING/KITSUNE/TIKI_TO_KITSUNE_CONVERSION_CODE/kitsune/apps/sumo/convertSuMoMoKBfiles.py 1> CONVERTED_TO_KITSUNE/"$i".stdout.txt 2> CONVERTED_TO_KITSUNE/"$i".stderr.txt; done
@rtanglao
rtanglao / findingSpamImagesInSuMoMoTiki.md
Created March 2, 2011 17:31
How to find spam images in tiki wiki before upgrading to tiki
  • cd to the directory with the articles from :gozer bug 634657
  • assuming all the images in articles aren't spam, then find all the unique images in the articles:
    • egrep -h -o '{img src=&quot;img/wiki_up/[^-]*-[^-]*-[^-]*-[^\.]*.(jpeg|jpg|png|PNG|JPG)[^&]*&quot;[a-zA-Z0-9 &;=}]*' * | sort | uniq > unique_sumomo_images_1march_2011.txt [file0]
    • egrep -o '[0-9a-f]{32}-[0-9]{10}-[0-9]{1,3}-[0-9]{1}.(png|PNG|jpg|JPG|jpeg|JPEG|gif|GIF)' unique_sumomo_images_1march_2011.txt > just.unique.image.filenames.1march2011.txt [file1]
  • open up those images from :sancus bug 634667 in [file1] and see if any are spam, if so update [file1] by removing them from [file1]
  • find the spam images by removing the known good images from [file1]
    • var=`cat /Users/rolandtanglao/Documents/MOZILLA_MESSAGING/KITSUNE/TIKI_WIKI_ARTICLES/sumo/just.unique.image.filenames.1march2011.txt`
    • `grep -v "$var
@jsocol
jsocol / twitter-fx4.js
Created March 22, 2011 23:32
watch #fx4 tweets stream in
/**
* Start by cloning git://github.com/technoweenie/twitter-node, then
* save this file in the same directory as the clone, edit the login
* information, and run it with:
*
* $ node twitter-fx4.js
*
* then sit back and watch!
*/
var twitter = require('./twitter-node/lib/twitter-node'),
@rtanglao
rtanglao / changed.msgids.javascript.po.txt
Created April 27, 2011 08:14
Changed msgids in messages.po
read 1 line and then replace Firefox with Thunderbird:
msgid "Love Firefox and have a few moments to help?<br /> Help other Firefox users on Twitter. Good things will come to those who tweet!"
msgid "Sign in with <mark>Twitter</mark>"
msgid "Want to go beyond 140 characters? <a href=\"%(join_url)s\">Join the support community</a> and help many more Firefox users."
msgid "Firefox Support Home Page"
msgid "Need Help With <mark>Firefox?</mark>"
msgid "Firefox Sync Support Home Page"
msgid "Need Help With <mark>Firefox Sync?</mark>"
msgid "Firefox Help"
@rtanglao
rtanglao / changed.msgids.javascript.po.txt
Created April 27, 2011 08:18
Changed msgids in javascript.po
msgid "Show content only for specific versions of Firefox or operating systems."
exceptions:
* note that in Polish, instead of Firefox->Thunderbird Firefox, Firefox ->Thunderbirda because the Polish organizers have decided to decline foreign language nouns like Thunderbird and Firefox (AFAIK no other locales have done that)