Skip to content

Instantly share code, notes, and snippets.

View ernsheong's full-sized avatar

Jonathan Lin ernsheong

View GitHub Profile
@apolloclark
apolloclark / postgres cheatsheet.md
Last active June 3, 2024 10:34
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

@paulirish
paulirish / what-forces-layout.md
Last active June 9, 2024 13:52
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
Array.apply(null, Array(15))
.map((_, i) => i + 1)
.map(i =>
[i, "Fizz", "Buzz", "FizzBuzz"][!(i % 3) + 2*!(i % 5)]
)
.forEach(::console.log)
@aclements
aclements / scale.go
Created June 26, 2015 15:07
Scale down by 2x using x/image/draw
package main
import (
"flag"
"fmt"
"image"
"image/png"
"log"
"os"
@peterjwest
peterjwest / git-cleanup.sh
Last active July 7, 2023 15:42
Git aliases
#!/usr/bin/env bash
set -euo pipefail
for BRANCH in $(git branch | grep -E -v "^(\* | (develop|master|main)$)"); do
if [[ -z $(git --no-pager log develop..$BRANCH --author=$(git config user.email)) ]]; then
git branch -D $BRANCH
fi
done
@v0lkan
v0lkan / nginx.conf
Last active May 31, 2024 09:40
Configuring NGINX for Maximum Throughput Under High Concurrency
user web;
# One worker process per CPU core.
worker_processes 8;
# Also set
# /etc/security/limits.conf
# web soft nofile 65535
# web hard nofile 65535
# /etc/default/nginx
@praphull27
praphull27 / Jenkins_Protractor_Headless_Chrome_Setup_Ubuntu_14.04.md
Last active April 9, 2024 11:44
Jenkins, Protractor and Headless Chrome Browser Setup on Ubuntu 14.04

Jenkins, Protractor and Headless Chrome Browser Setup on Ubuntu 14.04

Update Ubuntu

sudo apt-get update
sudo apt-get upgrade

Install Java

@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@msaglietto
msaglietto / gist:de7a0132612c6c7e980f
Created March 15, 2015 22:55
Simple route parser to extract parameters from a url given a format
var SimpleRouteParser = function(format) {
var namedParam = /\/(:(\w+))/g,
names,
route,
setFormat = function(format) {
if (!format) throw new Error('Please specify the url format');
names = [];
route = format.replace(namedParam, function(match, param, name) {
@domharrington
domharrington / gist:884346cc04c30eeb1237
Created November 28, 2014 14:55
Download file via ajax. Copied from here http://stackoverflow.com/a/23797348
module.exports = downloadAjaxFile
function downloadAjaxFile (xhr) {
/* jshint maxcomplexity: 7 */
var filename = ''
, disposition = xhr.getResponseHeader('Content-Disposition')
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
, matches = filenameRegex.exec(disposition)