Skip to content

Instantly share code, notes, and snippets.

View kharmabum's full-sized avatar
💭
🧀

Juan-Carlos Foust kharmabum

💭
🧀
View GitHub Profile
@kharmabum
kharmabum / sim-db-replace.sh
Created March 13, 2014 02:44
replace db in sim
ps auxw | grep Coff
cp ~/Downloads/sqlite.db ~/Library/Application\ Support/iPhone\ Simulator/7.1/Applications/9CD889F1-2335-481F-8C34-6E4B7E33F571/Documents/sqlite.db
#########################
# .gitignore file for Xcode5
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
# and https://gist.github.com/adamgit/3786883
- (CLLocationCoordinate2D)locationFromString:(NSString *)locationString{
CLLocationCoordinate2D coordinate;
// Extract individual components
NSMutableArray *locationColumns = [NSMutableArray arrayWithArray:
[locationString componentsSeparatedByCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]]];
// Remove empty objects

Keybase proof

I hereby claim:

  • I am kharmabum on github.
  • I am jc (https://keybase.io/jc) on keybase.
  • I have a public key whose fingerprint is A5AE AC2B 50E4 5BFF B4A3 38AF 225C CFDF 8D8A F6BF

To claim this, I am signing this object:

@kharmabum
kharmabum / bluetooth-audio.m
Last active December 11, 2021 04:11
Bluetooth audio session set up
// App delegate
#import <AVFoundation/AVFoundation.h>// place in .h
// applicationDidFinishLaunchingWithOptions
// [self prepareAudioSession];
- (BOOL)prepareAudioSession {
// deactivate session
@kharmabum
kharmabum / tappable-nav-bar.m
Last active July 20, 2016 15:17
Tappable title view UINavigationBar
#pragma mark - UIGestureRecognizerDelegate
// Toggle mode through touch gesture on navigation bar
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return (self.navigationController.visibleViewController == self &&
(ABS([touch locationInView:self.navigationController.navigationBar].x - self.navigationController.navigationBar.width/2) < 50));
}
- (void)viewWillAppear:(BOOL)animated {
@kharmabum
kharmabum / audio-id.m
Last active August 29, 2015 14:00
Create audio sound id
#import <AudioToolbox/AudioToolbox.h>
+(SystemSoundID)bleatSoundID {
static SystemSoundID bleatSoundID = 0;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Bleat" ofType:@"aif"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &bleatSoundID);
});
return bleatSoundID;
@kharmabum
kharmabum / cocoalumberjack-log-level-override.m
Created September 11, 2014 10:02
override cocoalumberjack per file
+ (void)initialize
{
if (self == [JBAPeripheral self]) {
// ddLogLevel = LOG_LEVEL_OFF;
}
}
@kharmabum
kharmabum / sf.md
Last active June 26, 2019 17:33
Welcome to SF

Abbreviations

  • Downtown = ~north of Market St
  • Richmond = ~north of Golden Gate Park
  • Mission = south of Market St to the West
  • SOMA - south of Market St to the East.

Food

@kharmabum
kharmabum / amibeingdebugged.m
Created January 5, 2015 05:34
AmIBeingDebugged
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
static Bool AmIBeingDebugged(void) {
int mib[4];
struct kinfo_proc info;
size_t size = sizeof(info);