Skip to content

Instantly share code, notes, and snippets.

@Su-Shee
Su-Shee / gist:4595381
Created January 22, 2013 15:16
example R code
# And what's the largest number of men and women in any neighbourhood?
max(aggregate(csv$Anzahl, by = list(csv$Bezirk), FUN = sum)[[2]])
# That doesn't really help, does it? So, display more information - in
# which row do we have the highest number?
which.max(aggregate(csv$Anzahl, by = list(csv$Bezirk), FUN = sum)[[2]])
# Still no use - let's display the entire row:
allHoods <- aggregate(csv$Anzahl, by = list(csv$Bezirk), FUN = sum)
maxRow <- which.max(allHoods[[2]])
@Su-Shee
Su-Shee / Firefox-Mechanize
Created February 10, 2013 16:19
This is how it works...
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize::Firefox;
use Data::Dumper;
my $mech = WWW::Mechanize::Firefox->new(create => 1, activate => 1);
$mech->get('https://familysearch.org/search/collection/index#count=20&query=%2Bgivenname%3ABenjamin%20%2Bsurname%3ASchuvlein%20%2Bbirth_place%3AGermany%20%2Bbirth_year%3A1910-1914~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219');
@Su-Shee
Su-Shee / gist:4955869
Created February 14, 2013 19:59
Plain R without Shiny
# Now we create the barchart:
barplot( height, ylim = c(0, max_bar), # height x axis, length y axis
main = "Zu- und Fortzüge nach Berlin", # headline
ylab = "Anzahl in 1000", # y axis label
names.arg = years, cex.names = 0.5, # year under bar, slightly smaller
beside = TRUE, # sideways
col = c("#990033", "#009933") # assign colors
)
# We're adding a shiny legend, placed topleft
plot( years, num_in, # x, y axis
type = "o", col = "blue", # type of plot lines, color
xlab = "Jahr", ylab = "Anzahl in Tausend", cex.axis = 0.7, #labels
xlim = xrange, ylim = yrange, # length of axis
)
@Su-Shee
Su-Shee / gist:5386828
Created April 15, 2013 08:56
R sqldf
# now let's see if sqldf works nicely. :)
library(sqldf);
file <- '../data/cleaned-einwohnermelderegister-2011.csv'
csv <- read.csv(file, header = TRUE, sep = ';')
# rename columns like the postgres schema
colnames(csv) <- c("official_district", "district", "gender", "nationality", "age", "quantity")
# show the three largest districts by inhabitants
@Su-Shee
Su-Shee / osmpostgis
Last active February 1, 2020 11:03
install open street map data via osm2psql in your postgres database
1) make sure you actually HAVE postgres AND postgis AND plsql!
2) enable postgis extension (may be in a different path or already coming from your distribution)
psql -U YOURUSER -d YOURDB -f /usr/share/postgresql/contrib/postgis-2.0/postgis.sql
or, on psql shell:
CREATE extension postgis;
@Su-Shee
Su-Shee / geocouchosm
Last active December 28, 2015 12:34
adding geocouch to couchdb and add osm data
1) have the couchdb source available, geocouch needs some headerfiles
2) get and unpack the appropriate branch of geocouch suited for your couchdb version -
I have 1.3.0 so I got
https://github.com/couchbase/geocouch/tree/couchdb1.3.x
3) set environment:
export COUCH_SRC=/WHEREVER/apache-couchdb-1.3.0/src/couchdb/
@Su-Shee
Su-Shee / gist:5607078
Created May 19, 2013 08:33
fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font" >
<edit mode="assign" name="autohint" >
<bool>true</bool>
</edit>
<edit mode="assign" name="hinting" >
<bool>true</bool>
</edit>
ImagePath $[FVWM_USERDIR]/icons:+ \
:$[FVWM_USERDIR]/wallpaper:+ \
:$[FVWM_USERDIR]/buttons:+ \
:$[FVWM_USERDIR]/images:+
DestroyFunc StartFunction
AddToFunc StartFunction
+ I Module FvwmPager 0 0
+ I Module FvwmButtons 0 0
+ I Module FvwmAuto 750
@Su-Shee
Su-Shee / gist:6920718
Created October 10, 2013 15:53
gtkrc
# CONFIG TOOLS DO NOT OVERRIDE THIS FILE - THEY ALL WORK ON .gtkrc!
include "/home/banshee/.themes/MyTheme/gtk-2.0/gtkrc"
style "user-font" {
font_name = "Bitstream Vera Sans 7"
}
gtk-font-name="Bitstream Vera Sans 7"
gtk-xft-antialias=1