Skip to content

Instantly share code, notes, and snippets.

@awendland
awendland / PasswordEncryptionService.java
Created July 29, 2013 22:38
A Java class for use in encrypting passwords and comparing previously encrypted passwords to clear-text passwords. Uses no dependencies outside of Java SE 6. Encryption uses the slow hashing algorithm PBKDF2 and generates salts using SecureRandom and SHA1. Adopted from code original posted at http://www.javacodegeeks.com/2012/05/secure-password-…
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Arrays;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
/**
@awendland
awendland / html-starter-simple.html
Last active August 29, 2015 14:11
Simple HTML starter file for quick prototyping
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>An Amazing Title</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<link rel="stylesheet" href="style.css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
@awendland
awendland / html-starter-lessjs.html
Created December 21, 2014 03:11
Simple HTML starter file w/ Less.js for quick prototyping
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>An Amazing Title</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<link rel="stylesheet/less" type="text/css" href="style.less">
<script type="text/javascript"src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.1.2/less.min.js"></script>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
@awendland
awendland / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@awendland
awendland / obscure-example.html
Last active August 29, 2015 14:22
Reverse the textContents of an element in order to hide an email by pasting it in reverse in the source, but displaying it properly after the "unObscureElements" JS function runs.
<span class="obscure">moc.elpmaxe@eman</span> will become <span ...>[email protected]</span> after the JS runs
@awendland
awendland / pretty-date.js
Created June 4, 2015 00:16
JS function that takes an ISO time and returns a string representing how long ago the date represents.
/*
* JavaScript Pretty Date
* Copyright (c) 2011 John Resig (ejohn.org)
* Licensed under the MIT and GPL licenses.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate (time) {
var date = time instanceof Date ? time : new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
diff = (((new Date()).getTime() - date.getTime()) / 1000),
@awendland
awendland / dl_in_pieces.py
Created June 4, 2015 21:02
This simple python script downloads the retina wallpapers from the gorgeous http://species-in-pieces.com web experience
#! /usr/bin/env python
#
# This should be run from whichever director is desired for the wallpapers to be downloaded to
#
# Also, take a look at http://species-in-pieces.com/, it's a gorgeous website!
#
# Thank you to Bryan James for creating Species in Pieces
#

Android Cheat Sheet

Styles

Font family

android:fontFamily="sans-serif"                 // roboto regular
android:fontFamily="sans-serif-light"           // roboto light
android:fontFamily="sans-serif-condensed"       // roboto condensed
@awendland
awendland / json-database-metadata.java
Created July 10, 2015 01:31
Converts a java.sql.DatabaseMetaData object to a JSON friendly Map<String, Object>. This is intended for debugging running Java Web APIs
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Map<String, Object> getMapOfDatabaseMetaData(DatabaseMetaData dbMeta) {
@awendland
awendland / huffman.java
Last active August 29, 2015 14:24
A huffman code table generator from a given input string
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Alex Wendland © 2015
*/