Skip to content

Instantly share code, notes, and snippets.

View mokxter's full-sized avatar
:shipit:
Ship

Ian Cristopher Buena mokxter

:shipit:
Ship
View GitHub Profile
@mokxter
mokxter / Knex-Migrations-Seeding.md
Created January 31, 2021 11:09 — forked from NigelEarle/Knex-Migrations-Seeding.md
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

Dropping Migration Table, Models, Controller

Command Line

1. Drop Table/Migration

rails generate migration DropTablename

A file will be created, in the db > migrate folder, make sure it looks like:

@mokxter
mokxter / Dockerfile
Created March 26, 2020 10:16 — forked from siklodi-mariusz/Dockerfile
Dockerfile example for Ruby on Rails running on Alpine Linux
FROM ruby:2.4-alpine3.7
# Install dependencies:
# - build-base: To ensure certain gems can be compiled
# - nodejs: Compile assets
# - postgresql-dev postgresql-client: Communicate with postgres through the postgres gem
# - libxslt-dev libxml2-dev: Nokogiri native dependencies
# - imagemagick: for image processing
RUN apk --update add build-base nodejs tzdata postgresql-dev postgresql-client libxslt-dev libxml2-dev imagemagick
@mokxter
mokxter / rails-docker.md
Last active March 31, 2019 15:42
Creating a Rails project with docker

Creating a Rails project with Docker.

Pull ruby gem

docker pull ruby:latest

Run bash using ruby image.

docker run -it -v "$(pwd):/workspace" ruby bash
@mokxter
mokxter / ssh-zsh.md
Last active March 31, 2019 15:06
SSH with ZSH

SSH

export SSH_KEY_PATH="~/.ssh/ssh-key"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/ssh-key
@mokxter
mokxter / axios-module.js
Created July 24, 2018 09:44
Axios Request Sample
const axios = require('axios');
const url = 'http://localhost/oauth/token';
const getToken = async url => {
try {
const body = {
grant_type: 'password',
client_id: '',
client_secret: '',
@mokxter
mokxter / docker-compose.yml
Created May 28, 2018 02:26
Simple mariadb docker compose for development work.
version: "2"
services:
db:
image: bianjp/mariadb-alpine
ports:
- 3306:3306
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: root
@mokxter
mokxter / pacman.md
Last active January 4, 2019 17:59
Pacman Cheatsheet

Install package(s)

sudo pacman -S chromium
sudo pacman -S firefox git // For multiple package install

Remove package(s)

sudo pacman -R chromium

Remove package including associated packages

@mokxter
mokxter / CtrlP_acceleration
Created December 5, 2017 08:53 — forked from davidmh/CtrlP_acceleration
Accelerate CtrlP by ignoring certain files and paths. Including node modules and grunt's .tmp
" Ignore some folders and files for CtrlP indexing
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.yardoc\|node_modules\|log\|tmp$',
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
\ }
@mokxter
mokxter / bashrc_code
Created November 29, 2017 09:46
Workaround for yarn / npm issue in WSL
# Workaround for issue: https://github.com/Microsoft/WSL/issues/2448
if ! mount | grep -q "C: on /mnt/c type drvfs (rw,noatime,fallback=1)"; then
echo "== Remount of C: drive required =="
pushd ~ > /dev/null
sudo umount /mnt/c
sudo mount -t drvfs -o noatime,fallback=1 C: /mnt/c
popd > /dev/null
fi