Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fsvehla's full-sized avatar

Ferdinand Svehla fsvehla

View GitHub Profile
// intersection of macOS, Linux and Windows ephemeral ports
val EphemeralPortRange: Range.Inclusive =
49152 to 60999
val freePort: IO[IOException, Int] = {
def ensureAvailable(int: Int): IO[IOException, Unit] =
ZIO.attemptBlockingIO {
ServerSocketFactory
.getDefault
.createServerSocket(int, 1 /* backlog */ , InetAddress.getByName("localhost"))
"optional": [
{ "name": "limit", "type": "Number", "description": "Number of results in response (in a page)." },
{ "name": "offset", "type": "Number", "description": "Number of results to skip (to get a particular page)." },
{ "name": "entity_type", "type": "String", "enumeration": [
"company",
"branch"
]},
{ "name": "parent_orb_num", "type": "String" },
{ "name": "ultimate_parent_orb_num", "type": "String" },
{ "name": "industry", "type": "String", "description": "Company’s industry." },

Keybase proof

I hereby claim:

  • I am fsvehla on github.
  • I am fsvehla (https://keybase.io/fsvehla) on keybase.
  • I have a public key ASCtvIXILZSrTz5gAnrBZp4hwT10Kp7KIfQ5URJgbybHaQo

To claim this, I am signing this object:

package json
import java.time.format.{DateTimeFormatter, DateTimeParseException}
import java.time.{Instant, LocalDateTime, ZoneId, ZonedDateTime}
import cats.data.Xor
import io.circe.{Decoder, DecodingFailure, HCursor}
object JsonInstances {
/** f.ex. 'Europe/Vienna' */
def transformKeys[A,B,C](m: Map[A, B], transformFunc: (A => C)): Map[C, B] = {
m.foldLeft(Map.empty[C, B]) { (acc, entry) =>
acc + (transformFunc(entry._1) -> entry._2)
}
}
val numMap: Map[Int, String] = Map(1 -> "Two", 2 -> "Four", 3 -> "Six")
val transformed = transformKeys(numMap, { (key:Int) => key * 2 })
// without (key:Int) = error: missing parameter type
#!/bin/bash
set -e
difftool=diff
[[ -f /usr/local/bin/ksdiff ]] && difftool=ksdiff
lname=$(echo $1 | tr '/' '-')
rname=$(echo $2 | tr '/' '-')
@fsvehla
fsvehla / gist:4149387
Created November 26, 2012 17:07
SMC Reset
Shut down the computer.
- Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
- On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
- Release all the keys and the power button at the same time.
- Press the power button to turn on the computer.
Note: The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.
var http = require('http');
var server = http.createServer(function (req, res) {
res.end('hullo');
});
server.listen(1250, function () {
console.log('Listening on 1250');
});
daemon off;
pid /tmp/nginx-80-to-8888.pid;
events {
worker_connections 102480;
multi_accept on;
}
http {
server {