Skip to content

Instantly share code, notes, and snippets.

View toepoke's full-sized avatar

fj toepoke

View GitHub Profile
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.Mvc;
using System;
/// MVC2 compatiable version of @haacked security checking class, for details, see
/// - http://haacked.com/archive/2017/08/10/mvc-action-security-audit/
@toepoke
toepoke / ditto-tests.ts
Created April 13, 2016 07:10
Tests for ditto.ts
import * as ditto from "./ditto";
// Yeah, I know use Karma, or assert or something ... I'm just playing around, sue me :-)
class Person {
firstName: string = "";
lastName: string = "";
partner: Person = null;
@toepoke
toepoke / ditto.ts
Last active February 9, 2017 14:40
An immutable-esk like TypeScript library for playing around (I wouldn't use this in production ... probably)
/**
* Module: "ditto" (coz the module delivers new objects, and uber [kinda used to] sounds cool!)
* Description: Set of [generic] helper methods for doing [very simple!] immutable type for TypeScript/ES6
* Tests: See set of noddy tests at ????
* Source: https://gist.github.com/toepoke/fafa3cbe7f8592d6286237bebe43af19
* Usage:
* "import * as ditto from './ditto';"
* ...
* ditto.updateItem( ... )
* Revisions:
@toepoke
toepoke / my-component.ts
Last active June 3, 2016 11:55
FCC Angular2 VS Code snippets
{
/*
// Place your snippets for TypeScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
module.exports ..... blah {
var target = (grunt.option("target") || "live");
var webConfig = "deployment/" + target + "/website/web.config";
xmlpoke: {
website: {
options{
....
},
@toepoke
toepoke / showey
Created December 31, 2013 10:47
jQuery extension methods
/// <summary>
/// showey - noddy example of how to add an extension method to jQuery
/// <summary>
jQuery.fn.showey = function() {
for (var i=0; i < this.length; i++) {
var $ele = $(this[i]);
$ele.show("fast", "linear");
}
@toepoke
toepoke / prettyCheckboxes
Created July 23, 2012 15:47
Pretty checkboxes (using ui-icon jQuery UI framework icons to overlay over the top of the underlying checkbox - _doesn't_ touch any associated label)
/// <summary>
/// Takes advantage of the jQuery UI framework icons (see http://jqueryui.com/themeroller/) to pretty
/// up checkboxes
/// </summary>
/// <param name="filter">jQuery selector targetting the checkboxes, e.g. "input[type=checkbox]" attaches to all checkboxes</param>
function prettyCheckboxes(filter) {
// some constants for the icons, here are some variants you might want to consider:
// onClass offClass
// "ui-icon-check" "ui-icon-close"
// "ui-icon-circle-check" "ui-icon-circle-close"
@toepoke
toepoke / gist:3159559
Created July 22, 2012 12:48
Add ui-icon icons to checkboxes to illustrate if they're clicked or not .. inspired by http://iwritecrappycode.wordpress.com/2012/03/01/jquery-ui-checkbox-better-feedback/
var onClass = "ui-icon-circle-check", offClass = "ui-icon-circle-close";
$( "input:checked[type=checkbox] " ).button({ icons: {primary: onClass} });
$( "input[type=checkbox]:not(:checked)" ).button({ icons: {primary: offClass} });
$( "input[type=checkbox]" ).click(function(){
var swap = function(me, toAdd, toRemove) {
// find the LABEL for the checkbox
// ... which should be _immediately_ before or after the checkbox
var node = me.next();