Skip to content

Instantly share code, notes, and snippets.

View ctrlShiftBryan's full-sized avatar

Bryan Arendt ctrlShiftBryan

View GitHub Profile
@ctrlShiftBryan
ctrlShiftBryan / compile_emacs.sh
Created August 9, 2016 15:31 — forked from marcwebbie/compile_emacs.sh
Compile emacs 24 on Red Hat 6 workstations
# install needed libraries
sudo yum install texinfo libXpm-devel giflib-devel libtiff-devel libotf-devel
# compile autoconf
cd /tmp
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.bz2
tar xjvf autoconf-2.68.tar.bz2
cd autoconf-2.68/
./configure && make && sudo make install
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
@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{}
#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
CREATE view [dbo].[vw_TablePrimaryKeys]
AS
/*
----------------------------------------------------------------------------
View: [vw_TablePrimaryKeys]
Description: Returns PK information for all tables
----------------------------------------------------------------------------
Who When Why
--------- --------- ---------
@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;
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) {
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;
//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; }
}
//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