Skip to content

Instantly share code, notes, and snippets.

View togakangaroo's full-sized avatar

George Mauer togakangaroo

View GitHub Profile
$tempDir = ([system.io.path]::GetTempPath())
Import-Module pscx 2>$null
$Pscx:Preferences['TextEditor'] = 'C:\Program Files\Sublime Text 3\subl.exe'
set-alias edit Edit-File -Scope Global
Set-Alias vim 'C:\Program Files (x86)\vim\vim74\vim.exe'
Set-Alias vi vim
Import-Module z
#if(-not $env:OwPassword) {
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