Skip to content

Instantly share code, notes, and snippets.

@jmora
jmora / HeuristicBacktrack.hs
Created July 31, 2011 13:59
Heuristic Backtracking - Backtracking that prioritizes branches depending on some heuristic
module HeuristicBacktrac (backtracking) where
import List
hbacktracking::
(partialSolution -> partialSolution -> Ordering) -- heuristic, A* like
-> (partialSolution -> Bool) -- isFinalSolution?
-> (partialSolution -> solution) -- convert
-> (partialSolution -> [partialSolution]) -- next
-> (partialSolution -> Bool) -- isValid?
-> [partialSolution] -- Estado inicial
#!/usr/bin/env python
#disclaimer: this code as a SAT solver is pure crap. Don't waste your time.
#prettify http://stackoverflow.com/questions/1151658/python-hashable-dicts
class hashdict(dict):
def __hash__(self):
return hash(tuple(sorted(self.items())))
@jmora
jmora / x.js
Created August 22, 2009 22:13
This is a Ubiquity (firefox extension) command to post to identi.ca, it's based (it's pretty much the same) in the twitter command available in Ubiquity by default.
const IDENTICA_STATUS_MAXLEN = 140;
var noun_type_identica_user = {
label: "user",
rankLast: true,
noExternalCalls: true,
suggest: function nt_idcauser_suggest(text, html, cb, selected) {
// reject text from selection.
if (!text || selected)
return [];