Skip to content

Instantly share code, notes, and snippets.

View rdeguzman's full-sized avatar

Rupert de Guzman rdeguzman

View GitHub Profile
@rdeguzman
rdeguzman / pg_functions
Last active April 23, 2018 06:43
Postgres functions for disk monitoring, etc
# postgres mgmt funcitons
## show total_bytes, index_bytes
SELECT c.oid,
nspname AS table_schema,
relname AS TABLE_NAME,
c.reltuples AS row_estimate,
pg_size_pretty(pg_total_relation_size(c.oid)) AS total_bytes,
pg_size_pretty(pg_indexes_size(c.oid)) AS index_bytes
@rdeguzman
rdeguzman / postgis_buffer.sql
Last active February 5, 2024 14:27
postgis buffer a lonlat point with radius in meters
TLDR;
----------------------------------------------------
st_transform(
st_buffer(
st_transform(st_geomFromText('POINT(145.228914 -37.92674)', 4326), 900913),
50 --radius in meters
),
4326
)
----------------------------------------------------
@rdeguzman
rdeguzman / australian-postcodes.sql
Created July 8, 2016 03:49 — forked from randomecho/australian-postcodes.sql
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@rdeguzman
rdeguzman / capybara cheat sheet
Last active August 29, 2015 14:04 — forked from zhengjia/capybara cheat sheet
Capybara Cheatsheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@rdeguzman
rdeguzman / android_developer.md
Last active December 24, 2015 23:09
Android Developer (Freelance)

Android Developer (Freelance)

  • This is project based + remote telecommute/work from home.
  • Port existing MyTravelPhilippines iTunes app (https://itunes.apple.com/ph/app/mytravel-philippines/id376830684?mt=8) to Android
  • Use AndroidStudio or IntellJ Idea (Community Edition).
  • Native Android. No PhoneGap, Appcelerator Titanium, etc. No it won't turn into embedded development! :P
  • You should at least know how to parse JSON from http.
  • Maps and Location experience in Google Android Maps v2, obtaining a GPS fix, etc.
  • You will build the activities, layouts and UI in Android.
  • UI should cater to mobile phones and tablets. Dynamic Layouts?
@rdeguzman
rdeguzman / blog.datalink.loc
Last active December 24, 2015 22:49
Sample apache2.conf with multiple subdomains pointing to a php or rails. Note, these are includes in httpd.conf
@rdeguzman
rdeguzman / gist:6152908
Last active December 20, 2015 15:19
Ruby 1.9.3-p0 Rails 3.1 Seg Fault on OSX10.8.4 WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
(eval):1: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin12.4.0]
-- Control frame information -----------------------------------------------
c:0130 p:---- s:0439 b:0439 l:000438 d:000438 CFUNC :public_instance_methods
c:0129 p:0009 s:0436 b:0436 l:000411 d:000435 EVAL (eval):1
c:0128 p:---- s:0434 b:0434 l:000433 d:000433 FINISH
c:0127 p:---- s:0432 b:0432 l:000431 d:000431 CFUNC :class_eval
c:0126 p:0063 s:0428 b:0428 l:000411 d:000427 BLOCK /Users/rupert/.rvm/gems/ruby-1.9.3-p0@dfms/gems/highline-1.6.19/lib/highline/string_extensions.rb:53
c:0125 p:---- s:0425 b:0425 l:000424 d:000424 FINISH
@rdeguzman
rdeguzman / fail
Last active December 16, 2015 19:38
Postgres Replication with Archiving on Master.
When I set wal_level = 'archive' on master and hot_standby = 'off' in slave.
The slave won't start, replication user seem to authenticate, however the postgres
startup process seems to keep on trying.. why?
# master
wal_level = 'archive'
archive_mode = on
archive_command = '../pgscripts/archive.sh %p %f'
# - Streaming Replication -
109 def getGames(n, t):
110 teams = n
111 table = t[:]
112 if n % 2 == 0:
113 games = [[] for i in range(0, (2*(n-1)))]
114 elif n % 2 != 0:
115 games = [[] for i in range(0, (2*n))]
116 for y in range(0, n):
117 a = table[y]
118 for x in range(0, n):
@rdeguzman
rdeguzman / alias
Last active December 11, 2015 09:59
RAILS_ENV shell shortcuts.. no need to type export RAILS_ENV=development
https://github.com/rdeguzman/dotfiles/blob/master/zsh/aliases
# cd
alias ..='cd ..'
# ls
alias ls="ls -F"
alias l="ls -lAh"
alias ll="ls -l"
alias la='ls -A'