Skip to content

Instantly share code, notes, and snippets.

"use client";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"; //shadcn ui folder
@laocoi
laocoi / vietnamese-slug.js
Last active January 19, 2025 10:05
Create Vietnamese slug from string - Javascript
function slugify(string){
const a = 'àáäâãåăæąçćčđďèéěėëêęğǵḧìíïîįłḿǹńňñòóöôœøṕŕřßşśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;'
const b = 'aaaaaaaaacccddeeeeeeegghiiiiilmnnnnooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/á|à|||ã|ă||||||â|||||/gi, 'a')
.replace(/é|è||||ê|ế||||/gi, 'e')
.replace(/i|í|ì||ĩ|/gi, 'i')
.replace(/ó|ò||õ||ô||||||ơ|||||/gi, 'o')
.replace(/ú|ù||ũ||ư|||||/gi, 'u')
@aderusha
aderusha / link_multiple_devices.yaml
Created September 12, 2022 21:19
Select multiple entities to link their on/off state. If any selected entity is turned on or off, the other selected entities will be sent a matching on or off command.
@CHIZI-0618
CHIZI-0618 / PuerNya_sing-box_fakeip_client_config.jsonc
Last active January 19, 2025 10:00
sing-box 带有 Proxy Providers 的客户端配置示例
{
"log": {
"level": "info",
"output": "sing-box.log",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "cloudflare",
@brettwold
brettwold / PdfPrint.java
Last active January 19, 2025 09:59
How to save a PDF from any Android WebView
package android.print;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import java.io.File;
public class PdfPrint {
@dkartachov
dkartachov / disable_wakeup_events.md
Last active January 19, 2025 09:58
Disable USB wakeup events on Linux

Disable USB wakeup events on Linux

I'm almost certain these steps will work on most distros but I've only been able to test on Linux Mint 21. Feel free to test on your own distros and add to the list :)

Tested on:

  • Linux Mint 21

Steps

  1. Run lsusb and lsusb -t to identify USB devices and what Bus/Port they are connected to
  2. Let's say you've identified Bus 1 -> Port 13 -> Port 1 in the listed tree, run:

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
@nandorojo
nandorojo / provider.native.tsx
Last active January 19, 2025 09:56
Next.js / Solito canGoBack()
// this won't ever get imported on native, but we put this file here to make that clear
export default ({children}) => children
@halfelf
halfelf / how_to_build_a_fast_limit_order_book.md
Created February 11, 2019 02:18
How to Build a Fast Limit Order Book

https://web.archive.org/web/20110219163448/http://howtohft.wordpress.com/2011/02/15/how-to-build-a-fast-limit-order-book/

The response to my first few posts has been much larger than I’d imagined and I’d like to thank everyone for the encouragement.

If you’re interested in building a trading system I recommend first reading my previous post on general ideas to keep in mind.

My first really technical post will be on how to build a limit order book, probably the single most important component of a trading system. Because the data structure chosen to represent the limit order book will be the primary source of market information for trading models, it is important to make it both absolutely correct and extremely fast.

To give some idea of the data volumes, the Nasdaq TotalView ITCH feed, which is every event in every instrument traded on the Nasdaq, can have data rates of 20+ gigabytes/day with spikes of 3 megabytes/second or more. The individual messages average about 20 bytes each so this means handling

@deniska
deniska / AndroidManifest.xml
Created July 13, 2024 13:16
Example of building raylib app for android
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" package="org.example.pongpong">
<uses-sdk android:minSdkVersion="29"
android:targetSdkVersion="29" />
<uses-permission android:name="android.permission.SET_RELEASE_APP"/>
<application android:debuggable="true" android:hasCode="false" android:label="PongPong" tools:replace="android:icon,android:theme,android:allowBackup,label" android:icon="@mipmap/icon">
<activity android:configChanges="keyboardHidden|orientation" android:label="PongPong" android:name="android.app.NativeActivity" android:exported="true">
<meta-data android:name="android.app.lib_name" android:value="pongpong"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>