Skip to content

Instantly share code, notes, and snippets.

@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
@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.

@subfuzion
subfuzion / github-wiki-how-to.md
Last active April 20, 2024 09:22
GitHub Wiki How-To

How do I clone a GitHub wiki?

Any GitHub wiki can be cloned by appending wiki.git to the repo url, so the clone url for the repo https://myorg/myrepo/ is: git@github.com:myorg/myrepo.wiki.git (for ssh) or https://github.com/my/myrepo.wiki.git (for https).

You make edits, and commit and push your changes, like any normal repo. This wiki repo is distinct from any clone of the project repo (the repo without wiki.get appended).

How do I add images to a wiki page?

@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)
@yajra
yajra / install-wkhtmltopdf.sh
Last active March 7, 2024 00:17
Install wkhtmltopdf 0.12.4 (with patched qt)
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin/
ln -nfs /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
@rverton
rverton / chrome_headless_screenshot.py
Created July 10, 2017 08:53
Make a screenshot with a headless google chrome in python
# Install chromedriver from https://sites.google.com/a/chromium.org/chromedriver/downloads
import os
from optparse import OptionParser
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
CHROME_PATH = '/usr/bin/google-chrome'
@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
@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
@Zulko
Zulko / nx_merge_nodes.py
Last active June 9, 2023 03:23
This is a function to merge several nodes into one in a Networkx graph
# This is a function to merge several nodes into one in a Networkx graph
def merge_nodes(G,nodes, new_node, attr_dict=None, **attr):
"""
Merges the selected `nodes` of the graph G into one `new_node`,
meaning that all the edges that pointed to or from one of these
`nodes` will point to or from the `new_node`.
attr_dict and **attr are defined as in `G.add_node`.
"""
@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()