Skip to content

Instantly share code, notes, and snippets.

Thanh Nguyen nguyenbathanh

Block or report user

Report or block nguyenbathanh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nguyenbathanh
nguyenbathanh / run.py
Last active Sep 15, 2019
Django Development Server - Skip system checks and migration checks
View run.py
# You need to put this under <app>/management/commands/run.py
# where <app> is whatever appropriate app should have this command.
# Then you can invoke it with ./manage.py run and you'll get something like:
# Performing system checks...
# SKIPPING SYSTEM CHECKS!
# SKIPPING MIGRATION CHECKS!
View gist:204baa2dac8e5ff150c9d61b1ab01bfb
This file has been truncated, but you can view the full file.
[
{
"name": "Apple",
"value": "214480",
"year": 2018,
"lastValue": "211447.400000003",
"rank": 1
},
{
@nguyenbathanh
nguyenbathanh / encoder.py
Last active Oct 31, 2018
MongoEngineJSONEncoder. Dump the data in a BaseDocument ,QuerySet of Mongo documents to JSON
View encoder.py
import datetime
import json
from bson import ObjectId
from mongoengine.base import BaseDocument
from mongoengine.queryset import QuerySet
class MongoengineEncoder(json.JSONEncoder):
def default(self, obj):
@nguyenbathanh
nguyenbathanh / squash-commits.sh
Created Aug 17, 2018 — forked from jbub/squash-commits.sh
git squash last two commits into one
View squash-commits.sh
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@nguyenbathanh
nguyenbathanh / encoder.py
Created Apr 15, 2018 — forked from gati/encoder.py
Mongoengine JSON encoder
View encoder.py
import json
from collections import Iterable
from bson import ObjectId
from datetime import datetime
class MongoengineEncoder(json.JSONEncoder):
"""
The default JSON encoder that ships with Mongoengine (the to_json method
exposed on Document instances) makes some odd choices. Datetime objects
are nested on a $date property, ObjectIds are nested on an $oid property,
View update-to-php5.6-on-ubuntu-14.04.sh
#!/bin/sh
# In case df shows >90% for /boot run:
#sudo apt-get autoremove
# Add repository
sudo add-apt-repository ppa:ondrej/php
# Install required packages
sudo apt-get update
View gist:3aea976fe3f7ea5dc60948b20a467fa2
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "DejaVu Sans Mono",
// "files.trimTrailingWhitespace": true,
"editor.fontSize": 14,
"editor.tabSize": 2,
"files.eol": "\n",
"editor.cursorBlinking": "smooth",
"search.exclude": {
"**/.git": true,
@nguyenbathanh
nguyenbathanh / config
Last active Jan 3, 2018
My sublime settings
View config
{
// "auto_complete_cycle": true,
"caret_extra_bottom": 1,
"caret_extra_top": 2,
"caret_extra_width": 1,
"caret_style": "blink",
"drag_text": false,
"draw_white_space": "none",
// "ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
View gist:7efe6851343875e15887a47d2b93f2f6
$spinner-color: #69717d !default
$spinner-size: 48px !default
.overlay
background: rgba(black,.8)
height: 100vh
.spinner
font-size: $spinner-size
position: relative
@nguyenbathanh
nguyenbathanh / foo.log
Created May 15, 2017 — forked from ibeex/foo.log
Flask logging example
View foo.log
A warning occurred (42 apples)
An error occurred
You can’t perform that action at this time.