Skip to content

Instantly share code, notes, and snippets.

View saturngod's full-sized avatar
🎯
Focusing

Htain Lin Shwe saturngod

🎯
Focusing
View GitHub Profile
@saturngod
saturngod / nodedbright.js
Created August 25, 2011 15:39
node.js insert db
var mysql= require('mysql');
var client = mysql.createClient({
user: 'root',
password: 'root',
host: 'localhost'
});
client.query('USE sample');
@saturngod
saturngod / MBRoundProgressView.h
Created September 18, 2011 02:44
MBRoundProgressView
#import <UIKit/UIKit.h>
@interface MBRoundProgressView : UIView
- (void)setProgress:(float)progress;
- (float)progress;
@end
@saturngod
saturngod / allheader.m
Created October 14, 2011 08:53
allheader
NSLog(@"%@",[request allHTTPHeaderFields]);
@saturngod
saturngod / NSData+Additions.h
Created October 14, 2011 08:56
base64encoding
//
// NSData+Additions.h
//
// Created by Samuel Chow on 4/26/11.
// Copyright 2011 MobyFab. All rights reserved.
//
@interface NSData (MBBase64)
+ (id)dataWithBase64EncodedString:(NSString *)string; // Padding '=' characters are optional. Whitespace is ignored.
@saturngod
saturngod / httpauth.m
Created October 14, 2011 08:59
http basic authorization
NSString* usernamepwd =[NSString StringWithFormat:@"%@:%@",username,password];
NSData* base64=[usernamepwd dataUsingEncoding:NSASCIIStringEncoding];
NSString* authHeader=[NSString stringWithFormat:@"Basic %@", [base64 base64Encoding]];
[request addValue:authHeader forHTTPHeaderField:@"Authorization"];
@saturngod
saturngod / asyncImage.m
Created November 8, 2011 13:13
Asynchronous load Image
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:profile_img]]];
dispatch_sync(dispatch_get_main_queue(), ^{
[[cell imageView] setImage:image];
[cell setNeedsLayout];
});
});
@saturngod
saturngod / article.h
Created November 8, 2011 13:58
ResKit Object Mapping
@interface Article : NSObject
@property (nonatomic, retain) NSString* title;
@property (nonatomic, retain) NSString* body;
@property (nonatomic, retain) NSString* author;
@property (nonatomic, retain) NSDate* publicationDate;
@end
@saturngod
saturngod / slim.php
Created November 10, 2011 04:41
Slim Hello Wrold
$app = new Slim();
//GET route
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
//POST route
$app->post('/person', function () {
//Create new Person
@saturngod
saturngod / create_post_tbl.sql
Created December 1, 2011 15:22
create post table
CREATE TABLE IF NOT EXISTS `posts` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR(255) NULL ,
`content` TEXT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
@saturngod
saturngod / phpcallback.php
Created March 9, 2012 02:46
php callback testing ( Need >= PHP 5.3 )
<?php
/**
* call back testing
*
* @return void
* @author saturngod
**/
function callback_testing($callback)