Skip to content

Instantly share code, notes, and snippets.

@aishikaty
aishikaty / tiny-view-libraries.md
Last active May 14, 2024 06:03
Tiny JavaScript UI

☀️ UI Libraries

  • redom (1.6k) - Tiny turboboosted JavaScript library for creating user interfaces
  • frzr (1.6k) - Turboboosted 2 KB view library for browser & node.js
  • killroy (1.9k) - A tiny ui library inspired by React
  • real-dom (0.7k) - A ~1K non-virtual DOM non-framework framework for simple apps
  • domchanger (1.8k) - Dombuilder that applies diffs only to the real dom
  • vomit (3.2k) - A high order function using virtual dom to build user interfaces
  • bel (3.5k) - A simple library for composable DOM elements using tagged template strings
  • yo-yo (5.4k) - A tiny library for building modular UI components using DOM diffing and ES6 tagged template literals (build on bel)
  • [choo](https://github.com/yos
@venam
venam / pw-setvol.sh
Last active May 14, 2024 06:03
Set PipeWire volume natively on the default sink
#! /bin/sh
# the metadata only contains the name of the default sink
default_sink_name=$(pw-metadata 0 'default.audio.sink' | grep 'value' | sed "s/.* value:'//;s/' type:.*$//;" | jq .name)
default_sink_id=$(pw-dump Node Device | jq '.[].info.props|select(."node.name" == '" $default_sink_name "') | ."object.id"')
current_volume=$(pw-cli enum-params "$default_sink_id" 'Props' | grep -A 2 'Spa:Pod:Object:Param:Props:channelVolumes' | awk '/Float / {gsub(/.*Float\s/," "); print $1^(1/3) }')
change="${1:-0.1}" # defaults to increment of 0.1
new_volume=$(echo "$current_volume $change" | awk '{printf "%f", $1 + $2}')
# we need to reconvert to cubic root
#new_volume_cube=$(echo "$new_volume" | awk '{ print $1^3 }')

Working with EET Files

This is my edited version of Jeff Hoogland's original article on the eet command. It is posted here because it is hard to find online as the original link is now dead and not even found in the Wayback Machine.

One of the things that allow the Enlightenment Foundation Libraries to be as fast and efficient as they are in their use of compiled files for storing information. While these compiled files are fast, the drawback to using them is that there is some difficulty when you want to manually access/edit the data these files contain. Today I am going to talk about how we can gain access to the data contained in compiled Enlightenment Foundation Library EET data files.

EET files are binary data files that generally hold configuration options/settings for applications. To work with these files we will need acce

@sindresorhus
sindresorhus / esm-package.md
Last active May 14, 2024 06:01
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.
@ryancdotorg
ryancdotorg / dnaas.c
Created October 30, 2013 23:20
Wrapper library to use /dev/null as a service on Linux via LD_PRELOAD
/* This is a wrapper library that will give your server the power of
* /dev/null as a service, as seen at http://devnull-as-a-service.com/
*
* Compile:
* gcc -ggdb -shared -fPIC dnaas.c -ldl -lcurl -o libdnaas.so
*
* Try:
* LD_PRELOAD=./libdnaas.so dd if=/dev/sda of=/dev/null bs=8192 count=16
*
* Install:
@kuroski
kuroski / camelCase-snake_case-types.ts
Last active May 14, 2024 05:56
Typescript type camelCase / snake_case conversion
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}`
? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}`
: Lowercase<S>
type KeysToCamelCase<T> = {
[K in keyof T as CamelCase<string & K>]: T[K]
}
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ?
@ukyo
ukyo / README.md
Last active May 14, 2024 05:55
maincontent取るくん

Install and Build and Screenshot.

git clone https://gist.github.com/906764beb36481301405c586abd81011.git
cd 906764beb36481301405c586abd81011
npm install
npm run build
npm run screenshot https://gist.github.com/ukyo/906764beb36481301405c586abd81011
open out.html
@taoyuan
taoyuan / generate_self_signed_certification.md
Last active May 14, 2024 05:48
Generation of a Self Signed Certificate

Generation of a Self Signed Certificate

Generation of a self-signed SSL certificate involves a simple 3-step procedure:

STEP 1: Create the server private key

openssl genrsa -out cert.key 2048

STEP 2: Create the certificate signing request (CSR)

openssl req -new -key cert.key -out cert.csr
@taocao
taocao / longest_chinese_tokens_gpt4o.py
Created May 14, 2024 05:48 — forked from ctlllll/longest_chinese_tokens_gpt4o.py
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:
@younesbelkada
younesbelkada / finetune_llama_v2.py
Last active May 14, 2024 05:46
Fine tune Llama v2 models on Guanaco Dataset
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# 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