Skip to content

Instantly share code, notes, and snippets.

View jozsef-vesza's full-sized avatar
🏡

József Vesza jozsef-vesza

🏡
View GitHub Profile
String returnString = "mystring";
Writer writer = new QRCodeWriter();
BitMatrix encoded = null;
try
{
encoded = writer.encode(returnString, BarcodeFormat.QR_CODE, 300, 300);
}
catch (WriterException ex)
class MainViewModel: NSObject {
var model :Meal[] = []
let mealUrl = "http://verdant-upgrade-554.appspot.com/soservices/mealmanager"
init() {
super.init()
}
func fetchModel(completion:() -> Void) {
@jozsef-vesza
jozsef-vesza / gist:5f1784dfd4fadbe826b2
Last active August 29, 2015 14:07
Map extension for Dictionaries in Swift
extension Dictionary {
    func map<U> (transform: Value -> U) -> Dictionary<Key, U> {
        var result = Dictionary<Key, U>()
        for (key, value) in self {
            result[key] = transform(value)
        }
        
        return result
 }
public class BinaryNode<T: Comparable>: Comparable {
var value: T
var left: BinaryNode<T>?
var right: BinaryNode<T>?
init(value: T) {
self.value = value
}
public class Box<T> {
let unbox: T
init(_ value: T) { self.unbox = value }
}
public enum ResultType<T> {
case Success(Box<T>)
case Error(String)
}
//
// TableViewController.swift
// TableViewExpansions
//
// Created by Vesza Jozsef on 05/05/15.
// Copyright (c) 2015 Vesza Jozsef. All rights reserved.
//
import UIKit
public static IEnumerable<T> FindVisualChildren<T>(this DependencyObject e) where T : DependencyObject
{
if (e == null) yield break;
VisualTreeHelper.GetChildren(e).Filter(child is T).Map(child => ()
{
if (children != null)
{
yield return children;
}
protocol BaseRequirements {
// List common requirements here.
}
protocol AdditionalRequirements {
// Any additional reqs here.
}
struct BasicType: BaseRequirements {
// I will only do the basics.
import UIKit
var array = [AnyObject]()
array.append(1)
array.append(2.0)
array.append("3")
array.append([4, 5, 6])
array.append([7: "7", 8: "8"])
// prints "true"
private func handleContentChange() {
let tableViewHeight = CGFloat(subViewModel.count()) * rowHeight
let contentHeight = standardPadding + segmentedControlHeight.constant + standardPadding + tableViewHeight + standardPadding + openButtonHeight.constant + standardPadding
dispatch_async(dispatch_get_main_queue()) {
self.tableView.reloadData()
self.preferredContentSize.height = contentHeight
}