Skip to content

Instantly share code, notes, and snippets.

View vukcevich's full-sized avatar

Marijan Vukcevich vukcevich

  • Huntington Beach, California
View GitHub Profile
// IE doesn't deal well with button elements.
// The following jQuery code fixes the two most common issues:
// 1. All button values being submitted whether they were clicked or not
// 2. Button labels being submitted instead of the value of the value attribute
// Make sure you have loaded jQuery, of course.
if ($.browser.msie) {
jQuery(function() {
$('form button[type=submit]').click(function() {
// Handle on the button clicked
@vukcevich
vukcevich / csv-to-json.php
Created May 9, 2012 06:06 — forked from robflaherty/csv-to-json.php
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

//
// UpdateManager.m
// ReactiveLearning
//
// Created by Stephen L. McMahon on 8/4/13.
//
// interface: https://gist.github.com/slmcmahon/6152156
static NSString *const kPreferenceAskUpdate = @"pref_ask_update";
// integerWithBytes.swift
// as seen in http://natecook.com/blog/2015/03/a-sanatorium-for-swift-generics/
//
// (c) 2015 Nate Cook, licensed under the MIT license
protocol BitshiftOperationsType {
func <<(lhs: Self, rhs: Self) -> Self
func >>(lhs: Self, rhs: Self) -> Self
func <<=(inout lhs: Self, rhs: Self)
func >>=(inout lhs: Self, rhs: Self)
@vukcevich
vukcevich / DispatchGroupDemo.swift
Last active August 29, 2015 14:25 — forked from kristopherjohnson/DispatchGroupDemo.swift
Simple demo of dispatch_group_async/dispatch_group_notify/dispatch_group_wait in Swift
import Foundation
let notified = dispatch_semaphore_create(0)
let group = dispatch_group_create()
let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
for n in 0..<20 {
dispatch_group_async(group, queue) {
let timeInterval = Double(arc4random_uniform(1000)) * 0.01
import Cocoa
// Note: use of enumeration var in generic is instadeath
// Note: use of static var in generic is not yet supported
public protocol EnumConvertible: Hashable {
init?(hashValue hash: Int)
static func countMembers() -> Int
static func members() -> [Self]
}
@vukcevich
vukcevich / HTSDReachability.swift
Created December 7, 2015 16:39 — forked from UjwalManjunath/HTSDReachability.swift
IOS Reachability: Swift 2.0
import UIKit
import SystemConfiguration
public let ReachabilityChangedNotification = "ReachabilityChangedNotification"
class HTSDReachabiltiy: NSObject {
typealias NetworkReachable = (HTSDReachabiltiy) -> ()
typealias NetworkUnreachable = (HTSDReachabiltiy) -> ()
enum NetworkStatus: CustomStringConvertible {
@vukcevich
vukcevich / endian-conversion-cheat-sheet.swift
Created December 21, 2016 21:33 — forked from DevAndArtist/endian-conversion-cheat-sheet.swift
A cheat sheet for byte conversion of number types in Swift 3.0
func _convertToBytes<T>(_ value: T, withCapacity capacity: Int) -> [UInt8] {
var mutableValue = value
return withUnsafePointer(to: &mutableValue) {
return $0.withMemoryRebound(to: UInt8.self, capacity: capacity) {
return Array(UnsafeBufferPointer(start: $0, count: capacity))
}
}
@vukcevich
vukcevich / convert_double_to_nsdata.swift
Created December 21, 2016 22:48 — forked from key/convert_double_to_nsdata.swift
Convert `Double` value to `NSData` in Swift
var x: Double = 0.99043125417
var length = sizeof(Double) // -> 8
var x_data = NSData(bytes: &x, length: length)
var buffer = [UInt8](count: sizeof(Double), repeatedValue: 0x00)
x_data.getBytes(&buffer, length: buffer.count)
print(buffer) // -> "[210, 21, 179, 226, 156, 177, 239, 63]\n"