Skip to content

Instantly share code, notes, and snippets.

View slaveofcode's full-sized avatar
🤷‍♂️
Smartest Idiot

Aditya Kresna Permana slaveofcode

🤷‍♂️
Smartest Idiot
View GitHub Profile
@slaveofcode
slaveofcode / restore dump docker
Created March 16, 2018 17:59 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@slaveofcode
slaveofcode / alter.sql
Created April 3, 2018 15:33
Alter Postgres User to Super USER
CREATE USER aditya with password 'aditya';
ALTER USER aditya with SUPERUSER CREATEDB CREATEROLE REPLICATION BYPASSRLS;
@slaveofcode
slaveofcode / install.txt
Created April 18, 2018 07:50
Installing Postgis
# Get ubuntu version
>> sudo lsb_release -a
# For xenial (16.04.2 LTS)
>> sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt xenial-pgdg main" >> /etc/apt/sources.list'
>> wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
>> sudo apt-get update
@slaveofcode
slaveofcode / ID.js
Created April 20, 2018 17:07
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@slaveofcode
slaveofcode / README.md
Created July 5, 2018 04:02 — forked from magnetikonline/README.md
Minimum Open Graph tags required for a webpage - for use with Facebook.

Open Graph tags for page <head>.

<meta property="og:title" content="title" />
<meta property="og:description" content="desc" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://url.com/" />
<meta property="og:image" content="http://url.com/image.jpg" />
@slaveofcode
slaveofcode / social-snippet.html
Created July 5, 2018 04:02 — forked from tgdev/social-snippet.html
Social media sharing snippet for facebook, twitter and pinterest. Place in <head> of your pages More info below: Facebook Open Graph tags - http://davidwalsh.name/facebook-meta-tags Twitter Cards - https://dev.twitter.com/docs/cards Pinterest Rich Pins - http://developers.pinterest.com/rich_pins/
<!-- Facebook Open Graph tags -->
<meta property="og:image" content="" />
<meta property="og:site_name" content="" />
<meta property="og:type" content="" />
<meta property="og:url" content="" />
<meta property="og:title" content="" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="">
@slaveofcode
slaveofcode / meta-tags.md
Created July 5, 2018 04:02 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@slaveofcode
slaveofcode / example-express-joi.js
Last active July 24, 2018 11:12
Example RESTful API on Express with Joi
async function handler(req, res, next) {
const userSchema = Joi.object().keys({
name: Joi.string().required(),
age: Joi.number().integer()
});
const params = req.params;
const {error, validValues} = Joi.validate(params, userSchema);
let result = null;
@slaveofcode
slaveofcode / podeng-in-express.js
Last active July 25, 2018 03:01
Podeng Example to Use in ExpressJs
const { blueprint, types, validator } = require('podeng');
async function handler(req, res, next) {
const UserShema = blueprint.object({
name: types.string({ serialize: { to: 'username' }}),
age: types.integer
});
const params = req.params;
@slaveofcode
slaveofcode / locales.json
Created July 25, 2018 09:13
Locales in JSON format
{
"af": "Afrikaans",
"sq": "Albanian",
"am": "Amharic",
"ar_DZ": "Arabic - Algeria",
"ar_BH": "Arabic - Bahrain",
"ar_EG": "Arabic - Egypt",
"ar_IQ": "Arabic - Iraq",
"ar_JO": "Arabic - Jordan",
"ar_KW": "Arabic - Kuwait",