Skip to content

Instantly share code, notes, and snippets.

View vilicvane's full-sized avatar
🌏

vilicvane vilicvane

🌏
View GitHub Profile
@vilicvane
vilicvane / settings.json
Last active April 16, 2016 05:26
VS Code settings
{
"window.zoomLevel": -0.5,
"editor.insertSpaces": true,
"editor.folding": false,
"files.autoSave": "afterDelay",
"files.trimTrailingWhitespace": true,
"files.eol": "\n",
@vilicvane
vilicvane / snake.html
Created September 9, 2015 15:47
Snake game written on Nokia 6120c in 2009
<body></body>
<script>
try{
var w=20, h=20;
var s=10;
var t=2500;
var sl=5;
var lx=1, ly=0;
var ax=1, ay=0;
@vilicvane
vilicvane / ip-info.ts
Last active August 29, 2015 14:27
Node.js. Get server IPs (v4) information (WAN/LAN IPs).
/*
Server IP Information Utils
by VILIC VANE <https://github.com/vilic>
MIT License
*/
import * as OS from 'os';
export interface IPInfo {
lanIP: string;
@vilicvane
vilicvane / cargo-shell.js
Last active April 13, 2020 22:56
Show rust build errors in Visual Studio Code.
var ChildProcess = require('child_process');
var task = process.argv[2];
var cargo = ChildProcess.exec('cargo ' + task);
cargo.stdout.on('data', function (data) {
process.stdout.write(data);
});
@vilicvane
vilicvane / lexer.ts
Last active February 19, 2020 09:58
A lexer (behave like Angular expression lexer) written with the help of regular expression.
/**
* A test using regular expression for lexing
* by vilicvane<https://vilic.github.io/>
*
* It turns out to be 50% faster comparing to original Angular lexer before JIT Compilation, but 50% slower then (in Chrome).
* And only 1/3 of the original lexer counting the core code lines.
* Though it's because the regular expressions are doing most of the work.
*
* Note: The regular expression and related enum declaration are managed by https://github.com/vilic/regex-tools/.
*/
@vilicvane
vilicvane / format-number.js
Last active August 29, 2015 14:12
Format number with leading zeros
// relatively safe
function formatSafely(num, digits) {
return (Array(digits).join('0') + Math.floor(num)).substr(-digits);
}
// or quick
function formatQuickly(num, digits) {
return (Array(digits).join('0') + num).substr(-digits);
}