Skip to content

Instantly share code, notes, and snippets.

View johno's full-sized avatar
🖤
Computering

John Otander johno

🖤
Computering
View GitHub Profile
/*
Author: John Otander
For: BSU CS 297
Date: 3/12/2014
Run Program: $ gcc godot.c -ogodot
$ ./godot <ALARM_INTERVAL>
*/
#include <stdlib.h>
@johno
johno / email.rb
Created May 8, 2014 23:13
config/initializers/email.rb
unless Rails.env.development? || Rails.env.test?
config.action_mailer.default_url_options = { :host => 'www.myappurl.com' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
@johno
johno / chosen.coffee
Created May 1, 2014 15:38
Integrating chosen for tags with the ability to add (the coffeescript portion).
window.chosen_select =
enable: ->
$('.chosen-select').chosen
allow_single_deselect: true
no_results_text: 'No results found'
width: '100%'
add: (select, string) ->
select.prepend($('<option selected="selected">', { value: string })
.text(string))
#include "mystrstr.h"
#include <string.h>
#include <stdio.h>
char big_string[] = "Hello";
char sub_string[] = "ell";
char *str = big_string;
char *substr = sub_string;
require 'date'
2.0.0p353 :001 > require 'date'
=> true
2.0.0p353 :002 > date_str = "Mon., Feb. 10, 8 p.m"
=> "Mon., Feb. 10, 8 p.m"
2.0.0p353 :003 > DateTime.strptime(date_str, "%a., %b. %e, %l %P")
ArgumentError: invalid date
from (irb):3:in `strptime'
from (irb):3
from /Users/johno/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'
@johno
johno / using_strptime.rb
Created February 15, 2014 18:31
The strftime method shows all the Ruby directives for different representations of time. This allows you to deal with tricky scenarios of ambiguous timestamps.
~|||$ irb
re2.0.0p353 :001 > require 'Time'
=> true
2.0.0p353 :002 > Time.strptime("12/22/2011", "%m/%d/%Y")
=> 2011-12-22 00:00:00 -0700
2.0.0p353 :003 > Time.strptime("12/11/2011", "%m/%d/%Y")
=> 2011-12-11 00:00:00 -0700
2.0.0p353 :004 > Time.strptime("12/11/2011", "%d/%m/%Y")
=> 2011-11-12 00:00:00 -0700
2.0.0p353 :005 >
@johno
johno / irb_example.rb
Created February 3, 2014 15:20
Running Boise Weekly scraper.
shovel|||master $ irb
2.0.0-p353 :001 > require './boise_weekly'
=> true
2.0.0-p353 :002 > Shovel::BoiseWeekly.scrape
=> [#<Event:0x007fb61a178dd8 @title="Banff Mountain Film Festival", @description="", @category=1, @address="700 Idaho", @venue=nil, @bw_id="3046754", @cost="$14-$48", @date="\r\n ..."]
@johno
johno / s3_credentials.rb
Created January 12, 2014 00:45
Carrierwave and fog config.
require 'colorize'
module Amazon
S3_BUCKET_NAME = ENV['S3_BUCKET_NAME']
AWS_ACCESS_KEY = ENV['AWS_ACCESS_KEY']
AWS_SECRET_ACCESS_KEY = ENV['AWS_SECRET_ACCESS_KEY']
def self.all_keys_initialized?
S3_BUCKET_NAME && AWS_SECRET_ACCESS_KEY && AWS_ACCESS_KEY
# Replace me.
def base_subscription
self.subscriptions.reverse.each do |sub|
return sub if sub.active and sub.plan.service_type == 'standard'
end
return nil
end
# With me.
def base_subscription
@johno
johno / html.html
Created October 17, 2013 22:16
Unobtrusive masonry for http://masonry.desandro.com/.
<div class="masonry" data-masonry-element="widget" data-masonry-gutter=20>
<!-- ... -->
</div>