Skip to content

Instantly share code, notes, and snippets.

View memorysaver's full-sized avatar

Ming-Cheng Ho memorysaver

View GitHub Profile

Keybase proof

I hereby claim:

  • I am memorysaver on github.
  • I am memorysaver (https://keybase.io/memorysaver) on keybase.
  • I have a public key whose fingerprint is 343C 18FC E3D7 2628 71A2 3A01 DD65 10B0 2160 7AA0

To claim this, I am signing this object:

@memorysaver
memorysaver / postgres-cheatsheet.md
Created November 11, 2017 12:45 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@memorysaver
memorysaver / staticencoder.py
Created August 23, 2017 10:14 — forked from goldhand/staticencoder.py
Django template tag for encoding images in base64 and rendering with server
from django import template
from django.contrib.staticfiles.finders import find as find_static_file
from django.conf import settings
register = template.Library()
@register.simple_tag
def encode_static(path, encoding='base64', file_type='image'):
"""
@memorysaver
memorysaver / gist:0f585e7a5479e1b4fe82d9671fd2c221
Created May 31, 2017 15:14
Simple Google Apps Script to export a single sheet to PDF and email it to a contact list
// Simple function to send Weekly Status Sheets to contacts listed on the "Contacts" sheet in the MPD.
// Load a menu item called "Project Admin" with a submenu item called "Send Status"
// Running this, sends the currently open sheet, as a PDF attachment
function onOpen() {
var submenu = [{name:"Send Status", functionName:"exportSomeSheets"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu('Project Admin', submenu);
}
function exportSomeSheets() {
@memorysaver
memorysaver / gist:deba7dc59ba5ac58b3bda382b738c8d2
Created May 31, 2017 14:40 — forked from kaizhu256/gist:4482069
javascript - very fast and simple uuid4 generator benchmarked on http://jsperf.com/uuid4/8
/*jslint bitwise: true, indent: 2, nomen: true, regexp: true, stupid: true*/
(function () {
'use strict';
var exports = {};
exports.uuid4 = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
var uuid = '', ii;
for (ii = 0; ii < 32; ii += 1) {
f <-- find a character
; <-- repeat find (f)
. <-- repeat action
shift+v <-- select all line
: <-- command (f:x) this can repeat an action
#!/bin/bash
# Run docker to build
#docker run -v $(pwd):/outputs -it amazonlinux:2016.09 \
# /bin/bash /outputs/build.sh
set -ex
yum update -y
yum install -y \
@memorysaver
memorysaver / ARKonamiKeyboardView.h
Created January 31, 2017 09:07 — forked from dblock/ARKonamiKeyboardView.h
ASCII Art + Konami Code Easter Egg for iOS
//
// ARKonamiKeyboardView.h
// Artsy
//
// Created by Daniel Doubrovkine on 3/21/14.
// Copyright (c) 2014 Art.sy. All rights reserved.
//
#import <DRKonamiCode/DRKonamiGestureRecognizer.h>
@memorysaver
memorysaver / iflet.m
Created January 12, 2017 13:11 — forked from CraigSiemens/iflet.m
if-let and guard macros for Objective C
#import <Foundation/Foundation.h>
// VARIABLE must be a variable declaration (NSString *foo)
// VALUE is what you are checking is not nil
// WHERE is an additional BOOL condition
#define iflet(VARIABLE, VALUE) \
ifletwhere(VARIABLE, VALUE, YES)
#define ifletwhere(VARIABLE, VALUE, WHERE) \

Videos