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 / karabiner-settings.sh
Last active April 12, 2016 07:03
Karabiner Settings
#!/bin/sh
cli=/Applications/Karabiner.app/Contents/Library/bin/karabiner
$cli set remap.fn_fkeys_to_consumer_f10 1
/bin/echo -n .
$cli set private.holdingEscape_to_Control-L 1
/bin/echo -n .
$cli set switch_input_language 1
/bin/echo -n .
@lorne-luo
lorne-luo / server_init.sh
Last active November 9, 2017 21:46
Setup Centos Server
sudo timedatectl set-timezone Australia/Sydney
sudo yum -y update
sudo yum -y install gcc gcc-c++ kernel-devel libxml++-devel libxml2-devel python-devel libxslt-devel libffi-devel openssl-devel mysql-devel
sudo yun -y install ImageMagick-devel libcurl-devel wget zip git bash-completion bash-completion-extras curl enchant
ssh-keygen -t rsa -b 4096 -C "[email protected]"
cat ~/.ssh/id_rsa.pub
sudo vi /etc/sysconfig/network
sudo echo 'HOSTNAME=luotao.net' >> /etc/sysconfig/network
# properly install redis follow official doc on centos
# https://redis.io/topics/quickstart#installing-redis-more-properly
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/
--- a/certification/forms.py
+++ b/certification/forms.py
@@ -309,3 +309,47 @@ class BaseCertRecipeIngredientFormSet(BaseFormSet):
+class CertRecipeAttachmentForm(forms.ModelForm):
+ # id = forms.CharField(label=_("id"), max_length=254, required=False, widget=forms.HiddenInput())
+ type = forms.ChoiceField(label=_("Attachment type"), choices=[('', '----')] + RECIPE_ATTACHMENT_TYPE_CHOICES,
+ required=True,
+ error_messages={'required': "Please select type."})
+ file = ExtFileField(label=_("File"), required=False,
+ ext_whitelist=['.pdf', '.doc', '.docx', '.jpg', '.png', '.gif', '.eps'],
@lorne-luo
lorne-luo / openssl_upgrade.sh
Created November 16, 2017 00:37
upgrade openssl on centos 7
openssl version
cd /home/install
wget https://www.openssl.org/source/openssl-1.0.2m.tar.gz
tar -zxf openssl-1.0.2m.tar.gz
cd openssl-1.0.2m/
./config
make
make test
make install
@lorne-luo
lorne-luo / python_console_for_pycharm.py
Last active March 17, 2020 10:03
django_extensions' shell_plus for Pycharm's python console
# open Pycharm settings->Build,Execution,Deployment->Console->Django Console
# 1.add env var: DJANGO_SETTINGS_MODULE -> settings.settings
# 2.copy below into Starting script
# open preferences->keymap->search `Python Console`->create new shortcut `cmd + 3`
from pprint import pprint
from django_extensions.management.shells import import_objects
from django.core.management.color import no_style
from datetime import datetime
@lorne-luo
lorne-luo / com.mysql.mysql.plist
Last active November 17, 2017 08:51
Mysql auto startup on Mac /Library/LaunchDaemons/com.mysql.mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
@lorne-luo
lorne-luo / README.md
Created November 17, 2017 03:49
Celery 4.1 Intergration with Django 1.11

Celery

Monitor celery by using celery -A freightquotes events

Start celery with beats celery -A freightquotes worker -B -E -l INFO --autoscale=2,1

Note:- 
    -B  beats - to execute schedule tasks
    -l  log-level (INFO/DEBUG)

-E --task-events

@lorne-luo
lorne-luo / run.sh
Last active November 17, 2017 08:47
Solve TLS 1.2 problem on Mac os
# 1. update openssl
brew install openssl
brew link openssl --force
# 2.reinstall python
brew install python --with-brewed-openssl
# 3.re-create virtualenv
rm -rf env/
virtualenv env --python=/usr/local/Cellar/python/2.7.14/bin/python
@lorne-luo
lorne-luo / node_npm_install.sh
Last active November 21, 2017 10:29
install nodejs and npm
# download https://nodejs.org/en/
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
npm init -y
npm set init.author.email "[email protected]"
npm set init.author.name "Lorne"
npm set init.license "MIT"
npm install express-generator -g