Skip to content

Instantly share code, notes, and snippets.

@scttymn
scttymn / parse.swift
Created September 22, 2014 15:32
Simple JSON Parse in Swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let urlPath = "http://www.telize.com/geoip"
@scttymn
scttymn / ViewController.swift
Created September 1, 2014 02:12
Future Day Calculator
//
// ViewController.swift
// DaysUntilDate
//
// Created by Scotty Moon on 8/31/14.
// Copyright (c) 2014 Scotty Moon. All rights reserved.
//
import UIKit
@scttymn
scttymn / nerdy-coffee.rb
Created July 29, 2014 16:19
Nerdy Coffee Recipe
#/usr/bin/ruby
WATER = 22.2593
WATER_MEASUREMENT = "ml"
COFFEE = 0.04493
COFFEE_MEASUREMENT = "g"
def get_water_weight(coffee)
(coffee.to_f * WATER).ceil.to_s + WATER_MEASUREMENT
end
@scttymn
scttymn / sample page output
Last active August 29, 2015 13:57
Page CMS output
{
"total_pages": 5,
"page": {
"number": 1,
"content": [
{
"type": "text",
"value": "Aliquam ut dui eu purus ultrices mollis. Nullam mattis, leo vitae accumsan rhoncus, nisl urna tincidunt lacus, ac fermentum ante neque at metus. Sed at eros hendrerit, lacinia augue et, facilisis velit. Praesent est metus, faucibus id mi quis, aliquet tempus urna. Suspendisse pellentesque <b>leo ut ligula luctus</b> ultrices. Sed at ultrices velit. In et leo turpis. Duis accumsan ante non nunc elementum, vitae dapibus metus pellentesque. Cras id tempor eros. Vivamus et scelerisque eros, sit amet laoreet lorem. <br/> Curabitur nisi nulla, congue et enim et, iaculis dictum lacus. Mauris id libero neque. Nulla condimentum dignissim nunc rhoncus mattis. Sed pellentesque nec ante at aliquam. Aliquam et dignissim ante. Sed sed tellus non turpis lacinia rutrum sit amet sit amet ligula. Integer enim mauris, ornare ut dapibus in, tempor ac justo. Donec condimentum sit amet metus eget euismod. Donec hen
@scttymn
scttymn / 0_reuse_code.js
Created January 20, 2014 19:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public class MainActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
Button clickMe = (Button) findViewById(R.id.button_name);
clickMe.setOnClickListener(this);
}
@Override
public void onClick(View view) {
function ThingController($scope, $http) {
var baseUrl = 'http://sinatra-api-example.scottymoon.c9.io';
$http.get(baseUrl + '/things').success(function(data) {
$scope.things = data;
});
$scope.create = function(thing) {
$http.post(baseUrl + '/things', thing).success(function(thing){
$scope.things.unshift(thing);
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<meta charset="utf-8">
<title>Sinatra JSON API Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
<script src="/controllers.js"></script>
</head>
<body ng-controller='ThingController'>
@scttymn
scttymn / gist:4059912
Created November 12, 2012 15:16
Angularize
#application.html.haml
%html(ng-app)
#event.js
function EventCtrl($scope){
$scope.current_user = {
name: "Scotty Moon",
email: "scotty@ovenbits.com"
}
module PgSearchable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def searchable_on(*args)
@@search_columns = args
end