Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
wisaruthk / .gitignore
Created March 25, 2016 03:04 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@wisaruthk
wisaruthk / CustomHeaderView.m
Created March 4, 2016 07:03
iOS custom uitableview header
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(tableView==self.tableView1){
CGRect frame = tableView.frame;
//NSLog(@"self view %@",NSStringFromCGRect(self.view.frame));
//NSLog(@"tableview frame %@",NSStringFromCGRect(frame));
UITableViewHeaderFooterView *headerView = [[UITableViewHeaderFooterView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 20)];
CGFloat btnWidth = 50;
CGFloat btnTrail = 10;
UIButton *sortButton = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width-(btnWidth+btnTrail), 0, btnWidth, 20)];
@wisaruthk
wisaruthk / NotifDemoVC.m
Created March 3, 2016 08:37
Demo NSNotification
//
// FirstViewController.m
// NotifDemo
//
// Created by wisaruthk on 3/3/2559 BE.
// Copyright © 2559 kojo. All rights reserved.
//
#import "FirstViewController.h"
#import "Children.h"
@wisaruthk
wisaruthk / Children.h
Created March 3, 2016 07:10
objc KVO example
//
// Children.h
// KVCODemo
//
// Created by wisaruthk on 3/3/2559 BE.
// Copyright © 2559 kojo. All rights reserved.
//
#import <Foundation/Foundation.h>
@wisaruthk
wisaruthk / VCTransition.swift
Last active March 1, 2019 04:30
ViewController Transition in swift
func transitionToChildViewController(toViewController:UIViewController){
var fromViewController:UIViewController?
if(self.childViewControllers.count > 0){
fromViewController = self.childViewControllers[0]
} else {
fromViewController = nil;
}
if(toViewController == fromViewController || !self.isViewLoaded()){
@wisaruthk
wisaruthk / yii2-behaviors.php
Created November 16, 2015 08:39
ตัวอย่าง กำหนด response เป็น json สำหรับ controller ที่ระบุ
public function behaviors() {
$behaviors = parent::behaviors();
$behaviors['authenticator'] = [
'class' => \yii\filters\auth\HttpBasicAuth::className(),
'only' => ['hi','token-log-in', 'log-out',
'list-template-data',
'download-template-data'],
];
$behaviors['response'] = [
'class' => 'yii\filters\ContentNegotiator',
@wisaruthk
wisaruthk / receipt.swift
Created November 6, 2015 03:54
iOS Receipt
// Initial Receipt
let receiptURL:NSURL? = NSBundle.mainBundle().appStoreReceiptURL
let data:NSData? = NSData(contentsOfURL: receiptURL!);
if(data == nil){
// No local receipt
print("No local receipt")
} else {
let temp = data!.base64EncodedStringWithOptions([])
let requestContent:NSDictionary = NSDictionary(object: temp, forKey: "receipt-data")
@wisaruthk
wisaruthk / MainDownloader.java
Created October 16, 2015 05:15
view html and find the image to download
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mangaloader;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@wisaruthk
wisaruthk / FVRInAppPurchaseVC.swift
Last active July 15, 2023 16:35
iOS In App Purchase Example with appusername
//
// FVRInAppPurchaseVC.swift
// favroutes
//
// Created by wisaruthk on 10/8/2558 BE.
// Copyright © 2558 kojo. All rights reserved.
//
import UIKit
import StoreKit
@wisaruthk
wisaruthk / batchupdate.swift
Created October 7, 2015 10:05
Swift NSBatchUpdateRequest
let batchRequest = NSBatchUpdateRequest(entityName: "Group")
batchRequest.predicate = NSPredicate(format: "SELF != %@", self.group!)
batchRequest.propertiesToUpdate = ["isFirstView":NSNumber(bool: false)]
batchRequest.resultType = .UpdatedObjectsCountResultType
do {
let results:NSBatchUpdateResult = try managedContext.executeRequest(batchRequest) as! NSBatchUpdateResult
print("update with result = \(results.result)")
} catch {
print("Error something..")