Skip to content

Instantly share code, notes, and snippets.

View benlesh's full-sized avatar
🐶
☕ 🔥 🔥 this is fine

Ben Lesh benlesh

🐶
☕ 🔥 🔥 this is fine
View GitHub Profile
@benlesh
benlesh / Program.cs
Created August 15, 2012 15:09
A basic digitally signed token in C#. More info at: http://www.benlesh.com/2012/08/creating-digitally-signed-security.html
class Program
{
static void Main(string[] args)
{
TokenTesting();
}
private static void TokenTesting()
{
// create a private key to use in our tests.
@benlesh
benlesh / Hasher.cs
Created August 22, 2012 19:08
A password hashing utility for .NET and a functional test console application for it.
/// <summary>
/// A hashing utility.
/// </summary>
public static class Hasher
{
/// <summary>
/// Gets an HMAC SHA512 hash for some text.
/// </summary>
/// <param name="text">The text to hash</param>
/// <param name="salt">The salt to use in hashing.</param>
@benlesh
benlesh / app.js
Created December 7, 2012 15:04
Angular 1.0.3/Jquery 1.8.3/Bootstrap Template
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {
});
@benlesh
benlesh / Date.add.js
Created January 7, 2013 01:57
Basic date add function in JavaScript.
/*
Copyright (c) 2013 Ben Lesh
[email protected]
MIT License
*/
;(function () {
var proto = Date.prototype;
function adder(value, getter, setter, toAdd) {
var d = new Date(value),
@benlesh
benlesh / test.json
Created September 10, 2013 12:33
Just some data for a wheel of fortune knockoff thingy
[
{
"text": "George Washington",
"type": "Person"
},
{
"text": "Abraham Lincoln",
"type": "Person"
}
]
@benlesh
benlesh / app.js
Last active August 30, 2024 08:37
Angular - Basics of Unit Testing a Controller
var app = angular.module('myApp', []);
/* Set up a simple controller with a few
* examples of common actions a controller function
* might set up on a $scope. */
app.controller('MainCtrl', function($scope, someService) {
//set some properties
$scope.foo = 'foo';
$scope.bar = 'bar';
@benlesh
benlesh / MainCtrl-better.js
Last active August 29, 2015 13:56
Angular - Testing Promises and Nested Promises
angular.module('myApp').controller('MainCtrl', ['$scope', 'people', function($scope, people) {
var self = this;
self.personSuccess = function(result) {
};
self.personFail = function(result) {
$scope.errorMessage = 'failed to load person';
};
@benlesh
benlesh / Ubuntu_Install_Java7.sh
Created February 9, 2014 15:26
Remove OpenJRE and install Oracle Java 7 on Ubuntu
# Remove OpenJRE stuff
sudo apt-get remove openjre*
# Add PPA to pull down Oracle JRE
sudo add-apt-repository ppa:webupd8team/java
# Get an updated list of packages
sudo apt-get update
# Install java 7
@benlesh
benlesh / BinaryTree.js
Created February 21, 2014 03:41
A simple Binary Tree implementation in JavaScript
/**
* Binary Tree
* (c) 2014 Ben Lesh <[email protected]>
* MIT license
*/
/*
* A simple Binary Tree implementation in JavaScript
*/
@benlesh
benlesh / README.md
Created April 10, 2014 06:31
Ember/Angular Table Component

Ember/Angular advanced nested components

Purpose

Working with @ebryn on a particular control that we discovered to be a pretty challenging and interesting problem to solve in EmberJS. Wanted to solve the same problem in AngularJS so we could discuss and draw comparisons. It seems to me at this point in both frameworks the situation is mostly covered, but perhaps requires some wiring that would be unintuitive for the average developer.

Requirement

A generic table control with templatable columns. Given a data set in the form of an array of objects, we need a customizable table because we need to do things like show/hide columns, sort consistantly, etc.