Skip to content

Instantly share code, notes, and snippets.

@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@devgeeks
devgeeks / s3-phonegap-upload.js
Created November 27, 2012 19:47
S3 direct upload
var options = new FileUploadOptions();
options.fileKey="fileupload";
var time = new Date().getTime();
var userId = getUserId(); // In my case, Parse.User.current().id;
var fileName = userId+"-"+time+".jpg";
options.fileName = fileName;
options.mimeType ="image/jpeg";
options.chunkedMode = false;
var uri = encodeURI("https://BUCKET_NAME.s3.amazonaws.com/");
@theangryangel
theangryangel / AuthController.js
Created February 28, 2013 21:54
sails (v0.8.82) + passport + passport-local Rough Example. For the love of all that is holy, don't use this in production.
// api/controllers/AuthController.js
var passport = require('passport');
var AuthController = {
login: function (req,res)
{
res.view();
},
@JesseObrien
JesseObrien / gist:7418983
Last active January 31, 2024 06:24
Bind parameters into the SQL query for Laravel ORM
<?php
class MyModel extends Eloquent {
public function getSql()
{
$builder = $this->getBuilder();
$sql = $builder->toSql();
foreach($builder->getBindings() as $binding)
{
@andrewxhill
andrewxhill / DataKind.md
Last active January 3, 2016 06:29
DataKind mapping crash course

Short link to this document http://bit.ly/Kh6TbW

Data for today's course is available from Nijel.org. Instead of downloading the data locally, we are just going to copy the URL to the public CSV of data, http://nijel.org/nysewage/ssoreports.csv. Select the URL http://nijel.org/nysewage/ssoreports.csv and copy to your clipboard.

Importing data

There are a few options in CartoDB for adding data to your account.

  1. Drag and drop files to your dashboard (CSV, KML, SHP, etc.)
  2. Paste URLs into the import menu
@mikepugh
mikepugh / FirebaseStateSecurityManager
Last active December 16, 2016 12:09
StateSecurityManager - ui-router version of the RouteSecurityManager from angularFire-seed
/*
MIT License
ui-router Port of Firebase Simple Login RouteSecurityManager from
https://github.com/firebase/angularFire-seed/blob/master/app/js/module.routeSecurity.js
For any state that requires security, setup a custom data authRequired flag:
.state('profile', {
url: '/acct/profile',
templateUrl: 'views/account/profile.html',
@dwchiang
dwchiang / .zshrc
Created April 16, 2014 10:30
gcloud with zsh
# The next line updates PATH for the Google Cloud SDK.
source /Users/dwchiang/google-cloud-sdk/path.zsh.inc
# The next line enables zsh completion for gcloud.
source /Users/dwchiang/google-cloud-sdk/completion.zsh.inc
@jeremeamia
jeremeamia / aws-csv-streamwrapper.php
Created June 6, 2014 18:23
Shows how to read a CSV stored in S3 using the AWS SDK for PHP's S3 Stream Wrapper.
<?php
require __DIR__ . '/vendor/autoload.php';
$s3 = Aws\S3\S3Client::factory($config);
$s3->registerStreamWrapper();
$url = 's3://{$bucket}/{$key}';
// Read CSV with fopen
@stevenmaguire
stevenmaguire / laravel-nearby-locations-query-scope.php
Last active March 28, 2020 22:40
Laravel (Illuminate) query builder scope to list neighboring locations within a given distance from a given location
<?php
/**
* Query builder scope to list neighboring locations
* within a given distance from a given location
*
* @param Illuminate\Database\Query\Builder $query Query builder instance
* @param mixed $lat Lattitude of given location
* @param mixed $lng Longitude of given location
* @param integer $radius Optional distance
@carymrobbins
carymrobbins / setup-postgresql-vagrant.md
Last active May 4, 2023 10:22
Configure PostgreSQL in a Vagrant guest to allow connections from the host.

Configure Postgres

  • Update pg_hba.conf (most likely in /etc/postgresql/9.4/main) with -
    • host all all 0.0.0.0/0 trust
  • Update postgresql.conf to use listen_addresses = '*'
  • Be sure to sudo service postgresql restart

Configure Vagrant