Skip to content

Instantly share code, notes, and snippets.

@hackman
hackman / pci-reset.sh
Created November 14, 2021 23:56
Script to reset a PCI device
#!/bin/bash
dev=$1
if [[ -z $dev ]]; then
echo "Error: no device specified"
exit 1
fi
if [[ ! -e /sys/bus/pci/devices/$dev ]]; then
@sarthakpranesh
sarthakpranesh / cleanMacVMs.sh
Last active May 14, 2024 07:57
Debloat Mac OS ( use at your own risk )
# I use MacOS VMs from github for iOS development.
# By no suprise they are a bit slow and have a lot of things I don't use
# Hence this script for lighter and better VM for my iOS development and builds
# GUI and animation related things to tweak
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
defaults write -g QLPanelAnimationDuration -float 0
defaults write com.apple.dock autohide-time-modifier -float 0
defaults write com.apple.dock launchanim -bool false
sudo sysctl debug.lowpri_throttle_enabled=0
#!/usr/bin/env python3
import os
import sys
import time
import numpy as np
import cv2 as cv
import threading
# also acts (partly) like a cv.VideoCapture
class FreshestFrame(threading.Thread):
@f3l3gy
f3l3gy / download-latest-release.ps1
Last active November 8, 2023 07:12 — forked from MarkTiedemann/download-latest-release.ps1
Download latest GitHub release via Powershell
# Download latest dotnet/codeformatter release from github
$repo = "dotnet/codeformatter"
$file = "CodeFormatter.zip"
$releases = "https://api.github.com/repos/$repo/releases"
Write-Host Determining latest release
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tag = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
@lukicdarkoo
lukicdarkoo / configure.sh
Last active November 22, 2023 04:37
Raspberry Pi: AP + client mode
#!/bin/sh
# The script configures simultaneous AP and Managed Mode Wifi on Raspberry Pi Zero W (should also work on Raspberry Pi 3)
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/6b92d182d37d0a10400060d8344f86e4/raw | sh -s WifiSSID WifiPass APSSID APPass
# Licence: GPLv3
# Author: Darko Lukic <lukicdarkoo@gmail.com>
# Special thanks to: https://albeec13.github.io/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/
MAC_ADDRESS="$(cat /sys/class/net/wlan0/address)"
CLIENT_SSID="${1}"
CLIENT_PASSPHRASE="${2}"
@amit-chahar
amit-chahar / download-script.sh
Last active February 20, 2023 12:57
Scirpt to download files from Google drive using curl (Detailed explanation can be read here: https://stackoverflow.com/a/49444877/4043524)
#!/bin/bash
fileid="FILEIDENTIFIER"
filename="FILENAME"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
@maditnerd
maditnerd / tc358743.sh
Last active March 25, 2022 13:40
Compile raspberry pi 3 kernel to add drivers (tc358743)
###########################
# bcm2835_unicam drivers #
###########################
# DESCRIPTION: Install bcm2835_unicam/tc358743 drivers from 6by9 Linux fork
# This should also work for adv7282m ov5647 (https://github.com/6by9/linux/commit/28ac7b3a2651d4b35204938e6c9ec2e4ba54c34e)
#
# CAUTION
# * Do not start this script! Copy/Paste each command.
# * Compilation will take over 1h30.
# * Any errors can potentially break the entire system
@moritzmhmk
moritzmhmk / rpi_camera_v4l2_ffmpeg.md
Last active April 16, 2024 19:20
using raspberry pi camera with ffmpeg (hardware accelerated)

Using Raspberry Pi Camera with ffmpeg

Capturing video from the rpi camera with ffmpeg can vary from less than 5% to 100% of the CPU (rpi zero) depending on ffmpeg using the hardware acceleration or not.

On many github issues one finds the suggestion of using h264_omx codec to use the gpu - but it does not ship with the default ffmpeg on Raspbian.

Instead I found that one can use the v4l2 driver provided by raspbian to get hardware accelerated h264 output. Also setting the video size will save one from using a (cpu) scale filter.

ffmpeg

capture h264 video from rpi camera

@whizzter
whizzter / mymod.js
Last active June 6, 2017 07:38
automatically exporting a module with koa (possibly insecure)
exports.bah=function(count,name){
let out="";
while(count--)
out+=name+" ";
return out;
};
@rzane
rzane / wait.sh
Created April 4, 2017 17:54
Wait for a port to become available (useful for docker-compose)
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: wait-for-it [host] [port] [timeout(optional)]"
exit 1
fi
host="$1"
port="$2"
timeout="${3:-0}"