Skip to content

Instantly share code, notes, and snippets.

View bobmoff's full-sized avatar

Fille bobmoff

View GitHub Profile
@bobmoff
bobmoff / gist:3755061
Created September 20, 2012 10:13
Heres how to manually set the Street name (title) etc on the Callout when using the new Apple Maps for directions.
NSDictionary *addressDict = @{(NSString *)kABPersonAddressStreetKey : @"THIS IS THE NAME OF THE STREET YOU WOULD LIKE TO SHOW"};
MKPlacemark *mapPlaceMark = [[MKPlacemark alloc] initWithCoordinate:placeMarkCoordinate addressDictionary:addressDict];
MKMapItem *mkMapItem = [[MKMapItemClass alloc] initWithPlacemark:mapPlaceMark];
NSMutableDictionary *launchOptions = [[NSMutableDictionary alloc] init];
[launchOptions setObject:MKLaunchOptionsDirectionsModeDriving forKey:MKLaunchOptionsDirectionsModeKey];
[mkMapItem openInMapsWithLaunchOptions:launchOptions];
// U need to import the native Addressbook framework as well to access the kABPersonAddressStreetKey constant which is set during runtime, i guess.
@bobmoff
bobmoff / UIView+ModifyFrame.h
Last active November 27, 2021 06:58
Simple but really useful category on UIView that makes modifying the frame NOT hellish. Published under WTFPL [http://www.wtfpl.net/]. Usage example can be found in the comments
/*
Before:
CGRect frame = myView.frame;
frame.origin.x = newX;
myView.frame = frame;
After:
myView.x = newX;
@bobmoff
bobmoff / UIView+Stacker.h
Created July 10, 2013 15:17
Stack subviews vertically ordered by their index. Good when u want to use XIB's and need to layout views (show/hide) based on external data, but cannot use autolayout.
#import <UIKit/UIKit.h>
@interface UIView (Stacker)
- (void)stackSubviews;
@end
@bobmoff
bobmoff / UIView+RoundedCorners.h
Created July 10, 2013 15:23
Add rounded corners to any view using layer mask.
#import <UIKit/UIKit.h>
@interface UIView (RoundedCorners)
- (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size;
@end
//
// RSTimingFunction.h
//
// Created by Raphael Schaad on 2013-09-28.
// This is free and unencumbered software released into the public domain.
//
#import <Foundation/Foundation.h>
//
// SKNode+TouchPriority.h
// ButtonLab
//
// Created by Fille Åström on 10/20/13.
// Copyright (c) 2013 IMGNRY. All rights reserved.
//
#import <SpriteKit/SpriteKit.h>
#!/bin/sh
CURRENT=$(node -v)
VERSION=$(curl -L -s http://nodejs.org/dist/latest/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| tail -n1)
PLATFORM=linux
ARCH=x64
PREFIX="/usr/local"
@bobmoff
bobmoff / MongoDB Install Script
Last active October 22, 2021 21:28
Script to Install MongoDB on Ubuntu / Digital Ocean Droplet
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
apt-get -y update
apt-get install -y mongodb-org
@bobmoff
bobmoff / ufw-dynamic-host-update
Created April 26, 2014 19:24
I found a very useful script that creates rules dynamically for specific hosts in this blog. The script needs to be run with cron, so it can lookup a hostname and add/delete rules in case the IP changed. The content of /etc/ufw-dynamic-hosts.allow could look like this: tcp:22:yourpc.no-ip.org and a crontab entry for executing the script every fi…
#!/bin/bash
HOSTS_ALLOW=/etc/ufw-dynamic-hosts.allow
IPS_ALLOW=/var/tmp/ufw-dynamic-ips.allow
add_rule() {
local proto=$1
local port=$2
local ip=$3

Keybase proof

I hereby claim:

  • I am bobmoff on github.
  • I am bobmoff (https://keybase.io/bobmoff) on keybase.
  • I have a public key whose fingerprint is 7B1A 17FD 3E98 B2EF 0B65 4355 F53F FB62 8E92 C33C

To claim this, I am signing this object: