Skip to content

Instantly share code, notes, and snippets.

View andrewpetrochenkov's full-sized avatar
🔍

Andrew P andrewpetrochenkov

🔍
View GitHub Profile
@andrewpetrochenkov
andrewpetrochenkov / homebrew.mxcl.postgresql.plist
Last active September 17, 2024 08:35
postgresql brew #brew #postgresql
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.postgresql</string>
<key>ProgramArguments</key>
<array>
@andrewpetrochenkov
andrewpetrochenkov / github-api-headers.py
Created August 24, 2024 19:49
github api headers #github
import os
import requests
headers = {
"Authorization": "Bearer %s" % os.getenv('GITHUB_TOKEN')
}
r = requests.get("https://api.github.com/",headers=headers)
for k,v in r.headers.items():
print('%s: %s' % (k,v))
@andrewpetrochenkov
andrewpetrochenkov / child-pids.sh
Created August 16, 2024 18:29
get child PIDs #pid
child-pids() {
local childs=
childs="$(pgrep -P "$1")"
[[ -n "$childs" ]] && while IFS= read child; do
pids "$child"
done <<< "$childs"
[[ $1 != $$ ]] && echo "$1"
}
child-pids "$1"
Development Status :: 1 - Planning
Development Status :: 2 - Pre-Alpha
Development Status :: 3 - Alpha
Development Status :: 4 - Beta
Development Status :: 5 - Production/Stable
Development Status :: 6 - Mature
Development Status :: 7 - Inactive
Environment :: Console
Environment :: Console :: Curses
Environment :: Console :: Framebuffer
@andrewpetrochenkov
andrewpetrochenkov / github-graphql-api.py
Created August 16, 2024 15:57
github python GraphQL API example #github #graphql
#!/usr/bin/env python
import json
import os
import requests
URL = "https://api.github.com/graphql"
headers = {
"Accept": "application/vnd.github+json",
"Authorization": "Bearer %s" % os.getenv('GITHUB_TOKEN'),
@andrewpetrochenkov
andrewpetrochenkov / webpack.sh
Created August 16, 2024 15:37
webpack #webpack
webpack --config prod.js --mode=none
@andrewpetrochenkov
andrewpetrochenkov / ngrok.sh
Last active August 16, 2024 15:36
ngrok #ngrok
ngrok http 8000
yq r ./ngrok.yml tunnels | grep -v ' .*' | sed 's/.$//' #3 names
ngrok start -config ./ngrok.yml name
# webpack tunnel
curl -s http://localhost:4040/api/tunnels | jq '.tunnels[] | select(.name=="webpack")' | jq -r '.public_url'
.git/hooks/post-commit
.git/hooks/pre-commit
@andrewpetrochenkov
andrewpetrochenkov / npx-force-unpublish.sh
Created August 16, 2024 15:28
npm npx unpublish #npm #node
# deprecate and transfer ownership to npm
name="$(node -e "console.log(require('./package.json').name)")"
npx force-unpublish "$name" 'reason message'
@andrewpetrochenkov
andrewpetrochenkov / github-api-create-repo.py
Created August 16, 2024 15:26
github API create repo #github
#!/usr/bin/env python
import json
import os
import requests
NAME = os.getcwd().split('/')[-1]
URL = 'https://api.github.com/user/repos'
headers = {
"Authorization": "Bearer %s" % os.getenv("GITHUB_TOKEN"),
}