Skip to content

Instantly share code, notes, and snippets.

View lorne-luo's full-sized avatar

Lorne Luo lorne-luo

  • Melbourne, Australia
View GitHub Profile
@lorne-luo
lorne-luo / stripe.html
Created November 23, 2017 23:10
Stripe checkout example
{% block content %}
<div class="row">
<div class="col-xs-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Credit Card</h3>
</div>
<form action="" method="post" id="payment-form">
<div class="box-body">
{% csrf_token %}
@lorne-luo
lorne-luo / install-tesseract_centos.sh
Created December 14, 2017 05:33
Install tesseract on centos
cd /opt
yum -y update
yum -y install libstdc++ autoconf automake libtool autoconf-archive pkg-config gcc gcc-c++ make libjpeg-devel libpng-devel libtiff-devel zlib-devel
#Install AutoConf-Archive
wget ftp://mirror.switch.ch/pool/4/mirror/epel/7/ppc64/a/autoconf-archive-2016.09.16-1.el7.noarch.rpm
rpm -i autoconf-archive-2016.09.16-1.el7.noarch.rpm
#Install Leptonica from Source
@lorne-luo
lorne-luo / forms.py
Last active February 21, 2018 22:10
Django forms
from django import forms
class ContactForm(forms.ModelForm):
message = forms.CharField(label='Message',
required=True,
widget=forms.Textarea(attrs={'placeholder': 'First name'}),
error_messages={'required': 'Please enter your message.'})
@lorne-luo
lorne-luo / gulpfile.js
Created March 21, 2018 00:58
gulpfile.js templates
var gulp = require("gulp"),
fastSass = require("gulp-sass"),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
rename = require("gulp-rename"),
imagemin = require('gulp-imagemin'),
iconfont = require('gulp-iconfont'),
iconfontCss = require('gulp-iconfont-css'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat-util'),
@lorne-luo
lorne-luo / post-receive
Last active June 2, 2018 11:11
Git hooks for deployment
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
sudo git --git-dir=/home/git/ozsales.git --work-tree=/opt/ozsales checkout -f master >/dev/null
cd /opt/ozsales
PIP=${HOME}/venv/ozsales/bin/pip
@lorne-luo
lorne-luo / documentation process.md
Created April 24, 2018 05:46
[Butterfly] Documentation process

For each project, dev team should have two kinds of documentation:

  1. documentation for project
  2. documentation for problem-solving which could share with team

Documentation for project

This part should be done in README.md of project root, the content should include:

  1. How to setup/config/build/test/deploy
  2. Brief architecture design
  3. Note for third-party service integration
  4. Troubleshooting
@lorne-luo
lorne-luo / django inline formset.diff
Last active May 22, 2018 23:10
django inline formset with jquery.formset.js
--- b/apps/product/forms.py
+
+class ProductAnalysisInlineForm(forms.ModelForm):
+ class Meta:
+ model = ProductAnalysis
+ fields = '__all__'
+
+ def __init__(self, *args, **kwargs):
+ super(ProductAnalysisInlineForm, self).__init__(*args, **kwargs)
+ for field_name in self.fields:
@lorne-luo
lorne-luo / .bash_profile
Created May 15, 2018 02:46
.bash_profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@lorne-luo
lorne-luo / django inline formset2.diff
Last active May 8, 2019 01:35
django inline formset version2
--- b/apps/product/forms.py
+
+class ProductAnalysisInlineForm(forms.ModelForm):
+ class Meta:
+ model = ProductAnalysis
+ fields = '__all__'
+
+ def __init__(self, *args, **kwargs):
+ super(ProductAnalysisInlineForm, self).__init__(*args, **kwargs)
+ for field_name in self.fields:
@lorne-luo
lorne-luo / xp.py
Last active December 19, 2018 21:56
Wows XP Calculator
def xp(exp_flag, free_exp_flag, exp=4000, first_victory=0.5, is_premium=True):
premium_ratio = 1.5 if is_premium else 1
xp_ratio = 1 + exp_flag + 0.07
if first_victory:
xp_ratio += first_victory
base_exp = exp * premium_ratio * xp_ratio
return int(base_exp), int(base_exp * 0.05 * (1 + 0.2 + free_exp_flag))
# XP Free Captain
# Spring Sky 2 7.77