Skip to content

Instantly share code, notes, and snippets.

View gavincangan's full-sized avatar

Barnabas Gavin Cangan gavincangan

View GitHub Profile
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@aggrolite
aggrolite / gist:5138710
Last active August 15, 2022 13:27
email deobfucsator
function obfuscateText(coded, key) {
// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/
shift = coded.length
link = ""
for (i = 0; i < coded.length; i++) {
if (key.indexOf(coded.charAt(i)) == -1) {
ltr = coded.charAt(i)
@astrojuanlu
astrojuanlu / bezier_curves.py
Last active September 25, 2023 13:09
Interactive Bézier curves with Python using just matplotlib.
import matplotlib
matplotlib.use('webagg')
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
@aallan
aallan / EthernetUdp.c
Created March 31, 2014 16:14
Mulitcast UDP patch for the EthernetUdp.c source code in Arduino Ethernet library.
/*
Add the following decleration to EthernetUdp.h directly after line 55
virtual uint8_t beginMulti(IPAddress, uint16_t);
then add the following code to the end of EthernetUdp.c
*/
@ctokheim
ctokheim / cython_tricks.md
Last active March 4, 2024 23:27
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.

@Schnouki
Schnouki / popcorntime-vpn.sh
Last active January 20, 2024 12:07
OpenVPN for a single application using network namespaces -- helper scripts
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup
@takluyver
takluyver / example
Created May 13, 2016 19:17
Debug on interrupt
$ python3 interrupt-debug.py
0
1
2
3
^C--Return--
> /home/takluyver/scratch/interrupt-debug.py(6)handle_sigint()->None
-> pdb.set_trace()
(Pdb) p a
4
@cbaziotis
cbaziotis / AttentionWithContext.py
Last active April 25, 2022 14:37
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':
@jarun
jarun / Goa tips.md
Last active July 17, 2021 19:51
Notes from Goa, India trip (22 Oct 2017)

Sunset at Benaulim

  1. Use Google Maps, save Goa offline for quick access. Jio works everywhere.
  2. Buy hats. Goa is hot and humid (between Feb to Dec).
  3. If you reach Madgaon by train and want to go to North Goa, take an auto to the Madgaon Bus stand (around Rs. 120). Book a ticket for the non-stop express bus to the Panjim Bus stand. At Panjim Bus stand, take a KTC prepaid taxi to North Goa.
  4. A nice place to homestay is Joe and Marietta's guesthouse, Calangute Goa. They have all amenities like AC, fridge, hot water, wifi... It's very near to KFC. They will provide numbers to cab and bike services too. But do NOT buy petrol from them even if the lady insists. They charged Rs. 80/ltr when the petrol price in Goa was Rs. 52/ltr on the day. There are petrol pumps everywhere. One can stay in North Goa and visit Old Goa + Panjim by bike.
  5. Autos and cabs will cost you dearly. Hire a bike for a few days (~Rs. 300/day for Honda Activa). No Uber or Ola, thanks to govt