Skip to content

Instantly share code, notes, and snippets.

@ChuckSavage
ChuckSavage / ViewExtensions.cs
Created June 6, 2012 19:58
MonoTouch Swipe Event
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
namespace iOSLib
{
public static class ViewExtensions
{
static Dictionary<UIView, Dictionary<UISwipeGestureRecognizerDirection, SwipeClass>>
@scottrippey
scottrippey / jQuery.antiforgerytoken.js
Created August 22, 2012 18:21
ASP.NET MVC AntiForgeryToken + AJAX = jQuery to the rescue
// Setup CSRF safety for AJAX:
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
if (options.type.toUpperCase() === "POST") {
// We need to add the verificationToken to all POSTs
var token = $("input[name^=__RequestVerificationToken]").first();
if (!token.length) return;
var tokenName = token.attr("name");
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mattt
mattt / uiappearance-selector.md
Last active June 4, 2024 13:28
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@southpawfishel
southpawfishel / Point.as
Last active December 19, 2015 03:18
Quick implementation of flash.geom.Point in Loomscript. I took loom2d.math.Point and used it as a base, and added all the methods from the Flash version, as well as a distanceSquared method since thats on loom.graphics.Point.
package loom2d.math
{
/**
* A slightly less simple Point class.
*/
public struct Point
{
public var x:Number, y:Number;
// CREATION / ASSIGNMENT
@nmilford
nmilford / 00_hello_world.markdown
Last active September 5, 2018 13:53
A quick, non-conclusive, non-scientific tete-a-tete HelloWorld off for poops-n-giggles.

Inspired by https://gist.github.com/josevalim/1582864

Environment

Ubuntu 12.04

Linux citadel 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

  • 12G of DDR3 RAM (@ 1033MHz)
  • 16 cores (E5530 @ 2.40GHz)
@mausch
mausch / gist:6774627
Created October 1, 2013 06:37
Applicative validation is simple.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
// As opposed to magic validation libraries that rely on reflection and attributes,
// applicative validation is pure, total, composable, type-safe, works with immutable types, and it's easy to implement.
public abstract class Result<T> {
private Result() { }
package main
import (
"github.com/codegangsta/martini"
"github.com/codegangsta/martini-contrib/binding"
"github.com/codegangsta/martini-contrib/render"
"labix.org/v2/mgo"
)
type Wish struct {
@StephenCleary
StephenCleary / Program.cs
Last active December 30, 2015 21:59
Serialization size test for Azure caching. Requires NuGet packages: Comparers, Newtonsoft.Json
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using Comparers;
@devinceble
devinceble / .goproject
Last active March 14, 2018 17:19
Starting My Golang Project Adding To Path and Exporting $GOPATH
#!/usr/bin/env bash
function goproject {
export GOPATH=$(pwd)
add_to_path "$GOPATH/bin"
alias gocd="cd $GOPATH"
if [ -f goconf ]
then
lines=($(cat goconf))
cd ${lines[0]}