Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Son Dang sondnm

View GitHub Profile
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active Apr 19, 2019
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
View gist:ebaca117ac9e44231421f04e7796d5ca
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active Apr 19, 2019
Linux: Understanding the Memory Layout of Linux Executables
View memory_layout.md

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@t-mart
t-mart / netrw quick reference.md
Last active Apr 10, 2019
A quick reference for Vim's built-in netrw file selector.
View netrw quick reference.md
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@spalladino
spalladino / mysql-docker.sh
Created Dec 22, 2015
Backup and restore a mysql database from a running Docker mysql container
View mysql-docker.sh
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@krlgrgn
krlgrgn / gist:7b020c89f98cef671c8a
Last active Apr 28, 2017
How To: Set Up a Grape API on Rack
View gist:7b020c89f98cef671c8a

How To: Set Up a Grape API on Rack

This is a step by step guide on how I setup a Grape API on Rack.

1. Dependencies

Our API will have a few dependencies:

@vitorbritto
vitorbritto / add_apache_brew.md
Last active Mar 4, 2019
Install Apache with Homebrew
View add_apache_brew.md

Install Apache with Homebrew

Installing Apache

# Start by stopping the built-in Apache, if it's running, and prevent it from starting on boot.
# This is one of very few times you'll need to use sudo:
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

# We need to tap homebrew-dupes because "homebrew-apache/httpd22" relies on "homebrew-dupes/zlib"
# and install Apache 2.2 with the event MPM, and we'll use Homebrew's OpenSSL library
View rspec_cheatsheet_controller_spec.rb
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@mziwisky
mziwisky / Oauth2.md
Last active Apr 13, 2019
Oauth2 Explanation
View Oauth2.md

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.

You can’t perform that action at this time.