Skip to content

Instantly share code, notes, and snippets.

View krhoyt's full-sized avatar

Kevin Hoyt krhoyt

View GitHub Profile
@krhoyt
krhoyt / write-text-file.m
Created November 7, 2013 18:34
Write a text file to disk.
- ( void ) writeTextFile : ( NSString * ) fileName withContents : ( NSString * ) contents
{
NSArray * directories;
NSDate * now;
NSDateFormatter * formatter;
NSError * error;
NSFileManager * manager;
NSMutableString * append;
NSMutableString * path;
@krhoyt
krhoyt / read-text-file.m
Created November 7, 2013 18:35
Read a text file from disk.
- ( NSString * ) readTextFile : ( NSString * ) fileName
{
NSArray * directories;
NSData * buffer;
NSFileHandle * handle;
NSFileManager * manager;
NSMutableString * path;
NSString * contents;
manager = [NSFileManager defaultManager];
@krhoyt
krhoyt / locate-desktop.m
Created November 7, 2013 18:36
Locate a file on the desktop using system paths (as opposed to specific path).
- ( NSString * ) locateFileOnDesktop : ( NSString * ) fileName
{
NSArray * directories;
NSFileManager * manager;
NSMutableString * path;
manager = [NSFileManager defaultManager];
directories = NSSearchPathForDirectoriesInDomains( NSDesktopDirectory, NSUserDomainMask, YES );
path = [[NSMutableString alloc] initWithString : [directories objectAtIndex : 0]];
@krhoyt
krhoyt / specific-path.m
Created November 7, 2013 18:36
Locate a file given a specific path.
- ( NSString * ) specificFilePath : ( NSString * ) path
{
NSFileManager * manager;
manager = [NSFileManager defaultManager];
// path = @"~/Desktop/colors.json";
path = [path stringByStandardizingPath];
NSLog( @"%@", path );
@krhoyt
krhoyt / working-directory.m
Created November 7, 2013 18:37
Get the current working directory.
- ( void ) currentWorkingDirectory
{
NSFileManager * manager;
manager = [NSFileManager defaultManager];
NSLog( @"%@", [manager currentDirectoryPath] );
}
@krhoyt
krhoyt / arduino-stomp.ino
Last active March 22, 2024 01:56
STOMP Implementation for Arduino Yun
// Libraries
#include <Bridge.h>
#include <YunClient.h>
// Defines
// Used for connectivity parameters
#define ENDPOINT "kaazing.kevinhoyt.com"
#define LOGIN " "
#define PASSCODE " "
#define PORT 61613
@krhoyt
krhoyt / aws-cli-policy
Created June 5, 2014 17:36
Series of command line steps used to create Kaazing Gateway instances on Amazon Web Services (AWS).
[default]
output = json
region = us-east-1
aws_access_key_id = __YOUR_KEY_ID__
aws_secret_access_key = __YOUR_SECRET_KEY__
@krhoyt
krhoyt / kaazing.me.py
Last active August 29, 2015 14:02
Create a Kaazing Gateway instance on Amazon Web Services EC2
# AWS Python library
import boto
# Hidden password input
import getpass
# Unique file name
import tempfile
# OS-level chmod access
@krhoyt
krhoyt / yun-stomp.ino
Created October 20, 2014 20:18
Custom rolled STOMP client for Arduino Yun. Should work with Ethernet client as well. Shows both publishing and subscribing.
// Libraries
#include <Bridge.h>
#include <Console.h>
#include <YunClient.h>
// Connectivity parameters
#define ENDPOINT "kaazing.kevinhoyt.com"
#define LOGIN " "
#define PASSCODE " "
#define PORT 61613
@krhoyt
krhoyt / parse.ino
Last active March 16, 2017 22:55
Arduino Yun to Parse.com (Process, curl).
// Original:
// http://hypernephelist.com/2014/08/19/https_on_arduino_yun.html
// Libraries
#include <Process.h>
// Literals
// #define DEBUG
// Constants