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
#see https://gist.github.com/1023982 (donotuse.py) | |
randomPasswordGenerator = ( | |
lambda repeat, choice, partial, digits, letters: | |
partial(lambda map_join, n: | |
map_join(choice, repeat(digits+letters, n)), | |
lambda f, lis: ''.join(map(f, lis))))( | |
__import__('itertools').repeat, | |
__import__('random').choice, | |
__import__('functools').partial, |
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
(defn drop-start-same | |
[ss] | |
(->> (loop [ss ss] | |
(if (apply = (map first ss)) | |
(recur (map rest ss)) | |
ss)) | |
(map (partial apply str)))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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
(defn- diff-seq | |
"Returns a lazy seq of numbers in s1 but not in s2. | |
Both of s1 and s2 must be increasing monotonically and infinite sequence." | |
[s1 s2] | |
(let [x1 (first s1), x2 (first s2)] | |
(cond | |
(= x1 x2) (recur (rest s1) (rest s2)) | |
(> x1 x2) (recur s1 (drop-while (partial > x1) s2)) | |
(< x1 x2) (let [[s1a s1b] (split-with (partial > x2) s1)] | |
(lazy-cat s1a (diff-seq s1b s2)))))) |
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
(defn- diff-seq | |
"Returns a lazy seq of numbers in s1 but not in s2. | |
Both of s1 and s2 must be increasing monotonically and infinite sequence." | |
[s1 s2] | |
(let [x1 (first s1), x2 (first s2)] | |
(cond | |
(= x1 x2) (recur (rest s1) (rest s2)) | |
(> x1 x2) (recur s1 (drop-while (partial > x1) s2)) | |
(< x1 x2) (let [[s1a s1b] (split-with (partial > x2) s1)] | |
(lazy-cat s1a (diff-seq s1b s2)))))) |
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
select | |
sys.tables.name as table_name, | |
sys.extended_properties.value as discription, | |
sys.columns.name as column_name, | |
sys.columns.* | |
from sys.columns | |
left outer join sys.tables on (sys.columns.object_id=sys.tables.object_id) | |
left outer join sys.extended_properties on (major_id=sys.columns.object_id and minor_id=sys.columns.column_id) | |
where sys.tables.name is not null | |
order by table_name, sys.columns.column_id |
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
// gmpxx : mpz_class で三項演算子が使えない(解決した) | |
#include <iostream> | |
#include <gmpxx.h> | |
// これなら OK | |
// mpz_class next_collatz(const mpz_class &n){ | |
// if(n % 2 == 0){ | |
// return n >> 1; | |
// }else{ | |
// return n * 3 + 1; |
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
(def alpha "ABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
(def alen (count alpha)) | |
(defn freq-alpha [n] | |
(mapcat (partial repeat n) alpha)) | |
(defn fun [[xss m]] | |
[(map cons (freq-alpha m) (cycle xss)), (* m alen)]) |
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
(defn N->A [n] | |
(let [za "0ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
alen (dec (count za)) | |
iter (fn [[n xs]] [(int (/ n alen)) | |
(cons (nth za (rem n alen)), xs)])] | |
(->> (iterate iter [n '()]) | |
(drop-while (comp not zero? first)) | |
first second | |
(apply str)))) |
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
;;; fs-mono.el --- A Helper of fsharp-mode (v0.3) for Mono | |
(require 'cl) | |
(add-to-list 'load-path "~/.emacs.d/site-lisp/fsharp-mode") | |
(add-to-list 'auto-mode-alist '("\\.fs[iylx]?$" . fsharp-mode)) | |
(require 'fsharp) | |
(autoload 'run-fsharp "inf-fsharp" "Run an inferior F# process." t) |
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
#light | |
type System.String with | |
member s.split (sep : char) = s.Split([|sep|]) |> Array.toList | |
let parseNumbersPyramid (s : string) = | |
[for x in (s.split '\n') -> x.Trim().split ' ' |> List.map int] | |
let greaters xs = | |
Seq.map2 max xs (List.tail xs) |
OlderNewer