Skip to content

Instantly share code, notes, and snippets.

@squioc
squioc / gist:3078803
Created July 9, 2012 20:49
conversion between iso8601 date format and unix epoch datetime
from datetime import datetime
import calendar
def epoch_to_iso8601(timestamp):
"""
epoch_to_iso8601 - convert the unix epoch time into a iso8601 formatted date
>>> epoch_to_iso8601(1341866722)
'2012-07-09T22:45:22'
"""
@jakevdp
jakevdp / README.md
Last active September 30, 2023 13:25
Numba Ball Tree example

Numba Ball Tree

This is a quick attempt at writing a ball tree for nearest neighbor searches using numba. I've included a pure python version, and a version with numba jit decorators. Because class support in numba is not yet complete, all the code is factored out to stand-alone functions in the numba version. The resulting code produced by numba is about ~10 times slower than the cython ball tree in scikit-learn. My guess is that part of this stems from lack of inlining in numba, while the rest is due to some sort of overhead

@XVilka
XVilka / TrueColour.md
Last active July 9, 2024 23:28
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@jberkus
jberkus / gist:6b1bcaf7724dfc2a54f3
Last active January 7, 2024 21:26
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@Jim-Holmstroem
Jim-Holmstroem / push_submodule_to_DEIS.sh
Last active August 29, 2015 14:14
Push private repository with submodules to DEIS (assuming the repo already has been ``deis create projectname``'d)
#!/usr/bin/env bash
export GIT_FLAGS=$*
OLD_BRANCH="master" # $(git $GIT_FLAGS rev-parse --abbrev-ref HEAD)
echo $OLD_BRANCH
TEMP_BRANCH="deis_build"
git $GIT_FLAGS branch --force $TEMP_BRANCH && git $GIT_FLAGS checkout --force $TEMP_BRANCH
git $GIT_FLAGS submodule status | cut -d' ' -f3 | xargs --no-run-if-empty -I{} bash -c "git $GIT_FLAGS config -f .git/config --remove-section submodule.{}" && find -type f -name .git -o -type f -name .gitmodules | xargs --no-run-if-empty rm -f && rm -rf .git/modules/* && rm -f .git/index && git $GIT_FLAGS add -A && git $GIT_FLAGS commit -m"flattened" && git $GIT_FLAGS push deis $TEMP_BRANCH:master --force
@izabera
izabera / ircsed
Last active June 21, 2023 14:49
a simple irc bot written in sed
#!/bin/bash
owner=izabera nick=sedirc network=irc.freenode.net
echo "
# send bot data
1 {
s/.*/nick $nick/p
s/.*/user $nick $nick $nick :$nick/p
s/.*/cat factoids 2>\/dev\/null/e; H
b
@dennybritz
dennybritz / plot_decision_boundary.py
Created September 18, 2015 16:45
plot_decision_boundary.py
# Helper function to plot a decision boundary.
# If you don't fully understand this function don't worry, it just generates the contour plot below.
def plot_decision_boundary(pred_func):
# Set min and max values and give it some padding
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
h = 0.01
# Generate a grid of points with distance h between them
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
# Predict the function value for the whole gid
@parmentf
parmentf / GitCommitEmoji.md
Last active July 23, 2024 11:27
Git Commit message Emoji
@d0c-s4vage
d0c-s4vage / autopypi.py
Created March 13, 2016 13:32
A simple script to auto-install packages from pypi when they are imported.
#!/usr/bin/env python
# encoding: utf-8
import imp
import os
import pdb
import pip
import readline
from pip.commands.search import SearchCommand
import sys
@sehugg
sehugg / nietz_stateful.py
Last active October 16, 2017 19:45
Stateful LSTM text generation with Keras 1.0
#!/usr/bin/env python
from __future__ import print_function
from keras.models import Sequential
from keras.layers import TimeDistributed
from keras.layers.core import Dense, Activation, Dropout, RepeatVector, TimeDistributedDense
from keras.layers.recurrent import LSTM
from keras.utils.data_utils import get_file
import numpy as np
import random,string
import sys