Skip to content

Instantly share code, notes, and snippets.

View wsams's full-sized avatar
🫖

Weldon Sams wsams

🫖
View GitHub Profile
@wsams
wsams / ExampleItemWriter.class
Created February 7, 2015 03:59
javap -c -v ExampleItemWriter.class
Classfile /tmp/example/com/example/repository/batch/ExampleItemWriter.class
Last modified Jan 28, 2015; size 10503 bytes
MD5 checksum 6ce62e4e964b10f9802927fe2ebfac85
Compiled from "ExampleItemWriter.java"
public class com.example.repository.batch.ExampleItemWriter extends java.lang.Object implements org.springframework.batch.item.ItemWriter<com.example.metadata.xkbml.entity.XKbml>
Signature: #168 // Ljava/lang/Object;Lorg/springframework/batch/item/ItemWriter<Lcom/example/metadata/xkbml/entity/XKbml;>;
SourceFile: "ExampleItemWriter.java"
InnerClasses:
public static #193= #18 of #191; //Builder=class com/example/exceptionlogger/ExampleCriticalException$Builder of class com/example/exceptionlogger/ExampleCriticalException
public static #193= #62 of #253; //Builder=class com/example/exceptionlogger/ExampleFatalException$Builder of class com/example/exceptionlogger/ExampleFatalException
@wsams
wsams / try-to-cheat-probability-lol.js
Last active August 29, 2015 14:16
I enjoy the game King of Thieves and one aspect I'm always trying to improve is picking the locks. I know I can't cheat probability but it sure is fun trying. You have X amount of locks and you try opening them one-by-one. My current strategy is to just start from the first lock and work my way through to the end. The following JavaScript will a…
(function() {
var numLocks = 8;
var iterations = 1000;
function random(min, max) {
"use strict";
return Math.round(Math.random() * (max - min) + min);
}
function buildLocksArray() {
@wsams
wsams / mkdirt.rb
Created March 12, 2015 20:26
Read two files and merge data with Ruby. This script came about while creating document IDs in a system. They consist of 4 characters and only contain a-z lowercase letters. I had created a list of so called "dirty words" used to filter Solr suggestions and also had a legacy list of 4 letter "dirty words". I was tasked to create a master list of…
legacy = 'legacy-dirt.txt'
solr = 'solr-dirt.txt'
dirt = 'dirt.txt'
dirt_final = 'dirt-final.txt'
# Read both text files into arrays
legacy_file_array = File.readlines(legacy);
solr_file_array = File.readlines(solr);
# Create empty dirt.txt file and open in append mode.
@wsams
wsams / espresso
Last active August 29, 2015 14:17
This is a command line script I use for managing my Java projects. It uses the optparse library for parsing command line options.
#!/usr/bin/ruby
require 'optparse'
require 'fileutils'
@APPLICATION
@ENVIRONMENT = "dev".freeze
@DROPSPOT = "/opt/j2ee/deploy".freeze
@WC = "/Users/foobar/espresso/nb-wc".freeze
@wsams
wsams / graph.rb
Last active August 29, 2015 14:17
Create an (X, Y) plane suitable for graphing equations in Ruby.
require "rubygems"
require 'png'
class RubyGraph
attr_accessor :x_precision
attr_accessor :y_precision
attr_accessor :x_pos_units
attr_accessor :y_pos_units
attr_accessor :x_neg_units
attr_accessor :y_neg_units
@wsams
wsams / gist:19fa53da811abe490c77
Created March 22, 2015 19:19
I have an image gallery application backed by MySQL. Each album is a directory on disk full of images. This is a Ruby script that pulls the data from the database and writes it as JSON to text files in each individual album directory. This is mainly for use when backing up and storing in my lock box at the bank. It could also be used for regener…
require "rubygems"
require "mysql"
require "json"
db = Mysql.new("localhost", "foobar", "ll33h5235kj", "images")
metadata = db.query("select * from metadata")
metadata.each_hash do |row|
full_album_path = "/path/to/images/#{row['album_dir']}"
if File.exists?(full_album_path)
meta = row
7/21/15 2:12:24.901 PM WindowServer[143]: Received display connect changed for display 0x4280882
7/21/15 2:12:24.903 PM WindowServer[143]: Found 27 modes for display 0x04280882 [27, 0]
7/21/15 2:12:24.904 PM WindowServer[143]: Received display connect changed for display 0x3f003f
7/21/15 2:12:24.904 PM WindowServer[143]: Found 1 modes for display 0x003f003f [1, 0]
7/21/15 2:12:24.904 PM WindowServer[143]: Received display connect changed for display 0x3f0040
7/21/15 2:12:24.907 PM WindowServer[143]: Found 96 modes for display 0x003f0040 [78, 10]
7/21/15 2:12:24.907 PM WindowServer[143]: Display 0x003f0040 changed state to online
7/21/15 2:12:24.918 PM WindowServer[143]: Received display connect changed for display 0x3f0041
7/21/15 2:12:24.918 PM WindowServer[143]: Found 1 modes for display 0x003f0041 [1, 0]
7/21/15 2:12:24.951 PM WindowServer[143]: MPServiceForDisplayDevice: Invalid device alias (0)
@wsams
wsams / .bashrc
Created September 16, 2015 20:54
Show new, removed, clean repository state icons while using svn-prompt.sh and git-prompt.sh
# https://github.com/mcandre/svn-prompt
function setSvnPrompt {
svn info &>/dev/null
if [ $? -eq 0 ]; then
svn st | grep "[0-9a-zA-Z?\!]" > /dev/null 2>&1
if [ $? -eq 1 ]; then
# nothing changed
echo -n "✓ "
fi
@wsams
wsams / prototype.html
Last active April 21, 2016 18:40
A simple HTML template with included jQuery, moment.js, Foundation, and Bootstrap frameworks. Inline CSS and JavaScript sections for quick prototyping.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- foundation -->
<!--
<link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.2.1/foundation.min.css">
@wsams
wsams / hasher.php
Last active March 28, 2017 02:57
Create a JSON object containing the sha256 hash of each photo in a directory. The main usage is to identify and quarantine or remove duplicates.
<?php
// hardcoded files created: pics.list, error.log
// config
$hashf = 'hash.json';
// globals
$movetotrash = true; # you can change this
$needskip = false; # must leave false