Skip to content

Instantly share code, notes, and snippets.

View cbednarski's full-sized avatar

Chris Bednarski cbednarski

View GitHub Profile
@cbednarski
cbednarski / factorio.md
Last active April 3, 2024 01:14
Host a factorio server
@cbednarski
cbednarski / camera.py
Last active February 17, 2024 05:54
Webcam capture for python - Pops up a preview from your webcam and snaps a picture when you press 'q'
import cv2
# Windows dependencies
# - Python 2.7.6: http://www.python.org/download/
# - OpenCV: http://opencv.org/
# - Numpy -- get numpy from here because the official builds don't support x64:
# http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
# Mac Dependencies
# - brew install python
@cbednarski
cbednarski / fix-libappindicator.sh
Last active October 23, 2023 16:39
Update deb package with libappindicator3-1 dependency to use libayatana-appindicator3-1 instead. For Debian 11.
#!/bin/bash
# Copying: Public domain.
set -e
sourceName=$1
if [[ $sourceName == "" ]]; then
echo "Usage: fix-libappindicator.sh <.deb>"
@cbednarski
cbednarski / gist:1038947
Created June 21, 2011 21:27
Detach a process from an apache web request
<?php
/**
* Detaches a process from apache so it can be invoked by a webpage but run
* under CLI context. Prevents apache from waiting for the process to
* finish before displaying output. All output is piped to null.
*
* @param string $process full path to executable / binary
* @param string $arguments arguments passed to the script
*/
@cbednarski
cbednarski / install-consul.sh
Last active September 27, 2020 17:53
Ubuntu installer script for consul
set -x
mkdir -p /tmp/consul
cd /tmp/consul
# Consul Configuration File
tee consul.json <<CONSULCONFIG
{
"bootstrap_expect": 3,
"client_addr": "0.0.0.0",
@cbednarski
cbednarski / nginx-error.conf
Created March 13, 2013 04:52
Example nginx.conf for custom error pages
server {
listen 80;
server_name HOSTNAME;
root /opt/PATH/;
index index.html;
rewrite ^/$ /en/PATH/ redirect;
@cbednarski
cbednarski / nginx.conf
Last active January 11, 2019 12:07
Nginx and php-fpm configs for local development
server {
listen 8080;
server_name local.webblob.com;
root /Users/cbednarski/code/WebBlob/src;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 /500.html;
error_page 502 /502.html;
error_page 503 /503.html;
@cbednarski
cbednarski / gist:4555141
Created January 17, 2013 10:37
Sublime Text keymap, which fixes the really annoying Ctrl+Tab order behavior
[
{ "keys": ["ctrl+shift+t"], "command": "open_terminal_project_folder" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }
]
@cbednarski
cbednarski / di.fm-playlist.py
Created February 3, 2016 00:13
di.fm iTunes playlist importer
import re
"""
di.fm allows you to download a playlist of all your favorite channels. For some
reason when you open this playlist with iTunes only one of the channels is
added. This script splits the playlist file into many playlist files so you can
easily load all of your favorites into iTunes and enjoy di.fm streaming without
running Flash in your browser.
"""
items = open("di.pls").read().split("File")
@cbednarski
cbednarski / statusline.sh
Last active September 24, 2016 17:15
Bash statusline
# Color codes look like this: \033[1;34m
#
# When used in a prompt, color codes and other special sequences have to be
# escaped so they are not counted in the width of the bash prompt. If the width
# is not calculated correctly backspace, up arrow, etc. will not work correctly.
#
# In the bash prompt itself (PS1) you should use the \[ \] an escape sequence.
# This indicates to bash that these characters are not part of the prompt.
#
# If you're using color codes in a bash function that is used in your prompt,