Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
wisaruthk / httpd-wsgi.conf
Last active February 28, 2018 08:04
djangocms apache mod_wsgi configuration with alias
Alias /media/ /usr/local/var/www/mysite/media/
# should run -> python manage.py collectstatic
Alias /static/ /usr/local/var/www/mysite/static/
<Directory /usr/local/var/www/mysite/static>
Require all granted
</Directory>
@wisaruthk
wisaruthk / tax_sum_example.php
Created January 21, 2018 09:47
PHP Array group and sum example
<?php
$array = [
['tax'=>'1','val'=>10],
['tax'=>'1','val'=>20],
['tax'=>'2','val'=>10]
];
$result = array_reduce($array,function($carry,$item){
if(!isset($carry[$item['tax']])){
@wisaruthk
wisaruthk / dict.ipynb
Last active February 11, 2017 06:15
python collection example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[
'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
]
@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,
@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 / 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 / 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 / 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 / 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];