Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
wisaruthk / simplex.swift
Last active December 30, 2022 04:17
simplex method coding in swift (by ChatGPT)
struct LinearProgram {
let objective: [Double]
let constraints: [[Double]]
let sense: [Character]
let rhs: [Double]
}
func simplex(lp: LinearProgram) -> [Double]? {
var tableau = lp.constraints
tableau.append(lp.objective)
@wisaruthk
wisaruthk / graph cache modify
Created August 12, 2021 13:26
apollo graph cache modify
const onSubmit = (values) => {
console.log(ingredient, values);
cache.modify({
id:cache.identify(ingredient),
fields: {
rcpNutrients(existNts, {readField}){
const index = existNts.findIndex(el => ingdNutrient.id === readField("id",el));
const newNts = [...existNts];
newNts[index] = {
@wisaruthk
wisaruthk / custage.sql
Created April 8, 2021 10:25
Crystal Report Command , SAP HANA, Semantic Parameter as Date (Create DateTo@ Parameter as Date in CR)
DO BEGIN
DECLARE varDateTo VARCHAR(10);
varDateTo := {?DateTo@};
tbResult =
SELECT T0.*
FROM "_SYS_BIC"."sap.{?Package@}.ar.case/CustomerReceivableAgingFact"
(PLACEHOLDER."$$P_AgingDate$$" => :varDateTo) T0;
@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))
@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 / SAPB1-QueryFromSemanticLayer.sql
Created July 19, 2020 08:13
SAPB1-QueryFromSemanticLayer
SELECT * FROM _SYS_BIC."sap.db1.stock/InventoryTransactionDocumentsQuery";
@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 / 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 / .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
$( "#form-memberRegister" ).validate( {
errorClass: "error",
rules: {
"formatted-citizenID": {
required:true,
remote:{
url: "action/checkCitizenID",
type: "post",
dataType:'json',
data: {