Skip to content

Instantly share code, notes, and snippets.

import xmlrpclib
url = 'http://localhost:8069'
db = 'kojostudio'
username = 'admin'
password = 'admin'
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
vVersion = common.version()
print(vVersion)
@wisaruthk
wisaruthk / AlertControllerEx.m
Created September 22, 2015 06:15
ตัวอย่างการใช้ UIAlertController
FDPGroup *group = self.datasource[indexPath.row];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:LocalizedString(@"Rename Group")
message:LocalizedString(@"Input Group Name")
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:LocalizedString(@"Cancel")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
[[self.tableView cellForRowAtIndexPath:indexPath] setSelected:false];
@wisaruthk
wisaruthk / main.php
Created September 29, 2015 08:36
Yii2 custom json response
'response'=>[
'format' => yii\web\Response::FORMAT_JSON,
'class' => 'yii\web\Response',
'on beforeSend' => function ($event) {
$response = $event->sender;
//var_dump($response);
if ($response->data !== null) {
$response->data = [
'success' => $response->getIsSuccessful(),
@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..")
@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 / 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 / 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 / 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 / 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 / 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>