Skip to content

Instantly share code, notes, and snippets.

View andhikayuana's full-sized avatar
🌏
bertapa

Andhika Yuana andhikayuana

🌏
bertapa
View GitHub Profile
@andhikayuana
andhikayuana / install_ruby_with_rbenv.md
Created April 11, 2019 03:24 — forked from stonehippo/install_ruby_with_rbenv.md
Installing a new Ruby with rbenv on Mac OS

Install a new Ruby with rbenv on Mac OS (and make yourself a superhero)

If you're doing stuff with Ruby on a Mac, e.g. installling Jekyll or something, by default you'll end up having to use the sudo command to do stuff, since the permission to modify the default config is not available to your user account.

This sucks and should be avoided. Here's how to fix that.

Installing a new Ruby

To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*

A word of warning: you will have to use Terminal to install this stuff. If you are uncomfortable with text, words, and doing stuff with your computer beyond pointing and hoping, this may not work well for you. But if that's the case, I'm not sure why you were trying to use Ruby in the first place.

@andhikayuana
andhikayuana / readme.md
Last active April 11, 2019 03:17
install asdf version manager in mac

Install asdf using homebrew

$ brew install asdf
$ echo -e '\n. $(brew --prefix asdf)/asdf.sh' >> ~/.zshrc
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
$ asdf

install ruby

@andhikayuana
andhikayuana / squah.md
Created April 9, 2019 08:14 — forked from shellkore/squah.md
squash your commits

SQUASH

Whenever you want to squash last commits in a single commit:-

first check your log

git log

CASE 1: your head is at the commit in which you want others to be squashed

@andhikayuana
andhikayuana / .env
Created April 8, 2019 10:10
docker-compose file for Drone CI
DRONE_HOST=https://loc-drone-ci.localtunnel.me
DRONE_GITHUB_CLIENT=af516d1889d283a6a30d
DRONE_GITHUB_SECRET=64994dabf745bc5076734aeff4cb41cd268782f8
DRONE_SECRET=drone-local-bla-bla-bla
@andhikayuana
andhikayuana / Makefile
Last active March 23, 2019 04:04
makefile build golang app
# @author andhikayuana
# @since Jan, 16 2019
GO=$(shell which go)
DEP=$(shell which dep)
DIR=$(shell pwd)
BUILD_DIR=$(DIR)/build
GOARCH=amd64
PROJECT_NAME=oauth2-demo
@andhikayuana
andhikayuana / gist:5e5d92143dbb3c6e7ebaeaa4192c6051
Created March 12, 2019 11:05 — forked from chanks/gist:7585810
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@andhikayuana
andhikayuana / fuzzy-search-postgres.md
Created February 22, 2019 04:11 — forked from nepsilon/fuzzy-search-postgres.md
PostgreSQL: Native fuzzy search with levenshtein() — First published in fullweb.io issue #41

PostgreSQL: Fuzzy search with levenshtein()

Ever wanted to implement a “Did you mean?” feature in your search results? Google is said to have greatly increased its user engagement with it. Here is how to implement it simply in Postgres (v9.1+):

Install the extension:

CREATE EXTENSION fuzzystrmatch;
@andhikayuana
andhikayuana / postgres-docker-config.sh
Created February 1, 2019 09:40 — forked from therusetiawan/postgres-docker-config.sh
Run postgres on docker host, connect from docker containers
#!/bin/bash
################################################################################
# Rather than run postgres in its own container, we want to run it on
# the (Ubuntu) host and allow:
#
# + peer connections on the host
# + local md5 connections from any docker container
#
# THIS IS COPY/PASTED FROM COMMAND LINE INPUT AND IS UNTESTED AS A SINGLE SCRIPT
################################################################################
@andhikayuana
andhikayuana / cleanup.sh
Created January 31, 2019 07:11 — forked from yusufsyaifudin/cleanup.sh
Cleaning up docker to reclaim disk space
#!/bin/bash
# based on https://lebkowski.name/docker-volumes/
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
docker volume ls -qf dangling=true | xargs -r docker volume rm
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
@andhikayuana
andhikayuana / mac-setup-redis.md
Created January 18, 2019 07:03 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis