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
@rtanglao
rtanglao / plot-top-colour-ig-vancouver-2014.r
Created April 28, 2015 00:16
plot colour counts in r using a bar graph
counts <- table(topcolour.ig.vancouver.2014$count)
barplot(counts, main="Colour Distribution",
+ xlab="Colour Counts")
@rtanglao
rtanglao / process100files.sh
Created April 3, 2015 20:03
process 100 files at a time
# Bash
files=(/usr/include/*.h /usr/include/sys/*.h)
for ((i=0; i<${#files[*]}; i+=100)); do
grep foo "${files[@]:i:100}" /dev/null
done
@rtanglao
rtanglao / crop10x1_to1x1.sh
Created April 1, 2015 07:31
crop 1.9 million top 10 colour 10x1 px to top colour 1x1 pixel pngs
gm convert -crop 1x1+0+0 @top10jpgs.txt +profile "*" +adjoin TOPCOLOUR/%07d-top-colour.png
@rtanglao
rtanglao / crop.sh
Created April 1, 2015 06:23
crop 10x1 image to 1x1
gm convert -crop 1x1+0+0 0000001-top10.jpg +profile "*" 0000001-top-colour.png
gm montage -verbose -adjoin -tile 192x1080 +f +shadow +label \
+adjoin -geometry '10x1+0+0<' @all_jpgs.txt %06d-hd-all-vancouver-2014.jpg
@rtanglao
rtanglao / indexsubfield.js
Created March 23, 2015 07:01
how to index a mogodb subfield
> db.photos.ensureIndex({"images.thumbnail.url": 1});
{
"createdCollectionAutomatically" : true,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
@rtanglao
rtanglao / getTop10.rb
Created March 22, 2015 17:17
get top 10 colours of an image
#!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
TOP_N = 10 # Number of swatches
# Create a 1-row image that has a column for every color in the quantized
# image. The columns are sorted decreasing frequency of appearance in the
# quantized image.
def sort_by_decreasing_frequency(img)
Verifying that +rtanglao is my Bitcoin username. You can send me #bitcoin here: https://onename.io/rtanglao
@rtanglao
rtanglao / _.md
Created July 14, 2014 23:12
test widget
@rtanglao
rtanglao / find-url-fragment-in-mongodb.js
Created May 26, 2014 23:08
find a piece of a url in a mongodb field
db.photos.findOne({"url_sq" : {$regex : ".*548386304_8c12cfe51c_s.*"}})