Skip to content

Instantly share code, notes, and snippets.

View Qata's full-sized avatar

Charles Maria Tor Qata

View GitHub Profile
- (RACSignal *)rac_capturedMetadataObjectsSignal
{
[self setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
RACSignal *signal = objc_getAssociatedObject(self, _cmd);
if (signal != nil) return signal;
signal = [[[[self rac_signalForSelector:@selector(captureOutput:didOutputMetadataObjects:fromConnection:) fromProtocol:@protocol(AVCaptureMetadataOutputObjectsDelegate)] reduceEach:^id(AVCaptureOutput * output, NSArray * objects, AVCaptureConnection * connection){
return objects;
}] filter:^BOOL(NSArray * objects) {
return objects.count;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
@weakify(self);
[[[[[[[[self.output.rac_capturedMetadataObjectsSignal filter:^BOOL(AVMetadataMachineReadableCodeObject * codeObject) {
return [codeObject isKindOfClass:[AVMetadataMachineReadableCodeObject class]] && [codeObject.type isEqual:@"org.iso.QRCode"];
}] map:^id(AVMetadataMachineReadableCodeObject * codeObject) {
return codeObject.stringValue;
}].distinctUntilChanged map:^id(NSString * JSONString) {
return [NSJSONSerialization JSONObjectWithData:[[JSONString stringByReplacingOccurrencesOfString:@"\\" withString:@""] dataUsingEncoding:NSASCIIStringEncoding] options:0 error:nil];
import Text
import Color exposing (..)
import Mouse
import Window
import Time exposing (inSeconds, fps)
import Signal exposing (..)
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
sampleWithFPS frames signal = sampleOn (inSeconds <~ fps frames) signal
let numbers = map show [1..100]
let fizzes = cycle $ (take 4 $ repeat "") ++ ["FIZZ"]
let buzzes = cycle $ (take 2 $ repeat "") ++ ["BUZZ"]
let fizzbuzzes = zipWith (++) fizzes buzzes
zipWith (max) numbers fizzbuzzes
import Html exposing (..)
import Html.Attributes as Attr exposing (..)
import Html.Events exposing (..)
import Http
import Json.Encode as Encode exposing (..)
import Json.Decode as Decode exposing ((:=))
import String
import Task exposing (..)
import Graphics.Element exposing (show)
[[[[self.gateways takeUntil:[[RACSignal empty] delay:timeout]] filter:^BOOL(NSDictionary *object) {
return [object[kMACAddressAccessor] caseInsensitiveCompare:mac] == NSOrderedSame;
}] concat:[RACSignal error:[NSError errorWithDomain:RPCErrorDomain code:ERROR_TIMEOUT userInfo:@{NSLocalizedDescriptionKey:@"Timed out while waiting for a response"}]]] take:1]
import Signal
import Graphics.Element exposing (..)
import Graphics.Input exposing (button)
import Graphics.Collage exposing (collage, toForm)
import List exposing (..)
import List.Extra exposing (..)
import Color
import Text
import Random
import Window
import Signal
import Graphics.Element exposing (..)
import Graphics.Input exposing (button)
import Graphics.Collage exposing (collage, toForm)
import List exposing (..)
import List.Extra exposing (..)
import Color
import Text
import Random
import Window
import Signal
import Graphics.Element exposing (..)
import Graphics.Input exposing (..)
import Graphics.Input.Field exposing (..)
import List
import String
import Window
import Task exposing (Task)
import Text
import Keyboard
//
// CTMaybe.c
// Firestarter
//
// Created by Charlotte Tortorella on 17/03/2016.
// Copyright © 2016 DALI Lighting. All rights reserved.
//
#include "CTMaybe.h"