This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contains(X, [X | _]). | |
| contains(X, [_ | T]) :- contains(X, T). | |
| equals([], []). | |
| equals([_|T1], [_|T2]) :- equals(T1, T2). | |
| len([], 0). | |
| len([_|T], L) :- len(T, L1), succ(L1, L). | |
| empty([]). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| connect() { | |
| ssh proxyserver -fN | |
| } | |
| disconnect() { | |
| kill -n 9 $(pgrep -f "ssh proxyserver -fN") 2>/dev/null | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| $< and die "This won't work unless run by root"; | |
| my @errors; | |
| sub log_error { | |
| push(@errors, pop); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| defaults write com.apple.dashboard mcx-disabled -boolean YES | |
| killall Dock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int Dict::update(string s) { | |
| if (accept(s)) return; | |
| int index = 0; | |
| NodePtr n1, n2; | |
| for (index = 0; index <= s.size(); index++) { | |
| if ((index->match(s[index])) == NULL) n2 = n1->update(s[index]); | |
| n1 = n2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bst2array(tree : BST[G]; a : ARRAY[G]) is | |
| require | |
| tree /= Void | |
| do | |
| -- Traverse the tree in-order | |
| if tree.left /= Void then | |
| -- Recursively add all the elements of the left subtree | |
| bst2array(tree.left, a) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_node(item : G; root : BIN_NODE[G]) is | |
| local | |
| previous_node, current_node, new_node : BIN_NODE[G] | |
| do | |
| if root = Void then | |
| -- The trivial case, creating the root of the tree | |
| -- with no subtrees | |
| create root | |
| root.build(item, Void, Void) | |
| count := 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| q = lambda l : l if len(l) <= 1 else (q([x for x in l[1:] if x < l[0]]) + [l[0]] + q([x for x in l[1:] if x >= l[0]])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| digraph CYK_parse { | |
| rankdir=LR; | |
| node [shape = point,height=0.3]; 0,1,2,3,4,5,6; | |
| // k = 1 | |
| // -------------------- | |
| 0 -> 1 [label = "DET",color=black]; | |
| 0 -> 1 [label = "the",color=red]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| def mel(f) | |
| include Math | |
| (1000.quo(Math.log(2))) * Math.log(1 + (f.quo(1000))) | |
| end | |
| 1.upto(1000) do |f| | |
| puts "#{f} Hz --> #{mel(f).round(1)} mel" | |
| end |