Skip to content

Instantly share code, notes, and snippets.

@joninvski
joninvski / bellman.py
Created November 16, 2010 11:31
Bellman ford python implementation
import pdb
"""
The Bellman-Ford algorithm
Graph API:
iter(graph) gives all nodes
iter(graph[u]) gives neighbours of u
graph[u][v] gives weight of edge (u, v)
"""
@beccasaurus
beccasaurus / README.markdown
Created May 5, 2011 19:37
Adds hooks to jQuery.validate's form/element validation methods (via trigger())

jQuery Validate Hooks

If you're using [ASP.NET MVC3][], it uses [jQuery Validate][] to do client-side validations. Instead of using [jQuery Validate][] directly, however, it wraps it with its own jQuery plugin called [jQuery.Validate.Unobtrusive][]. [jQuery.Validate.Unobtrusive][] sets up [jQuery Validate][] for you, behind the scenes, so you don't have an opportunity to customize your [jQuery Validate][] settings at all!

We've been running into trouble with this when we've been doing our own custom client-side validations. We need a way to integrate with the build-in [ASP.NET MVC3][] validation so we can:

@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
}
@mboersma
mboersma / yaml2json
Last active July 31, 2023 12:34
YAML to JSON one-liner
python3 -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))'
@spudbean
spudbean / gist:1558257
Last active July 18, 2024 20:15
Look of disapproval and other emoticons
ಠ_ಠ
( ͡° ͜ʖ ͡°)
¯\_(ツ)_/¯
(╯°□°)╯︵ ┻━┻
http://www.fileformat.info/convert/text/upside-down.htm
WRTTN http://wrttn.me/30dbfd/
Unicode Emoticons
@fyears
fyears / soinput.py
Created November 28, 2012 14:46
python stdin example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
usage:
cat about.txt | python soinput.py
'''
import sys
@pseudomuto
pseudomuto / Feature.cs
Last active March 16, 2017 17:20
Blog Code: Continuous Integration for .NET with Travis and xUnit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CI.Demo
{
public class Feature
{
public string Name { get; private set; }
@mwhite
mwhite / git-aliases.md
Last active July 18, 2024 03:14
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@KoGor
KoGor / README.md
Last active June 9, 2017 05:10
Globe to Map

Globe rotating all the time, when mouse click event fires - transition begins. For transition backwards use double click on any country. In this example transition is simple path to path (shortest way).

For other variations of transition from Orthographic to Equirectangular and back check these examples:

This projected is licensed under the terms of the MIT license.

@mlconnor
mlconnor / excel_spreadsheet.html
Created June 26, 2014 18:39
Spreadsheet Excel in 31 lines of code
<!DOCTYPE html>
<html>
<head>
<!-- fiddle is here http://jsfiddle.net/ondras/hYfN3 -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Tiny Excel-like app in vanilla JS - jsFiddle demo by ondras</title>
<script type='text/javascript' src='/js/lib/dummy.js'></script>