Skip to content

Instantly share code, notes, and snippets.

View coquin's full-sized avatar

Denis Kokin coquin

  • HelloFresh
  • Berlin, Germany
View GitHub Profile
@coquin
coquin / geoposition.js
Created August 18, 2017 06:52
Getting current location of the user
// Note: promise will be rejected if user won't allow browser
// to detect location
function getLocation () {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(resolve, reject)
} else {
reject()
}
})
@coquin
coquin / fib_tail_rec.scala
Created August 7, 2017 17:37
Fibonacci numbers with tail recursion in Scala
def fib(n: Int) = {
def fib_tail(n: Int, a: Int, b: Int): Int = n match {
case 0 => a
case _ => fib_tail(n - 1, a + b, a)
}
fib_tail(n, 0, 1)
}
@coquin
coquin / command-line-cheatsheet.md
Last active February 13, 2017 16:13
Command line tools cheat sheet

sed

sed -i '' '/null/d' filename.txt — removes all strings containing null from a file filename.txt

wc

wc -l filename.txt — prints the number of lines in the file

searching for text in files (in current directory)

@coquin
coquin / emacs-cheat-sheet.md
Last active May 26, 2017 08:07
Emacs cheat-sheet

Killing, yanking text

C-w — Kill active region.

M-w — Copy to kill ring.

C-M-w — Append kill.

C-y — Yank last kill.

@coquin
coquin / LICENSE.txt
Last active October 10, 2016 06:45 — forked from podefr/LICENSE.txt
Finite State Machine
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Olivier Scherrer
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@coquin
coquin / bson-objectid-regex.js
Created October 31, 2012 12:16
A regular expression to match BSON ObjectID
var objectIdRegEx = /^([^\/]+)\/(.*?)\/([^\/]+)\/([0-9a-f]{24})$/;