Skip to content

Instantly share code, notes, and snippets.

@raffitz
raffitz / quadint.m
Created July 3, 2016 23:07
Quadruple integral to calculate average distance between two random points within a unit square
% Matlab script to determine average distance between two random points within a unit square
f=@(x,y,z,w) sqrt((x-z).*(x-z) + (y-w).*(y-w)); % Distance Function between points (x,y) and (z,w)
a=0.5;b=0.5;c=0.5;d=0.5; % Integration limits: -a<=x<a -b<=y<b -c<=z<c -d<=w<d
I=integral2(@(x,y)arrayfun(@(x,y)integral2(@(z,w)f(x,y,z,w),-c,c,-d,d),x,y),-a,a,-b,b)
@jackcarter
jackcarter / slack_delete.py
Last active November 29, 2023 07:03
Delete Slack files older than 30 days. Rewrite of https://gist.github.com/jamescmartinez/909401b19c0f779fc9c1
import requests
import time
import json
token = ''
#Delete files older than this:
ts_to = int(time.time()) - 30 * 24 * 60 * 60
def list_files():
@ed-flanagan
ed-flanagan / geo_distance.cpp
Last active May 22, 2020 13:24
Great-circle distance computational forumlas in C++
/*
* Great-circle distance computational forumlas
*
* https://en.wikipedia.org/wiki/Great-circle_distance
*/
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <cmath>

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@BigglesZX
BigglesZX / gifextract.py
Created November 5, 2012 10:31
Extract frames from an animated GIF, correctly handling palettes and frame update modes
import os
from PIL import Image
'''
I searched high and low for solutions to the "extract animated GIF frames in Python"
problem, and after much trial and error came up with the following solution based
on several partial examples around the web (mostly Stack Overflow).
There are two pitfalls that aren't often mentioned when dealing with animated GIFs -
@revolunet
revolunet / extractGifs.py
Created March 1, 2011 09:48
extract frames from animated gif using python+PIL
import os
from PIL import Image
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF')
nframes += 1