Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import os
import sys
import subprocess
def simplify_pg_index_line(line):
"""
Given a postgres index file line returns it's simplified form.
Returns None for comments
@oopsops
oopsops / edit-vm-hostname.py
Created April 2, 2012 13:41 — forked from tnmt/edit-vm-network-setting.py
Modify KVM VM (stopped) network setting using libguestfs
#!/bin/env python
import sys
import libvirt
import guestfs
from lxml import etree
if (len(sys.argv) != 3):
sys.exit('Usage: # sudo python %s old_domain new_domain' % sys.argv[0])
old_domain = sys.argv[1]
@catawbasam
catawbasam / pandas_dbms.py
Last active May 26, 2024 05:32
Python PANDAS : load and save Dataframes to sqlite, MySQL, Oracle, Postgres
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,
@jugglinmike
jugglinmike / index.html
Last active February 16, 2021 04:51
Stock chart with d3.chart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active June 7, 2024 05:09
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@karpathy
karpathy / min-char-rnn.py
Last active July 7, 2024 10:14
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)