Skip to content

Instantly share code, notes, and snippets.

@dong
dong / FirstGist.md
Last active August 29, 2015 14:16
first gist

First Gist

print 'Hi, this is first gist.'
@dong
dong / 00.howto_install_phantomjs.md
Last active August 29, 2015 14:25 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@dong
dong / NSCSearchBar.h
Last active September 11, 2015 05:33 — forked from nscoding/NSCSearchBar.h
On iOS 7 UISearchBar the placeholder text is centred and I want to disable that and make it always stick to the left like it was before. There is a private method setCenterPlaceholder and calling this with a BOOL work will make the trick. I am wondering if there is any other, not "Hacked" that does the same thing.
@interface NSCodingSearchBar : UISearchBar
// Default by the system is YES.
// https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UISearchBar.h
@property (nonatomic, assign, setter = setHasCentredPlaceholder:) BOOL hasCentredPlaceholder;
@end
@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>
@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
- (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 / 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 {
@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 / 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 / Free Resources.txt
Created April 9, 2016 21:26
Free Resources
pictures under cc0: http://skuawk.com/?fr