Skip to content

Instantly share code, notes, and snippets.

@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 / 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];
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 / cell_image.m
Created April 6, 2015 03:31
Cell with customize cell image
CGRect mybounds = CGRectMake(0, 0, 20, 20);
UIGraphicsBeginImageContext( mybounds.size );
CGContextRef context = UIGraphicsGetCurrentContext();
CIColor *itemColor = [CIColor colorWithString:item.color];
CGContextSetFillColorWithColor(context, [[UIColor colorWithCIColor:itemColor] CGColor]);
CGRect mybounds = CGRectMake(0, 0, 24, 24);
UIGraphicsBeginImageContext( mybounds.size );
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextFillRect(context, mybounds);
@wisaruthk
wisaruthk / OrderItem.m
Last active August 29, 2015 14:08
Order item in NSMutableArray by dictionary
-(void)sortMyGroupArray:(NSMutableArray *)items{
NSSortDescriptor *sd = [[NSSortDescriptor alloc] initWithKey:@"groupName" ascending:YES];
[items sortUsingDescriptors:@[sd]];
}
@wisaruthk
wisaruthk / TextFieldListener.m
Created October 7, 2014 15:36
Add textfield listener while edit
_textInputHelper = [[FDPTextInputHelper alloc] init];
[self.batchSizeTextField addTarget:_textInputHelper action:@selector(textFieldIntegerDidChange:) forControlEvents:UIControlEventEditingChanged];
@wisaruthk
wisaruthk / NSMutableArray-Sort
Last active August 29, 2015 14:06
Sorted object in NSMutableArray
NSMutableArray *items = [self initialItems];
[items sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
Item *i1 = obj1;
Item *i2 = obj2;
if (i1.code > i2.code) {
return (NSComparisonResult)NSOrderedDescending;
}
if (i1.code < i2.code) {
@wisaruthk
wisaruthk / Main.java
Last active August 29, 2015 14:04
My Java Annotation Example
package my;
import java.lang.reflect.Field;
import my.annotation.MyColumn;
public class Main {
public static void main(String[] args) {
MyObject o = new MyObject("Jonathan", "Jo", "GREEN");
//อีกเทคนิคหนึ่งที่ใช้ร่วมกับ Annotation คือ reflect เพื่อเรียกดูข้อมูลของ Class
@wisaruthk
wisaruthk / mywsadmin.py
Last active November 26, 2020 03:33
Jython Script - Create Datasource on Websphere
#รัน Library Script
execfile('wsadminlib.py')
enableDebugMessages() #สำหรับเปิด Log
#==============================
#เริ่มด้วยการสร้าง JDBCProvider
#==============================
_parent = getServerId(_nodeName,'server1') #กำหนดว่าเราจะสร้าง JdbcProvider ใน Scope 'Server'
_name ='DB2 Using IBM JCC Driver (XA)'