Skip to content

Instantly share code, notes, and snippets.

View kjlape's full-sized avatar
🤝
nice to meet you

Kaleb Lape kjlape

🤝
nice to meet you
View GitHub Profile
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
Exec=/usr/local/sublime-text-3/sublime_text
Icon=/usr/local/sublime-text-3/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"
@kjlape
kjlape / SillyModule.cs
Created August 14, 2014 14:17
NancyFX: How to use fancy route segments in module level base routes.
using Nancy;
namespace SillyWebsite
{
public class SillyModule : NancyModule
{
public SillyModule() : base("/{chicken}/with/cheese")
{
Get["/"] = _ =>
{
@kjlape
kjlape / datatables-processing-example.js
Created August 4, 2014 20:03
How to do custom stuff when jQuery DataTables is processing something.
// Docs URL: http://datatables.net/reference/event/processing
// This is your DataTable in the DOM.
$('#example')
// Listen for the processing event.
.on('processing.dt', function(e, settings, processing) {
// The processing variable is a boolean.
if (processing)
showCustomProcessingEffects();
else
@kjlape
kjlape / POCO2Expando.cs
Created July 30, 2014 21:02
Odd little code nugget for converting POCOs to ExpandoObjects.
public static ExpandoObject ToExpando(this object obj)
{
IDictionary<string, object> expando = new ExpandoObject();
foreach (var info in obj.GetType().GetProperties())
expando.Add(new KeyValuePair<string, object>(info.Name, info.GetValue(obj)));
return (ExpandoObject)expando;
}
@kjlape
kjlape / BigIQKidsWords_scraper.rb
Last active August 29, 2015 14:02
Scrape wordlists from BigIQKids.com.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
urls = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth']
.map {|ordinal| "http://www.bigiqkids.com/SpellingVocabulary/Lessons/wordlistSpelling#{ordinal}Grade.shtml"}
8.times do |number|
page = Nokogiri::HTML(open(urls[number]))
@kjlape
kjlape / CloudPanel_EF_example.cs
Created May 8, 2014 17:15
Example of how to use the new EF code in CloudPanel...
using (var ctx = new CloudPanelContext(@"Database=[Name your DB];Server=.\SQLSERVER;Integrated Security=true"))
{
// Do stuff with data...
ctx.SaveChanges();
}
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Globalization;
namespace MyNamespace
{
public class HumanStringWithNumbersComparer : StringComparer
{
public static Func<A, R> Memoize<A, R>(this Func<A, R> f)
{
var cache = new System.Collections.Concurrent.ConcurrentDictionary<A, R>();
return a => cache.GetOrAdd(a, f);
}
@kjlape
kjlape / copyVB6proj.py
Last active December 30, 2015 07:29
Barebones script for copying all files necessary to build a given Visual Basic 6.0 project file, or any file with a complete listing of all project dependencies.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import string
from fileinput import input
from os.path import dirname, basename, isdir, isfile, join, splitext
from shutil import copy2
def copyProject(project, destinationDir = ""):
projectDir = dirname(project)
@kjlape
kjlape / TicketingSession.cs
Last active December 28, 2015 08:39
How to turn off the default database initialization in Entity Framework 6 Code First.
using AdmitOne.Domain.Entities;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace AdmitOne.Persistence.Ticketing
{
public class TicketingSession : Session
{
public TicketingSession() : base(new TicketingContext()) { }