Skip to content

Instantly share code, notes, and snippets.

View togakangaroo's full-sized avatar

George Mauer togakangaroo

View GitHub Profile
define(
['_underscore', 'jquery'],
function underscoreExtensions(_, $){
//Object and collection helpers
_.mixin({
// Create object from a callback that returns [name, value] pairs. We use this combination a lot
// so might as well bake it into the framework
mapObject: _.compose(_.object, _.map)
@togakangaroo
togakangaroo / supersimple-commonjs.md
Last active August 29, 2015 14:04
Super Simple CommonJs-ish module system
@togakangaroo
togakangaroo / node-stringprep-install
Created July 18, 2014 18:49
node-stringprep install errors
W:\temp> npm install node-stringprep
npm http GET https://registry.npmjs.org/node-stringprep
npm http 304 https://registry.npmjs.org/node-stringprep
npm http GET https://registry.npmjs.org/nan
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/nan
> node-stringprep@0.5.2 install W:\temp\node_modules\node-stringprep
> node-gyp rebuild
app.SimpleAuthorization("/Admin/SimpleTableEditor/France/UserPermissions", (owinEnvironment) =>
Ogre.RoleConfiguration.GetRolesForUser(owinEnvironment["username"].ToString()).Contains("Editor"))
//^ Not exactly sure how to do Authorization. Should probably go in its own Nuget package?
// My idea is basically just for any request to that route run the lambda, and 401 if it returns false.
app.UseSimpleTableEditor(new SimpleTableEditorOptions {
Url = "/Admin/SimpleTableEditor/France/UserPermissions",
Label = "France - User Permissions",
ConnectionString: x => x.ConnectionString( OgreDeployment.ConnectionString("frenchDatamart") ), //Nested closure rather than just interface to make it easier to find
//^ or x => x.ConnectionStringName("frenchDatamart") which will pluck the value out of ConfigurationManager
@togakangaroo
togakangaroo / Presentation.cs
Created July 25, 2014 17:05
Demonstration of things you can do with inner classes
public class Presentation
{
public class PackageResult
{
public string Name;
public Stream Stream;
}
//PackageResult as an inner clas can be a good idea since its really just a Tuple and has no reusability value
public PackageResult Package()
{
@togakangaroo
togakangaroo / Download-Infos.ps1
Created August 6, 2014 01:35
Get a bunch of data from facebook and dump it to a powershell file
$tokens = cat .\facebook-tokens.csv
pushd
$wc = New-Object Net.WebClient
mkdir infos
cd infos
$cntr = 0
foreach($t in $tokens) {
$cntr += 1
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#code {
position: relative;
transition: all 1s ease;
@togakangaroo
togakangaroo / ObjectExtensions.cs
Created November 21, 2014 15:03
some extension methods
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace System
{
public static class ObjectExtensions
{
@togakangaroo
togakangaroo / gist:2c1433c1710a0143e214
Created February 21, 2015 04:06
How a Get method in Asp.Net works?

How a Get method in Asp.Net works?

It works something like this when your db context is injected (and you use AutoMapper)

public IEnumerable<MainScreenSlideDefinition> Get(string type) {
    return db.SlideDefinition.Where(s => s.Type == type).ToList().Select(s => Mapper.Map<MainScreenSlideDefinition>(s));
}

or like this if it is not

@togakangaroo
togakangaroo / about-arrays.md
Last active August 29, 2015 14:20
First pass on lecture introducing the concept of arrays

Last week you learned about objects and how objects are used to group data. Of all the things we've taught you so far its probably least clear how you would use these. I assure you, once you get past very simple websites, you use objects all the time. Let's look at some web applications and identify where the objects might be hiding.

http://content.screencast.com/users/togakangaroo/folders/Jing/media/069877db-54cd-40c6-b468-170187d5882e/2015-05-03_0933.png I'll start with the application I just finished writing. We were building it for two years so I can assure you it's not very simple. It's a web application that helps business analysts generate slide decks that answer questions like "why isn't dairy selling in August". Can you tell where some objects probably are? I worked on it so I can tell you. See each of these slid thumbnails below? Each one has a name, a url to the preview image - remember for images you put in a url into the src attribute, you might have difficulty seeing but it also has the name