Skip to content

Instantly share code, notes, and snippets.

View EchoAbstract's full-sized avatar

Brian Wilson EchoAbstract

  • TrustCloud
  • Boston, MA
View GitHub Profile
@EchoAbstract
EchoAbstract / strwidth.c
Last active December 13, 2015 17:09
Simple utility to compute the *Display Width* of a UTF-8 string.
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <stdlib.h>
#include <locale.h>
#include <assert.h>
// Tested with:
// Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
// Target: x86_64-apple-darwin12.2.0
@EchoAbstract
EchoAbstract / pictures.markdown
Created September 10, 2012 18:18 — forked from sent-hil/pictures.markdown
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature
@EchoAbstract
EchoAbstract / Coffeescript ctags
Created September 10, 2012 17:32 — forked from Talleyran/Coffeescript ctags
ctags definitions for Coffeescript. Very basic for now. "> ctags -e -R source_folder" and then M-. to jump to the definition of any function or variable (if you're using emacs)
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/^[ \t]*class ([a-zA-Z_$][0-9a-zA-Z_$]*).*$/\1/c,class/
--regex-coffee=/^[ \t]*([a-zA-Z_$@][0-9a-zA-Z_$\.]*)[ \t]*[:=].*[=-]>.*$/\1/f,function/
--regex-coffee=/^[ \t]*([a-zA-Z_$@][0-9a-zA-Z_$\.]*)[ \t]*=[^->\n]*$/\1/v,variable/
@EchoAbstract
EchoAbstract / init.el
Created August 20, 2012 21:56
Some notes from init.el
; Syntax checking
(add-to-list 'load-path "~/Emacs/lintnode")
(require 'flymake-jslint)
;; Make sure we can find the lintnode executable
(setq lintnode-location "~/Emacs/lintnode")
;; JSLint can be... opinionated
(setq lintnode-jslint-excludes (list 'nomen 'plusplus 'onevar 'white))
;; Start the server when we first open a js file and start checking
(add-hook 'js-mode-hook
(lambda ()
@EchoAbstract
EchoAbstract / googleSpreadsheetToKinvey.js
Created July 30, 2012 14:19
Convert Google Spreadsheet into Kinvey Collections
function getKinveyParameters(){
return {
kinvey_app_id: " YOUR APP ID ",
kinvey_master_secret: " YOUR MASTER SECRET "
};
};
// Use this function for time based script updating, since
// the id is hard-coded
function readRowsHelper(){
@EchoAbstract
EchoAbstract / managedObject.m
Created June 26, 2012 19:57
Managed Object
@implementation managedObject
@synthesize managedObjectContext;
+ (NSDictionary *)kinveyObjectBuilderOptions
{
static NSDictionary *options = nil;
if (options == nil){
options = [NSDictionary dictionaryWithObjectsAndKeys:
@EchoAbstract
EchoAbstract / dbManager.coffee
Created June 25, 2012 22:49 — forked from ivanstoyanov/dbManager.coffee
Node/Mongo Replica set connect string
mongo = require 'mongodb'
# full connect string
mongodbURI = "mongodb://
#{process.env.MONGO_USER}:#{process.env.MONGO_PASSWORD}@
mongoA.company.com,mongoB.company.com,mongoC.company.com/
admin?replicaSet=company&autoReconnect=true&connectTimeoutMS=500"
# obtaining a connection is now simple
mongo.connect mongodbURI, (err, db) =>
// This is in our CLLocationManagerDelegate
// Also, this code builds on https://github.com/Kinvey/KinveyGeoTag
// from the blog: http://www.kinvey.com/blog/item/155-ios-corner-taking-your-mobile-local-using-kinvey-for-location-based-apps
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
// This class assumes that you ask the user if they want to share their location
// To create a coupon or storecard feature in your app
// you can do the following
@interface Card : NSObject <KCSPersistable>
@property (nonatomic, retain) NSString *cardId;
@property (nonatomic, retain) NSString *code;
@property (nonatomic, retain) NSString *cardName;
@property (nonatomic, retain) NSString *firstName;
@property (nonatomic, retain) NSString *lastName;
// In your view controller
// Make sure you have a class that stores image metadata
// For example, you could have your MyMetadata class with
// the following iVars:
// name -- The name of the image
// size -- The expected size of the image
// date -- The time the picture was taken
// location -- The place the image was taken
// peopleInPhoto -- An array of the 'id' attribute from KCSUsers
// in the picture