Skip to content

Instantly share code, notes, and snippets.

@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'
@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
@subfuzion
subfuzion / github-wiki-how-to.md
Last active January 15, 2024 15:17
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?

@aembleton
aembleton / docx2md.md
Last active May 17, 2023 07:04 — forked from vdavez/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

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.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@jamesarosen
jamesarosen / two-travis-builds.md
Last active June 5, 2021 18:39
Running Two Very Different Travis Builds

I have a project that's been happily chugging along on Travis for a while. Its .travis.yml looks something like

script:
  - node_modules/ember-cli/bin/ember test

I wanted to add a second parallel build that did something very different. I didn't want to run ember test with a different Ember version or some other flag. I wanted to run a completely different command. Specifically, I wanted to run LicenseFinder's audit.

Travis has great docs on customizing parallel builds, but nothing describes how to do two completely different commands.

@guilhermemm
guilhermemm / k_shortest_paths.py
Last active May 12, 2021 02:47
Yen's K-Shortest Path Algorithm for NetworkX. Yen's algorithm computes single-source K-shortest loopless paths for a graph with non-negative edge cost. For more details, see http://en.m.wikipedia.org/wiki/Yen%27s_algorithm
# -*- coding: utf-8 -*-
"""
A NetworkX based implementation of Yen's algorithm for computing K-shortest paths.
Yen's algorithm computes single-source K-shortest loopless paths for a
graph with non-negative edge cost. For more details, see:
http://networkx.github.io
http://en.m.wikipedia.org/wiki/Yen%27s_algorithm
"""
__author__ = 'Guilherme Maia <guilhermemm@gmail.com>'
@T31337
T31337 / CapCam.py
Last active January 11, 2017 12:49
ScreenRecorder&Microphone Audio Recorder Using FFMPEG & Python
#!/usr/bin/env python3
'''
This Script Is Mainly From A Youtube User,
I Only Modified It Slightly To Make It Python3 Compatable,
And Added Custom Microphone Recording Support
Original Source Code: http://pastebin.com/BY1t5AcC
Thanks To Youtube User NoBeansJose
License:
@mikkelam
mikkelam / hamilton.py
Last active October 29, 2022 07:21
Finds a hamiltonian path using networkx graph library in Python with a backtrack solution
import networkx as nx
def hamilton(G):
F = [(G,[list(G.nodes())[0]])]
n = G.number_of_nodes()
while F:
graph,path = F.pop()
confs = []
neighbors = (node for node in graph.neighbors(path[-1])
if node != path[-1]) #exclude self loops
@pyos
pyos / ping.py
Last active November 16, 2021 15:31
import time
import random
import struct
import select
import socket
def chk(data):
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF
x = (x >> 16) + (x & 0xFFFF)
@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`.
"""