Skip to content

Instantly share code, notes, and snippets.

@dong
dong / .gitconfig
Created February 7, 2017 07:26 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@dong
dong / serial.m
Created November 18, 2016 15:37 — forked from markd2/serial.m
Playing with NSPropertyListSerialization
#import <Foundation/Foundation.h>
// clang -g -Wall -fobjc-arc -framework Foundation -o serial serial.m
static id makePlistObjects (void) {
NSMutableDictionary *top = [NSMutableDictionary dictionary];
[top setObject: @"Hi I'm a string" forKey: @"string"];
[top setObject: [NSNumber numberWithInt: 23] forKey: @"number"];
@dong
dong / topological.py
Created July 8, 2016 13:57 — forked from kachayev/topological.py
Topological sort with Python (using DFS and gray/black colors)
# Simple:
# a --> b
# --> c --> d
# --> d
graph1 = {
"a": ["b", "c", "d"],
"b": [],
"c": ["d"],
"d": []
}
@dong
dong / Free Resources.txt
Created April 9, 2016 21:26
Free Resources
pictures under cc0: http://skuawk.com/?fr
@dong
dong / afnetwork_periodic_timer.m
Last active April 3, 2016 20:29
afnetwork examples, and periodic timer task
- (void)setPeriodicTask{
[NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(updateStatusToServer:)
userInfo:nil
repeats:YES];
}
- (void)updateStatusToServer:(NSTimer *)timer{
@dong
dong / iosPeriodicTimerTask.m
Created April 3, 2016 01:40
ios fire a periodic timer task every 5 seconds
- (void)setPeriodicTask{
[NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(ontick:)
userInfo:nil
repeats:YES];
}
- (void)ontick:(NSTimer *)timer{
@dong
dong / iosAddCircleAnimation.m
Last active April 3, 2016 01:27
create circle animation
- (void)setupCircleView{
CGFloat circleView_width = ScreenWidth * 3/10.0;
CGRect circleViewRect = CGRectMake(0.0f, 0.0f, circleView_width, circleView_width);
self.circleView.bounds = circleViewRect;
self.circleView.backgroundColor = LightBlue;
self.circleView.layer.cornerRadius = circleView_width/2.0;
self.circleView.layer.position = CGPointMake(ScreenWidth/2.0, 100.0f);
}
- (void)addCircleAnimation {
- (void)addAnimationsToLayers
{
NSInteger timeOffset = 10;
for (CALayer *layer in self.view.layer.sublayers) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeColor"];
animation.duration = 10.0f;
// Stagger the animations so they don't begin until the
// desired time in each
animation.timeOffset = timeOffset--;
@dong
dong / singleton.py
Created March 18, 2016 18:12 — forked from werediver/singleton.py
A thread safe implementation of singleton pattern in Python. Based on tornado.ioloop.IOLoop.instance() approach.
import threading
# Based on tornado.ioloop.IOLoop.instance() approach.
# See https://github.com/facebook/tornado
class SingletonMixin(object):
__singleton_lock = threading.Lock()
__singleton_instance = None
@classmethod
@dong
dong / MapViewController.h
Last active September 12, 2015 21:15 — forked from jonfriskics/MapViewController.h
Custom info window that can be interacted with using the Google Maps SDK for iOS
//
// MapViewController.h
// MapsCustomInfoWindow
//
// Created by Jon Friskics on 4/22/14.
// Copyright (c) 2014 Jon Friskics. All rights reserved.
//
#import <UIKit/UIKit.h>