Skip to content

Instantly share code, notes, and snippets.

View scottoffen's full-sized avatar
💭
Live in SLC

Scott Offen scottoffen

💭
Live in SLC
View GitHub Profile
@scottoffen
scottoffen / declassify.pl
Last active August 29, 2015 14:01
Declassify arguments to a perl exported/static method
use Scalar::Util ('blessed');
###############################| Declassify |###############################
sub Declassify
{
my @params = @_;
shift (@params) if ($params[0] eq __PACKAGE__);
my @args = (ref $params[0] eq 'ARRAY') ? @{$params[0]} : ();
my $pkg = $params[1] || __PACKAGE__;
@scottoffen
scottoffen / CommandLine.java
Created June 7, 2014 00:18
Java Command Line Made Easy
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CommandLine
{
private static final BufferedReader input;
static
{
input = new BufferedReader(new InputStreamReader(System.in));
@scottoffen
scottoffen / layers.html
Created June 30, 2014 16:54
HTML CSS Layers Example
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Layers</title>
<style type="text/css">
#loading, #loaded
{
position: fixed;
@scottoffen
scottoffen / encode.html
Created July 2, 2014 21:19
Base64 Encode/Decode using HTML JavaScript
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Encode/Decode Base64</title>
<style type="text/css">
body
{
margin: 0px;
@scottoffen
scottoffen / linker.html
Created July 2, 2014 21:25
HTML page to make links to resources you want to download with a right click
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Save URL Contents</title>
<style type="text/css">
body
{
@scottoffen
scottoffen / comments.pl
Created July 10, 2014 23:59
Perl References
#----------------------------------#
# localtime() array reference #
#----------------------------------#
# 0 - seconds #
# 1 - minutes #
# 2 - hours #
# 3 - day of month #
# 4 - month #
# 5 - year #
# 6 - day of week #
@scottoffen
scottoffen / jquery.styleexists.js
Last active August 29, 2015 14:06
jQuery namespaced function to determine if a css selector is defined in any attached stylesheet
(function ($)
{
$.styleExists = function (s)
{
var exists = false;
var stylesheets = document.styleSheets;
for (var sx = 0, sl = stylesheets.length; sx < sl; sx += 1)
{
var sheetclasses = stylesheets[sx].rules || document.styleSheets[sx].cssRules;
@scottoffen
scottoffen / WrappedList.cs
Created October 8, 2014 19:37
Creating a custom thread-safe List<T> in C# that supports Add, Remove and Yank
using System;
using System.Linq;
using System.Collections.Generic;
namespace SampleNamespace
{
class WrappedList<T>
{
private List<T> list = new List<T>();
private object sync = new object();
@scottoffen
scottoffen / barspacing.js
Created October 21, 2014 17:13
Javascript Exponential Bar Spacing
barMargin = (150 * Math.exp(-0.15 * array.length))
@scottoffen
scottoffen / MyRESTResource.cs
Last active August 29, 2015 14:08
A RESTResource extension for handling JSON
public abstract class MyRESTResource : RESTResource
{
protected JObject GetJsonPayload(HttpListenerRequest request)
{
try
{
string data = this.GetPayload(request);
if (!object.ReferenceEquals(data, null))
{
JObject json = JObject.Parse(data);