Skip to content

Instantly share code, notes, and snippets.

View KiT106's full-sized avatar

Dzung KiT KiT106

View GitHub Profile
@KiT106
KiT106 / async-await.py
Created October 28, 2017 17:44
generator vs. coroutines vs. async/await
import asyncio
async def compute(x, y):
print("Compute %s + %s ..." % (x, y))
await asyncio.sleep(1.0)
return x + y
async def print_sum(x, y):
result = await compute(x, y)
print("%s + %s = %s" % (x, y, result))
@KiT106
KiT106 / win10colors.cmd
Created March 29, 2017 09:37 — forked from mlocati/win10colors.cmd
ANSI Colors in standard Windows 10 shell
@echo off
cls
echo  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
@KiT106
KiT106 / admin.cmd
Created March 28, 2017 04:46
Check Administrator PRIVILEGES
@rem ----[ This code block detects if the script is being running with admin PRIVILEGES If it isn't it pauses and then quits]-------
echo OFF
NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
ECHO Administrator PRIVILEGES Detected!
) ELSE (
echo ######## ######## ######## ####### ########
echo ## ## ## ## ## ## ## ## ##
echo ## ## ## ## ## ## ## ## ##
echo ###### ######## ######## ## ## ########
@KiT106
KiT106 / dir.cmd
Created March 28, 2017 04:04
Check directory in Windows batch
@echo off
echo %~1
::::::::::::::::::: has argument ? :::::::::::::::::::
IF ["%~1"]==[""] (
echo Missing argument!!!
echo Syntax:
echo setup ^<main_repo^>
exit /B 1;
@KiT106
KiT106 / bash-color.sh
Created March 20, 2017 10:11
Color terminal
##### Color table #####
# Black 0;30 Dark Gray 1;30
# Red 0;31 Light Red 1;31
# Green 0;32 Light Green 1;32
# Brown/Orange 0;33 Yellow 1;33
# Blue 0;34 Light Blue 1;34
# Purple 0;35 Light Purple 1;35
# Cyan 0;36 Light Cyan 1;36
# Light Gray 0;37 White 1;37
if test -t 1; then # if terminal
@KiT106
KiT106 / customValidationMessage.js
Created February 4, 2017 19:15
HTML form custom validation message
$("input").on("invalid", function(e) {
if (this.validity.valueMissing){
this.setCustomValidity("valueMissing");
}
if (this.validity.tooShort){
this.setCustomValidity("tooShort");
}
// .... more custom message here.
});
$("input").on("input", function(e) {
@KiT106
KiT106 / main.js
Created October 22, 2016 10:31
AngularJS $routeProvider.resolve
var app = angular.module("app", ["ngRoute"]);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: "app.html",
controller: "ViewCtrl",
resolve: {
first: function () {
return "Hello world";
@KiT106
KiT106 / index.html
Created October 21, 2016 10:43
AngularJS : 2 controllers inside a scope
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>Egghead Videos</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/6.2.4/foundation.css">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body ng-app="app" scope="{{$id}}">
ALTER TABLE revinfo
AUTO_INCREMENT = 3;
INSERT INTO revinfo
(REV, REVTSTMP)
VALUES (2, 146613965300);
UPDATE revinfo
SET REV = REV + 1
WHERE REVTSTMP > 1466139651507
/**
* @file A sample file demo about JSDoc
* @author dungdm93
* @since 2016-05-26
*/
/**
* Person entity class
* @class
*/