Skip to content

Instantly share code, notes, and snippets.

@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:
@umayr
umayr / recover-deleted-branch.sh
Created April 1, 2016 11:41
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@sebzur
sebzur / polish_holidays.py
Created February 12, 2012 20:25
Python generator for public holidays in Poland
from datetime import date, timedelta
from dateutil import easter
from dateutil.relativedelta import *
def get_holidays(year=2010):
""" Returns Polish hollidays dates (legally considered non-working days) """
easter_sunday = easter.easter(year)
holidays = {'New Year': date(year,1,1),
'Trzech Kroli': date(year,1,6),
'Easter Sunday': easter_sunday,
@skoqaq
skoqaq / build4123.sublime4.key
Last active May 14, 2024 09:01
Sublime Text 4 License Key
—– BEGIN LICENSE —–
Mifeng User
Single User License
EA7E-1184812
C0DAA9CD 6BE825B5 FF935692 1750523A
EDF59D3F A3BD6C96 F8D33866 3F1CCCEA
1C25BE4D 25B1C4CC 5110C20E 5246CC42
D232C83B C99CCC42 0E32890C B6CBF018
B1D4C178 2F9DDB16 ABAA74E5 95304BEF
9D0CCFA9 8AF8F8E2 1E0A955E 4771A576
@tkurki
tkurki / 00doc.md
Last active May 14, 2024 08:59
Wind Speed and Direction with Grafana ECCharts plugin
@luckylittle
luckylittle / Splunk_Certified_Cybersecurity_Defense_Analyst.md
Last active May 14, 2024 08:59
Splunk Certified Cybersecurity Defense Analyst [SPLK-5001] - Notes

Splunk Certified Cybersecurity Defense Analyst [SPLK-5001]

1.0 The Cyber Landscape, Frameworks, and Standards (*10%*)
  1.1 Summarize the organization of a typical SOC and the tasks belonging to Analyst, Engineer and Architect roles.
  1.2 Recognize common cyber industry controls, standards and frameworks and how Splunk incorporates those frameworks.
  1.3 Describe key security concepts surrounding information assurance including confidentiality, integrity and availability and basic risk management.

2.0 Threat and Attack Types, Motivations, and Tactics (*20%*)
  2.1 Recognize common types of attacks and attack vectors.
@taoyuan
taoyuan / generate_self_signed_certification.md
Last active May 14, 2024 08:59
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
@paulirish
paulirish / what-forces-layout.md
Last active May 14, 2024 08:57
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
@sevkin
sevkin / getfreeport.go
Last active May 14, 2024 08:56
get free port in golang
// GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePort() (port int, err error) {
var a *net.TCPAddr
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
}
@amalmurali47
amalmurali47 / edit_commit_history.md
Last active May 14, 2024 08:56
Change ownership of selected older commits in Git
  1. Clone the repo.
  2. Use git rebase -i --root
  3. vim will open. Select the commits you want to modify by changing pick to edit. If you would like to change all the commits, perform the following replace: :%s/^pick/edit/g. This command changes all instances of "pick" at the start of lines to "edit".
  4. You will now be shown all the selected commits one by one. Each commit message will be displayed. You have two options:
    • If you would like to keep the commit author details the same, do a git rebase --continue.
    • If you would like to change it to a different name/email, do git commit --amend --reset-author. If --reset-author is specified, it will use the details from your git config. (If you need to specify an alternate name/email, you can do so with --author="John Doe <john@example.com>". If you would like to change the time to a previous date, you can do so with --date "2 days ago".)
  5. Do the same for all the commits and finish the rebase.
  6. Perform git push -f origin master to