Skip to content

Instantly share code, notes, and snippets.

View brianium's full-sized avatar
🕊️
Human

Brian Scaturro brianium

🕊️
Human
View GitHub Profile
jQuery.noConflict();
(function() {
var $ = this.jQuery,
MyNamespace = {};
MyNamespace.SuperAwesomeFunction = function() {
//do awesome stuff
};
$(function() {
MyNamespace.SuperAwesomeFunction();
@brianium
brianium / fluentsession.cs
Created July 3, 2012 18:06
NHibernate fluent out of the box
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString("server=.\\SQLEXPRESS;database=NH3BeginnersGuide;Integrated Security=SSPI"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionFactoryProvider>())
.ExposeConfiguration((cfg) => {
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(false, true);
schemaExport.Create(false,true);
})
.BuildConfiguration()
.CurrentSessionContext<ThreadStaticSessionContext>()
@brianium
brianium / nhibernatehelper.cs
Created July 3, 2012 18:10
NHibernate simplified with helper class
void Main()
{
//Create Session Provider With CurrentSessionContext
var provider = new SessionFactoryProvider<ThreadStaticSessionContext>(
MsSqlConfiguration.MsSql2008.ConnectionString("server=.\\SQLEXPRESS;database=NH3BeginnersGuide;Integrated Security=SSPI"),
typeof(SessionFactoryProvider<>),
(cfg) => {
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(false, true);
schemaExport.Create(false,true);
@brianium
brianium / gist:3042459
Created July 3, 2012 19:48
watcher F#
open System;
open System.IO;
open Microsoft.FSharp.Collections;
//setup the watcher and events
let watcher = new FileSystemWatcher(@"C:\Users\brians\Python")
let logFileInfo (args:FileSystemEventArgs) = Console.WriteLine(args.Name)
let events = [watcher.Changed; watcher.Created; watcher.Deleted] |> List.iter(fun e -> e.Add(logFileInfo))
//read from console
@brianium
brianium / gist:3055843
Created July 5, 2012 19:19
EntityBuilder
void Main()
{
var f = new DogBuilder();
f.GetInstance().Dump();
}
// Define other methods and classes here
public class Dog : Entity<Dog>
{
public string Name {get;set;}
@brianium
brianium / watcher.fs
Created July 12, 2012 14:46
A simple F# program to concat js given an input and output file (provided sprockets exists on the system)
open System;
open System.IO;
open Microsoft.FSharp.Collections;
open System.Diagnostics;
let projectDirectory = Directory.GetCurrentDirectory()
let args = Environment.GetCommandLineArgs();
let watcher = new FileSystemWatcher(projectDirectory)
@brianium
brianium / gist:3165240
Created July 23, 2012 18:27
is_mobile
function isMobileDevice()
{
var agent = navigator.userAgent.toLowerCase();
var otherBrowser = (agent.indexOf("series60") != -1) || (agent.indexOf("symbian") != -1) || (agent.indexOf("windows ce") != -1) || (agent.indexOf("blackberry") != -1);
var mobileOS = typeof orientation != 'undefined' ? true : false;
var touchOS = ('ontouchstart' in document.documentElement) ? true : false;
var iOS = (navigator.platform.indexOf("iPhone") != -1) ||
(navigator.platform.indexOf("iPad") != -1) ? true : false;
var android = (agent.indexOf("android") != -1) || (!iOS && !otherBrowser && touchOS && mobileOS) ? true : false;
@brianium
brianium / euler1.scala
Created August 28, 2012 19:29
euler problem 1
(for(i <- 1 to 999 if(i % 3 == 0 || i % 5 == 0)) yield i) reduceLeft(_ + _)
@brianium
brianium / repo.get.scala
Created August 30, 2012 02:13
repo get
def get(fbid: String):Option[FacebookObject] = {
val response = graphFetch(fbid)
response().map(jstr => {
val js = jstr.asJson.asJsObject
val obj = js.convertTo[FacebookObject]
val comments = js.getFields("comments")
if (comments.isEmpty) obj else build(obj, comments.head.asJsObject.convertTo[CommentsJson])
})
}
@brianium
brianium / scproj.sh
Created September 3, 2012 22:43
bash script for making a new sbt project
#!/bin/bash
mkdir -p src/main/{resources,scala}
mkdir -p "src/test/"{resources,scala}
mkdir -p src/it/{resources,scala}
mkdir project
#create project files
echo "sbt.version=0.11.3" > project/build.properties
echo -e 'resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"\n' > project/plugins.sbt
echo 'addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0-SNAPSHOT")' >> project/plugins.sbt