Skip to content

Instantly share code, notes, and snippets.

@ashimaathri
ashimaathri / use_list_not_tuple.py
Created October 17, 2021 06:51
To tuple or not to tuple
# Will print 'r', 'e', 'd'
for color in ('red'):
print(color)
# Will print 'red'
for color in ['red']:
print(color)
@ashimaathri
ashimaathri / residual_rms.m
Created April 23, 2020 18:07
Calculates the expected RMS distance of points from their best fit line using orthogonal regression
pkg load statistics;
function [rms] = mean_squared_distance(orthogonal_to_line, points)
numPoints = rows(points);
% Errors are projection in the direction orthogonal to the estimated line
errors = points * orthogonal_to_line;
rms = sqrt(errors' * errors / numPoints);
end
function regression_graph(points, sigma, direction)
@ashimaathri
ashimaathri / kill_iframes.js
Last active August 12, 2017 20:27
Kill Iframes on a web page. Inspired by Kill Sticky - https://alisdair.mcdiarmid.org/kill-sticky-headers/
javascript:(function(){var%20iframes=document.getElementsByTagName('iframe');for(i%20in%20iframes){iframes[i].remove()}})()
#!/bin/bash
# Remember to make this file executable and place it in .git/hooks with the name pre-push
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
echo "You were going to push to master and I can't allow that. Disable this hook if you really want to continue."
@ashimaathri
ashimaathri / saml_tool.py
Last active December 8, 2015 21:16
Tool that provides some basic methods to manipulate saml messages
import urllib
import base64
from zlib import decompress, compress
from xml.dom.minidom import parseString
from lxml import etree
from saml2.server import Server
def base64_decode(encoded_XML):
print '\nDecoding base64...\n'
return base64.b64decode(encoded_XML)
@ashimaathri
ashimaathri / game.js
Last active August 29, 2015 14:14
Step 6 of VTHacks Angry Bird Tutorial
var game, createRenderer, createAngryBird, createPlanks, createPigs;
createRenderer = function (width, height) {
return Physics.renderer('canvas', {
el: 'my-game',
width: width,
height: height,
meta: false,
autoResize: false,
styles: {
@ashimaathri
ashimaathri / game.js
Last active August 29, 2015 14:14
Step 5 of VTHacks Angry Bird Tutorial
var game, createRenderer, createAngryBird, createPlanks, createPigs;
createRenderer = function (width, height) {
return Physics.renderer('canvas', {
el: 'my-game',
width: width,
height: height,
meta: false,
autoResize: false,
styles: {
@ashimaathri
ashimaathri / game.js
Last active August 29, 2015 14:14
Step 4 of VTHacks Angry Bird Tutorial
var game, createRenderer, createAngryBird;
createRenderer = function (width, height) {
return Physics.renderer('canvas', {
el: 'my-game',
width: width,
height: height,
meta: false,
autoResize: false,
styles: {
@ashimaathri
ashimaathri / game.js
Last active August 29, 2015 14:14
Step 3 of VTHacks Angry Bird Tutorial
var game, createRenderer, createAngryBird;
createRenderer = function (width, height) {
return Physics.renderer('canvas', {
el: 'my-game',
width: width,
height: height,
meta: false,
autoResize: false,
styles: {
@ashimaathri
ashimaathri / game.js
Last active August 29, 2015 14:14
Step 2 of VTHacks Angry Bird Tutorial
var game, createRenderer;
createRenderer = function (width, height) {
return Physics.renderer('canvas', {
el: 'my-game',
width: width,
height: height,
meta: false,
autoResize: false,
styles: {