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 / 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: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 / 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 / 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 / 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>()
jQuery.noConflict();
(function() {
var $ = this.jQuery,
MyNamespace = {};
MyNamespace.SuperAwesomeFunction = function() {
//do awesome stuff
};
$(function() {
MyNamespace.SuperAwesomeFunction();
@brianium
brianium / gist:2934077
Created June 15, 2012 01:19
sample Wulib
(function(exports, undefined){
var Wulib = {},
activeDoc = app.activeDocument;
var ArtBoard = function(board) {
this.board = board;
};
ArtBoard.prototype = {
addPadding:function(val) {
@brianium
brianium / gist:2859761
Created June 2, 2012 19:59
sermon query for custom wordpress
SELECT DISTINCT p.ID
FROM wp_posts p
LEFT JOIN wp_term_relationships tr ON tr.object_id = p.ID
LEFT JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_id
LEFT JOIN wp_terms t ON tt.term_id = t.term_id
WHERE p.post_type = "sermon"
AND p.post_status = "publish"
ORDER BY p.ID ASC
@brianium
brianium / dynamictypes.cs
Created May 30, 2012 13:34
Creating Dynamic Generic Types in C#
void Main()
{
var genericType = typeof(GenericClass<>);
Type[] t = { typeof(int) };
var toCreate = genericType.MakeGenericType(t);
object o = Activator.CreateInstance(toCreate, "brian", "scaturro");
o.Dump();
}
class GenericClass<T>
@brianium
brianium / create.sql
Created May 30, 2012 03:08
SqlServer Script
--Employees
CREATE TABLE Employees(
Id int not null,
LastName nvarchar(50) not null,
MiddleName nvarchar(50),
FirstName nvarchar(50) not null,
primary key(Id)
)
GO