Skip to content

Instantly share code, notes, and snippets.

View gavincangan's full-sized avatar

Barnabas Gavin Cangan gavincangan

View GitHub Profile
@ozbillwang
ozbillwang / Git_Behind_Proxy.md
Last active April 20, 2024 15:58
Configure Git to use a proxy (https or SSH+GIT)
@komasaru
komasaru / spline_interpolation.py
Created January 10, 2018 04:40
Python script to calc 3D-Spline-Interpolation.
#! /usr/local/bin/python3.6
"""
3-D spline interpolation
(with graph drawing by matplotlib)
"""
import matplotlib.pyplot as plt
import sys
import traceback
class SplineInterpolation:
@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
@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':
@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
@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
@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.

@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
*/
@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
@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)