Skip to content

Instantly share code, notes, and snippets.

import Combine
import UIKit
public protocol CombineCompatible {}
// MARK: - UIControl
public extension UIControl {
final class Subscription<SubscriberType: Subscriber, Control: UIControl>: Combine.Subscription where SubscriberType.Input == Control {
private var subscriber: SubscriberType?
private let input: Control
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@voluntas
voluntas / webrtc.rst
Last active May 14, 2024 10:12
WebRTC コトハジメ
@ljb
ljb / README.md
Last active May 14, 2024 10:09 — forked from PotatoesMaster/fdfmdaemon.py
Using vifm to opening a file directly from the Firefox download manager

Description

A simple daemon implementing freedesktop.org's file manager interface. This interface is used by Firefox download manager to select a downloaded file in the file manager (since Firefox 28).

Paths

The vifm.service file should be put in the ~/.local/share/dbus-1/services directory.

The vifm-service.py file can be put anywhere as long as the same path is used in vifm.service`.

@antonfrancisjeejo
antonfrancisjeejo / index.css
Created February 5, 2024 17:27
For three.js portfolio
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&family=Work+Sans:wght@100;200;300;400;500;600;700;800;900&display=swap");
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--blue-rgb: 237 245 255;
--green-rgb: 125 161 35;
}
@sindresorhus
sindresorhus / esm-package.md
Last active May 14, 2024 10:07
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@swinton
swinton / README.md
Last active May 14, 2024 10:06
Automatically sign your commits from GitHub Actions, using the REST API

Verified commits made easy with GitHub Actions

image

So you want to commit changes generated by a GitHub Actions workflow back to your repo, and have that commit signed automatically?

Here's one way this is possible, using the REST API, the auto-generated GITHUB_TOKEN, and the GitHub CLI, gh, which is pre-installed on GitHub's hosted Actions runners.

You don't have to configure the git client, just add a step like the one below... Be sure to edit FILE_TO_COMMIT and DESTINATION_BRANCH to suit your needs.

@ruanbekker
ruanbekker / tree_style_tab_firefox.md
Created November 28, 2019 06:18
Hide Native Tabs with Tree Style Tabs for Firefox

Describe the network protection controls used by your organization to restrict public access to databases, file servers, and desktop/developer endpoints.

  • Access to the Amazon Aurora database through the network is disabled and standard ports are closed. The database is only accessible through a socket on the server itself.
  • The reverse proxy only serves whitelisted directories that are only from sources controlled by Teecom used (AWS Amplify).
  • API endpoints are password protected (PBKDF2 & SHA512 encryption, salted, and stretched for thousands of rounds).
  • Login credentials are always transmitted securely over SSL.

Describe how your organization individually identifies employees who have access to Amazon Information, and restricts employee access to Amazon information on a need- to-know basis.

  • If all your employees are properly assigned separate users and given only relevant access rights: Access rights are provided to employees based on their role within the company and are progressive, base
#!/usr/bin/python3
import sys
import asyncio
import greenlet
class AsyncIoGreenlet(greenlet.greenlet):
def __init__(self, driver, fn):
greenlet.greenlet.__init__(self, fn, driver)
self.driver = driver