Skip to content

Instantly share code, notes, and snippets.

View lsancho's full-sized avatar

Leonardo Sancho lsancho

View GitHub Profile
@Paradroid888
Paradroid888 / sluggenerator.cs
Created February 12, 2013 22:49 — forked from onebeatconsumer/sluggenerator.cs
Added missing RemoveAccent function
/// <summary>
/// Generates a permalink slug for passed string
/// </summary>
/// <param name="phrase"></param>
/// <returns>clean slug string (ex. "some-cool-topic")</returns>
public static string GenerateSlug(this string phrase)
{
var s = phrase.RemoveAccent().ToLower();
s = Regex.Replace(s, @"[^a-z0-9\s-]", ""); // remove invalid characters
s = Regex.Replace(s, @"\s+", " ").Trim(); // single space
@alexsandro-xpt
alexsandro-xpt / gist:4357148
Created December 22, 2012 02:32
Internet check experiment
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
if (!InternetConnection.HasProxy() && InternetConnection.HasInternet())
{
Console.WriteLine("Interent liberada");
}
@n1k0
n1k0 / casper_speed.js
Created June 10, 2012 17:11
Silly benchmarks
var casper = require("casper").create();
var start = new Date().getTime();
var links = [
"http://google.com/",
"http://yahoo.com/",
"http://bing.com/"
];
casper.start();
@brianlow
brianlow / FindConflictingReferences.cs
Created January 3, 2012 03:04
Find conflicting assembly references
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace MyProject
{
[TestFixture]
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@Yaffle
Yaffle / URLUtils.js
Last active September 5, 2022 02:19
parse URL + absolutize URL in javascript (URLUtils shim - http://url.spec.whatwg.org/#url)
/*jslint regexp: true, maxerr: 50, indent: 2 */
(function (global) {
"use strict";
function URLUtils(url, baseURL) {
var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
if (!m) {
throw new RangeError();
}
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//