Skip to content

Instantly share code, notes, and snippets.

View stevenpetryk's full-sized avatar

Steven Petryk stevenpetryk

View GitHub Profile
@stevenpetryk
stevenpetryk / sb2-better_errors.md
Last active December 11, 2015 19:08
Using Sublime Text 2 with better_errors on Ubuntu

Using better_errors on Ubuntu with SublimeText 2

After I installed the fantastic better_errors gem, I was disappointed to notice that linking to your text editor doesn't work correctly on Ubuntu (at least, it didn't for me). Here's how I fixed it.

First, create a new desktop entry:

# /usr/share/applications/subl-urlhandler.desktop
@stevenpetryk
stevenpetryk / punnet_square.rb
Created March 31, 2013 04:48
This is just a nifty little script I wrote that will solve a Punnett square. I plan to make it into a full-featured gem that will be used a future project.
module Geneticist
# The syntax is easy here. If you know how to set up a Punnett Square in real life,
# it's pretty self explanatory.
#
# # Checking for green eyes
# square = Geneticist::PunnettSquare.new('Gg', 'gg')
# square.result
# #=> {"Gg"=>2, "gg"=>2}
#
# # Checking a cross between a spider ball python and a pastel ball python
@stevenpetryk
stevenpetryk / journal.md
Created June 20, 2013 21:24
Europe Grand Tour Journal

Europe Grand Tour Notebook

Rome, Italy

We arrived in Rome very early in the morning, after having endured an 8-hour plane ride. Due to the difference in time, we left Tampa International at 12 P.M. or so, and arrived at the Roman countryside at around 7:30 A.M. the next day. I didn't sleep on the plane a bit; it was extremely uncomfortable. The food wasn't bad, though. I learned the importance of standing occasionally.

We stayed at the Hotel Tiziano, a relatively large and up-scale hotel only a few blocks away from the Pantheon. They had old-fashioned metal keys, affixed via keychain to large weights which displayed our room numbers. I stayed in a small room with a king-sized bed with a TV on the opposite wall, end stands standing at either side, and a desk for work in a small nook sporting a beautiful, close-up view of a brick wall. The bathroom was small and the shower even smaller, about large enough to bathe an adult mouse.

Day 1

// :::::::::::::::::::::::: LICENSE AND COPYRIGHT NOTICE :::::::::::::::::::::::
// Copyright (c) 2013 Andrew Hamon. All rights reserved.
//
// This file is part of FFT-LED-Visualization. FFT-LED-Visualization is
// distributed under the MIT License. You can read the full terms of use in the
// LICENSE file, or online at http://opensource.org/licenses/MIT.
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <Adafruit_NeoPixel.h>
#define sampleRate 1
#define progChangeDuration 1000
#define threshold 20
void setup()
{
pinMode(2, INPUT);
}
void loop()

Web design path

  • [HTML][html]
  • [CSS][css]
  • [JavaScript][javscript]

You can stop there if you only want to learn basic web design. If you want to make web-apps and stuff, these are highly recommended:

  • [Ruby][ruby]
  • [Sass][sass] (think of this as super-powered CSS)
  • [CoffeeScript][coffee] (think of this as super-powered and better-looking JavaScript)
@stevenpetryk
stevenpetryk / better_setinterval.coffee
Created July 2, 2014 13:29
This is quite a useful improvement over the regular Javascript setInterval()
# Usage:
# every 250, (stop) ->
# stop() if condition
# # some logic...
#
# Still preserves original behavior if you want to do that:
# interval_id = every 250, someFunction
# clearInterval(interval_id)
every = (time, fn) ->
int earliestHitInChain(Attack * attacks[]) {
int i;
for(i = MAX_ATTACKS-1; i > 0; i--) {
if(attacks[i] != NULL && attacks[i]->result == HIT && attacks[i-1]->result == MISS)
return i;
}
return -1; // didn't find anything
}
@stevenpetryk
stevenpetryk / bash_prompt.sh
Last active August 29, 2015 14:10
My bash prompt
# spetryk in ~/code $
PS1='\n\[\e[1;34m\]\u\[\e[m\] in \[\e[1;34m\]\w\[\e[m\]\n\[\e[1;32m\]>\[\e[m\] \[\e[37m\]'
void DrawSquares( Graphics canvas )
{
canvas.setColor(Color.BLACK);
for( int nRow=0; nRow<NUMROWS; nRow++ )
{
for( int nCol=0; nCol<NUMCOLS; nCol++ )
{
canvas.drawRect( BOARDLEFT + nCol * SQUAREWIDTH,
BOARDTOP + nRow * SQUAREHEIGHT, SQUAREWIDTH, SQUAREHEIGHT );