Skip to content

Instantly share code, notes, and snippets.

@adamyanalunas
adamyanalunas / levenshtein.swift
Created May 9, 2016 16:00
Siwft 3 compatible Levenshtein distance
// Light syntax cleanup from https://gist.github.com/daehn/f17e8cdcf8d91b046f3c
private extension String {
subscript(index: Int) -> Character {
return self[startIndex.advancedBy(index)]
}
subscript(range: Range<Int>) -> String {
let start = startIndex.advancedBy(range.startIndex)

Addresses issue: #

Preflight (optional)

  • List work to be done before PR can be reviewed
  • Keep this as brief as possible, this is not a place for storytelling
  • bundle install or bundle exec pod install
  • Reading some backstory
  • Set up credentials someuser@domain.com/password in the “foo” database
@adamyanalunas
adamyanalunas / dummy_server.sh
Created October 23, 2013 00:04
Create a local, dummy API server that will dump out any request received
# Listen on port 5000
nc -k -l 5000
# Test by posting a JSON file
curl -X POST -d @filename.txt http://local.devmachine/path/to/resource --header "Content-Type:application/json"
@adamyanalunas
adamyanalunas / 1.js
Created August 20, 2013 16:41 — forked from padolsey/1.js
/x/==x
@adamyanalunas
adamyanalunas / scrubadub_mixpanel.js
Last active December 18, 2015 01:59
Making real JSON from Mixpanel's dump API.
var takeDump = function(foo, bar, body) {
// The "body" is the raw response from https://data.mixpanel.com API
// At this point there are line returns (\n) separating each event and the list of events is not wrapped in an array literal ([])
// Take out line returns and replace with proper comma separators
var tight = body.replace(/[\n\r\t]/g, ',');
// To return a list you've got to wrap it in an array
// There's a trailing newline returned, hence the substring snip
var wrapped = '[' + tight.substring(0, tight.length-1) + ']';
@adamyanalunas
adamyanalunas / base.css
Created May 30, 2013 16:34
Fix the chat so the × icon and text don't compete for layout space (and other UI tweaks).
.activity-text {
padding-right: 22px;
}
.activity-item .activity-delete {
top: 9px;
}
.activity-item:hover .activity-delete {
opacity: .75;
@adamyanalunas
adamyanalunas / example.m
Created May 11, 2013 06:14
Stubbing PSPDFViewController
context(@"stubbing init/alloc", ^{
describe(@"can stub", ^{
__block PSPDFViewController *psVC;
__block PSPDFViewController *initVC;
beforeEach(^{
psVC = PSPDFViewController.alloc;
initVC = [psVC init];
[PSPDFViewController stub:@selector(alloc) andReturn:psVC];
@adamyanalunas
adamyanalunas / date_helper.coffee
Last active December 16, 2015 17:59
Sinon's time freezing is destroyed by Sugar.js
exports.DateHelper = {
lock: (msSinceEpoc) ->
# NOTE: Needed because Calendar model expects moment in the global scope.
global.moment = require('moment')
# NOTE: This can be removed once Sugar.js is removed
dateSugar = Date.SugarMethods
clock = sinon.useFakeTimers(msSinceEpoc)
# NOTE: This can be removed once Sugar.js is removed
Date[k] = v.method for k,v of dateSugar
@adamyanalunas
adamyanalunas / broker.js
Created November 9, 2012 20:43
Abstracting event names from broker calls
app.events = {
data: {
},
ui: {
main: {
channel: 'ui.main',
topics: {
layoutLoaded: 'layout.loaded'
@adamyanalunas
adamyanalunas / sdbw.css
Created October 23, 2012 05:37
Updates to make SDBW entries more readable
.ui-addtocal {
cursor: pointer; /* No need for cursor: hand; Nobody uses IE 5.5 any more */
position: absolute;
bottom: 10px;
right: 17px;
}
ol#eventsList h6.eventHost {
width: 220px
}