Skip to content

Instantly share code, notes, and snippets.

View rainrisa's full-sized avatar
🏠
Working from home

Ra rainrisa

🏠
Working from home
  • Japan
View GitHub Profile
@uWynell
uWynell / note.md
Last active May 24, 2023 04:49
Telegraf parallel handling

Introduction

Telegraf handles all requests sequentially, one after another. I won't get into details about why it might be done like that by default, but sometimes it's not really what you want.

So I had this problem too. While the bot was handling one heavy command, it could not handle other commands at the same time. Even if they were in different chats. That was quite a problem for me.

I didn't dive inside Telegraf, instead I just came up with a guess and it worked. I'm just sharing my experience, you might need to tweak the code for yourself a little.

Solutions

@marc-x-andre
marc-x-andre / event_emitter.py
Created June 26, 2020 21:23
A event emitter in Python
from typing import Dict
class EventEmitter:
def __init__(self):
self._callbacks: Dict[str, callable] = {}
def on(self, event_name, function):
self._callbacks[event_name] = self._callbacks.get(event_name, []) + [function]
@h4n2k
h4n2k / gist:82ffe7a7ab4097d94c63831ae2cd272b
Created March 24, 2019 03:05
install minikube arch linux
egrep --color 'vmx|svm' /proc/cpuinfo
sudo pacman -Sy libvirt qemu ebtables dnsmasq
sudo usermod -a -G libvirt $(whoami)
newgrp libvirt
sudo systemctl start libvirtd.service
sudo systemctl enable libvirtd.service
sudo systemctl start virtlockd.service
@tanaikech
tanaikech / submit.md
Last active March 20, 2024 04:21
Upload Files to Google Drive using Javascript

Upload Files to Google Drive using Javascript

News

At October 11, 2019, I published a Javascript library to to run the resumable upload for Google Drive. When this is used, the large file can be uploaded. You can also use this js library.

Description

This is a sample script for uploading files to Google Drive using Javascript. The files are uploaded by Drive API v3. gapi.client.drive.files.create() can create an empty file on Google Drive. But it cannot directly upload files including contents. I think that this might not be able to upload files and metadata with the multipart/related, although this might be resolved by the future update. So now, as one of workarounds, I use using XMLHttpRequest.

  • This sample uses gapi.
  • Before you use this, please enable Drive API at API console and carr
// ==UserScript==
// @name Spotify ad skipper
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Detects and skips ads on spotify
// @match https://*.spotify.com/*
// @grant none
// @run-at document-start
// @downloadURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw
// @updateURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw
@paulirish
paulirish / what-forces-layout.md
Last active June 26, 2024 20:47
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
@awidegreen
awidegreen / vim_cheatsheet.md
Last active June 17, 2024 03:41
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close