Skip to content

Instantly share code, notes, and snippets.

View t18n's full-sized avatar
🔥
Building

Turbo Ninh t18n

🔥
Building
View GitHub Profile
@t18n
t18n / Quickly roll up REST API with Django and Postgres.md
Last active September 6, 2018 19:38
Quickly roll up Django app.md
  1. Prerequisites
  • Install Python 3
  • Install Pip
  • Install Virtualenv
  • Install Postgres
  • Install Django
  1. Installation
  • Create project
@t18n
t18n / Vagrant CentOS LAMP - PHP7.bash
Last active May 19, 2020 19:31
[Vagrant CentOS LAMP - PHP7] Vagrant CentOS LAMP stack #vagrant #php #lamp
#!/bin/bash
# Update CentOS with any patches
sudo yum update -y --exclude=kernel
# Tools
sudo yum install -y nano unzip screen wget
# Apache 2
sudo yum install -y httpd httpd-devel httpd-tools
  1. Prerequisite
  • Having Django app with basic set up running
  1. Install Graphene pip install graphene-django

  2. Register graphene-django In Project > Settings.py

  • Add graphene-django to INSTALLED_APPS array
  • Add Graphene schema under INSTALLED_APPS
@t18n
t18n / generate-site-map.js
Last active May 19, 2020 19:32
[Generate sitemap with sitemap-generator] Javascript snippet for generating sitemap with sitemap-generator #javascript
// Install sitemap-generator first
const SitemapGenerator = require('sitemap-generator');
// create generator
var generator = SitemapGenerator('http://localhost:8080/', {
maxDepth: 10,
filepath: 'src/sitemap.xml',
maxEntriesPerFile: 50000,
stripQuerystring: true
// Return multiple className which separate by space
// Usage : Really useful when adding multiple classes to className as modules
export function classes(classArray) {
  return classArray.join(' ');
}

const squareBox = <div className={classes([styles['shape'], styles.square ])}>
Usage Command
Open postgres with postgres user permission psql -U postgres
Check Postgres version select version();
Show all users with permissions \du
List all databases \l
Create a database CREATE DATABASE db_name;
Grant all permission of a database to Postgres user GRANT ALL PRIVILEGES ON DATABASE db_name TO pg_user;
Connect to a database \c db_name
Connect to a database as specific user \c db_name pg_user
@t18n
t18n / Show all constraints PostgresSQL.sql
Created November 26, 2018 01:59
Show all constraints PostgresSQL.md
SELECT conrelid::regclass AS table_from
, conname
, pg_get_constraintdef(c.oid)
FROM pg_constraint c
JOIN pg_namespace n ON n.oid = c.connamespace
WHERE contype IN ('f', 'p ')
AND n.nspname = 'public' -- your schema here
ORDER BY conrelid::regclass::text, contype DESC;
@t18n
t18n / Automatically run script on OS X with Crontab.md
Created December 9, 2019 19:38
Automatically run script on OS X with Crontab
  1. Prepare a bash script to run what ever you like to, in this case, I want to run my Mackup backup to backup all of my settings
 1   │ #!/bin/bash
 2   │
 3   │ cd /Users/turbo/Code/Mackup
 4   │ mackup backup -f
 5   │ git add .
 6   │ git commit -m "Updated changes"
 7   │ git push
@t18n
t18n / Tmux Cheatsheet.md
Last active November 9, 2020 13:11
[Tmux Basic Cheatsheet] Basic commands to use in Tmux #tmux #shell #tool

‎# Tmux Basic Cheatsheet

Bash Session

These commands are to use in Bash, not inside a tmux session

  • Show all sessions: tmux ls
  • Attach to session: tmux attach -t <session-name>
  • Create new session: tmux new -s <session-name>
  • Kill session: tmux kill-session -a -t <session-name>

Session

@t18n
t18n / tsconfig.json
Last active June 15, 2024 07:40 — forked from vemarav/tsconfig.json
[Example tsconfig.json] Tsconfig.json with description #typescript
{
"compilerOptions": {
/* Basic Options */
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"esnext",
"dom"
] /* Specify library files to be included in the compilation. */,
// "allowJs": true, /* Allow javascript files to be compiled. */