Skip to content

Instantly share code, notes, and snippets.

@jpotts18
jpotts18 / Alamofire-JSON-Serialization.md
Last active August 17, 2020 15:44
Alamofire JSON Serialization of Objects, Collections, Nesting

Alamofire JSON Serialization of Objects and Collections

Alamofire is a great Swift library developed by the creator of AFNetworking @mattt. The purpose of this gist is to explain how to use the built-in power of Alamofire to serialize your JSON. In this example we will be serializing a simple blog API. First we will start with serializing a single JSON object and add complexity as we go along.

Warning: This was written before Swift 1.2

A Single JSON Serialization

This is the first JSON object that we will be serializing.

@jpotts18
jpotts18 / great-expectations-results.txt
Last active August 29, 2015 14:15
Charles Dickens Stylometry Results
>>> Phraseology Analysis <<<
Lexical diversity : 5.47097094655
Mean Word Length : 7.38521400778
Mean Sentence Length : 99.7832417023
STDEV Sentence Length : Not Supported
Mean paragraph Length : Not Supported
Document Length : 980071
>>> Punctuation Analysis (per 1000 tokens) <<<
@jpotts18
jpotts18 / huckleberry-finn.txt
Created February 23, 2015 18:14
Mark Twain Stylometry Analysis
Lexical diversity : 6.60800900797
Mean Word Length : 6.86258874932
Mean Sentence Length : 96.1115333774
STDEV Sentence Length : Not Supported
Mean paragraph Length : Not Supported
Document Length : 581667
>>> Punctuation Analysis (per 1000 tokens) <<<
Commas : 59.1725372445
@jpotts18
jpotts18 / new-testament-tyndale.txt
Created February 23, 2015 23:01
Tyndale New Testament Stylometry
>>> Phraseology Analysis <<<
Lexical diversity : 2.69612791466
Mean Word Length : 6.74392160488
Mean Sentence Length : 112.818411954
STDEV Sentence Length : Not Supported
Mean paragraph Length : Not Supported
Document Length : 1827207
>>> Punctuation Analysis (per 1000 tokens) <<<
// MARK: UICollectionViewFlowDelegate methods
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
var borderWidth = COLUMN_NUMBER * BORDER_WIDTH
var width:CGFloat = CGFloat((collectionView.frame.width - borderWidth) / COLUMN_NUMBER)
return CGSize(width: width, height: width) // square
}
import re
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import RegexpTokenizer
from nltk.collocations import *
from bs4 import BeautifulSoup
class HTMLDocumentParser(object):
@jpotts18
jpotts18 / JPUserAgent.m
Last active August 29, 2015 14:18
iOS User Agent
//
// JPUserAgentHelper.m
//
// Created by Jeff Potter on 4/1/15.
//
#import "JPUserAgentHelper.h"
@implementation JPUserAgentHelper
@jpotts18
jpotts18 / gist:672af1b0f1cca7e5ba6c
Last active August 29, 2015 14:18
Starter Gist
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var fs = require('fs'),
gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
@jpotts18
jpotts18 / gist:5542d148447d92fd1612
Last active August 29, 2015 14:19
Brew Cask Setup Script
echo "Installing brew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Installing brew requires command line tools and prompts user to install them
# Vundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
brew install the_silver_searcher
echo "Installing brew cask..."
Screen Name Screen Views Unique Screen Views Avg. Time on Screen % Exit
.MealInputActivity 52,957 13,025 00:00:13 7.96%
.MenuActivity 36,996 15,743 00:00:07 32.96%
.DrinkInputActivity 12,858 5,282 00:00:05 0.36%
.CropperActivity 9,014 7,964 00:00:05 1.00%
.PhysicalActivityActivity 7,896 1,959 00:00:06 3.19%
.DrinkGroupPicker 6,604 4,946 00:00:02 0.98%
.DrinkTypePicker 6,265 4,851 00:00:02 0.11%
.TimelineActivity 6,246 3,958 00:00:12 16.39%
.ReportsActivity 5,882 4,169 00:00:23 31.81%