Skip to content

Instantly share code, notes, and snippets.

View auginator's full-sized avatar

Agustin Sevilla auginator

View GitHub Profile
@richtr
richtr / config.yml
Last active November 28, 2017 21:36
Parse YAML from bash with sed and awk.
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
password:
apt:
- somepackage
- anotherpackage
font-family: -apple-system, BlinkMacSystemFont, “Roboto”, “Droid Sans”, “Helvetica Neue”, Helvetica, Arial, sans-serif;
@dtrietsch
dtrietsch / gist:1186289
Created September 1, 2011 14:35
iTerm2 command for split panes via AppleScript
tell i term application "System Events" to keystroke "D" using command down
tell i term application "System Events" to keystroke "d" using command down
@bzerangue
bzerangue / update-hosts.sh
Last active March 3, 2020 13:54
A small shell script that will add and remove lines from the hosts file. Originally created by Claus Witt, http://clauswitt.com/319.html.
#! /bin/sh
# @author: Claus Witt
# http://clauswitt.com/319.html
# Adding or Removing Items to hosts file
# Use -h flag for help
DEFAULT_IP=127.0.0.1
IP=${3:-$DEFAULT_IP}
@erelson
erelson / gist:35a23ac28aa800af9a06ba7822afdaa7
Created August 13, 2021 05:04
Set an email when cloning repos
# Use this with a git alias like `cl = "!sh ~/clone_helper.sh"`
# A bash function to replace `git clone` could also be done
# like in https://stackoverflow.com/a/39357426/999505
set -e
if [ $# = 0 ]; then # forgot to pass anything, d'oh
echo ERROR Must pass repo path to clone
exit 1
fi
@nasirkhan
nasirkhan / git command.markdown
Last active May 12, 2022 03:17
`git` discard all local changes/commits and pull from upstream

git discard all local changes/commits and pull from upstream

git reset --hard origin/master

git pull origin master

@msssk
msssk / throttleBoss.js
Last active May 20, 2022 16:58
Throttle with trailing call preservation
// This is a typical throttle implementation with the difference that it doesn't discard
// the final invocation - instead it runs it at the next valid timeslice.
throttleBoss: function(callback, delay) {
var ready = true,
args = null;
return function throttled() {
var context = this;
class MyEventEmitter {
constructor() {
this._events = {};
}
on(name, listener) {
if (!this._events[name]) {
this._events[name] = [];
}
@werediver
werediver / websse.py
Last active June 1, 2023 14:17
Simple demonstration of how to implement Server-sent events (SSE) in Python using Bottle micro web-framework. SSE require asynchronous request handling, but it's tricky with WSGI. One way to achieve that is to use gevent library as shown here.
"""
Simple demonstration of how to implement Server-sent events (SSE) in Python
using Bottle micro web-framework.
SSE require asynchronous request handling, but it's tricky with WSGI. One way
to achieve that is to use gevent library as shown here.
Usage: just start the script and open http://localhost:8080/ in your browser.
Based on:
@davidgilbertson
davidgilbertson / http2.js
Last active October 9, 2023 06:09
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};