Skip to content

Instantly share code, notes, and snippets.

View BYK's full-sized avatar
🔦
Helping engineers help themselves help us all

Burak Yigit Kaya BYK

🔦
Helping engineers help themselves help us all
View GitHub Profile
@BYK
BYK / libwindows.py
Last active August 6, 2019 03:51
sudo for Python 3 on Windows
'''
This file is based on the code from https://github.com/JustAMan/pyWinClobber/blob/master/win32elevate.py
Copyright (c) 2013 by JustAMan at GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
@BYK
BYK / script.js
Created May 20, 2021 08:02
A simple async mutex implementation
let locks = [];
const fn = async () => {
let resolve;
locks.push(new Promise(r => (resolve=r)));
let lock;
while (locks.length > 1 && (lock = locks.shift()))
await lock;
console.log(new Date());
setTimeout(resolve, 1000);
@BYK
BYK / GHAPILanguageStats.js
Created July 11, 2011 07:42
Get language stats of your GitHub
window.getLangStats = function getLangStats(repos) {
var mapper = function(ent){return ent.language},
reducer = function(stats, lang) {stats[lang] = (stats[lang] || 0) + 1; return stats},
langStats = repos.map(mapper).reduce(reducer, {});
delete langStats['null'];
return Object.keys(langStats).sort(function(a,b){return langStats[b] - langStats[a]});
};
window.ghApiCallHandler = function(result) {
if (Math.floor(result.meta.status/100) == 2)