Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / 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>
$( "#form-memberRegister" ).validate( {
errorClass: "error",
rules: {
"formatted-citizenID": {
required:true,
remote:{
url: "action/checkCitizenID",
type: "post",
dataType:'json',
data: {
@wisaruthk
wisaruthk / .gitignore
Created October 17, 2018 05:00
git ignore wordpress except themes/twentyseventeen-child
# ต้องใช้ทุกบรรทัดไล่ลงไป
# git ignore wordpress but except themes-name
wordpress/*
!wordpress/wp-content
wordpress/wp-content/*
!wordpress/wp-content/themes
wordpress/wp-content/themes/*
!wordpress/wp-content/themes/twentyseventeen-child
@wisaruthk
wisaruthk / yii2_view.php
Last active October 23, 2018 07:40
การใช้ <script> ใน yii2 view
/**
* ปกติการ ใช้ registerJs("") ของ yii2 จะทำให้การเขียน script ค่อนข้างยาก
* ดังนั้นจึงเขียน javascript ในลักษณะนี้จะจัดการได้ง่ายกว่า ไม่ต้องคอยกังวลกับปัญหา "", ''
*/
<script type="text/javascript">
var obj = {
init:function(){
$('#po-product_uom_qty').on('change',function(e){
obj.calculateAmount();
});
@wisaruthk
wisaruthk / formik_yup_example.js
Created February 27, 2020 09:25
react-native example formik and yup
import { Formik } from 'formik';
import * as Yup from 'yup';
class SignInScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
username: null,
password: null,
rememberMe: false,
@wisaruthk
wisaruthk / SAPB1-QueryFromSemanticLayer.sql
Created July 19, 2020 08:13
SAPB1-QueryFromSemanticLayer
SELECT * FROM _SYS_BIC."sap.db1.stock/InventoryTransactionDocumentsQuery";
@wisaruthk
wisaruthk / docker-tip-01.txt
Last active August 15, 2020 16:42
ความแตกต่างระหว่าง docker run กับ docker exec
ความแตกต่างระหว่าง docker run กับ docker exec
docker run
- docker run #{image} sh
- จะมีการสร้าง temporary container ขึ้นมาเพื่อรัน command เมื่อรันเสร็จจะหยุด container แต่ไม่ terminate
-- ดังนั้นจะมี container id ค้างอยู่ในระบบ
docker exec
- docker exec #{container} sh
- จะใช้ container ที่มีอยู่แล้วในการรัน
@wisaruthk
wisaruthk / gist:fd611bdb564dfa71c247ca6a47ce00bd
Last active September 1, 2020 07:58
string to date excel
dd.mm.yy
to excel date
=DATE("20"&RIGHT(B2,2),MID(B2,4,2),LEFT(B2,2))