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 addHex(left /*: string*/, right /*: string*/) /*: string*/ { | |
if (left.length < right.length) { | |
[left, right] = [right, left]; | |
} | |
// left is "longer" | |
// left = a b c | |
// right = d | |
// --> add c + d, | |
// --> carry 1 to b + <nothing> |
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 {} from 'jasmine'; | |
import {trimSuffix, trimPrefix} from './string'; | |
describe('string utils', () => { | |
describe('trimSuffix', () => { | |
for (const [from, trim, to] of [ | |
[null, 'abc', null], | |
['abc', 'c', 'ab'], | |
['abc', '', 'abc'], | |
['abc', null, 'abc'], | |
['abc', 'bc', 'a'], |
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
package main | |
import ( | |
"fmt" | |
"time" | |
logsentry "github.com/evalphobia/logrus_sentry" | |
"github.com/sirupsen/logrus" | |
) |
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
<div class="levels"> | |
{{ $groups := .LevelGroups }} | |
{{ $groupedLevels := .Levels }} | |
{{ $completeLevels := .CompleteLevels }} | |
{{ if $groupedLevels }} | |
{{ range $group := $groups }} | |
<div class="intro"><h2>{{$group}}</h2></div> | |
{{ range index $groupedLevels $group }} | |
<a href="/level/{{.Number}}" class="{{if index $completeLevels .Number}}complete{{end}}"> | |
<span class="level">{{.Number}} </span> |
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
/** | |
usage: copy/paste code into your console to view all numeric responses, summed, printed per question. | |
example output: | |
[1] 6180176821 => 2 | |
... | |
[23] 6167268127 => 2 | |
Total 62 for 23 items (2.6956521739130435 / item) | |
*/ | |
/** |
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
test 'should create account' do | |
user = User.find_by(provider: mock_user['provider'], uid: mock_user['uid']) | |
assert_nil user | |
# mock model remote updates | |
stub_request(:post, "#{fixtures(:some1).api_url}/destinations") | |
.to_return(status: 200, body: {}.to_json, headers: {}) | |
stub_request(:put, %r{#{fixtures(:some1).api_url}/destinations/\d+}) | |
.to_return(status: 204, body: {}.to_json, headers: {}) |
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 humanDuration(number, unit = "s") { | |
let result; | |
switch (unit) { | |
case "ns": | |
result = number / 1000000; | |
if (result < 1) break; | |
number = result; | |
unit = "ms"; | |
case "ms": | |
result = number / 1000; |