Skip to content

Instantly share code, notes, and snippets.

View fodra's full-sized avatar
🎯
Focusing

Andrew Artajos fodra

🎯
Focusing
  • Australia
View GitHub Profile
@fodra
fodra / Makefile
Created March 28, 2018 22:42
A sample makefile
# Shortcuts for doing stuff in gametraka_project_v3
.PHONY : clean help build redisq gui devdeps dev clean run requirements test
help:
@echo "lint - check style with flake8 and isort"
@echo "devdeps - runs rqworker and gui front-end"
@echo "dev - runs gametraka on localhost"
@echo "test - runs test suite"
@echo "clean - deletes temporary files"
@fodra
fodra / Django.md
Last active May 31, 2018 04:55
Notes on Django
  1. Create an empty django migration

python manage.py makemigrations --empty yourappname

  1. Show applied migrations

python manage.py showmigrations <app_name>

  1. Rollback migration to a specific state
@fodra
fodra / Postgres.md
Last active June 20, 2018 07:42
Notes on postgres database
  1. Create a copy of a database

$ createdb -O <owner> -T database_to_copy new_database

  1. Create a database

$ createdb -O <owner> database_name

@fodra
fodra / DjangoRelationships.md
Created April 18, 2018 01:21
Django Relationship notes.
  1. One-to-Many or Many-to-One relationships
  • One gets no field
  • Many gets the ForeignKey field
class One(models.Model):
  pass
  
class Many(models.Model):
@fodra
fodra / snippets.js
Created May 11, 2018 04:33
Useful snippets of js code
// sleep using promise
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@fodra
fodra / GitStuff.md
Last active May 30, 2018 04:50
Git commands
  1. Remove all untracked git files

$ git clean -fd

  1. View all tags

$ git tag

  1. Undo last commit
@fodra
fodra / index.html
Created June 7, 2018 05:52
A MutationObserver example.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<div id="target">
<div id="inner">
@fodra
fodra / promises_reduce.js
Created June 12, 2018 07:02 — forked from anvk/promises_reduce.js
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@fodra
fodra / Python.md
Last active June 20, 2018 07:36
Some useful notes on working with python.
  1. Using ipdb, when in ipdb.set_trace() mode use s command to step into the function.
  1. Simple http server to transfer files from your computer. This will enable users in the same network access the files in your server directory by http://<local_ip>:8000.

python -m http.server 8000

@fodra
fodra / CssDemos.md
Created June 21, 2018 23:15
This is a collection of CSS articles I found very useful.