Skip to content

Instantly share code, notes, and snippets.

@jacks205
jacks205 / cellularAutomata.js
Created March 9, 2015 06:36
Node.js script to simulate Cellular Automata
main();
//Create array of booleans
function main(){
var length = 64,
cellArray = new Array(length);
for(var i = 0; i < cellArray.length; ++i){
cellArray[i] = (i === 31);
}
//Run through 32 lines of cells
//
// ViewController.swift
// BluetoothExample
//
// Created by Mark Jackson on 3/18/15.
// Copyright (c) 2015 Mark Jackson. All rights reserved.
//
import UIKit
import CoreBluetooth
@jacks205
jacks205 / CustomView.swift
Last active August 29, 2015 14:17
Some Path and Image drawing in Swift
//
// CustomView.swift
// BluetoothExample
//
// Created by Mark Jackson on 3/18/15.
// Copyright (c) 2015 Mark Jackson. All rights reserved.
//
import UIKit
@jacks205
jacks205 / TimeEstimateCell.swift
Created March 27, 2015 06:25
Old style of custom cell for Routes
//
// TimeEstimateCell.swift
// Routes
//
// Created by Mark Jackson on 3/21/15.
// Copyright (c) 2015 Mark Jackson. All rights reserved.
//
import UIKit
class TimeEstimateCell: UITableViewCell {
@jacks205
jacks205 / addGradientToBezierPath.swift
Created April 5, 2015 01:35
How to add a gradient layer to bezierpath swift
func fillTrafficIndicatorBase(ref : CGContextRef, rect : CGRect, cornerRadius : CGFloat, colorLight : CGColorRef, colorDark: CGColorRef, fillWidth : CGFloat){
CGContextSaveGState(ref)
let gradient : CGGradientRef = CGGradientCreateWithColors(Colors.genericRGBSpace(), [colorLight, colorDark], nil)
let path = UIBezierPath(roundedRect: rect, cornerRadius: cornerRadius)
path.fill()
path.addClip()
CGContextDrawLinearGradient(ref, gradient, CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect)), CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect)), 0)
CGContextRestoreGState(ref)
}
@jacks205
jacks205 / resignKeyboardScrollView.swift
Created April 5, 2015 01:40
Resigning keyboard when using a searchbar and a tableview
func scrollViewWillBeginDragging(scrollView: UIScrollView) {
self.searchBar.resignFirstResponder()
}
@jacks205
jacks205 / MapDirections.swift
Created April 6, 2015 07:29
MKMapKit showing route and zooming to show source and destination
//
// ViewController.swift
// MapDirections
//
// Created by Mark Jackson on 4/5/15.
// Copyright (c) 2015 Mark Jackson. All rights reserved.
//
import UIKit
import MapKit
//How to URL Encode string
CFURLCreateStringByAddingPercentEscapes(nil, str, nil, "!*'();:@&=+$,/?%#[]\" ", kCFStringEncodingASCII)
@jacks205
jacks205 / Constants.swift
Created May 6, 2015 00:05
Constants for Routes
//
// Constants.swift
// Routes
//
// Created by Mark Jackson on 3/21/15.
// Copyright (c) 2015 Mark Jackson. All rights reserved.
//
struct Constants{
@jacks205
jacks205 / XMLtoFile.cs
Created June 11, 2015 18:58
Write to XML File C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace JanteqTestConsoleApplication
{
public class Program