Skip to content

Instantly share code, notes, and snippets.

Lawrence Nara nara-l

Block or report user

Report or block nara-l

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
View 1-handlebars-cheatsheet.hbs
Handlebars is a semantic web template system, started by Yehuda Katz in 2010.
Handlebars.js is a superset of Mustache, and can render Mustache templates in addition to Handlebars templates.
More: http://handlebarsjs.com/
1. Expressions.
1.1 Basic usage.
@nara-l
nara-l / iife-destructure-spreading
Last active May 23, 2019
Remove some element from an object with IIFE, destructuring, and spreading
View iife-destructure-spreading
# IIFE, destructuring, and spreading
# given and object of colors
const colors = {red: '#ff0000',green: '#00ff00', blue: '#0000ff' }
# We can remove blue without using a filter by doing this
((blue, ...rest) => rest)(colors)
@nara-l
nara-l / basic.md
Created Mar 31, 2019 — forked from zenorocha/basic.md
New Firebase Auth vs Old Firebase Auth
View basic.md
@nara-l
nara-l / markdown-cheatsheet.md
Created Mar 29, 2019 — forked from jonschlinkert/markdown-cheatsheet.md
A better markdown cheatsheet.
View markdown-cheatsheet.md
View gist:28f1fd00af9e03b550102285794475c4

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor
@nara-l
nara-l / add_to_git_ignore_after_uploading
Created Feb 7, 2019
Add files to gitignore even after uploading to github
View add_to_git_ignore_after_uploading
a. git rm -r --cached . # unstage all files on your local machine
b. add the said files to gitignore
c. git add . # add all files again
d. commit and push again or rebase. use rebase guide
@nara-l
nara-l / name_migration_files
Created Nov 30, 2018
Name django migration files
View name_migration_files
# To add a name to migration files rather than 001_auto_20189084774
python manage.py makemigrations --name DESIRED_NAME appName
# e.g. if app name is `site` and you want to name migration, `new_side_bar`
python manage.py makemigrations --name new_side_bar site
@nara-l
nara-l / get_model_object_django
Last active Nov 1, 2018
How to get a model object from instance in Django
View get_model_object_django
# Sometimes you need to determine a model name from an object, before using
# First long approach may work in every version of Django? not tested
import sys
model_obj # let model_obj be the model object ( instance) from some input
model_name_str = type(model_obj).__name__ # this is model name as string, but we need the object to do the
model_object = getattr(sys.modules[__name__], model_name_str)
# now we can use model object normally
@nara-l
nara-l / reverse_lookup_django
Created Oct 25, 2018
Django What is reverse relationship?
View reverse_lookup_django
`class Blog(models.Model):
#some attributes
class Entry(models.Model):
blog = models.ForeignKey(Group, related_name='entries') . # this is a ForeignKey relationship, not a OneToOneField
#more attributes
`
@nara-l
nara-l / Heroku_Monthly_Scheduler
Created Sep 26, 2018
Heroku Monthly Scheduler
View Heroku_Monthly_Scheduler
# funny thing Heroku scheduler has no way of running a task monthly easily, one has to use a command like this:
if [ "$(date +%d)" = 01 ]; then MY_COMMAND; fi
# Run task every monday
if [ "$(date +%u)" = 1 ]; then MY_COMMAND; fi
# Run task every 24th of the year
if [ "$(date +%m)" = 12 ] && [ "$(date +%d)" = 24 ]; then MY_COMMAND; fi
You can’t perform that action at this time.