Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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
//
// 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 / 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
@jacks205
jacks205 / palidromicNumbers.py
Created March 8, 2015 23:50
Script to find how many palindromic numbers there are in a set representable by a 16 bit unsigned integer
def main():
# length of unsigned 16 bit int
length = 65535
# keep count of how many palindromic numbers there are
count = 0
# loop through entire range
for i in range(0,length):
#cast i to a string and compare reverse
if(str(i) == reverseString(str(i))):
count += 1
static int[] bubblesort(int[] numbers)
{
int tempVar;
for (int i = 0; i < numbers.length; i++)
{
for(int j = 0; j < numbers.length; j++)
{
if(numbers[i] > numbers[j + 1])
{
tempVar = numbers [j + 1];
using UnityEngine;
using System.Collections;
public class MenuCamera : MonoBehaviour {
public Transform[] cameraPositions;
public Vector2[] moveSpeeds;
public float[] cameraZoomSpeeds;
public float[] initalZoom;
public float timeAtEachPosition = 5f;
@jacks205
jacks205 / update.sh
Last active August 29, 2015 14:10
Schedules update server script
#!/bin/bash
if [ $# -ge 2 ]
then
bash ~/launch.sh -k
if [ "$2" == "-f" ]
then
rm -r $1/
git clone https://github.com/jacks205/$1.git
cd ~/$1 && npm install
cp ~/local.js ~/$1/config/