Skip to content

Instantly share code, notes, and snippets.

@alexlipa91
alexlipa91 / Server.scala
Created November 16, 2019 01:48
multi-client chat with java sockets
import java.io.PrintWriter
import java.net.{ServerSocket, Socket}
import scala.concurrent.Future
import java.io.BufferedReader
import java.io.InputStreamReader
import scala.collection.mutable
class Server(port: Int) {
@ruvnet
ruvnet / *notepad.ipynb
Last active May 14, 2024 07:44
*metaprompt.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@f-steff
f-steff / excel formulas.md
Last active May 14, 2024 07:42
Excel formulas to calculate IP values such as Netmask, IP range start, IP range end, Broadcast IP, Number of hosts.

Excel formulas to calculate IP values - Works in Excel and Google Sheet.

Updated 2023-12-11: Hosts calculation updated to support CIDR or 31 and 32.

Prerequisites:

  • A1 contains an IP address, such as 10.0.0.2
  • B1 contains the number of bits in the netmask (CIDR) such as 24

The below formulas then go into C1, D1 etc. to perform the various calculations. Some calculations depends on other calculations.

@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:
@danielef
danielef / hamachi.sh
Created March 28, 2022 19:23
Hamachi Ubuntu 18.04 Jetson arm64
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install libc6:armhf
sudo ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
sudo apt-get install libstdc++6:armhf
sudo wget https://www.vpn.net/installers/logmein-hamachi_2.1.0.203-1_armhf.deb
sudo dpkg -i logmein-hamachi_2.1.0.203-1_armhf.deb
sudo hamachi login
sudo hamachi attach-net my@mail.com
@shaunmolloy
shaunmolloy / secret-key.py
Last active May 14, 2024 07:34
secret-key - Generate an app secret key
#!/usr/bin/env python
# secret-key
# Generate an app secret key
from base64 import b64encode
from os import urandom
random_bytes = urandom(64)
token = b64encode(random_bytes).decode()
@matijagrcic
matijagrcic / Batch-convert-webp-to-png.txt
Created November 18, 2016 18:28
Batch convert webp to png
#Download dwebp (WebP decoder tool) https://developers.google.com/speed/webp/download
#Run
for %f in (*.webp) do dwebp.exe "%f" -o "%~nf.png"
@fomightez
fomightez / useful_python_snippets.py
Last active May 14, 2024 07:34
Useful Python snippets
# These are meant to work in both Python 2 and 3, except where noted.
# See my useful_pandas_snippets.py for those related to dataframes (such as pickling/`df.to_pickle(save_as)`)
# https://gist.github.com/fomightez/ef57387b5d23106fabd4e02dab6819b4
# also see https://gist.github.com/fomightez/324b7446dc08e56c83fa2d7af2b89a33 for examples of my
# frequently used Python functions and slight variations for more expanded, modular structures.
#argparse
# good snippet collection at https://mkaz.tech/code/python-argparse-cookbook/