Skip to content

Instantly share code, notes, and snippets.

View tibbon's full-sized avatar

David Fisher tibbon

View GitHub Profile
@tibbon
tibbon / suggested_gems.rb
Last active August 29, 2015 13:55
Suggested Ruby Gems for Development in Rails
gem 'dotenv-rails'
group :development do
gem 'time_difference'
gem 'pry-rails'
gem 'better_errors'
gem 'binding_of_caller'
gem 'annotate'
gem 'bullet'
gem 'debugger'
@tibbon
tibbon / method_scope_exercises.rb
Created September 24, 2014 16:12
WDI Method and Scope Exercises
####
# Exercise 1
# What bug prevents the circle circumference from being calculated in the code section below?
# How can you prevent such a bug in the future?
####
def circumference(r)
return 2 * pi * r
end
@tibbon
tibbon / map_each_array.rb
Created September 24, 2014 18:02
Ruby Array Map and Each
# .each is pretty easily, and simply loops through the array.
colors = ["red", "green", "blue"]
colors.each do |color|
puts color
end
# What is the "return value" of each?
@tibbon
tibbon / ruby_bytecode_view.rb
Created November 11, 2014 20:22
Viewing Ruby Bytecode
code = <<SRC
puts "Hello World"
SRC
bytecode = RubyVM::InstructionSequence.compile(code)
puts bytecode.disasm
@tibbon
tibbon / bubble_sort.c
Created December 3, 2014 15:34
Bubble Sort in C
#include <stdio.h>
#define ARRAYSIZE 8
void bubble_srt(int unsortedArray[], int arraySize) {
int temp;
for(int i = 0; i < arraySize; i++) {
for(int j = 0; j < (arraySize - 1); j++) {
@tibbon
tibbon / git_circus.md
Created March 4, 2015 15:33
Git Circus

SETUP -

Create a new organization with a group name (this is public, so don't make it anything terrible) Create a new Github repo and all all group members to it Everyone create a fork of it

Now, create the appropriate branches and move through this story:

You're writing a story about a current event and using Github to help organize it. The story will be in a file that someone creates called storytime.md

@tibbon
tibbon / silly_page.md
Created March 4, 2015 17:04
Silly Page

SETUP

Create a new organization with a group name (this is public, so don't make it anything terrible) Create a new Github repo and all all group members to it Everyone create a fork of it

Features

Now, create the appropriate feature branches and move through this program:

diff --git a/src/yajl_parser.c b/src/yajl_parser.c
index 398873c..96add32 100644
--- a/src/yajl_parser.c
+++ b/src/yajl_parser.c
@@ -226,11 +226,11 @@ yajl_do_parse(yajl_handle hand, unsigned int * offset,
_CC_CHK(hand->callbacks->yajl_number(
hand->ctx,(const char *) buf, bufLen));
} else if (hand->callbacks->yajl_integer) {
- long int i = 0;
+ unsigned long i = 0;
@tibbon
tibbon / gist:1363126
Created November 14, 2011 02:52
Fixing Skype Links
@skype_text = 'The <a href="http://www.imvox.com">bar</a> of <a href="http://foo.bar">cat</a>'
@skype_text.scan(/\S+">(\S+)<\/a>/).each do |link|
linktext = link[0]
@skype_text.gsub!(/<a href=\"\S+#{linktext}<\/a>/, linktext)
end
p @skype_text
@tibbon
tibbon / gist:1375104
Created November 18, 2011 00:32
Debugging file upload
post '/file_upload' do
@skype_name = params[:user]
if params[:action] == "FILE-UPLOAD"
unless params[:name].match(/\.jpg|png|jpeg/).nil?
current_user = User[:skype_name => @skype_name, :current_account => "1"]
client = current_user.authorize_to_twitter
datafile = Tempfile.new(params[:data])
client.update_with_media("File upload from Skype: ", datafile)
return "text: File posted."
datafile.unlink