Skip to content

Instantly share code, notes, and snippets.

View peterwwillis's full-sized avatar

Peter W peterwwillis

View GitHub Profile
@egelev
egelev / connect_bluetooth_headphones.sh
Last active April 26, 2024 14:14
Connect bluetooth headphones on Ubuntu 18.04
#!/usr/bin/env bash
function get_headphones_index() {
echo $(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}')
}
function get_headphones_mac_address() {
local temp=$(pacmd list-cards | grep bluez_card -C20 | grep 'device.string' | cut -d' ' -f 3)
temp="${temp%\"}"
temp="${temp#\"}"
@tschieggm
tschieggm / flask_server.py
Created November 22, 2013 18:51
Stackdriver webhook server example
import string
import sys
import logging
import json
from flask import Flask
from flask import Response, request
logger = logging.getLogger(__name__)
logger.info("Stackdriver webhook-sample starting up on %s" % (string.replace(sys.version, '\n', ' ')))
@joyrexus
joyrexus / README.md
Last active April 8, 2024 09:15
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@btoone
btoone / curl.md
Last active April 2, 2024 20:18
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@plugnburn
plugnburn / README.md
Last active March 27, 2024 00:01
Statix - the simplest static website generator in bash

Statix - the simplest static website generator in Bash

Statix is a stand-alone Bash script aimed at generating full-featured, routable static websites from reusable HTML snippets. It features the most basic templating engine ever possible but allows to organize your content in a SEO-friendly way. All Statix-based websites contain these parts:

  • Templates: a directory where all HTML templates are stored
  • Route configuration: a file that maps each publicly accessible template to a SEO-friendly URL
  • Assets: a directory with optional files copied to the output website directory with no processing.

This script is also lightweight. Aside from some standard file management commands such as cp, mkdir and rm, the only serious dependency for Statix is GNU Grep compiled with PCRE support (i.e. the version that supports -P flag, included in most Linux distributions).

@ssp
ssp / turn off spindumps
Created March 7, 2010 15:35
Turn off spindump in MacOS X. This can improve the performance of the whole system in some situations.
launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist
# 10_basic.py
# 15_make_soup.py
# 20_search.py
# 25_navigation.py
# 30_edit.py
# 40_encoding.py
# 50_parse_only_part.py
@scrapehero
scrapehero / fandango.py
Created February 12, 2018 07:46
Python 3 Code for scraping movie details from fandango.com
from lxml import html, etree
import datetime
import requests
import re
import os
import sys
import unicodecsv as csv
import argparse
import json
# from exceptions import ValueError
@fulldecent
fulldecent / travis-local.md
Created November 29, 2017 02:33
Run Travis build locally

travis-local.md

Preconditions:

  1. POSIX or Windows system
  2. Install Docker
  3. A GitHub repo that already builds on Travis

Postcondition:

@cloudsben
cloudsben / md-menu.html
Last active June 14, 2023 07:46
markdown menu
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.2/styles/googlecode.min.css">
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://yandex.st/highlightjs/6.2/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
$(document).ready(function(){
$("h2,h3,h4,h5,h6").each(function(i,item){
var tag = $(item).get(0).localName;