Skip to content

Instantly share code, notes, and snippets.

@vdavez
vdavez / docx2md.md
Last active April 21, 2024 20:05
Convert a Word Document into MD

Converting a Word Document to Markdown in Two Moves

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

The Solution

As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.

@Stanback
Stanback / nginx.conf
Last active April 22, 2024 19:23 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@gka
gka / sqlite3-example.py
Last active June 4, 2023 01:32
The code below does the same as the example snippet you've just seen: opening a database connection, creating a new table with some columns, storing some data, altering the table schema and adding another row.
import sqlite3
# open connection and get a cursor
conn = sqlite3.connect(':memory:')
c = conn.cursor()
# create schema for a new table
c.execute('CREATE TABLE IF NOT EXISTS sometable (name, age INTEGER)')
conn.commit()
@ezyang
ezyang / index.html
Created December 7, 2012 21:21
Text rotation in D3.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script src="http://d3js.org/d3.v2.js"></script>
</head>
<body>
<script type="text/javascript">
/**
* A convenient function for taking a transformation (with rotation) on
@shobhit
shobhit / nwxpython.py
Created August 2, 2012 11:21
Put Images as Nodes using Networkx and Python
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img=mpimg.imread('/home/shobhit/Desktop/shobhit.jpg')
# draw graph without images
G =nx.Graph()
G.add_edge(0,1,image=img,size=0.1)
G.add_edge(1,2,image=img,size=0.05)
G.add_edge(2,3,image=img,size=0.02)
G.add_edge(3,4,image=img,size=0.075)
@daien
daien / video_stabilize.py
Created January 2, 2012 18:23
Video stabilization with OpenCV and Hugin
#!/usr/bin/env python
""" Video stabilization with OpenCV (>=2.3) and Hugin
Adrien Gaidon
INRIA - 2012
TODO: add cropping, clean-up and improve doc-strings
"""
@FestivalBobcats
FestivalBobcats / gist:1323387
Created October 28, 2011 19:57
Underscore.js implementation of Cartesian Product
function cartesianProductOf(){
return _.reduce(arguments, function(mtrx, vals){
return _.reduce(vals, function(array, val){
return array.concat(
_.map(mtrx, function(row){ return row.concat(val); })
);
}, []);
}, [[]]);
}
@brantfaircloth
brantfaircloth / gist:260331
Created December 20, 2009 02:09
Python multiprocessing.JoinableQueue()
import os
import subprocess
import multiprocessing
def q_runner(n_procs, list_item, function, *args):
'''generic function used to start worker processes'''
task_queue = multiprocessing.Queue()
results_queue = multiprocessing.JoinableQueue()
if args:
arguments = (task_queue, results_queue,) + args
@endolith
endolith / frequency_estimator.py
Last active October 30, 2023 18:08
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
@kogakure
kogakure / .gitignore
Last active December 17, 2023 08:21
Git: .gitignore file for LaTeX projects
*.acn
*.acr
*.alg
*.aux
*.bak
*.bbl
*.bcf
*.blg
*.brf
*.bst