Skip to content

Instantly share code, notes, and snippets.

View smarj's full-sized avatar
🏠
Working from home

Bill Smargiassi smarj

🏠
Working from home
  • GitHub Staff
  • New Jersey
View GitHub Profile
@smarj
smarj / resolve.rb
Created May 7, 2012 14:57
Naive reverse resolver
#!/usr/bin/env ruby -wKU
require 'resolv'
while line = gets
ip = line.chomp
begin
host_name = Resolv.getname(ip)
rescue Resolv::ResolvError => error
host_name = "noname"
@smarj
smarj / isa-fields.rb
Created January 10, 2013 16:27
ISA W3C Logging Fields as a Ruby Hash
FLD = { "c-ip" => 0, "cs-username" => 1, "c-agent" => 2, "sc-authenticated" => 3, "date" => 4, "time" => 5, "s-svcname" => 6,
"s-computername" => 7, "cs-referred" => 8, "r-host" => 9, "r-ip" => 10,
"r-port" => 11, "time-taken" => 12, "sc-bytes" => 13, "cs-bytes" => 14,
"cs-protocol" => 15, "cs-transport" => 16, "s-operation" => 17,
"cs-uri" => 18, "cs-mime-type" => 19, "s-object-source" => 20,
"sc-status" => 21, "s-cache-info" => 22, "rule" => 23,
"FilterInfo" => 24, "cs-Network" => 25, "sc-Network" => 26,
"error-info" => 27, "action" => 28, "GmtLogTime" => 29,
"AuthenticationServer" => 30 }
@smarj
smarj / Markdown Syntax.md
Last active April 15, 2017 16:10
Fletcher Penney's Markdown Syntax from https://github.com/fletcher/MultiMarkdown

Phrase Emphasis

*italic*   **bold**
_italic_   __bold__

Links

Inline:

@smarj
smarj / MultiMarkdown Table Syntax.md
Last active April 15, 2017 16:10
MultiMarkdown Table Syntax from Fletcher Penney's MultiMarkdown User's Guide https://github.com/fletcher/MultiMarkdown

| | Grouping ||

First Header Second Header Third Header
Content Long Cell
Content Cell Cell

New section | More | Data | And more | And more | [Prototype table]

@smarj
smarj / makeAnyPdfExcel.rb
Last active December 14, 2015 05:29 — forked from sck/makeAnyPdfSearchable.rb
makeAnyPdfSearchable.rb and makeAnyPdfExcel.rb
#! /usr/bin/env ruby
require 'tmpdir'
def fixed?(fn) fn =~ /\.searchable\.pdf/; end
def searchable_fn(fn)
return fn if fixed?(fn)
"#{File.dirname(fn)}/#{File.basename(fn, File.extname(fn))}.searchable.pdf"
end
@smarj
smarj / zendesk-marked.css
Last active March 2, 2017 01:47
Marked preview CSS for ZenDesk comments
/*
* zendesk-marked.css - CSS to preview ZenDesk comments in Marked
* Copyright (C) 2016 Bill Smargiassi bill@smargiassi.us
*/
body {
font-family: proxima-nova, sans-serif;
font-size: 14px;
font-style: normal;
font-weight: normal;
@smarj
smarj / check-debugs.sh
Created May 5, 2016 15:39 — forked from angrycub/check-debugs.sh.md
Forever WIP preprocessor for a cluster's worth of Riak Debugs. Catches some of the faves and biggies
#! /bin/bash
echo Creating Combined console.log
for I in *-riak-debug; do NODE=${I//-riak-debug/}; echo " Processing ${NODE}..."; for J in $I/logs/platform_log_dir/console.lo*; do sed -n -e '/^2015/!{H;d;};/^2015/{x;s/\n/ /g;p;};${x;s/\n/ /g;p;}' $J | awk '!/^$/{print $1"T"$2,"'${NODE}'",$0}' | sed 's/\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\) \(.*\)/\1 \2 \5/' >> temp.log ; done; done; sort temp.log > combined_console.log;rm temp.log;
echo Creating Combined error.log
for I in *-riak-debug; do NODE=${I//-riak-debug/}; echo " Processing ${NODE}..."; for J in $I/logs/platform_log_dir/error.lo*; do sed -n -e '/^2015/!{H;d;};/^2015/{x;s/\n/ /g;p;};${x;s/\n/ /g;p;}' $J | awk '!/^$/{print $1"T"$2,"'${NODE}'",$0}' | sed 's/\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\) \(.*\)/\1 \2 \5/' >> temp.log ; done; done; sort temp.log > combined_error.log;rm temp.log;
echo Checking for LevelDB Compaction Errors
find . -name "LOG" -exec grep -l 'Compaction error' {} \;
@smarj
smarj / one_24.erl
Created March 5, 2017 23:04
Functional Programming in Erlang, assignment 1.24 2017-03-05
-module(one_24).
-export([bits/1, enclose/1, perimeter/1, tail_bits/1]).
%% perimeter/1 - calculate the perimeter of common shapes
%% circle - πD, unrelated to coordinates
perimeter({circle, {_X,_Y}, Radius}) ->
Radius * 2 * math:pi();
%% rectangle - assumes coordinate 1 is lower left, coordinate 2 is upper
%% right, clauses with guards could be used to ensure it
perimeter({rectangle, {X1,Y1}, {X2,Y2}}) ->
@smarj
smarj / w2a1.erl
Created March 11, 2017 19:04
Functional Programming in Erlange 2.6
-module(w2a1).
-export([maximum/1,
product/1,
tail_maximum/1,
tail_product/1]).
product([]) -> 1;
product([Num|Nums]) -> Num * product(Nums).
tail_product(Nums) -> tail_product(Nums, 1).
@smarj
smarj / w2a2.erl
Created March 15, 2017 17:11
Functional Programming in Erlang, Week 2, Assignment 2
-module(w2a2).
-export([double/1, evens/1]).
double([]) -> [];
double([X|Xs]) ->
[2 * X|double(Xs)].
evens([]) -> [];
evens([X|Xs]) ->
case X rem 2 of