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 load-resource | |
[name] | |
(let [rsc-name (str "somefolder/" name) | |
thr (Thread/currentThread) | |
ldr (.getContextClassLoader thr)] | |
(.getResourceAsStream ldr rsc-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
new_list = [number for row in numbers | |
for number in row] |
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
#!/usr/bin/env python | |
import json | |
import fileinput | |
def compact(raw): | |
parsed = json.loads(raw) | |
compacted = json.dumps(parsed, separators=(',',':')) | |
return compacted |
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
val regex = """mongodb://(\w+):([\w|-]+)@([\w|\.]+):(\d+)/(\w+)""".r | |
url match { | |
case Some(regex(u, p, host, port, dbName)) => | |
ConnectionParams(host, port.toInt, dbName, u, p) | |
case None => { | |
ConnectionParams("127.0.0.1", 27017, "mylocaldb") | |
} |
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
function textFieldValue(parentElement, inputFieldSelector) { | |
return parentElement.asEventStream("keyup input").filter(isNotEnter). | |
merge(parentElement.asEventStream("cut paste").delay(1)). | |
merge(autofillPoller()). | |
map(getValue).toProperty(getValue()).skipDuplicates(); | |
function getValue() { | |
var inputField = parentElement.find(inputFieldSelector) | |
return _.isEmpty(inputField) ? "" : inputField.val(); | |
} |
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
For the lack of a nail, | |
throw new HorseshoeNailNotFoundException("no nails!"); | |
For the lack of a horseshoe, | |
EquestrianDoctor.getLocalInstance().getHorseDispatcher().shoot(); | |
For the lack of a horse, | |
RidersGuild.getRiderNotificationSubscriberList().getBroadcaster().run( | |
new BroadcastMessage(StableFactory.getNullHorseInstance())); |
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
#!/bin/bash | |
set -e | |
command="$1" | |
eka() { | |
local use_x_flag=false | |
while getopts ":x:" o; do | |
case "${o}" in |
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
class WeeksAdapter(activity: Activity, dimensions: ScreenParameters) extends BaseAdapter { | |
val nowIndex = Integer.MAX_VALUE/2 | |
val nowDateTime = new DateTime().withTimeAtStartOfDay | |
val nowWeek = nowDateTime.getWeekyear | |
def positionOfNow: Int = nowIndex | |
override def getCount: Int = Integer.MAX_VALUE |
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
fi/allacca/WeeksAdapter; | |
I/System.out(20532): getView call with pos 0 count 1 | |
I/System.out(20532): getView call with pos 1 count 2 | |
I/System.out(20532): getView call with pos 2 count 3 | |
I/System.out(20532): getView call with pos 3 count 4 | |
I/System.out(20532): getView call with pos 4 count 5 | |
I/System.out(20532): getView call with pos 5 count 6 | |
I/System.out(20532): getView call with pos 6 count 7 | |
I/System.out(20532): getView call with pos 7 count 8 | |
I/System.out(20532): getView call with pos 8 count 9 |
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
D/ALLACCA (26924): elapsed time readEvents: 3716771 ns (3.716771 ms) | |
D/ALLACCA (26924): elapsed time groupBy: 7391823 ns (7.391823 ms) | |
D/ALLACCA (26924): elapsed time getDays: 4553697 ns (4.553697 ms) | |
D/ALLACCA (26924): elapsed time create daysWithEventsMap: 4560521 ns (4.560521 ms) | |
D/ALLACCA (26924): elapsed time filter which contents are new: 461042 ns (0.461042 ms) | |
D/ALLACCA (26924): elapsed time concatenating: 211146 ns (0.211146 ms) | |
D/ALLACCA (26924): elapsed time Id array creation: 2030520 ns (2.03052 ms) | |
D/ALLACCA (26924): elapsed time Fast(?) sort: 190313 ns (0.190313 ms) | |
D/ALLACCA (26924): elapsed time Construct new contents: 2500313 ns (2.500313 ms) | |
D/ALLACCA (26924): elapsed time Update model: 7531979 ns (7.531979 ms) |
OlderNewer