Skip to content

Instantly share code, notes, and snippets.

View ctrlShiftBryan's full-sized avatar

Bryan Arendt ctrlShiftBryan

View GitHub Profile
@ctrlShiftBryan
ctrlShiftBryan / test.html
Last active January 3, 2016 19:29
This is a test gist!
public class MyTest{
public string HelloEveryone(){
var x = 1;
return "Hello Everyone";
}
}
//unmodified
var original = new List<Person>() {
new Person() { Id = 1, Name = "Bryan" },
new Person() { Id = 2, Name = "Randy" },
new Person() { Id = 3, Name = "Jill" } };
//modified
var updated = new List<Person>() {
new Person() { Id = 1, Name = "Bryan" },
new Person() { Id = 2, Name = "Randi" }, //Update Randy to Randi
//a class that has a parent id and contains a list of children
public class Folder {
public int Id { get; set; }
public string Name { get; set; }
public int? ParentId { get; set; }
public List<Folder> Children { get; set; }
public int Level { get; set; }
}
public class FakePage<T> : List<T> , IPagedList<T>
{
public FakePage(int page, int pageSize, int totalRecords, IEnumerable<T> collection ) : base(collection)
{
this.PageCount = (totalRecords + pageSize -1 ) / pageSize;
this.TotalItemCount = totalRecords;
this.PageNumber = page;
this.PageSize = pageSize;
this.HasPreviousPage = page > 1;
ko.extenders.precisionScale = function (target, dynamicProperty) {
//create a writable computed observable to intercept writes to our observable
var result = ko.pureComputed({
read: target, //always return the original observables value
write: function (newValue) {
var current = target();
var valueToWrite = newValue;
if (valueToWrite) {
@ctrlShiftBryan
ctrlShiftBryan / gist:7849d03137a8bdb20ccd
Created January 2, 2015 21:21
Cancel a route and reload in sammy
sam.before({}, function () {
var cancel = false;
if (vm.LastLocation) {
cancel = vm.LastLocation !== window.location.pathname;
}
vm.LastLocation = window.location.pathname;
CREATE view [dbo].[vw_TablePrimaryKeys]
AS
/*
----------------------------------------------------------------------------
View: [vw_TablePrimaryKeys]
Description: Returns PK information for all tables
----------------------------------------------------------------------------
Who When Why
--------- --------- ---------
#if INTERACTIVE
#r "../../packages/Selenium.WebDriver.2.48.2/lib/net40/WebDriver.dll"
#r "../../packages/Selenium.Support.2.48.2/lib/net40/WebDriver.Support.dll"
#r "../../packages/Newtonsoft.Json.6.0.6/lib/net40/Newtonsoft.Json.dll"
#r "../../packages/SizSelCsZzz.0.3.36.0/lib/SizSelCsZzz.dll"
#r "../../src/canopy/bin/Debug/canopy.dll"
#endif
@ctrlShiftBryan
ctrlShiftBryan / FooController.ex
Last active May 4, 2016 20:36
Struct As Params?
defmodule Foo.BarController do
use Foo.Web, :controller
defmodule ByKeyParams do
defstruct dob: "", last_name: "", request_id: ""
end
def by_key(conn, params) do
params = %ByKeyParams{} |> map.merge(params)
request = %Foo.Request{}
defmodule Image do
@moduledoc false
use Ecto.Model
@primary_key {:Id, :binary_id, autogenerate: false}
schema "Images" do
field :name
field :extension
field :path
end