Skip to content

Instantly share code, notes, and snippets.

View felipeleusin's full-sized avatar

Felipe Leusin felipeleusin

View GitHub Profile
@thecodejunkie
thecodejunkie / gist:883061
Created March 23, 2011 13:00
Using a custom extension to the Nancy test harness to be able to add multipart/form-data encoded data into the request
[Fact]
public void Should_add_multipart_formdata_encoded_files_to_request_filestream()
{
// Given
var stream =
CreateFakeFileStream("This is the contents of a file");
var multipart = new BrowserContextMultipartFormData(x => {
x.AddFile("foo", "foo.txt", "text/plain", stream);
});
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@addyosmani
addyosmani / pubsub.md
Created October 28, 2011 06:49
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@mattwarren
mattwarren / gist:1376252
Created November 18, 2011 11:50
Funky Map reduce
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using Raven.Abstractions.Extensions;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
using Raven.Client.Linq;
@praeclarum
praeclarum / CodeShareReport.cs
Created January 13, 2012 20:42
Computes the code share stats for the iCircuit project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.IO;
namespace CodeShareReport
{
class App
@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@JakeWharton
JakeWharton / BaseActivity.java
Created July 6, 2012 01:17
Scoped event bus which automatically registers and unregisters with the lifecycle.
package com.squareup.example;
public abstract BaseActivity extends SherlockActivity {
private final ScopedBus scopedBus = new ScopedBus();
protected ScopedBus getBus() {
return scopedBus;
}
@Override public void onPause() {
param(
[string]$server = "origin",
[string]$branch = "master"
)
$gitStatus = (Get-GitStatus)
if ($gitStatus -eq $null) {
write-error "Not in a Git repository."
} elseif ($gitStatus.HasUntracked -or $gitStatus.HasWorking -or $gitStatus.HasIndex) {
@mckn
mckn / semver.ps1
Created November 23, 2012 15:13
Semver stuff in powershell
function Bump-Version
{
param([string]$part = $(throw "Part is a required parameter."))
$version = Get-AssemblyInfoVersion -Directory ..\Source -GlobalAssemblyInfo $true
$bumpedVersion = Clone-Object -Object $version
switch -wildcard ($part)
{
"ma*" { $bumpedVersion.Major = Bump-NumericVersion -Current $version.Major }