Skip to content

Instantly share code, notes, and snippets.

View Kamandlou's full-sized avatar
💭
I may be slow to respond.

Amir Hossein Kamandlou Kamandlou

💭
I may be slow to respond.
View GitHub Profile
@Kamandlou
Kamandlou / gorm.go
Created May 10, 2023 09:09
Set timeout for sql query in GORM
// It will cancel at one second
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
db.WithContext(ctx).Find(&User)
@Kamandlou
Kamandlou / github.gif
Last active March 18, 2023 12:39
github
github.gif
@Kamandlou
Kamandlou / auth-bypass.sql
Created February 23, 2023 19:56
SQL Injection Payloads
'-'
' '
'&'
'^'
'*'
' or ''-'
' or '' '
' or ''&'
' or ''^'
' or ''*'
@Kamandlou
Kamandlou / main.js
Created November 3, 2022 09:10
Split array into chunks
const chunkSize = 10;
for (let i = 0; i < array.length; i += chunkSize) {
let chunk = array.slice(i, i + chunkSize);
}
@Kamandlou
Kamandlou / mysql.sql
Created November 3, 2022 09:06
Insert into a MySQL table or update if exists
INSERT INTO t1 (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
@Kamandlou
Kamandlou / main.go
Created May 25, 2022 11:29
Golang numerics types
type Numerics interface {
uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64 | float32 | float64
}
bool
string
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
byte // alias for uint8
rune // alias for int32
@Kamandlou
Kamandlou / main.js
Created April 28, 2022 13:11
Get Persian local time
(new Date()).toLocaleTimeString('fa-IR')
uint8 : 0 to 255
uint16 : 0 to 65535
uint32 : 0 to 4294967295
uint64 : 0 to 18446744073709551615
int8 : -128 to 127
int16 : -32768 to 32767
int32 : -2147483648 to 2147483647
int64 : -9223372036854775808 to 9223372036854775807
@Kamandlou
Kamandlou / composer.json
Created February 22, 2022 10:29
for develop laravel custom package
"repositories": [
{
"type": "path",
"url": "../laravel-custom-package",
"options": {
"symlink": true
}
}
]