Skip to content

Instantly share code, notes, and snippets.

View chrisduong's full-sized avatar

Chris Duong chrisduong

  • Berlin
View GitHub Profile
@chrisduong
chrisduong / curl.md
Created February 27, 2019 08:23 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@chrisduong
chrisduong / postgres cheatsheet.md
Last active August 9, 2016 09:23 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@chrisduong
chrisduong / 0_reuse_code.js
Created July 29, 2016 08:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@chrisduong
chrisduong / gdiff
Created June 24, 2016 04:08 — forked from miner/gdiff
using FileMerge as git difftool on Mac OS X
#!/bin/bash
# my git difftool, calls FileMerge with project as -merge target
# better than using opendiff
#
# cd to your project dir and and run difftool like this:
# git difftool -d -x gdiff
# find top level of git project
dir=$PWD
until [ -e "$dir/.git" ]; do
@chrisduong
chrisduong / iterm2.md
Last active July 29, 2016 08:42
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
@chrisduong
chrisduong / codility_demo_test.rb
Created April 16, 2016 04:35 — forked from sobstel/codility_demo_test.rb
Codility demo test (Ruby)
def equi(a)
lower_elements_sum = 0
higher_elements_sum = a.inject(:+)
a.each_with_index do |el, i|
lower_elements_sum += a[i - 1] if i > 0
higher_elements_sum -= el
return i if lower_elements_sum == higher_elements_sum
end
@chrisduong
chrisduong / kitchen.local.yml
Last active March 20, 2016 09:22 — forked from fnichol/README.md
Auto-enable Local HTTP Caching in Test Kitchen
<%
require 'socket'
# @return [String] public IP address of workstation used for egress traffic
def local_ip
@local_ip ||= begin
# turn off reverse DNS resolution temporarily
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
UDPSocket.open do |s|
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/latest"
Using the nc command you can scan a port or a range of ports to verify whether a UDP port is open and able to receive traffic.
This first command will scan all of the UDP ports from 1 to 65535 and add the results to a text file:
$ nc -vnzu server.ip.address.here 1-65535 > udp-scan-results.txt
This merely tells you that the UDP ports are open and receive traffic.
Perhaps a more revealing test would be to actually transfer a file using UDP.