Skip to content

Instantly share code, notes, and snippets.

@jtr109
jtr109 / ex0107.scm
Created May 15, 2017 12:52
SICP ex1.7
(define (average x y)
(/ (+ x y) 2))
(define (improve guess x)
(average guess (/ x guess)))
(define (goodenough? guess x)
(< (/ (abs (- guess
(improve guess x)))
guess)
@jtr109
jtr109 / .zshrc
Created June 19, 2017 10:27
rebase master from uptream into current branch
alias rebase_upstream="export CURRENT_BRANCH_NAME=`git branch | grep \* | cut -d ' ' -f2` && git checkout master && git pull upstream master && git checkout $CURRENT_BRANCH_NAME && git rebase master"
@jtr109
jtr109 / convert.sh
Created August 2, 2017 15:17
convert all files from dos to unix
find -name "*" -print0 | xargs -0 dos2unix
// TODO: the binary files will raise warning without convert.
@jtr109
jtr109 / README.md
Created August 4, 2017 07:14
wxapp bottom popup
@jtr109
jtr109 / local_settings.py
Last active August 16, 2017 00:15
从环境变量中获取 WXAPP_TEST_SITEUSER
import os
WXAPP_TEST_SITEUSER = os.getenv('WXAPP_TEST_SITEUSER') # return None if not exist
@jtr109
jtr109 / README.md
Created August 27, 2017 01:51
A function that takes a list (ls) and an object (x) as arguments and returns a list removing x from ls.
@jtr109
jtr109 / sort.sql
Created November 1, 2017 05:11
Update sort of GenericImage queryset
UPDATE "area_genericimage"
SET "sort" =
CASE WHEN "id" = 40964 THEN 1
WHEN "id" = 40965 THEN 2
END
WHERE "area_genericimage"."id" in (40964, 40965)
@jtr109
jtr109 / backup.sh
Last active November 8, 2017 01:14
Bash Cheatsheet
#!/bin/bash
# Copy a file with time as tail.
# Reference: https://i.linuxtoy.org/docs/guide/ch15s05.html
sudo cp $1 $1_`date +%y%m%d_%H:%M:%S`
@jtr109
jtr109 / datetime.md
Last active January 27, 2018 05:07
My Python Note

Datetime

Native and aware

Definition

There are two kinds of date and time objects: “naive” and “aware”.

An aware object has sufficient knowledge of applicable algorithmic and political time adjustments, such as time zone and daylight saving time information, to locate itself relative to other aware objects. An aware object is used to represent a specific moment in time that is not open to interpretation.

@jtr109
jtr109 / README.md
Last active January 27, 2018 05:54
Eslint tips

Eslint tips