Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / .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 / BlurUIView.m
Created March 25, 2016 07:22
objective c blur background
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *bluredView = [[UIVisualEffectView alloc] initWithEffect:effect];
bluredView.frame = self.view.bounds;
[self.view insertSubview:bluredView atIndex:0];
@wisaruthk
wisaruthk / Layout.m
Created April 18, 2016 08:33
About layout
[button setTranslatesAutoresizingMaskIntoConstraints: NO];
id topGuide = myViewController.topLayoutGuide;
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (button, topGuide);
[myViewController.view addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat: @"V:[topGuide]-20-[button]"
options: 0
metrics: nil
views: viewsDictionary]
];
@wisaruthk
wisaruthk / UIViewAnimationBasic.m
Created April 22, 2016 14:08
เปลี่ยนสี UIView อย่างง่าย
func animateView3(view:UIView){
let animation:CABasicAnimation = CABasicAnimation(keyPath: "backgroundColor")
animation.fromValue = FlatWhite().CGColor
animation.toValue = FlatYellowDark().CGColor
animation.duration = 0.5
//animation.autoreverses = true
view.layer.addAnimation(animation, forKey: "backgroundColor")
}
@wisaruthk
wisaruthk / HtmlDemo.swift
Created May 18, 2016 06:38
load html to UIWebView
let url:NSURL = NSBundle.mainBundle().URLForResource("howto", withExtension: "html", subdirectory: "local_html")!
self.webViewDialog.loadRequest(NSURLRequest(URL: url))
@wisaruthk
wisaruthk / odoo_api_demo.py
Last active July 18, 2016 08:34
odoo api / create purchase order line and Many2Many tax
order_line_id = self.models.execute_kw(self.db, self.uid, self.password, 'purchase.order.line', 'create',
[{'order_id': opo_id,
'partner_id':partner_id,
'name': product['name'],
'product': product,
'product_qty': xpo_line['ordqty'],
'price_unit': xpo_line['unitpr'],
'date_planned':rcvdat,
'taxes_id':[(6,False,[tax_id])],
}])
@wisaruthk
wisaruthk / Example_kartik_gridview_select2_ajax.php
Last active January 15, 2017 10:39
Example Kartik gridview with select2 filter column
[
'attribute'=>'lot_id',
'value'=>'lot.name',
'label'=>'Control No.',
'filterType'=> GridView::FILTER_SELECT2,
'filterWidgetOptions'=>[
'initValueText'=>'hello',
'options' => ['placeholder' => 'Search for a city ...'],
'pluginOptions' => [
'allowClear' => true,
[
'attribute'=>'in_date',
'format'=>['date', 'dd/MM/yyyy'], //format นี้จะใช้ในการแสดง
'filterType'=>GridView::FILTER_DATE,
'filterWidgetOptions'=>[
'type' => DatePicker::TYPE_COMPONENT_APPEND,
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy-mm-dd' //format นี้จะใช้ใน Query statement
]