Skip to content

Instantly share code, notes, and snippets.

View memorysaver's full-sized avatar

Ming-Cheng Ho memorysaver

View GitHub Profile
@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) {
@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 / 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 / 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)

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 / ethereum.md
Created December 7, 2017 19:14 — forked from suhailvs/ethereum.md
pyethapp tutorial

Pyethapp example

Installation

Virtualenv: $ apt-get install virtualenv

Create an env and activate it:

$ virtualenv venv
$ source venv/bin/activate
@memorysaver
memorysaver / README.md
Created December 9, 2017 13:17 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@memorysaver
memorysaver / README-Template.md
Created December 9, 2017 13:18 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@memorysaver
memorysaver / django_admin_mpld3_view.py
Created March 1, 2020 09:47 — forked from leriomaggio/django_admin_mpld3_view.py
Interactive Matplotlib (Bar) Chart with mpld3 in Django Custom Admin View
#----------------------------------------------------------------------------------------
# model.py
#----------------------------------------------------------------------------------------
from django.db import models
from numpy.random import random_sample
class CustomModel(models.Model):
# Put your fields here
def get_data(self):
def price_twe(date):
date_str = date.strftime('%Y%m%d')
res = requests_get('https://www.twse.com.tw/exchangeReport/MI_INDEX?response=csv&date='+date_str+'&type=ALLBUT0999', headers=headers, )
if res.text == '':
print('holiday')
return pd.DataFrame()
price_row = 200
if date >= datetime.date(2020, 8, 10):