Skip to content

Instantly share code, notes, and snippets.

@AlexMikhalev
AlexMikhalev / get-obsidian-posts.py
Created January 19, 2021 13:46
Sync notion to obsidian world md
from notion.client import NotionClient
import datetime
import os
from slugify import slugify
import re
import requests
import time
import hashlib
import shutil
import sys
#!/usr/bin/env python
# jj-github-pr: Create Github PRs from jujutsu changes
# Each change will be one PR. Relations between changes will be preserved by setting the PR base branch.
# The commit title/message will be used for the PR title/body.
# The command can be used multiple times to update the stack of PRs, titles and commits.
# A "Relation chain" which shows the relation between the submitted PRs will be added to the PR body.
# Usage: Run jj-github-pr <revision> to submit each jj change as a PR.
#
# Example usage:
@steipete
steipete / PSPDFThreadSafeMutableDictionary.m
Last active January 20, 2025 07:33
Simple implementation of a thread safe mutable dictionary. In most cases, you want NSCache instead, but it can be useful in situations where you want to manually control what is evicted from the cache in low memory situations.**Warning:** I only use this for setting/getting keys. Enumeration is not thread safe here and will still throw exception…
//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@zhuang-hao-ming
zhuang-hao-ming / main.md
Last active January 20, 2025 07:31
如何对python代码做性能分析

做实验的时候常常会遇到一个脚本跑的很慢的情况,这个时候我们常常会想方设法的去做一些优化,来让脚本跑的快一些。 但是优化带来了两个问题,一个是优化后的代码仍然是正确的吗,第二个问题是优化有效果吗?

第一个问题可以依靠编写合适的单元测试来解决, 但是究竟如何编写合适的单元测试仍然是一个很大的问题,这个问题我们留待以后在讨论。

第二个问题可以依靠性能分析来解决,性能分析就是测试代码的执行时间,很多时候我们经常会用如下的方式来做性能分析,但是这种方法一来麻烦,二来会把代码弄得很混乱。

from time import time

begin_tick = time()
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CloudContent]
"ConfigureWindowsSpotlight"=dword:00000002
"IncludeEnterpriseSpotlight"=dword:00000000
"DisableThirdPartySuggestions"=dword:00000001
"DisableTailoredExperiencesWithDiagnosticData"=dword:00000001
"DisableWindowsSpotlightFeatures"=dword:00000001
"DisableWindowsSpotlightWindowsWelcomeExperience"=dword:00000001
"DisableWindowsSpotlightOnActionCenter"=dword:00000001
@ravron
ravron / README.md
Last active January 20, 2025 07:27
Options to prevent accidental Yubikey OTP triggering

Tired of spamming Yubikey one-time password (OTP) codes into Slack? Here are two options to help prevent that. You can do either or both. Both require ykman, the Yubikey CLI configuration manager. Get it with Homebrew:

brew install ykman

If you…

@jrnk
jrnk / ISO-639-1-language.json
Last active January 20, 2025 07:24
ISO 639-1 Alpha-2 codes of languages JSON
[
{ "code": "aa", "name": "Afar" },
{ "code": "ab", "name": "Abkhazian" },
{ "code": "ae", "name": "Avestan" },
{ "code": "af", "name": "Afrikaans" },
{ "code": "ak", "name": "Akan" },
{ "code": "am", "name": "Amharic" },
{ "code": "an", "name": "Aragonese" },
{ "code": "ar", "name": "Arabic" },
{ "code": "as", "name": "Assamese" },
@dperconti
dperconti / .zshrc
Created December 5, 2017 17:39
oh-my-zsh / zsh / iterm2 init ASCII art
COLUMNS=`tput cols` export COLUMNS # Get screen width.
WELCOME="WELCOME, DONATO"
VERSE="If you're worn out in this footrace with men, what makes you think you can race against horses?"
L_1=" ..,:cloddooddooooddoooddxxdolc:,... ..';coxxdo:,. ..',;:c:cllloooooooooooodddllc:,.. "
L_2=" .:loooloool;,'....';::ccc::;:cllclxkxdddooc:,. .:x00OOOkxddk000kd:. ..';clodkOkxxdoooool:::::;:;'';dkocc;:lx000ko, "
L_3=" 'dko;'...,ld; .,dkdl::,.. ,lc;:c:cox00Oxdoc,.. .dWWXo'.'.. ';:dO0O, ..;loddddolcoxo;. .. .:l::cc' .oKk;. .';:lk0k:."
L_4=" :XXc ..';cd: ;OO' .,;ccccccokkl:ldxooddooxO0OOOxo:'. ;OWO, .;'. .c:... .,codxxdl:,'',:lol'..;ccclc:cllcc:. .,ko. .,clc:,;:'. "
L_5=".dWk' 'll:;,',:cc, .,,..;c,. .''''.'''. .;ccoxkxxkkkkkO0KXX0xl;. oNXo,:0Oc'..c0l.,' .,:oxxxol:;;;coollll:. .',,,,,:xx;. .;' .c0kc::;:k0xlcc' "
@zacwest
zacwest / ios-font-sizes.swift
Last active January 20, 2025 07:14
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]