Skip to content

Instantly share code, notes, and snippets.

View nbari's full-sized avatar
🪴

nbari

🪴
View GitHub Profile
INFO: analyzing "profile.servers"
INFO: "servers": scanned 1 of 1 pages, containing 1 live rows and 9 dead rows; 1 rows in sample, 1 estimated total rows
INFO: analyzing "profile.samples"
INFO: "samples": scanned 1 of 1 pages, containing 8 live rows and 33 dead rows; 8 rows in sample, 8 estimated total rows
INFO: analyzing "profile.baselines"
INFO: "baselines": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
INFO: analyzing "profile.bl_samples"
INFO: "bl_samples": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
INFO: analyzing "profile.sample_stat_cluster"
INFO: "sample_stat_cluster": scanned 1 of 1 pages, containing 8 live rows and 33 dead rows; 8 rows in sample, 8 estimated total rows
@nbari
nbari / update.sh
Created August 18, 2023 13:07
update freebsd
#!/bin/sh
FREEBSD_VERSION=13
NUMBER_OF_CORES=`sysctl -n hw.ncpu`
ZPOOL="zroot"
START=$(date +%s)
if [ `sysctl -n kern.securelevel` -gt 0 ]; then
sysrc kern_securelevel_enable="NO"
echo "need to reboot with securelevel 0"
exit
@nbari
nbari / chunk_upload.py
Last active July 16, 2023 18:04
python chunk upload files
#!/usr/bin/env python
import os
import requests
import uuid
from random import randint
from uuid import uuid4
def read_in_chunks(file_object, chunk_size=65536):
while True:
@nbari
nbari / export-ble-infos.py
Created December 18, 2022 13:35 — forked from Mygod/export-ble-infos.py
Export your Windows Bluetooth LE keys into Linux!
#!/usr/bin/python3
"""
Copyright 2021 Mygod
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@nbari
nbari / dwr
Created March 23, 2022 10:05
delete git workflows
#!/usr/bin/env bash
# Delete workflow runs - dwr
# Given an "owner/repo" name, such as "qmacro/thinking-aloud",
# retrieve the workflow runs for that repo and present them in a
# list. Selected runs will be deleted. Uses the GitHub API.
# Requires gh (GitHub CLI) and jq (JSON processor)
@nbari
nbari / consume.rs
Created August 16, 2020 21:08
how to use traits
use futures::stream::TryStreamExt;
use ring::digest::{Context, SHA256};
use std::error::Error;
use std::fmt::Write;
use std::time::Instant;
use tokio::fs::File;
use tokio::io::AsyncBufRead;
use tokio::io::BufReader;
// use tokio::prelude::*;
use tokio_util::codec::{BytesCodec, FramedRead};
@nbari
nbari / upload.py
Last active February 17, 2020 20:03
add a file into a mysql BLOB column
""" Example for adding a file into a blob
CREATE TABLE test (
id INT AUTO_INCREMENT,
data LONGBLOB NOT NULL,
PRIMARY KEY (id)
);
pip install --upgrade --user mysqlclient
"""
@nbari
nbari / gist:386af0fa667ae03daf3fbc80e3838ab0
Created July 2, 2016 07:56 — forked from juanqui/gist:7564275
Golang Kqueue Snippet
// helpful links:
// https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/EV_SET.2.html
// http://julipedia.meroh.net/2004/10/example-of-kqueue.html
// create kqueue
kq, err := syscall.Kqueue()
if err != nil {
log.Println("Error creating Kqueue descriptor!")
return
}
@nbari
nbari / smartos-on-a-budget.sh
Created November 3, 2019 09:34 — forked from jahewson/smartos-on-a-budget.sh
Installing and Configuring SmartOS on a budget server (with a /29)
# Licensed under CC BY 3.0 http://creativecommons.org/licenses/by/3.0/
# Derived works must attribute https://gist.github.com/4492300 at the beginning, and the date.
##################################################################
Installing and Configuring SmartOS on a budget server (with a /29)
##################################################################
# if you find this gist useful, please star it
# please be aware that budget hosting companies usually cut corners somewhere,
@nbari
nbari / read_only.js
Created March 5, 2019 16:02
couchdb read-only _design/read_only
function(newDoc, oldDoc, userCtx, secObj) {
var ddoc = this;
secObj.admins = secObj.admins || {};
secObj.admins.names = secObj.admins.names || [];
secObj.admins.roles = secObj.admins.roles || [];
var IS_DB_ADMIN = false;
if(~ userCtx.roles.indexOf("_admin"))
IS_DB_ADMIN = true;
if(~ secObj.admins.names.indexOf(userCtx.name))
IS_DB_ADMIN = true;