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
package com.company;
// สร้างโปรแกรมที่สามารถ วาด * ออกมาเป็นรูป เลขาคณิต 3 แบบ
// - สี่เหลี่ยมจตุรัส
// - สามเหลี่ยม
// - ข้าวหลามตัด
// โดยที่มี input เป็น int ที่ 0 < n < 20
class Shape {
package com.company;
class GameObject {
// Coordinate
public int x;
public int y;
// Dimension
public int width;
public int height;
}
@zapkub
zapkub / day1.js
Last active March 21, 2021 04:42
Code From Zero Day1 assignment
// Assignment A. ทำโปรแกรมตัดเกรด โดย Input เป็น Number
// output เป็น ตัวอักษตัวเดียว A, B, C หรือ D
// โดยที่
// 80 - 100 = A
// 70 - 79 = B
// 60 - 69 = C
// 50 - 59 = D
@zapkub
zapkub / mathstr.go
Created August 13, 2020 14:10
math strategy example
package main
import "fmt"
// strategy: square, factorial, absolute
// input : integer
// output : integer
type MathStrategy interface {
assert(strategyType string) bool
import { BehaviorSubject, Subject, Observable, of, interval } from 'rxjs';
import { delay, map, take, tap, timeout } from 'rxjs/operators';
function PostLogin(): Observable<number> {
return interval(1000).pipe(take(1), map(() => 200));
}
class LoginService {
@zapkub
zapkub / get-back-my-focus-no-mad.sh
Last active April 2, 2020 08:00
Bring back your frontmost application in macOS after NoMAD try to steal it🤖 ( make sure you do chmod +x before execute )
#!/usr/bin/python
try:
from AppKit import NSWorkspace, NSApplicationActivateIgnoringOtherApps
except ImportError:
print "Can't import AppKit -- maybe you're running python from brew?"
print "Try running with Apple's /usr/bin/python instead."
exit(1)
from datetime import datetime
from time import sleep
package main
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"net/http"
"strconv"
"time"
@zapkub
zapkub / fake-random.go
Created November 19, 2019 03:28
Another appoarch of fake type
type Random interface {
Number(min, max int) int
String(char []byte) string
}
type FakeRandomPreparer struct {
}
func (f *FakeRandomPreparer) NumberAllAny() {
SELECT [PlantSeason].[PlantSeason_ID] AS [id], [PlantSeason].[PlantSeason_Active] AS [active], [PlantSeason].[PlantSeason_Changed] AS [updatedAt], [PlantSeason].[PlantSeason_Created] AS [createdAt], [PlantSeason].[PlantSeason_Changer] AS [updatedBy], [PlantSeason].[PlantSeason_NewSurvey] AS [newSurvey], [PlantSeason].[PlantSeason_BonsucroProj] AS [bonsucroProj], [PlantSeason].[PlantSeason_LoanSeason] AS [loanSeasonName], [PlantSeason].[Season_ID] AS [seasonId], [PlantSeason].[PlantSeason_BonsucroArea] AS [bonsucroArea], [PlantSeason].[PlantSeason_PlantingDate] AS [plantingDate], [PlantSeason].[PlantSeason_HarvestDate] AS [harvestDate], [PlantSeason].[PlantSeason_SurveyVolumn] AS [surveyVolumn], [PlantSeason].[PlantSeason_SurveyBy] AS [surveyBy], [PlantSeason].[PlantSeason_ApproveDate] AS [approveDate], [PlantSeason].[PlantSeason_ApproveBy] AS [approveBy], [PlantSeason].[PlantSeason_ClosePlantDate] AS [closePlantDate], [PlantSeason].[PlantSeason_ClosePlantBy] AS [closePlantBy], [PlantSeason].[Plant_ID] AS [pla
SELECT [Plant_ID] AS [id], [Plant_Active] AS [active], [Plant_Changed] AS [updatedAt],
[Plant_Created] AS [createdAt], [Plant_Changer] AS [updatedBy], [Plant_No] AS [no], [Plant_Name] AS [name],
[Plant_Moo] AS [moo], [Plant_District] AS [district], [Plant_Province] AS [province],
[Plant_SubDistrict] AS [subdistrict], [Plant_Latitude] AS [lat], [Plant_Longitude] AS [long],
[Plant_AreaRai] AS [areaAsRai], [Plant_AreaShape] AS [areaFromShape], [Quota_ID] AS [quotaId],
[Plant_CreateBy] AS [createdBy], [Plant_GeoLocation] AS [geoLocation], CONVERT(varchar(max),
[Plant_GeoLocation]) AS [geoLocation] FROM [tb_opr_Plant] AS [Plant]
WHERE [Plant].[Plant_Active] = 1 ORDER BY [Plant].[Plant_ID] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;