Skip to content

Instantly share code, notes, and snippets.

@djleeds
djleeds / htb-css3-leaderboard-full-multiple.html
Created Aug 26, 2015
Hit the Bits! - CSS3 Leaderboard - With Multiple Lists
View htb-css3-leaderboard-full-multiple.html
<html>
<head><title>Animating a List with CSS3 Transitions - Multiple Lists</title></head>
<body>
<!-- Demonstrates one way to animate multiple lists -->
<style type="text/css">
.leaderboard li {
font-family: sans-serif;
font-size: 12px;
@djleeds
djleeds / htb-css3-leaderboard-full.html
Last active Mar 29, 2018
Hit the Bits! - CSS3 Leaderboard - Full
View htb-css3-leaderboard-full.html
<style type="text/css">
#leaderboard li {
font-family: sans-serif;
font-size: 12px;
line-height: 12px;
}
#leaderboard #players li {
display:block;
clear: both;
position: absolute;
@djleeds
djleeds / htb-whats-a-unit-1.java
Last active Dec 18, 2015
Code samples supporting the article _"Unit Testing: What's a Unit?"_ on the *Hit the Bits!* programming blog.
View htb-whats-a-unit-1.java
public int triple(int x) {
return x * 3;
}
@djleeds
djleeds / htb-35cf-1a.cfc
Last active Dec 17, 2015
Demonstrates inheritance, composition, mixins, and patches in ColdFusion. The article that corresponds to these code snippets can be found here: http://www.hitthebits.com/2013/05/coldfusion-code-reuse.html
View htb-35cf-1a.cfc
<!--- EggLayer.cfc --->
<cfcomponent>
<cffunction name="layEggs">
<cfargument name="count" />
<cfreturn "I just laid #count# eggs." />
</cffunction>
</cfcomponent>
@djleeds
djleeds / gplus-prog-01-trycatch.java
Last active Dec 16, 2015
One way to get around a need for a try/catch block, when you can change the code you're calling into. Doesn't apply in all situations.
View gplus-prog-01-trycatch.java
// If you call records.find() with an id that doesn't exist, you get a RecordNotFound Exception
int id = 1;
try {
records.find(id).setName("Joe");
} catch(RecordNotFoundException e) {
System.out.println("Record wasn't found!");
}
@djleeds
djleeds / htb-html5-date-picker-1.html
Last active Dec 12, 2015
Converting an HTML5 Date Picker value to a JavaScript Date object might not produce the result you expect. These gists demonstrate how you can create the Date object at GMT or your local time zone.
View htb-html5-date-picker-1.html
<script>
$(document).ready(function() {
$("#execute").bind("click", function() {
var dateString = $("#date").val();
var date = new Date(dateString);
$("#dateObject").text(date.toString());
});
});
</script>
@djleeds
djleeds / GoodIdentifiers.java
Created Jan 7, 2013
Demonstrates variable and method names that align better with the abstraction level of the code. Copyright (c) 2012 Lampo Licensing, LLC and released under the MIT license
View GoodIdentifiers.java
public Address findAddress(String city) {
Address matchingAddress = null;
List<Address> addresses = getAddresses();
for(Address address : addresses) {
if(address.getCity().equals(city)) {
if(matchingAddress == null) {
matchingAddress = address;
} else {
@djleeds
djleeds / BadIdentifiers.java
Created Jan 7, 2013
Demonstrates suboptimal variable and method names. Copyright (c) 2012 Lampo Licensing, LLC and released under the MIT license
View BadIdentifiers.java
public Address processData(String city) {
Address ret = null;
List<Address> list = getAddresses();
for(Address obj : list) {
if(obj.getCity().equals(city)) {
if(ret == null) {
ret = obj;
} else {
You can’t perform that action at this time.