Skip to content

Instantly share code, notes, and snippets.

View rjz's full-sized avatar
👋
Hey there!

RJ Zaworski rjz

👋
Hey there!
View GitHub Profile
@rjz
rjz / bounce.c
Created May 2, 2011 02:27
C program to bounce an asterisk across the screen
#include <stdio.h>
#include <string.h> /* for memset() */
#include <unistd.h> /* for usleep() */
#define MAXLEN 80
int main(void) {
int spaces = 0,
iterator = 1;
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
@rjz
rjz / checkboxdemo.html
Created May 6, 2011 20:48
Checkbox replacement example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript">
/**
* Demo for replacing checkboxes with a custom element using jQuery
*
* @author RJ Zaworski <[email protected]>
*/
@rjz
rjz / autocheckbox_16.css
Created May 17, 2011 23:42
16px styling for autocheckbox
/**
* Some default styling for our new checkbox elements. We'll need to style
* two states -- when the box is checked (.checked) and when it isn't
* (no class). For both states, we'll need both a default appearance and
* an appearance that's used when the checkbox is being hovered over/focused
* on. Here goes nothing:
*/
.p-checkbox,
.p-radio {
width:16px;
@rjz
rjz / Backbone-force-navigate
Created November 16, 2011 17:34
Force Backbone to load the current URL
var fragment = Backbone.history.getFragment();
Backbone.history.loadUrl(fragment, true)
@rjz
rjz / js-screensaver.js
Created December 18, 2011 22:34
Javascript screensaver
(function(poll, timeout){
var _idle = false,
_lastActive = 0,
_activeNow = function() {
_lastActive = new Date();
if (_idle) {
$('#screensaver').hide();
_idle = false;
@rjz
rjz / pretty-date.rb
Created January 24, 2012 19:05
Pretty Date in Ruby
# Nothin' special here: just Resig's pretty date function ported to Ruby
# http://ejohn.org/blog/javascript-pretty-date/
def pretty_date(stamp)
now = Time.new
diff = now - stamp
day_diff = ((now - stamp) / 86400).floor
day_diff == 0 && (
diff < 60 && "just now" ||
@rjz
rjz / heroku_parser.php
Created March 17, 2012 05:38
Heroku log parser
<?php
if (!class_exists('HerokuParser')):
/**
* A super-quick parser for Heroku logfiles
*/
class HerokuParser {
/**
@rjz
rjz / gist:2553749
Created April 29, 2012 23:01
Rails helper for pretty-printing ordered parameters
# Compile a list of options into an ordered array
def compile_options(obj, order = [])
components = []
order = obj.keys if order.empty?
order.each { |k| components << obj[k] unless obj[k].blank? }
components
end
# Example: returns "Omaha", "Omaha, Nebraska", or "Nebraska"
def pretty_location(opts = {})
@rjz
rjz / range_check.py
Created May 16, 2012 17:05
Google v. Oracle
def range_check(num, min, max):
return num <= max and num >= min;
print range_check(3, 0, 10) # True
print range_check(13, 0, 10) # False