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 / HomeController.java
Last active April 10, 2024 06:45
Luatvicca HomeController
package vn.luatvicca.website.web.controller.view;
import static org.youngmonkeys.ezyplatform.constant.CommonConstants.VIEW_VARIABLE_PAGE_TITLE;
import com.tvd12.ezyfox.collect.Lists;
import com.tvd12.ezyfox.util.EzyMapBuilder;
import com.tvd12.ezyhttp.server.core.annotation.DoGet;
import com.tvd12.ezyhttp.server.core.view.View;
public class HomeController {
2024-01-19 16:01:43.982 [qtp1071783182-87] WARN c.t.e.s.jetty.JettyBlockingServlet handle request uri: /login error
java.lang.IllegalStateException: can not generate access token for admin id: 1
at org.youngmonkeys.ezyplatform.util.AccessTokens.generateAccessToken(AccessTokens.java:46)
at org.youngmonkeys.ezyplatform.service.DefaultAdminAccessTokenService.generateAccessToken(DefaultAdminAccessTokenService.java:60)
at org.youngmonkeys.ezyplatform.admin.service.AdminAdminService.newAdminAccessToken(AdminAdminService.java:508)
at org.youngmonkeys.ezyplatform.admin.service.AdminAdminService.getOrCreateAccessTokenByAdminId(AdminAdminService.java:198)
at org.youngmonkeys.ezyplatform.admin.controller.view.AdminAuthenticationController.doPost(AdminAuthenticationController.java:158)
at AdminAuthenticationController$doPost$Handler$AutoImpl$71.handleRequest(AdminAuthenticationController$doPost$Handler$AutoImpl$71.java)
at com.tvd12.ezyhttp.server.core.handler.AbstractRequestHandler.handle(AbstractRequestHandler.
@tvd12
tvd12 / findinidata_one.cpp
Created May 8, 2023 10:32
findinidata_one.cpp
CCTexture2D *Kgetinidata::findinidata_one(char *nFileName,int nFrameIndex,int *mCurwidth, int *mCurheight,int *mFrams,SPRFRAMSINFO *nSprInfo,int m_converType)
{
if (!nFileName || !nFileName[0])
return NULL;
if (!strstr(nFileName,".spr"))
return NULL;
@tvd12
tvd12 / qrcode_generator.py
Last active April 28, 2023 00:54
qrcode_generator.py
import qrcode
def generate_check_sum(text):
crc = 0xFFFF # initial value
polynomial = 0x1021 # 0001 0000 0010 0001 (0, 5, 12)
bytes_ = text.encode("utf-8")
for b in bytes_:
for i in range(8):
bit = ((b >> (7 - i) & 1) == 1)
c15 = ((crc >> 15 & 1) == 1)
@tvd12
tvd12 / clone_with_mirrors.dart
Last active April 5, 2023 09:12
Design Patterns
import 'dart:mirrors';
class A {
late String a;
A clone() {
var instance = reflect(this);
var newInstance = reflect(this).type.newInstance(
Symbol.empty,
[]
@tvd12
tvd12 / OcTreeExample.java
Created December 14, 2022 04:24
Simple OcTree
package com.tvd12.example;
import java.util.Arrays;
import lombok.AllArgsConstructor;
public final class OcTreeExample {
public static class OcTree {
public final OcTreeNode root;
/*
* 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
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;
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
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 ...");