Skip to content

Instantly share code, notes, and snippets.

View cyrusfirheir's full-sized avatar
👾
npm i -g common-sense

Cyrus Firheir cyrusfirheir

👾
npm i -g common-sense
  • India
  • 04:53 (UTC +05:30)
View GitHub Profile
@cyrusfirheir
cyrusfirheir / nvmlink
Created April 21, 2024 19:41 — forked from MeLlamoPablo/nvmlink
Creates a symlink to /usr/bin/node after using nvm
@cyrusfirheir
cyrusfirheir / .svg-image-map-tutorial.md
Last active April 9, 2024 02:11
Easy, Interactive, and Scalable Image Maps using SVGs

Easy, Interactive, and Scalable Image Maps using SVGs

Requirements

  • A vector art program which can export SVGs (eg. Adobe Illustrator, Inkscape, Affinity Designed, Figma, Krita, etc.)
  • An image to make the map on. This does not have to be vector.

Steps

@cyrusfirheir
cyrusfirheir / convert.py
Last active November 14, 2022 10:25
Converts Tensorflow checkpoints to FP16 Huggingface Diffusers
# coding=utf-8
# Copyright 2022 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@cyrusfirheir
cyrusfirheir / index.html
Last active September 21, 2022 18:19
Canvas drawing input for img2img and inpainting (Stable Diffusion) generation.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
@cyrusfirheir
cyrusfirheir / dragToScroll.js
Created August 18, 2021 14:40
Drag element to scroll
(function () {
"use strict";
jQuery.fn.extend({
dragToScroll({ horizontal = true, vertical = true } = {}) {
const position = { top: 0, left: 0, x: 0, y: 0 };
const element = this.get(0);
function downHandler({ clientX, clientY }) {
@cyrusfirheir
cyrusfirheir / smartquotes.js
Last active August 24, 2021 12:20
Converts dumb quotes (" ') to smart (“ ” ‘ ’) ones.
// Adapted from `smartquotes.js` at https://github.com/kellym/smartquotes.js
// LICENCE: https://github.com/kellym/smartquotes.js/blob/master/LICENSE
if (!String.prototype.smartQuotes) {
Object.defineProperty(String.prototype, 'smartQuotes', {
configurable: true,
writable: true,
value: function smartQuotes() {
return this
.replace(/'''/g, '\u2034')
.replace(/(\W|^)"(\S)/g, '$1\u201c$2')
@cyrusfirheir
cyrusfirheir / branch.js
Created September 2, 2020 12:46
SugarCube 2 - Branch out of the State system to create a snapshot for later use
(function() {
"use strict";
Macro.add("branch", {
handler() {
let id = this.args[0];
let list = this.args.slice(1);
variables()["#macro-branch"] = variables()["#macro-branch"] || {};
variables()["#macro-branch"][id] = variables()["#macro-branch"][id] || {};
@cyrusfirheir
cyrusfirheir / hold-down.js
Last active July 29, 2020 04:39
jQuery extension which adds a 'click/tap and hold' handler - For SugarCube 2
(function () {
"use strict";
jQuery.fn.extend({
holdDown: function holdDown(duration, handler) {
if (this.length === 0 || arguments.length === 0) return this;
if (arguments.length === 1) {
handler = arguments[0];
duration = 1000;
@cyrusfirheir
cyrusfirheir / timer.js
Last active July 5, 2020 11:32
Timers with Pause/Resume/Reset
window.Timer = function(callback, duration = 500) {
if (!callback) return;
this.callback = callback;
this.duration = duration;
this.remaining = duration;
this.resume();
};
Timer.prototype.resume = function() {
this.start = new Date();