Skip to content

Instantly share code, notes, and snippets.

@sunnycyk
sunnycyk / googlemap.js
Created February 20, 2014 04:13
Asynchronous Loading Google Map API
angular.module('googleMapAPI', [])
.config(function(googleMapServiceProvider) {
googeMapServiceProvider.setLang('zh-HK'); // Configuration that loading Google Map API in Traditional Chinese
})
.provider('googleMapService', function () {
var language = 'en-US';
function loadScript($document, callback, success) {
var scriptTag = $document.createElement('script');
scriptTag.id = "google-map-script";
scriptTag.type = "text/javascript";
@sunnycyk
sunnycyk / NSImage+OpenCV.h
Last active August 29, 2015 14:02
opencv
//
// NSImage+OpenCV.mm
//
#import "NSImage+OpenCV.h"
static void ProviderReleaseDataNOP(void *info, const void *data, size_t size)
{
return;
}
@sunnycyk
sunnycyk / UILocalNotification
Last active August 29, 2015 14:06
my IOS notes
// Set up Actions for notifications
let viewDetailAction:UIMutableUserNotificationAction = UIMutableUserNotificationAction()
viewDetailAction.identifier = "VIEW_ACTION"
viewDetailAction.title = "View Detail"
viewDetailAction.activationMode = UIUserNotificationActivationMode.Foreground
viewDetailAction.destructive = false
viewDetailAction.authenticationRequired = true
let cancelAction:UIMutableUserNotificationAction = UIMutableUserNotificationAction()
@sunnycyk
sunnycyk / Ex7.1-3.swift
Last active August 29, 2015 14:08
IOS Core Animation Example Chapter 7
//
// ViewController.swift
// animation71
//
// Created by Sunny Cheung on 24/10/14.
// Copyright (c) 2014 khl. All rights reserved.
//
import UIKit
import QuartzCore
@sunnycyk
sunnycyk / arduino_ble_service_setup.ino
Last active August 29, 2015 14:09
Rapiro BLE Nano
// The Nordic UART Service
static const uint8_t uart_base_uuid[] = {0x71, 0x3D, 0, 0, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
static const uint8_t uart_tx_uuid[] = {0x71, 0x3D, 0, 3, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
static const uint8_t uart_rx_uuid[] = {0x71, 0x3D, 0, 2, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E};
static const uint8_t uart_base_uuid_rev[] = {0x1E, 0x94, 0x8D, 0xF1, 0x48, 0x31, 0x94, 0xBA, 0x75, 0x4C, 0x3E, 0x50, 0, 0, 0x3D, 0x71};
uint8_t txPayload[TXRX_BUF_LEN] = {0,};
uint8_t rxPayload[TXRX_BUF_LEN] = {0,};
GattCharacteristic txCharacteristic (uart_tx_uuid, txPayload, 1, TXRX_BUF_LEN,
@sunnycyk
sunnycyk / autodownload
Created May 24, 2015 05:10
Layer Notes
// ATLMIMETypeImageJPEGPreview, ATLMIMETypeTextPlain defined in Altas to present the MIME tpye for the medias
self.layerClient = [LYRClient clientWithAppID:YOUR_APP_ID];
self.layerClient.autodownloadMIMETypes = [NSSet setWithObjects:ATLMIMETypeImageJPEGPreview, ATLMIMETypeTextPlain, nil];
@sunnycyk
sunnycyk / dismissMessage.m
Last active August 29, 2015 14:23
ios 8 notes
#pragma mark -MFMEssageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
switch(result) {
case MessageComposeResultCancelled:
// user canceled sms
[self dismissViewControllerAnimated:YES completion:nil];
break;
@sunnycyk
sunnycyk / IFTTT-newFollower.ino
Created December 5, 2015 03:45
Duo Exampple
// This #include statement was automatically added by the Particle IDE.
#include "TM1637Display/TM1637Display.h"
TM1637Display display(4, 5); // connect CLK to D4, DIO to D5
int followers = 0; // or start with number that in your profile
void setup()
{
Serial.begin(9600);
@sunnycyk
sunnycyk / html
Last active December 14, 2015 08:28
HTML Template
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
@sunnycyk
sunnycyk / api.js
Created March 8, 2013 08:14 — forked from fwielstra/api.js
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');