Skip to content

Instantly share code, notes, and snippets.

View brianium's full-sized avatar
🕊️
Human

Brian Scaturro brianium

🕊️
Human
View GitHub Profile
@brianium
brianium / reltypes.scala
Created November 12, 2012 15:31
neo4j relationship types in scala
package com.brianscaturro
import org.neo4j.graphdb.RelationshipType
object RelTypes extends Enumeration {
type RelTypes = Value
val KNOWS = Value
implicit def conversion(rt: RelTypes) = new RelationshipType() { def name = rt.toString }
}
@brianium
brianium / grunt.js
Created December 1, 2012 19:15
grunt file
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
concat: {
dist: {
src: [
'vendor/bootstrap.js',
'vendor/underscore.js',
@brianium
brianium / guess.rb
Created December 28, 2012 02:38
7 weeks of 7 langues: Ruby Day 1 Bonus Challenge
puts "Guess a number between 1 and 10\n"
goal = rand(10) + 1
until((answer = gets.chomp) == goal.to_s)
puts "Too low\n" if answer.to_i < goal
puts "Too high\n" if answer.to_i > goal
end
puts "Good job! You guessed #{goal} correctly!\n"
@brianium
brianium / tree.rb
Created December 29, 2012 21:45
Tree solution for Ruby Day 2 HW
class Tree
attr_accessor :children, :node_name
def initialize(node = {})
(node.length == 1) && (@node_name = node.first[0]) || @node_name = 'root'
children = (@node_name == 'root') ? node : node[@node_name]
@children = []
children.each do |k, v|
@children.push(Tree.new({k => v}))
end
@brianium
brianium / acts_as_csv_module.rb
Created December 31, 2012 17:01
7 weeks of 7 languages - Ruby Day 3 Metaprogramming
module ActsAsCsv
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_csv
include InstanceMethods
end
end
module InstanceMethods
@brianium
brianium / gist:4436179
Created January 2, 2013 17:10
7 weeks of 7 Langues - Io Day 1 Simple Program
Party := Object clone
Party getRowdy := ("Rabble rabble rabble" println)
Party getRowdy
@brianium
brianium / catalogitemmodel.js
Created May 20, 2013 20:39
angular service
/**
* Sets up a model that depends on resource pools
* and catalogs
*/
angular.module("uss.services").
factory('CatalogItemModel', ['Catalog', 'ResourcePool', function(Catalog, ResourcePool) {
return {
setModel: function($scope, /** invoked with first cat */ cfn, /** invoked with first pool */ pfn) {
$scope.catalogs = Catalog.query({'public':0}, function(cats){
cfn(cats[0].id);
solve problems
software
AngularJS
passionate
teamwork
meet commitments
skill
proven history of shipping software
collaboration
creating solutions
@brianium
brianium / authenticated.js
Last active January 2, 2016 02:39
create authenticted app in express
var _ = require('lodash')
, problem = require('../errors').problem;
/**
* Check the request for a user. If none found
* create an API-Problem style error
*/
function check(req, res, next) {
if (!req.user) return next(
problem(new Error("Resource requires authorization"), {
@brianium
brianium / app.php
Created January 13, 2014 21:10
Swamp of POX with Silex
<?php
$app = new \Silex\Application();
$doOrder = function(\SimpleXMLElement $order) {
$orderService = new OrderService();
$orderService->setBeerId((string) $order['beer_id']);
$creditCard = CreditCardFactory::fromXml($order->CreditCard);
$orderService->setCreditCard($creditCard);
$order = $orderService->createOrder();