Skip to content

Instantly share code, notes, and snippets.

View antfu's full-sized avatar

Anthony Fu antfu

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace Utils
{
public sealed class KeyboardHook : IDisposable
@antfu
antfu / MathConverter.cs
Created March 23, 2017 17:30
[WPF] BindingMathConverter
// Does a math equation on the bound value.
// Use @VALUE in your mathEquation as a substitute for bound value
// Operator order is parenthesis first, then Left-To-Right (no operator precedence)
public class MathConverter : IValueConverter
{
private static readonly char[] _allOperators = new[] { '+', '-', '*', '/', '%', '(', ')' };
private static readonly List<string> _grouping = new List<string> { "(", ")" };
private static readonly List<string> _operators = new List<string> { "+", "-", "*", "/", "%" };
@antfu
antfu / hotel.vbs
Created July 1, 2017 18:27
Hotel startup script
CreateObject("Wscript.Shell").Run "cmd /c """"C:\Program Files\nodejs\node.exe"" ""C:\Users\Antho\AppData\Roaming\npm\node_modules\hotel\lib\daemon"" > ""C:\Users\Antho\.hotel\daemon.log""""", 0, true
@antfu
antfu / requestAnimationFrame.js
Created May 21, 2018 08:17
requestAnimationFrame Pollyfile
window.requestAnimationFrame = (function () {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
function closest(num, arr) {
let idx = 0
let curr = arr[idx]
let diff = Math.abs(num - curr);
for (var val = 0; val < arr.length; val++) {
var newdiff = Math.abs(num - arr[val])
if (newdiff < diff) {
diff = newdiff
curr = arr[val]
idx = val
@antfu
antfu / swap.md
Created April 11, 2019 22:45
Create swap
@antfu
antfu / semantic-commit-messages.md
Created April 19, 2019 17:25 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@antfu
antfu / 📊 Weekly development breakdown
Last active November 20, 2023 10:25
📊 Weekly development breakdown
TypeScript 21 hrs 47 mins ████████████████▒░░░ 67.1%
Vue.js 6 hrs 21 mins ██████▓░░░░░░░░░░░░░ 19.6%
JSON 2 hrs 10 mins ████▒░░░░░░░░░░░░░░░ 6.7%
JavaScript 46 mins ███▒░░░░░░░░░░░░░░░░ 2.4%
@antfu
antfu / resume.json
Last active November 28, 2023 17:15
{
"basics": {
"name": "Anthony Fu",
"picture": "https://antfu.me/avatar.png",
"label": "Software Engineer",
"headline": "A ship in harbor is safe, but that is not what ships are built for.",
"summary": "My name is Anthony Fu, a master of computer science student and a freelance software engineer. My passion for software lies with dreaming up ideas and making them come true with elegant interfaces. I take great care in the experience, architecture, and code quality of the things I build.\n\nI am also an open-source enthusiast and maintainer. I love how collaboration and knowledge sharing happens through open-source and I am happy to see what I do could eventually feedback to the community and industry.",
"website": "https://antfu.me",
"address": "",
"projects_url": "https://antfu.me/projects",