Skip to content

Instantly share code, notes, and snippets.

Daniel Chia danielcodes

Block or report user

Report or block danielcodes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8e6ee3eea155d9e6bcd191e8f7bbab6d
upstream app_server {
server unix:/home/daniel/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
root /home/daniel/voting_app/client/build;
server_name <your_server_ip>;
index index.html index.htm;
@danielcodes
danielcodes / migrate-django.md
Created Mar 3, 2018 — forked from sirodoht/migrate-django.md
How to migrate Django from SQLite to PostgreSQL
View migrate-django.md

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 manage.py dumpdata > datadump.json

Change settings.py to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

View library.js
// library class, 2 methods
// find book details by ISBN
// find book by title
// can add more metadata later
function Book(title, author, isbn){
this.title = title;
this.author = author;
this.isbn = isbn;
@danielcodes
danielcodes / minimax.js
Created Jan 10, 2017
Minimax implementation
View minimax.js
'use strict';
// testing out minimax algorithm on node first before adding it to client side
/*
a recursize algorithm
base cases are end states
1 for a win, 0 for a draw and -1 for a loss
recursive steps
@danielcodes
danielcodes / app.py
Created Apr 15, 2016
Flask, messing with file upload
View app.py
import os
from flask import Flask, request, redirect, url_for
from werkzeug import secure_filename
#create this folder structure, static/uploads
UPLOAD_FOLDER = './static/uploads/'
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
View symdiff_es6.js
function sym(args) {
//solution with ES6
//instead of doing manual work, make set operations
//combine values
var union = (set1, set2) => new Set([...set1, ...set2]);
//Common values, set1 values, if set2 has them, keep them
var intersection = (set1, set2) => new Set( [...set1].filter(value => set2.has(value)) );
//keep values that are found only in set1
View table.py
#table formatting example
# lists to create table
header = ['First name', 'Last name']
first = ['Daniel', 'Ronnie', 'Vanessa']
last = ['Chia', 'Hernandez', 'Luka']
# define variables
col_count = 2
col_widths = [10, 9]
View .tmux.conf
#set -g default-terminal "screen-256color"
#prefit to ctrl+a
unbind C-b
set -g prefix C-a
# easy-to-remember split pane commands
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
You can’t perform that action at this time.