Skip to content

Instantly share code, notes, and snippets.

View eriadam's full-sized avatar

Adam Eri eriadam

View GitHub Profile
@eriadam
eriadam / git.sh
Created November 5, 2019 11:03
git log for all subfolders
#!/bin/bash
AUTHOR=$(git config user.name)
DATE=$1
echo "folder;date;comment"
for D in *; do
if [ -d "${D}" ]; then
# echo $D
cd $D
git log \
--no-merges \
/// Nearest neigbour to a defined point.
let nearest = tree.element(nearestTo: float2(0, 0))
/// You may filter for different types (classes) when performing
/// a nearest element search.
let nearestLocation = tree.element(
nearestTo: float2(0, 0),
type: CLLocation.self)
/// All of the elements in the quadtree node this point would be placed in.
// Let's add a simple CLLocation to the tree.
let location = CLLocation(
latitude: item.latitude,
longitude: item.longitude)
tree.add(location, at: float2(item.latitude, item.longitude))
// And then remove it.
tree.remove(location)
let tree = BMQuadtree(
boundingQuad: boundingQuad,
minimumCellSize: 3)
@eriadam
eriadam / logstash.conf
Last active March 16, 2020 21:19
Logstash serve configuration for the JustLog iOS logger.
input {
tcp {
port => 5000
# You need to have the json_lines plugin installed
codec => json_lines
# It is necessary to configure the SSL properly. Otherwise
# the logs wont make it to ES.
ssl_enable => true
@eriadam
eriadam / GKRuleSystem-example.swift
Created February 2, 2018 15:28
GKRuleSystem-example.swift
// Being online asserts the online navigation option.
// And retracts the offline option.
self.add(GKRule(blockPredicate: { ruleSystem -> Bool in
return Reachability.isOnline == true
}, action: { ruleSystem in
log.verbose("Rule 1: User is online")
ruleSystem.assertFact("navigableRoute")
ruleSystem.retractFact("offlineNavigableRoute")
}))
@eriadam
eriadam / GKRandomDistribution.swift
Created February 2, 2018 15:11
Basic examples of GKRandomDistribution
// Random number between 1 and 6
let d6 = GKRandomDistribution.d6()
d6.nextInt()
// 20-sided die? Done.
let d20 = GKRandomDistribution.d20()
d20.nextInt()
// Random number between 5 and 10
GKRandomDistribution(
@eriadam
eriadam / test.json
Last active October 9, 2017 14:36
bikemap-tile-style.json
{
"version": 8,
"name": "Klokantech Terrain",
"metadata": {
"mapbox:autocomposite": false,
"mapbox:type": "template",
"maputnik:renderer": "mbgljs",
"openmaptiles:version": "3.x",
"openmaptiles:mapbox:owner": "openmaptiles",
"openmaptiles:mapbox:source:url": "mapbox://openmaptiles.4qljc88t"
@eriadam
eriadam / do-stuff-async-example.swift
Created May 31, 2017 20:41
Do Stuff Async Example
do {
// Closure
try self.doStuff(string: "Some string") { result in
print(result)
}
// Promise
let promise = try self
.doStuff(string: "Some other string")
@discardableResult func doStuff(
string: String,
completion: (([String]) -> Void)? = nil) throws -> Promise<[String]> {}