Skip to content

Instantly share code, notes, and snippets.

View gblazex's full-sized avatar

Blaze (Balázs Galambosi) gblazex

View GitHub Profile
@gblazex
gblazex / contrastive.js
Last active July 9, 2024 11:55 — forked from jph00/contrastive.js
Chrome tampermonkey helper for the elderly
// ==UserScript==
// @name Keyboard Shortcut Scripts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Run scripts with keyboard shortcuts
// @match *://*/*
// @grant none
// ==/UserScript==
// Parameters
@andrewyu0
andrewyu0 / obsidian-copilot.md
Last active February 19, 2025 11:07
obsidian-copilot

obsidian copilot

your notes = your lifelong ai companion + intelligence augmentation

COMMENTS VERY WELCOME! this is a first pass to put these ideas in one place

tldr - combine obsidian + openinterpreter to create a bespoke pkm copilot experience. if you follow the "file over app" philosophy, this combination can be your lifetime AI companion

image
@amrrs
amrrs / avoid_colab_close.js
Created August 17, 2021 20:02
How to avoid Google Colab Session Closing automatically?
//credit - https://huggingface.co/blog/fine-tune-wav2vec2-english (Patrick von Platen)
// run this on your Chrome / Browser Console (where Colab is present)
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
var colab = setInterval(ConnectButton,60000);
function toBaseN(num, base) {
if (num === 0) {
return '0';
}
var digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var len = Math.min(digits.length, base);
var result = '';
while (num > 0) {
result = digits[num % len] + result;
num = parseInt(num / len, 10);
@gblazex
gblazex / promise_preferred.js
Created November 22, 2016 21:37
Promise.preferred
// Promises are started in parallel.
// Resolves with the first resolved value in array order.
// If there's no winner, it rejects with last rejection.
Promise.preferred = function (promisesOrdered) {
return new Promise((resolve, reject) => {
var resolvedValues = new WeakMap();
var resolvables = promisesOrdered.slice(); // copy
function onMemberResolved(value, member) {
resolvedValues.set(member, value);
if (member == resolvables[0])
@MarkHerhold
MarkHerhold / generators-vs-asyncawait.js
Last active September 4, 2017 18:47
Generators VS Async/Await Performance
//
// Simple generator (with co) VS async/await benchmark
// Article: https://medium.com/p/806d8375a01a
//
const co = require('co');
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite;
// add tests
@gblazex
gblazex / promise_any.js
Last active November 22, 2016 21:37
Promise.any
// Promises are started in parallel.
// Resolves with the first resolved value in time.
// If there's no winner, it rejects with last rejection.
Promise.any = function (promises) {
return new Promise((resolve, reject) => {
var rejectedCount = 0;
function onMemberResolved(value) {
resolve(value);
}
function onMemberRejected(reason) {
@gblazex
gblazex / BLZLabelWithInset.h
Created March 4, 2016 10:33
BLZLabelWithInset - simple UILabel subclass with inset
@interface BLZLabelWithInset : UILabel
@property (nonatomic) UIEdgeInsets insets;
@end
@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2025 09:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
public struct Error: ErrorType {
let source: String; let reason: String
public init(_ source: String = __FILE__, _ reason: String) {
self.reason = reason; self.source = source
}
}
protocol Contextualizable {}
extension Contextualizable {
func functionContext(function : String = __FUNCTION__) -> String {