Skip to content

Instantly share code, notes, and snippets.

View netconstructor's full-sized avatar
💭
pushing pixels

Christian Hochfilzer netconstructor

💭
pushing pixels
View GitHub Profile
@javisantana
javisantana / cartodb.js
Created December 19, 2011 14:40
simple cartodb nodejs client
// OAuth supports 3 legged and 2 legged (aka XAuth) authentication.
// This app demonstrates how to use 2 legged authentication with CartoDB
var sys = require('sys')
, querystring = require('querystring')
, OAuth = require('oauth').OAuth
, EventEmitter = require('events').EventEmitter;
function CartoDBClient(user, password, consumer_key, consumer_secret) {
@rbncha
rbncha / image-resize-crop.php
Created January 19, 2012 11:52
Wordpress Image resize and crop function
<?php
/**
* This function is used to resize and crop image
* based on width from the center of the image
*
* creates new image from jpg,gif,png,bmp to png images
*/
function image_resize_crop ( $src, $w, $h, $dest = null, $override = false, $createNewIfExists = false ) {
$ext = array_pop ( explode ('.', $src) );
$filenameSrc = str_replace (".$ext", '', basename($src) );
@Jabbslad
Jabbslad / xbox.js
Created January 21, 2012 19:55
Xbox Live Scraper For PhantomJS
/*
Copyright (c) 2012 Jabbslad
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@drewjoh
drewjoh / custom.js
Created January 27, 2012 13:55
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@tokumine
tokumine / labels.cartodb
Created January 27, 2012 17:57
carto to use labels in CartoDB maps
Just a quick sketch to explain how to use labels in CartoDB:
http://dl.dropbox.com/u/193220/CartoDB/labels.png
Something like this should work while we sort out exactly how to release this:
#populated_places_points_2{
marker-fill:#0099FF;
marker-line-color:white;
marker-line-width:1;
@DGuidi
DGuidi / TileLayer.TileJSON.js
Created February 1, 2012 08:49
Leaflet TileCanvas
L.TileLayer.TileJSON = L.TileLayer.Canvas.extend({
options: {
debug: false
},
tileSize: 256,
initialize: function (options) {
L.Util.setOptions(this, options);
@tokumine
tokumine / hetzner
Created February 2, 2012 15:06
Hetzner EX 4S Unixbench, dd and htparm results
The Unixbench results for the Hetzner EX 4S servers recently featured on HackerNews. (dd and htparm tests at the bottom)
- http://news.ycombinator.com/item?id=3537513
- http://www.hetzner.de/en/hosting/produkte_rootserver/ex4s
To compare with AWS, see the Unixbench results from: http://blog.cloudharmony.com/2010/05/what-is-ecu-cpu-benchmarking-in-cloud.html
TLDR; the €59/mo EX 4S scores higher (1729) than AWS m2.4xlarge (1511) on single threaded loads.
Postscript
@andrewxhill
andrewxhill / file.sql
Created February 3, 2012 15:37
fastest query for admin content
WITH foo AS (SELECT ST_AsGeoJSON(ST_Centroid(ST_Envelope(admin1_attributes_live.the_geom))) as center, ST_AsGeoJSON(ST_Envelope(admin1_attributes_live.the_geom)) as bbox, name_1 as name, id1 FROM admin1_attributes_live WHERE admin1_attributes_live.iso = 'IDN') SELECT center, bbox, foo.name, foo.id1, sum(global_4x_grid.total_incr) as total FROM foo,global_4x_grid WHERE global_4x_grid.iso='IDN' AND global_4x_grid.id1 = foo.id1 group by foo.id1, foo.name, center, bbox ORDER BY total;
--HUMAN READABLE
WITH foo AS
(SELECT
ST_AsGeoJSON(ST_Centroid(ST_Envelope(admin1_attributes_live.the_geom))) as center,
ST_AsGeoJSON(ST_Envelope(admin1_attributes_live.the_geom)) as bbox,
name_1 as name,
<div class="carousel">
<a href="#" class="prev">&nbsp</a>
<ul id="mycarousel" class="jcarousel-skin-carousel">
<?php global $ad_metabox; ?>
<?php query_posts('post_type=ad&showposts=-1') ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<li>
@thisislawatts
thisislawatts / location.php
Created February 22, 2012 23:16
Advanced Custom Field - Location (+Search)
<?php
/*
* Advanced Custom Fields - New field template
*
* Create your field's functionality below and use the function:
* register_field($class_name, $file_path) to include the field
* in the acf plugin.
*
* Documentation: