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 chk-ins [w1 w2] | |
(when (< (count w1) (count w2)) | |
(some #(= w1 %) | |
(for [i (range (count w2))] | |
(str (subs w2 0 i) (subs w2 (inc i)))) | |
) | |
)) | |
(defn chk-subs [w1 w2] | |
(when (= (count w1) (count w2)) |
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
//manifest.json | |
{ | |
"name": "bookmark-search-export", | |
"version": "1.0", | |
"manifest_version": 2, | |
"description": "This extention will dump all bookmarks", | |
"browser_action": { | |
"default_icon": "icon.png" | |
}, | |
"background": { |
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
--this scripts searches for DateTime.Min dates in the whole database | |
declare @SearchDate [date] = CONVERT(DATE, '0001-01-01',120); | |
IF OBJECT_ID('tempdb.dbo.#Results', 'U') IS NOT NULL | |
DROP TABLE dbo.#Results | |
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue [date] ) | |
SET NOCOUNT ON |
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
/* | |
Export bookmarks from Chrome as text. | |
Go to Bookmarks Manager->Organize->Export to HTML file. | |
Then open that file, open console and run this command: | |
*/ | |
[].map.call(document.querySelectorAll("dt a"), function(a) { | |
return a.textContent + " - " + a.href | |
}).join("\n"); |
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
module Hamming | |
let distance (strand1: string) (strand2: string): int option = | |
if strand1.Length = strand2.Length | |
then | |
Some(Seq.zip strand1 strand2 |> Seq.sumBy (fun (a, b) -> if a = b then 0; else 1)) | |
else None |
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
const features = [{ | |
'name': 'feature1', | |
'tags': [{ | |
'weight': 10, | |
'tagName': 't1' | |
}, { | |
'weight': 20, | |
'tagName': 't2' | |
}, { | |
'weight': 30, |
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
//here is document with NESTED Array | |
{ | |
"_id": "xyz-800", | |
"site": "xyz", | |
"user": 800, | |
"timepoints": [ | |
{"timepoint": 0, "a": 1500, "b": 700}, | |
{"timepoint": 2, "a": 1000, "b": 200}, | |
{"timepoint": 4, "a": 3500, "b": 1500} | |
] |
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
db.somethings.find({$where: function() { | |
var deepIterate = function (obj, value) { | |
for (var field in obj) { | |
if (obj[field] == value){ | |
return true; | |
} | |
var found = false; | |
if ( typeof obj[field] === 'object') { | |
found = deepIterate(obj[field], value) | |
if (found) { return true; } |
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
const map = (f, [x, ...xs]) => ( | |
(x === undefined && xs.length === 0) ? [] | |
: [f(x), ...map(f, xs)] | |
); |
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
// === Arrays | |
var [a, b] = [1, 2]; | |
console.log(a, b); | |
//=> 1 2 | |
// Use from functions, only select from pattern | |
var foo = () => [1, 2, 3]; |
OlderNewer