Skip to content

Instantly share code, notes, and snippets.

View tvd12's full-sized avatar
💭
Think better, Do better

Ta Van Dung tvd12

💭
Think better, Do better
View GitHub Profile
@tvd12
tvd12 / VideoPoker.zone.xml
Created June 8, 2016 04:23
Support for EzyFox wiki
<zone>
<name>video-poker</name>
<isCustomLogin>true</isCustomLogin>
<isForceLogout>false</isForceLogout>
<applyWordsFilterToUserName>true</applyWordsFilterToUserName>
<applyWordsFilterToRoomName>true</applyWordsFilterToRoomName>
<applyWordsFilterToPrivateMessages>true</applyWordsFilterToPrivateMessages>
<isFilterBuddyMessages>true</isFilterBuddyMessages>
<maxUsers>1000</maxUsers>
<maxUserVariablesAllowed>10</maxUserVariablesAllowed>
@tvd12
tvd12 / rsa.m
Created May 31, 2021 05:05
objective-c: generate rsa key pair
#import <CommonCrypto/CommonCrypto.h>
+ (void)generateKeyPair:(NSUInteger)keySize {
OSStatus sanityCheck = noErr;
SecKeyRef publicKeyRef = NULL;
SecKeyRef privateKeyRef = NULL;
NSData *publicTag = [@"com.apple.sample.privatekey" dataUsingEncoding:NSUTF8StringEncoding];
NSData *privateTag = [@"com.apple.sample.privatekey" dataUsingEncoding:NSUTF8StringEncoding];
@tvd12
tvd12 / dat_async_and_isolate.dart
Last active June 19, 2021 00:55
dart async and isolate
import 'dart:async';
import 'dart:isolate';
import 'dart:io';
Future<void> firstFunc()async{
print('First comment: thread ' + Isolate.current.debugName!);
await Future.delayed(Duration(seconds:2000));
print('Second comment: ' + Isolate.current.debugName!);
}
void secondFunc(){
@tvd12
tvd12 / StringRegex.kt
Created July 1, 2021 14:51
StringRegex.kt
fun main() {
val str = "abc-5xyz-12k-9l--p-9"
val reg = Regex("-\\d")
val matchers = reg.findAll(str)
val numbers = matchers.map {
it.value.toInt()
}
val numberCounts = numbers.groupBy { it }
.map { it.key to it.value.size}
.toMap()
@tvd12
tvd12 / ObjectSortExample.kt
Last active July 4, 2021 11:08
ObjectSortExample
package com.tvd12.kotlin.examples.databinding
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.ObjectMapper
fun main() {
val json = """
[
{
"object":"Book object in json string",
@tvd12
tvd12 / webrtc_client_example.js
Created July 9, 2021 14:31
webrtc client example js
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
window.onbeforeunload = function(e){
hangup();
}
var sendChannel, receiveChannel;
var sendButton = document.getElementById("sendButton");
var sendTextarea = document.getElementById("dataChannelSend");
var receiveTextarea = document.getElementById("dataChannelReceive");
package com.tvd12.example.concurrent.sync;
public class VolatileBooleanExample {
private volatile boolean active;
private static int number;
public void prepare() throws InterruptedException {
new Thread(() -> {
System.out.println("application preparing ...");
Classfile /Users/tvd12/tmp/VolatileBooleanExample.class
Last modified Aug 14, 2021; size 1783 bytes
MD5 checksum df4780a626dc6a9221674f383a9459f2
Compiled from "VolatileBooleanExample.java"
public class VolatileBooleanExample
minor version: 0
major version: 52
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Methodref #20.#41 // java/lang/Object."<init>":()V
using System;
using System.Threading;
using com.tvd12.ezyfoxserver.client.io;
using com.tvd12.ezyfoxserver.client.evt;
using com.tvd12.ezyfoxserver.client.request;
using com.tvd12.ezyfoxserver.client.config;
using com.tvd12.ezyfoxserver.client.setup;
using com.tvd12.ezyfoxserver.client.handler;
using com.tvd12.ezyfoxserver.client.constant;
using com.tvd12.ezyfoxserver.client.entity;
/*
* Copyright 2022 youngmonkeys.org
*
* Licensed under the ezyplatform, Version 1.0.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://youngmonkeys.org/licenses/ezyplatform-1.0.0.txt
*
* Unless required by applicable law or agreed to in writing, software