Skip to content

Instantly share code, notes, and snippets.

View olegam's full-sized avatar

Ole Gammelgaard Poulsen olegam

  • Shape
  • Copenhagen
View GitHub Profile
@olegam
olegam / find_closest_scooter.js
Created February 9, 2019 15:28
Scriptable app script to find closest scooter in Copenhagen
let googleApiKey = '' // Insert your own key for Google Maps + Directions JS SDK here
let copenhagenBounds = {minLat: 55.5, minLong: 12.5, maxLat: 55.8, maxLong: 12.7}
let copenhagenCenter = {lat: copenhagenBounds.maxLat - copenhagenBounds.minLat, lng: copenhagenBounds.maxLong - copenhagenBounds.minLong}
let getLocation = Location.current()
// const getLocation = new Promise(resolve => resolve({latitude: 55.7, longitude: 12.5})) // hardcoded location resolver for airplane debug use
const [allTIERScooters, allVOIScooters, myLocation] = await Promise.all([getTIERScooters(copenhagenBounds), getVOIScooters(copenhagenBounds), getLocation])
console.log('My location: ' + JSON.stringify(myLocation))
if (allTIERScooters.length + allVOIScooters.length <= 0) {
var preventMultipleInstances = function(window) {
var socket = (process.platform === 'win32') ? '\\\\.\\pipe\\myapp-sock' : path.join(os.tmpdir(), 'myapp.sock');
net.connect({path: socket}, function () {
var errorMessage = 'Another instance of ' + pjson.productName + ' is already running. Only one instance of the app can be open at a time.'
dialog.showMessageBox(window, {'type': 'error', message: errorMessage, buttons: ['OK']}, function() {
window.destroy()
})
}).on('error', function (err) {
if (process.platform !== 'win32') {
// try to unlink older socket if it exists, if it doesn't,
@olegam
olegam / gist:2d89bf00c43581a944cc
Created January 17, 2015 20:55
Hay JW01 Chair foot
$fa = 1; // minimum angle
$fs = 0.5; // minimum fragment size
height = 11;
length = 46;
width = 15;
screw_diameter = 4;
screw_head_diameter = 8;
screw_head_height = 4;
{
"status" : "ok"
}
{
"value" : 1
}
Pod::Spec.new do |s|
s.name = "google-plus-ios-sdk"
s.version = "1.7.0"
s.summary = "Google+ Platform for iOS."
s.description = "Create a more engaging experience and connect with more users by integrating social into your app. Extend your app in new and creative ways using these Google+ platform features."
s.homepage = "https://developers.google.com/+/mobile/ios/"
s.license = {
:type => 'Copyright',
:text => 'Copyright 2013 Google Inc.'
}
@olegam
olegam / gist:9545390
Last active August 29, 2015 13:57
NSLog tweak to create a clickable link to the file and line that created the log output. Short and concise format to fit on a single line in most cases.

Sometimes it can be hard to figure out where log statements in the console come from. With this tweak you get log output like this:

11:03:12.257 : User logged in with username: olegam (FIBAPIClient.m:507)

Because of AppCode awesomeness the FileName:LineNumber part will be clickable and take you right to the code that produced the log statement. To get this in your own project you should:

  1. Redefine NSLog in your prefix.pch file
#define NSLog(format,...) SHPLogFunction(format, [@""__FILE__ lastPathComponent], __LINE__, ##__VA_ARGS__);
@olegam
olegam / gist:8997427
Created February 14, 2014 08:08
AppCode code template to implement lazy-loaded property getters

This template let's you easily implement a property getter like this:

- (UIView *)myView {
	if (!_myView) {
		_myView = [UIView new];
	}
	return _myView;
}
@olegam
olegam / gist:8846283
Created February 6, 2014 15:23
AppCode Objective-C Class file template with class extension

Since I always declare private properties in the class implementation file it's nice to have new class implementation files already include a class extension.

This is my template file for doing this. You change the template in Preferences->File and Code Templates->Templates->Objective-C Class.

#parse("Objective-C File Header.m")
#import "${HEADER_FILENAME}"

@interface ${NAME} ()
@olegam
olegam / gist:5419001
Last active December 16, 2015 10:19
This is a podspec pointing to the HEAD of ReactiveCocoa. To use it add the following line to your Podfile: pod 'ReactiveCocoa', :podspec => 'https://gist.github.com/olegam/5419001/raw/93e2e2e7c3c35fc10e6ca660bfd18309b666af36/gistfile1.rb'
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "1.x-head"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "josh@github.com" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git" }
s.license = 'Simplified BSD License'
s.description = "ReactiveCocoa offers:\n" \
"1. The ability to compose operations on future data.\n" \