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
// import types: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types | |
// allow us to import types on global type definitions | |
// To use, eg, for a map of User: | |
// type UserMap = ImmutableMap<User>; | |
interface ImmutableMap<T> extends import('immutable').Map<string, any> { | |
get<K extends keyof T>(name: K): T[K]; | |
} | |
type ImmutableMapList<T> = import('immutable').List<ImmutableMap<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
;; example to split on @ | |
(clojure.string/split "carolyne.jones@gnail.com" #"(?=@)|(?<=@)") |
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
al: Albania | |
dz: Algeria | |
ao: Angola | |
ai: Anguilla | |
ag: Antigua and Barbuda | |
ar: Argentina | |
am: Armenia | |
au: Australia | |
at: Austria | |
az: Azerbaijan |
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
" From https://damien.pobel.fr/post/configure-neovim-vim-gf-javascript-import/ | |
set path=.,src | |
set suffixesadd=.js,.jsx | |
function! LoadMainNodeModule(fname) | |
let nodeModules = "./node_modules/" | |
let packageJsonPath = nodeModules . a:fname . "/package.json" | |
if filereadable(packageJsonPath) | |
return nodeModules . a:fname . "/" . json_decode(join(readfile(packageJsonPath))).main |
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
(ns question.pool | |
(:refer-clojure :exclude [take]) | |
(:require | |
[clojure.tools.logging :as log])) | |
(def pool (ref [])) | |
(defn take | |
[pool] | |
(dosync |
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 queue-size 30) | |
(defn make-object [] | |
(.. some object ..)) | |
(defn build-queue [_] | |
(let [block-queue (LinkedBlockingQueue. (int queue-size))] | |
(do | |
(repeat queue-size (.put block-queue (make-object))) | |
block-queue))) |
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 trutty-map [matcher] | |
(if (.find matcher) | |
(lazy-seq | |
(cons (.group matcher) | |
(trutty-map matcher))))) |
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
{ | |
"explain": true, | |
"query": { | |
"filtered": { | |
"query": { | |
"match": { | |
"content": "github" | |
} | |
}, | |
"filter": { |
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
import multiprocessing | |
# Parallel | |
# So, it goes like this: | |
# Given the number of 'to process' items, | |
# Check how the distribution for cores will be (eg: 100 items on 2 cores = 50) | |
# Then, split items in *number of cores* collections and spread them aroung a | |
# subprocess pool | |
# To split the set, we create the interval [0, number_of_items] and make it | |
# go up the original items collection *number of cores* times |
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
In [4]: ext.extract(u"""Hi Sebastian, Thanks for reaching out to us. My name is Kevin and I'll be happy to help you out! :) I understand that you're looking to use OAuth 2.0. Unfortunately, we don't support OAuth 2.0. We support HTTP Basic Auth. If you haven't already, you can find your API Key under your Account Details. Would you mind telling me a little more about why you'd like you use OAuth 2.0? Cheers, Kevin""") | |
Out[4]: [u'HTTP Basic Auth', u'Sebastian', u'Kevin', u'Kevin'] |
NewerOlder