Skip to content

Instantly share code, notes, and snippets.

View nelldnine's full-sized avatar

Nell David Soledad nelldnine

  • Cebu, Philippines
  • 06:43 (UTC +08:00)
View GitHub Profile
import logging
import random, string
import cloudstorage as gcs
from google.appengine.ext import blobstore
from google.appengine.api import images
from settings import BUCKET_NAME
def random_string(n=8):
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(n))
@nelldnine
nelldnine / routes.js
Created July 31, 2018 20:22 — forked from rcanepa/routes.js
Private routes with React Router v4
function PrivateRoute ({component: Component, authenticated, ...rest}) {
return (
<Route
{...rest}
render={(props) => authenticated === true
? <Component {...props} />
: <Redirect to={{pathname: '/login', state: {from: props.location}}} />}
/>
)
}
You could just make your own pg_dump directly from your Heroku database.
First, get your postgres string using `heroku config:get DATABASE_URL`.
Look for the Heroku Postgres url (example: `HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8@ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398`), which format is `postgres://<username>:<password>@<host_name>:<port>/<dbname>`.
Next, run this on your command line:
pg_dump --host=<host_name> --port=<port> --username=<username> --password --dbname=<dbname> > output.sql
@nelldnine
nelldnine / gist:2ef194cfae5f691bf074a0c27b35c927
Created October 24, 2017 06:51 — forked from imjakechapman/gist:9945290
iOS 7 fix for not triggering select's onChange event
$.fn.quickChange = function(handler) {
return this.each(function() {
var self = this;
self.qcindex = self.selectedIndex;
var interval;
function handleChange() {
if (self.selectedIndex != self.qcindex) {
self.qcindex = self.selectedIndex;
handler.apply(self);
}
@nelldnine
nelldnine / 0-react-hello-world.md
Created September 22, 2017 05:27 — forked from danawoodman/0-react-hello-world.md
React Hello World Examples

React "Hello World" Examples

Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.

They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).

Usage

You will want to create an index.html file and copy/paste the contents of 1-base.html and then create a scripts.js file and copy/paste the contents of one of the examples into it.

# print prints, puts adds a break line?
puts 'Hello world'
# for loop!
[1, 2, 3].each { |e| puts e }
# classes is over
class Person
def initialize(fname, lname)
@fname = fname
@nelldnine
nelldnine / PostGIS install
Created July 28, 2016 07:56 — forked from sholloway/PostGIS install
Set up a spatial database with PostGIS on EC2 using an EBS.
Steps:
Set up EBS
21Created 1 TB EBS
Created 64 Bit Amazon Linux AMI 2012.09 M1 Medium 3.7 gb ram, 2 ECUs
Connect to ec2 instance via ssh
chmod 400 IFS-KeyPair.pem
ssh -v -i IFS-KeyPair.pem ec2-user@ec2-54-234-14-65.compute-1.amazonaws.com
Note: Do not replace ec2-user with your user id. This is a AWS Amazon AMI requirement.