Skip to content

Instantly share code, notes, and snippets.

View dmgolembiowski's full-sized avatar

David M. Golembiowski dmgolembiowski

View GitHub Profile
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@jvhaarst
jvhaarst / movedigiphotos.bash
Last active December 12, 2022 22:02
Bash script to move images, based on exif data and file timestamp
#!/bin/bash
# Reads EXIF creation date from all .JPG files in the
# current directory and moves them carefully under
#
# $BASEDIR/YYYY/YYYY-MM/YYYY-MM-DD/
#
# ...where 'carefully' means that it does not overwrite
# differing files if they already exist and will not delete
# the original file if copying fails for some reason.
@kohsuke
kohsuke / 2nd smartctl
Created September 11, 2012 18:19
smartmontools
kohsuke@cabbage:~$ date; sudo smartctl -a /dev/sda
Tue Sep 11 18:23:11 UTC 2012
smartctl version 5.38 [i686-pc-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
Device: ADAPTEC RAID-5 Version: 3B05
Device type: disk
Transport protocol: Parallel SCSI (SPI-4)
Local Time is: Tue Sep 11 18:23:11 2012 UTC
Device supports SMART and is Enabled
@trauber
trauber / mdlp.awk
Last active January 28, 2023 02:04
Agnostic literate programming for github flavored markdown.
#!/usr/bin/awk -e { if (/^```/) { i++; next } if ( i % 2 == 1) { print } }
# mdlp - agnostic literate programming for github flavored markdown.
# I release this script into the public domain.
# Rich Traube, Fri Feb 15 09:07:27 EST 2013
@leonardreidy
leonardreidy / prep-contacts-for-ponymailer
Created July 5, 2013 14:07
Parse html file with Beautiful Soup, find emails and names and output as json, ready for ponymailer.rb. Emails are found (with href=mailto) and names (inside <strong> tags). The program creates a single list that contains both names, and emails, and then output it as json, ready for ponymailer to send.
# A simple python script to extract names, and emails from
# a certain online directory
import os, json
from bs4 import BeautifulSoup
#get a list of the files in the current directory
inputfiles = os.listdir(os.getcwd())
def postproc(inputfiles):
@pe3
pe3 / scrape_entire_website_with_wget.sh
Last active May 25, 2024 19:58
Scrape An Entire Website with wget
this worked very nice for a single page site
```
wget \
--recursive \
--page-requisites \
--convert-links \
[website]
```
wget options
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active July 18, 2024 07:57
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@jeremychone
jeremychone / handlebars-render.js
Last active October 31, 2022 05:44
Simple HTML and js templates
// Just a little indirection to render a template using handlebars.
// This simple indirection allows much flexibility later one,
// when using pre-compiling or other templating engine are needed.
Handlebars.templates = Handlebars.templates || {};
function render(templateName,data){
var tmpl = Handlebars.templates[templateName];
if (!tmpl){
tmpl = Handlebars.compile($("#" + templateName).html());
Handlebars.templates[templateName] = tmpl;
}
@MichaelPote
MichaelPote / md5.js
Last active October 8, 2022 23:52 — forked from PixnBits/md5.js
invalid reference fix and fixed add32 not being overwritten properly.
/*
* http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
(function (global) {
var md5cycle = function (x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3];