Skip to content

Instantly share code, notes, and snippets.

View gscalzo's full-sized avatar
👨‍🍳
Cooking...

Giordano Scalzo gscalzo

👨‍🍳
Cooking...
View GitHub Profile
<?php
class Weather extends Common
{
function __construct()
{
}
public function deviceHistoryAggregate($deviceId,$type,$time=null){
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *identifier = @"PPSpot";
if ([annotation isKindOfClass:[PPSpot class]]) {
PPAnnotationView *annotationView = (PPAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
annotationView = [[PPAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationView.parent = self;
NSString *text = @"";
-(void)setupInvaders {
NSMutableArray *start = [NSMutableArray array];
for (int i = 0; i < kInvaderRowCount*kInvaderColCount; ++i) {
[start addObject:@(i)];
}
CGPoint baseOrigin = CGPointMake(kInvaderSize.width / 2, 180);
RACSequence *aliens = [start.rac_sequence map:^(id value){
NSUInteger row = [value integerValue]/kInvaderColCount;
NSUInteger col = [value integerValue]%kInvaderColCount;
@gscalzo
gscalzo / QuickSort.swift
Created June 19, 2014 15:06
[Playground] Quicksort implementation in Swift
func qs<T: Comparable>(ary: T[]) -> T[] {
if ary.isEmpty {
return []
}
let x = ary[0]
let xs = ary[1..ary.count]
let smallerSorted = qs(Array(filter(xs) { $0 <= x }))
let biggerSorted = qs(Array(filter(xs) { $0 > x }))
@gscalzo
gscalzo / mixins1.swift
Last active August 29, 2015 14:03
Need for Mixins: what I have
protocol Observable {
func observe(onUpdate: (Void) -> Void) -> String
func unobserve(key: String)
}
class ObservableDispatcher {
var observerClosures: Dictionary<String, (Void) -> Void> = Dictionary<String, (Void) -> Void>()
func observe(onUpdate: (Void) -> Void) -> String {
let key = "key_\(observerClosures.count+1)_key"
@gscalzo
gscalzo / mixins2.swift
Created July 8, 2014 15:58
Need For Mixins: what I want
protocol Observable {
func observe(onUpdate: (Void) -> Void) -> String
func unobserve(key: String)
}
class ObservableDispatcher {
var observerClosures: Dictionary<String, (Void) -> Void> = Dictionary<String, (Void) -> Void>()
func observe(onUpdate: (Void) -> Void) -> String {
let key = "key_\(observerClosures.count+1)_key"
@gscalzo
gscalzo / From String To Token
Created May 11, 2015 13:12
From String To Token
import Foundation
enum LayoutToken: StringLiteralConvertible {
case Plain(Int)
case Container(Int)
case ComponentId(Int)
func description() -> String{
switch self {
case .Plain(let value):
Verifying that +giordano_scalzo is my blockchain ID. https://onename.com/giordano_scalzo
@gscalzo
gscalzo / SpinnableArtworkPublic.swift
Last active March 13, 2016 11:27
SpinnableArtwork: 01 Public Interface
import UIKit
@IBDesignable
class SpinnableArtwork: UIView {
@IBOutlet var view: UIView!
@IBOutlet var artworkImageView: UIImageView!
@IBOutlet var playerButton: PlayerButton!
@IBInspectable var imageName: String! {
didSet {
#!/bin/bash
pbpaste|sed 's/^[[:space:]]*"//g'|sed 's/"$//g' |sed 's/\\"/"/g'|sed 's/\\\\/\\/g'|pbcopy