(defun tangle-init ()
"If the current buffer is 'init.org' the code-blocks are
tangled, and the tangled file is compiled."
(when (equal (buffer-file-name)
This file contains 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
VALUE | |
rb_ary_sort_bang(VALUE ary) | |
{ | |
rb_ary_modify(ary); | |
assert(!ARY_SHARED_P(ary)); | |
if (RARRAY_LEN(ary) > 1) { | |
VALUE tmp = ary_make_substitution(ary); /* only ary refers tmp */ | |
struct ary_sort_data data; | |
long len = RARRAY_LEN(ary); |
This file contains 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
a = [ "d", "a", "e", "c", "b" ] | |
a.sort! #=> ["a", "b", "c", "d", "e"] | |
a.sort! { |x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] |
This file contains 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
// Collect the complete content of three URLs and print it to the console. | |
// Print one line per URL. | |
// Print out them out in the same order as the URLs are provided to you as command-line arguments. | |
var http = require('http'); | |
var urls = []; | |
for (var i = 2; i < process.argv.length; i++) { | |
urls.push(process.argv[i]); | |
} |
This file contains 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
var http = require('http') | |
var bl = require('bl') | |
var results = [] | |
var count = 0 | |
function printResults () { | |
for (var i = 0; i < 3; i++) | |
console.log(results[i]) | |
} | |
This file contains 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
(defun tangle-init () | |
"If the current buffer is 'init.org' the code-blocks are | |
tangled, and the tangled file is compiled." | |
(when (equal (buffer-file-name) | |
(expand-file-name (concat user-emacs-directory "init.org"))) | |
;; Avoid running hooks when tangling. | |
(let ((prog-mode-hook nil)) | |
(org-babel-tangle) | |
(byte-compile-file (concat user-emacs-directory "init.el"))))) |
This file contains 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
/* | |
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod | |
May contain errors where latitude and longitude are off. Use at own non-validated risk. | |
*/ | |
SET NAMES utf8; | |
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; | |
DROP TABLE IF EXISTS postcodes_geo; |
This file contains 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
# Sample implementation of quicksort and mergesort in ruby | |
# Both algorithm sort in O(n * lg(n)) time | |
# Quicksort works inplace, where mergesort works in a new array | |
def quicksort(array, from=0, to=nil) | |
if to == nil | |
# Sort the whole array, by default | |
to = array.count - 1 | |
end |
OlderNewer