-
This is a numbered list.
-
I'm going to include a fenced code block as part of this bullet:
Code More Code
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix | |
;; and optionally can refer functions to the current ns. | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; | |
;; * :refer-clojure affects availability of built-in (clojure.core) | |
;; functions. |
/* | |
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace | |
so it's better encapsulated. Now you can have multiple random number generators | |
and they won't stomp all over eachother's state. | |
If you want to use this as a substitute for Math.random(), use the random() | |
method like so: | |
var m = new MersenneTwister(); |
Topic | |
- NoSQLite | |
- Consider 3 useful things: | |
- SQLite - SQLite is itself a great datastore because it is a | |
fast and powerful SQL database in one file and is widely | |
deployed and supported. | |
- JSON - JSON is a simple and cruft free way to describe and | |
transport objects. That is why programmers love it. There is | |
good support for it in virtually every language. | |
- HTTP - HTTP allows things to connect and talk to each other. |
(defn partition-between | |
"Splits coll into a lazy sequence of lists, with partition | |
boundaries between items where (f item1 item2) is true. | |
(partition-between = '(1 2 2 3 4 4 4 5)) => | |
((1 2) (2 3 4) (4) (4 5))" | |
[f coll] | |
(lazy-seq | |
(when-let [s (seq coll)] | |
(let [fst (first s)] | |
(if-let [rest-seq (next s)] |
/* The API controller | |
Exports 3 methods: | |
* post - Creates a new thread | |
* list - Returns a list of threads | |
* show - Displays a thread and its posts | |
*/ | |
var Thread = require('../models/thread.js'); | |
var Post = require('../models/post.js'); |
(defn remove-duplicates | |
"Returns a lazy sequence of the elements of coll with duplicates removed using a predicate" | |
[coll pred] | |
(let [step (fn step [xs seen] | |
(lazy-seq | |
((fn [[f :as xs] seen] | |
(when-let [s (seq xs)] | |
(if (some #(pred f %) seen) | |
(recur (rest s) seen) | |
(cons f (step (rest s) (conj seen f)))))) |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Olivier Scherrer | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
var http = require('http'); | |
var sys = require('sys'); | |
var exec = require('child_process').exec; | |
var util = require('util'); | |
var fs = require('fs'); | |
http.createServer(function(request, response) { | |
var dummyContent = '<!doctype html><html><head><title>Test</title><meta charset="utf-8"></head><body><p>Hello world!</p></body></html>'; | |
var htmlFileName = "page.html", pdfFileName = "page.pdf"; | |
These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).
First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter
(2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.
Finally all remaining files are listed using git ls
, the files to keep are removed from that using grep -v
and the resulting list is passed to git rm
which is invoked by git filter-branch --index-filter
(3.). A bit convoluted but it does the trick.