Skip to content

Instantly share code, notes, and snippets.

View leblancfg's full-sized avatar

François Leblanc leblancfg

View GitHub Profile
@bart314
bart314 / watch.rb
Created January 13, 2022 09:19
Watch for changes and reload chrome page
#!/usr/bin/env ruby
# watch.rb by Brett Terpstra, 2011 <http://brettterpstra.com>
# with credit to Carlo Zottmann <https://github.com/carlo/haml-sass-file-watcher>
trap("SIGINT") { exit }
if ARGV.length < 2
puts "Usage: #{$0} watch_folder keyword"
puts "Example: #{$0} . mywebproject"
exit
@Dan-Patterson
Dan-Patterson / e_dist.py
Last active November 2, 2021 18:07
Euclidean distance in n-dimensions using einsum
import numpy as np
def e_dist(a, b, metric='euclidean'):
"""Distance calculation for 1D, 2D and 3D points using einsum
preprocessing :
use `_view_`, `_new_view_` or `_reshape_` with structured/recarrays
Parameters
----------
# coding: utf-8
# Imports
import os
import cPickle
import numpy as np
import theano
import theano.tensor as T
@jasonlopez01
jasonlopez01 / Update Tableau Packaged Workbook from SQL
Last active May 3, 2021 03:06
Update Tableau Packaged Workbook from SQL
#-------------------------------------------------------------------------------
# Purpose: refresh Tableau packaged workbook file's underlying dataextract file from SQL
# Author: jasonlopez01
# Created: 05/08/2016
# Note: could also load in from csv, Excel, etc.
#-------------------------------------------------------------------------------
import pyodbc, os, shutil, datetime, zipfile, time, sys
import dataextract as tde
@adamfisher
adamfisher / MIME Extension Mappings.xml
Created December 7, 2015 20:29
Maps file extensions to MIME types.
<staticContent lockAttributes="isDocFooterFileName">
<mimeMap fileExtension=".323" mimeType="text/h323" />
<mimeMap fileExtension=".aaf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".aca" mimeType="application/octet-stream" />
<mimeMap fileExtension=".accdb" mimeType="application/msaccess" />
<mimeMap fileExtension=".accde" mimeType="application/msaccess" />
<mimeMap fileExtension=".accdt" mimeType="application/msaccess" />
<mimeMap fileExtension=".acx" mimeType="application/internet-property-stream" />
<mimeMap fileExtension=".afm" mimeType="application/octet-stream" />
<mimeMap fileExtension=".ai" mimeType="application/postscript" />
@joehand
joehand / ShapeFilter.py
Last active November 22, 2022 02:39
Filter Shapefiles with Python
"""
Shapefile Filters
~~~~~~~~~
:copyright: (c) 2015 by Joe Hand, Santa Fe Institute.
:license: MIT
"""
import ntpath
import os
import re
@rafaan
rafaan / gist:4ddc91ae47ea46a46c0b
Created February 24, 2015 20:24
Convert Nested JSON to Pandas DataFrame and Flatten List in a Column
import json
from pandas.io.json import json_normalize
import pandas as pd
with open('C:\filename.json') as f:
data = json.load(f)
df = pd.DataFrame(data)
normalized_df = json_normalize(df['nested_json_object'])
@urschrei
urschrei / basemap_descartes.py
Last active November 6, 2020 02:49
How to plot Shapely Points using Matplotlib, Basemap, and Descartes
"""
required packages:
numpy
matplotlib
basemap: http://matplotlib.org/basemap/users/installing.html
shapely: https://pypi.python.org/pypi/Shapely
descartes: https://pypi.python.org/pypi/descartes
random
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@shakefu
shakefu / example.sh
Last active August 30, 2022 01:22
Bash Script with Short and Long Options
# Option defaults
OPT="value"
# getopts string
# This string needs to be updated with the single character options (e.g. -f)
opts="fvo:"
# Gets the command name without path
cmd(){ echo `basename $0`; }