Skip to content

Instantly share code, notes, and snippets.

View stungeye's full-sized avatar

Kyle Geske stungeye

View GitHub Profile
@stungeye
stungeye / diff_it.rb
Last active August 29, 2015 14:03
Google News Search Geo Parameter Evaluation
require 'feed-normalizer'
no_geo_feed = FeedNormalizer::FeedNormalizer.parse(open('harvey_no_geo.rss'))
geo_feed = FeedNormalizer::FeedNormalizer.parse(open('harvey_geo.rss'))
geo_titles = []
no_geo_titles = []
titles_count = Hash.new(0)
geo_feed.entries.each do |entry|
<?php require('animal_functions.php') ?>
<!DOCTYPE html>
<html>
<head>
<title>Strange Animals</title>
</head>
<body>
<h1>Strange Animals</h1>
<?php if (selected_animal_and_count_are_valid()): ?>
<?php for ($i = 0; $i < selected_count(); $i++): ?>
@stungeye
stungeye / tap.rb
Created December 17, 2014 16:04
Using tap, and then on second though each_with_object.
# Using Tap
def search(query)
[].tap do |matches|
for record in @all do
matches << record if ((record['866']['t'] == query) || (record['866']['s'] == query))
end
end
end
@stungeye
stungeye / mux_mp4.md
Created January 21, 2015 19:54
MUX MP4 Audio and Video Together

The second file can be an mp4 instead of an mp3:

ffmpeg -i input.mp4 -i input.mp3 -c copy -map 0:0 -map 1:0 output.mp4

To concat to mp4s:

ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts

ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4

@stungeye
stungeye / first_ar.rb
Created January 27, 2015 16:45
Simple AR without Rails Example
require 'active_record'
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => 'db/development.sqlite3'
class Customer < ActiveRecord::Base
# Associated with the customers.
end
# SELECT * FROM customers ORDER BY id ASC LIMIT 1
first_customer = Customer.first
<!DOCTYPE html>
<html>
<head>
<title>The Final Countdown</title>
</head>
<body>
<?php for($i=0; /* condition */; /* update */): ?>
<p><?= /* # */ ?></p>
<?php endfor ?>
</body>
@stungeye
stungeye / poodr.md
Last active August 29, 2015 14:20
POODR Notes
  • Hide Instance Variables. Wrap instance variables with simple getter methods using attr_reader. This turns data into behaviour. Consider making these getters private.
@stungeye
stungeye / signal_trap.rb
Last active August 29, 2015 14:20
Trap Ctrl-C and exit.
Signal.trap("INT") do
puts "L8r Sk8r!"
exit
end
loop do
puts "Forever is longer than you'd imagine."
sleep 1
end
@stungeye
stungeye / index.php
Created June 1, 2015 17:46
Hello World PHP Test Script
<?php
$highlighted_source = highlight_file(__FILE__, true); // Documentation for this function listed below.
?>
<!DOCTYPE html>
<html>
<head>
<title>Hello World PHP Demo</title>
</head>
<body>
<?php for($i = 0; $i < 3; $i++): ?>
@stungeye
stungeye / core.clj
Last active August 29, 2015 14:25
EDS Lookup Table Refactor
(ns eds-lookup.core
(:gen-class))
(require '[clj-yaml.core :as yaml]
'[clojure-csv.core :as csv]
'[clojure.string :as str])
(def new-locations (yaml/parse-string (slurp "locations.yml")))
(def eds-locations (csv/parse-csv (slurp "eds-locations.csv")))