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
Rolands-MBP:BIKETOWORKSHOP_COM_SURGE rolandtanglao$ nslookup t.co
Server: 10.244.75.5
Address: 10.244.75.5#53
Non-authoritative answer:
Name: t.co
Address: 199.59.150.44
Name: t.co
Address: 199.59.148.12
Rolands-MBP:BIKETOWORKSHOP_COM_SURGE rolandtanglao$ curl -ILA "Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12H321 Safari/600.1.4" http://t.co/N9vtiDampH
HTTP/1.1 200 OK
cache-control: private,max-age=300
content-length: 0
content-type: text/html; charset=utf-8
date: Fri, 21 Aug 2015 23:10:36 GMT
expires: Fri, 21 Aug 2015 23:15:36 GMT
server: tsa_a
set-cookie: muc=131d3196-0696-4b62-b8fd-de52282c4abd; Expires=Wed, 02 Aug 2017 23:10:36 GMT; Domain=t.co
x-connection-hash: 87566868df47a46e07b2bb987bdb00f0
ggplot(sorted_top_50,aes(x=colorname,y=count))+
geom_bar(colour=head(colour_hex_strings_all,50),
stat=identity”,fill=head(colour_hex_strings_all,
50),width=1,position = position_dodge(width = 0.005)+
scale_x_discrete(limits = sorted_top_50$colorname)+theme(
axis.text.x = element_text(angle=90, hjust=1,
vjust=0.5,size=10))
@rtanglao
rtanglao / testgh.md
Created May 18, 2015 04:32
test-markdown-in-github

The following (hmmm jekyll won’t render my html tag correctly; until I get it fixed, you can find the proper html rendering of the notebook here) is an Jupiter(fka iPython) notebook showing how to download and install my instagram Vancouver 2014 top colour dataset in R

r = getOption(“repos”) # hard code the UK repo for CRAN
r[“CRAN”] = “http://cran.uk.r-project.org”
options(repos = r)
rm(r)

install.packages(“ig.vancouver.2014.topcolour”)
@rtanglao
rtanglao / correctBarGraphggplot2.r
Created May 6, 2015 09:46
correct bar graph using ggplot
ggplot(sorted3,aes(x=colorname,y=count,fill=as.character(sorted3$colorname)))+
stat_summary(fun.y=identity,geom="histogram")+
scale_fill_manual(values=c(as.character(sorted3$colorname)),+
name= "My name", guide = guide_legend(reverse = TRUE))+
scale_x_discrete(limits = sorted3$colorname)
@rtanglao
rtanglao / barplot-csv-with-colour-names-from-csv.r
Created May 2, 2015 05:08
how to make a barplot in R with a CSV file using colours from the CSV file itself
sorted = read.csv("/Users/rolandtanglao/Dropbox/PHOTOS/instagram-top10-vancouver-2014/sorted-ig-van-2014-top-colour-names.csv")
counts3 = head(sorted[,2],200)
colours3 = head(sorted[,1],200)
barplot(counts3, main="Colour Distribution",
col=colours3,
xlab="Top Colours",
ylab="Colour Counts")
@rtanglao
rtanglao / compute colour names.r
Last active August 29, 2015 14:20
compute colour names
require("plotrix")
tc <- function(x) {
return (head(color.id(x),n=1))
}
colour_list8000 = dt8000[,tc(colour),by=colour]
> head(colour_list8000, n=100
+ )
colour V1
1: #FFFFFF white
2: #FEFEFE white
@rtanglao
rtanglao / rgbToSingleColorName.r
Created May 1, 2015 06:12
rgb to single colour
> tc <-function(x) {
+ return (head(color.id(x),n=1))
+ }
> tc("#fefefe")
[1] "white"
> tc("#fefeff")
[1] "white"
> tc("#fefe00")
[1] "yellow"
> lappy(h$count,tc)
@rtanglao
rtanglao / rgbToColorName.r
Created April 28, 2015 06:38
colour rgb to nearest colour name
> nearColour <- function(r,g,b){
+ ctable = col2rgb(colors())
+ cdiff = ctable - c(r,g,b)
+ cdist = cdiff[1,]*cdiff[1,]+cdiff[2,]*cdiff[2,]+cdiff[3,]*cdiff[3,]
+ return(colors()[cdist == min(cdist)])
+ }
> rgb2 = col2rgb("#FEFDFC")
> rgb2[[1,1]]
[1] 254
> rgb2[[2,1]]
@rtanglao
rtanglao / FIXED-plot-top-colour-ig-vancouver-2014.r
Created April 28, 2015 01:27
FIXED plot colour counts in r using a bar graph
counts3 = head(topcolour.ig.vancouver.2014[,2], n=200)
barplot(counts3, main="Colour Distribution",
+ xlab="Top Colours",
+ ylab="Colour Counts")