Skip to content

Instantly share code, notes, and snippets.

View wsdookadr's full-sized avatar
🎯
Focusing

Stefan Corneliu Petrea wsdookadr

🎯
Focusing
  • Nowhere
  • Nowhere
View GitHub Profile
@wsdookadr
wsdookadr / jq.md
Created March 23, 2025 11:40 — forked from jwbee/jq.md
Make Ubuntu packages 90% faster by rebuilding them

Make Ubuntu packages 90% faster by rebuilding them

TL;DR

You can take the same source code package that Ubuntu uses to build jq, compile it again, and realize 90% better performance.

Setting

I use jq for processing GeoJSON files and other open data offered in JSON format. Today I am working with a 500MB GeoJSON file that contains the Alameda County Assessor's parcel map. I want to run a query that prints the city for every parcel worth more than a threshold amount. The program is

@wsdookadr
wsdookadr / emmc_health.py
Last active March 8, 2025 14:49 — forked from kylemanna/parse-ext-csd.py
Parse eMMC Extended CSD and print useful things.
#!/usr/bin/env python
"""
Upstream: https://gist.github.com/kylemanna/5692543
Blog post: https://blog.kylemanna.com/linux/parse-emmc-extended-csd-ecsd-registers-with-python/
Description: Get eMMC health information
Tested on ASUS T100TA
Example:
root@fedora:/home/user# ./emmc_health.py | rg -i 'LIFE|HEALTH|EOL'
function scroll_to(splash, x, y)
local js = string.format(
"window.scrollTo(%s, %s);",
tonumber(x),
tonumber(y)
)
return splash:runjs(js)
end
@wsdookadr
wsdookadr / fetch-repos.sh
Created September 30, 2018 19:22 — forked from hhutch/fetch-repos.sh
find file changes in all forks of a github repo
curl -i https://api.github.com/repos/scrooloose/nerdtree/forks |grep -e "git_url" |awk '{gsub(/,/,"");split($2,a,"/"); system("mkdir "a[4]"; cd "a[4]"; git clone " $2);}'
@wsdookadr
wsdookadr / statistics.sql
Created November 6, 2016 12:54 — forked from ruckus/statistics.sql
Postgres statistics queries
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
----------------------+--------------+---------------+------------------------
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000
@wsdookadr
wsdookadr / queue.sh
Created November 1, 2016 11:53 — forked from timtadh/queue.sh
BASH Job Queue. This is a example of how to make a job queue in GNU Bash. It may not work for other shells as it relies on the bash built in `read`. You will need to see the man pages for your shell to determine if this will work for you.
#!/usr/bin/env bash
rep() {
i=$1
data=$2
## run the replicate ....
}
# make the files
START=$(mktemp -t start-XXXX) ## signals the workers are starting
@wsdookadr
wsdookadr / json_manipulator.sql
Created May 31, 2016 10:57 — forked from matheusoliveira/json_manipulator.sql
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
@wsdookadr
wsdookadr / node-and-npm-in-30-seconds.sh
Created July 5, 2011 06:01 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
var http = require("http")
http.createServer(function (req, res) {
// let it time out
// just hold the connection open forever
}).listen(8080)
var r = http.createClient(8080, "localhost").request("GET", "/", {})
r.on("response", function (res) {
console.log("got response")