Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
wisaruthk / MyFilelog.java
Last active January 2, 2016 11:48
Openjpa customize @SequenceGenerator for @id
package my.database;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
@wisaruthk
wisaruthk / PathExample.m
Last active August 29, 2015 13:57
Path Example, Documents, Bundle
#pragma mark - Defind Functions
- (void)copyBundleToDocuments{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
//Document path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
NSString *docDBPath = [docDir stringByAppendingPathComponent:@"database.sqlite"];
@wisaruthk
wisaruthk / mysample.c
Last active August 29, 2015 14:00
GLPK Example
/* mysample.c */
/* gcc -I../src -o mysample mysample.c ../src/*.o */
#include <stdio.h>
#include <stdlib.h>
#include <glpk.h>
/*
minimize
z = 14.7x1 + 10.7x2 + 7.2x4
@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)'
@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 / 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 / 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 / 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]];
}
CGRect mybounds = CGRectMake(0, 0, 24, 24);
UIGraphicsBeginImageContext( mybounds.size );
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextFillRect(context, mybounds);
@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]);