Skip to content

Instantly share code, notes, and snippets.

View greggroth's full-sized avatar

Greggory Rothmeier greggroth

  • GitHub
  • San Francisco, CA
View GitHub Profile
@greggroth
greggroth / cover_flow.nb
Created September 1, 2011 14:10
Mathematica:coverflow
pic = Import["ExampleData/rose.gif"];
Module[{width = 28, layers = 6, offset, highlight, slides, img,
data},
offset[x_, slide_] := 15/(1 + Exp[-(x - slide) 3]);
highlight[x_, slide_] :=
0.85 PDF[NormalDistribution[slide, 1], x]/
PDF[NormalDistribution[slide, 1], slide] + 0.15;
img = Table[pic, {n, 1, layers}];
Manipulate[Graphics3D[{
Table[{
@greggroth
greggroth / gist:1259157
Created October 3, 2011 13:59
SPM Error
------------------------------------------------------------------------
Running job #1
------------------------------------------------------------------------
Running 'Model estimation'
SPM8: spm_spm (v4191) 09:58:05 - 03/10/2011
========================================================================
Initialising parameters : ...done
Plane 34/34 , block 1/1 : ...done
Failed 'Model estimation'
@greggroth
greggroth / gist:1330921
Created November 1, 2011 15:58
learning algorithm my ass.
% --- Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit3,'String','Loading Learning Algorithm From Default Directory');
pause(3);
set(handles.edit3,'String','Loading..');
pause(3);
set(handles.edit3,'String','Succesfully Loaded Learning Algorithm Library');
hrf = spm_hrf(1);
box = [zeros(1,2) 1.9*ones(1,350), zeros(1,48)];
result = conv(box, hrf);
@greggroth
greggroth / gist:1346239
Created November 7, 2011 21:26
The Porter's Beer List
[["Brewery", "Beer", "Style", "Origin", "Volume", "ABV", "Description"], ["21st Amendment/Ninkasi", "Allies Win the War", "Amber Ale", "California", "8oz", "8.5", "this amber ale from 21st amendment and Ninkasi boasts citrus hops melded with caramel and dark fruit "], ["Ace", "Pear Cider", "Cider", "Sonoma County, CA", "8 oz", "5", "crisp, clean, gluten-free, refreshingly delicious pear cider"], ["Ace", "Pumpkin Cider", "Fruit Beer", "Sonoma County, CA", "8oz", "5", "seasonal flavors of spice and pumpkin; sweet with a tart apple finish "], ["Allagash ", "Curieux ", "Tripel", "Portland, ME", "8 oz", "11", "a Belgian triple aged in Jim Beam barrels, bourbonlicious! "], ["Allagash ", "Hugh Malone", "Belgian-style IPA", "MAine", "8oz", "8.5", "great Belgian style IPA, pine and grapefruit hop character, dry and astringent finish"], ["Avery", "DuganA IPA", "American Double IPA", "Colorado", "16oz", "8.5", "pine and citrus hop bitterness with malty sweetness"], ["Baladin", "Ali-skir", "Belgian Style Light Strong Ale
@greggroth
greggroth / porter_beer_list
Created November 7, 2011 21:32
The Porter's Beer List (499 beers!)
---
- - Brewery
- Beer
- Style
- Origin
- Volume
- ABV
- Description
- - 21st Amendment/Ninkasi
- Allies Win the War
@greggroth
greggroth / gist:1346276
Created November 7, 2011 21:39
Process The Porter's List
require "nokogiri"
require "open-uri"
require "yaml"
# Let's check out The Porter's selection
doc = Nokogiri::HTML(open('http://www.theporterbeerbar.com/drink/beer/'))
puts "Loaded the website OK"
# Make an array to hold all of the data
data = Array.new
@greggroth
greggroth / gist:1405766
Created November 29, 2011 18:10
bad way
include Process
pid = spawn("rails r my_file_1.rb")
waitpid(pid, 0)
pid = spawn("rails r my_file_2.rb")
waitpid(pid, 0)
pid = spawn("rails r my_file_3.rb")
waitpid(pid, 0)
@greggroth
greggroth / gist:1405798
Created November 29, 2011 18:16
how about this?
Dir['*.rb'].each do |file_name|
pid = spawn("rails r #{file_name}")
waitpid(pid, 0)
end
@greggroth
greggroth / gist:1419423
Created December 1, 2011 20:03
how I do it.
#include <iostream>
#include <string>
#include <math.h>
using namespace std ;
bool checkForDouble(string const& s) {
istringstream ss(s);
double d;
return (ss >> d) && (ss >> std::ws).eof();
}