Skip to content

Instantly share code, notes, and snippets.

View demimismo's full-sized avatar

David Arango demimismo

View GitHub Profile
@demimismo
demimismo / gist:3987282
Created October 31, 2012 14:20 — forked from snikch/gist:2582549
Prevent AssetNotPrecompiledError before it occurs.
##
# Checks that the precompile list contains this file or raises an error, in dev only
# Note: You will need to move config.assets.precompile to application.rb from production.rb
def javascript_include_tag *sources
raise_on_asset_absence sources
super *sources
end
def stylesheet_link_tag *sources
raise_on_asset_absence sources
differ = RSpec::Expectations::Differ.new
puts differ.diff_as_object "Lorem Ipsum is simply dummy text of the printing\n and typeseting industry",
"Lorem Ipsum is simply dummy text of the printing\n and typesetting industry"
Lorem Ipsum is simply dummy text of the printing
- and typesetting industry
+ and typeseting industry
# Fix for bubblemaps
# Applying an SQL to polygon tables with bubble maps until Mapnik 2.1.1 is released
if data_layer.options['tile_style'].present? &&
table.the_geom_type == "multipolygon" &&
data_layer.options['tile_style'] =~ /.*marker-placement:\s*point.*/
fields = table.schema(:reload => true).map {|i| i.first.to_s } - ["the_geom_webmercator"]
data_layer.options['query'] = "SELECT #{fields.join(',')}, ST_PointOnSurface(the_geom_webmercator) as the_geom_webmercator FROM #{table.name}"
end
UPDATE zip_nyc o SET o.the_geom = n.the_geom\n FROM ( VALUES\n (ST_SetSRID(ST_GeomFromText('MULTIPOLYGON (((-60.22 -80.28584, -60.90862 -80.74834, -61.84389 -80.8364, -67.03195 -80.1664, -62.55 -80.2589, -60.69501 -79.61, -60.17361 -79.71167, -60.22 -80.28584)), ((162.15973 -79.06168, 161.94779 -79.03084, 161.92584 -78.98167, 162.15973 -79.06168)), ((-162.13336 -78.74112, -158.5325 -79.7139, -161.08585 -79.83528, -163.81641 -79.2075, -162.13336 -78.74112)), ((-39.9725 -78.55473, -37.45945 -78.64029, -41.93056 -78.59195, -39.9725 -78.55473)), ((-70.94556 -79.65001, -71.85529 -79.42029, -70.30417 -78.80528, -67.31723 -78.50362, -70.94556 -79.65001)), ((167.31555 -78.25362, 166.87164 -78.20808, 167.67749 -78.11752, 167.31555 -78.25362)), ((166.35221 -78.31363, 166.06555 -78.11475, 166.77417 -78.22112, 166.35221 -78.31363)), ((-44.11445 -78.6989, -45.57528 -78.85196, -43.79333 -79.00362, -44.58334 -79.33389, -43.46612 -79.47029, -43.35445 -79.77972, -44.5725 -80.09222, -4
SELECT sum(pg_relation_size(quote_ident(table_name)))
FROM information_schema.tables
WHERE table_catalog = database_name AND table_schema = 'public'
AND table_name != 'spatial_ref_sys' AND table_type = 'BASE TABLE'
@demimismo
demimismo / gist:5414443
Last active December 16, 2015 09:39
Install CartoDB-ready gdal on OSX using brew

Install CartoDB-ready gdal on OSX using brew

First of all, remove your previous version of gdal (if any):

brew uninstall gdal --force

Next, you need to remove any references to sqlite and spatialite from brew's gdal formula:

@demimismo
demimismo / gist:5525507
Last active December 17, 2015 00:59
Cartodbfy any existing postgresql table

First of all, open a rails console

bundle exec rails c

And then:

table = Table.new

Keybase proof

I hereby claim:

  • I am demimismo on github.
  • I am demimismo (https://keybase.io/demimismo) on keybase.
  • I have a public key whose fingerprint is F529 65CA 9262 89C9 2F1F DFBE D6C2 F97E 068E 0A8D

To claim this, I am signing this object:

//Compara el índice del array de objetos TramoEduBean y el índice de la opción del combo seleccionado
if (document.getElementById("comboTipoEnsenanza").selectedIndex == 1){
RecuperarNivelesEducativosDWR.obtenerNivEdu("comboNivelEducativo","0010","LOGSE","",rellenarComboNivelEducativoDWR);
//ComboRS('RefrescarComboNivelEduRS.icm','0010'+'#'+'LOGSE','comboNivelEducativo');
varcedlegislacion = 'LOGSE';
}
//Compara el índice del array de objetos TramoEduBean y el índice de la opción del combo seleccionado
if (document.getElementById("comboTipoEnsenanza").selectedIndex == 2){
💩 = ["David", "Raúl"]
💩[10.times.map{Random.new.rand(2)}.group_by{|e| e}.values.max_by(&:size).first]