Skip to content

Instantly share code, notes, and snippets.

View zapkub's full-sized avatar
🦄
Doing FINE !

Rungsikorn Rungsikavarnich zapkub

🦄
Doing FINE !
View GitHub Profile
SELECT [PlantFieldModel].[Plant_ID] AS [id], [PlantFieldModel].[Plant_CreateSeasonID] AS [createdSeasonId], [PlantFieldModel].[Plant_Name] AS [name], [PlantFieldModel].[Plant_No] AS [no], [PlantFieldModel].[Plant_Moo] AS [villageNo], [PlantFieldModel].[Plant_SubDistrict] AS [subdistrict], [PlantFieldModel].[Plant_District] AS [district], [PlantFieldModel].[Plant_Province] AS [province], [PlantFieldModel].[Zone_ID] AS [zoneId], [PlantFieldModel].[Plant_Latitude] AS [lat], [PlantFieldModel].[Plant_Longitude] AS [long], [PlantFieldModel].[Plant_AreaRai] AS [areaAsRai], [PlantFieldModel].[Plant_AreaShape] AS [areaFromShape], [PlantFieldModel].[Plant_GeoLocation] AS [geoLocation], [PlantFieldModel].[Quota_ID] AS [quotaId], [PlantFieldModel].[Plant_Created] AS [createdAt], [PlantFieldModel].[Plant_Changed] AS [updatedAt], [PlantFieldModel].[Plant_Creator] AS [createdBy], [PlantFieldModel].[Plant_CreateBy] AS [creatorFullName], CONVERT(varchar(max), [Plant_GeoLocation]) AS [geoLocationParsed], CAST(Plant_CreateDate
@zapkub
zapkub / assessment.ts
Created May 20, 2019 10:12
Assessment API abstraction
import { CommonEntityAttrs } from './default'
// Reference to ./docs/assessment-specs.md
export interface PlantFieldAssessment extends CommonEntityAttrs {
kind: 'PlantFieldAssessment'
plantSeasonId: number
seasonId: number
@zapkub
zapkub / isEmpty.ts
Last active May 19, 2019 04:11
Empty checking with type guard
import { isNull } from 'util'
type Empty = null | undefined | 0 | false | ''
export function IsEmpty<T>(thing: T | undefined | null | 0 | false | ''): thing is Empty {
const undefinedOrNull = typeof thing === 'undefined' || thing === null
if (undefinedOrNull) {
return true
}
declare @p geography = geography::Point(10.5, 10.5, 4326);
SELECT *
FROM (
select Plant_ID,Plant_GeoLocation.STIsValid() as IsSTValid, Plant_GeoLocation.MakeValid().RingN(1).STDistance(@p) as Distance, Plant_GeoLocation as Geolocation from dbo.tb_opr_Plant
WHERE Plant_GeoLocation IS NOT NULL AND Plant_GeoLocation.STIsValid() = 1
) DistanceMeastureFromPoint
WHERE Distance < 1000
interface UserAccount {
id: string
createdAt: Date
name: string
mobileNumber: string
password: string
}
type CreateNewUserAccountInput = Pick<UserAccount, Exclude<keyof UserAccount, 'id' | 'createdAt'>>
export type CreateNewUserAccount = (input: CreateNewUserAccountInput) => UserAccount
interface UserAccount {
id: string
createdAt: Date
name: string
mobileNumber: string
password: string
}
interface CreateUserAccountInput{
name: string
mobileNumber: string
password: string
}
interface CreateUserAccountOutput extends CreateUserAccountInput{
id: string
createdAt: Date
}
@zapkub
zapkub / aws-ecr-credential.go
Last active March 7, 2024 07:52
how to get AWS credential from ECR with golang
/*
* Copyright (c) 2019. Inception Asia
* Maintain by DigithunWorldwide ❤
* Maintainer
* - rungsikorn.r@digithunworldwide.com
* - nipon.chi@digithunworldwide.com
*/
package util
import * as React from 'react'
import Head from "next/head";
export default () => {
return (
<div>
<Head>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
package main
import (
"bufio"
"encoding/json"
"fmt"
"github.com/stellar/go/build"
"github.com/stellar/go/clients/horizon"
"github.com/stellar/go/keypair"
"net/http"