Skip to content

Instantly share code, notes, and snippets.

View sammcj's full-sized avatar
🦃

Sam sammcj

🦃
View GitHub Profile
@mustafaturan
mustafaturan / latest-ffmpeg-centos6.sh
Last active October 25, 2022 20:14
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@MihailJP
MihailJP / gpufan.bash
Created November 5, 2013 13:02
Script to control the fan speed automatically (works only for NVIDIA graphic cards)
#!/bin/bash
# Script to control the fan speed automatically
setFanSpeed() {
eval "nvidia-settings -a GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=$1 > /dev/null"
}
cleanup() {
eval "nvidia-settings -a GPUFanControlState=0"
@Andrewpk
Andrewpk / OSX-junos_pulse_listenToMe.sh
Last active July 11, 2024 20:22
wtf juniper.Anyone else find it irritating that junos pulse services and pulse tray must always running in OS X regardless of whether or not you're currently connected?Yeah, me too.I added the following as aliases to my shell to fix this problem.Be sure to change your /Library/LaunchAgents/net.juniper.pulsetray.plist file to reflect the `KeepAli…
#################################################################################
# start and stop the vpn from the command line from now on with these two commands
#################################################################################
startvpn() {
sudo launchctl load -w /Library/LaunchDaemons/net.pulsesecure.AccessService.plist
launchctl load -w /Library/LaunchAgents/net.pulsesecure.pulsetray.plist
}
quitvpn() {
launchctl unload -w /Library/LaunchAgents/net.pulsesecure.pulsetray.plist
sudo launchctl unload -w /Library/LaunchDaemons/net.pulsesecure.AccessService.plist
#!/bin/bash
set -o errexit -o nounset -o pipefail
function -h {
cat <<USAGE
USAGE: ln_libjvm.bash
Symlink a likely libjvm.so into /usr/bin.
USAGE
}; function --help { -h ;}
@mangecoeur
mangecoeur / concurrent.futures-intro.md
Last active July 20, 2024 10:30
Easy parallel python with concurrent.futures

Easy parallel python with concurrent.futures

As of version 3.3, python includes the very promising concurrent.futures module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.

For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.

We use the context manager thusly:

with concurrent.futures.ProcessPoolExecutor() as executor:
#!/bin/bash
JQPATH=$(which jq)
if [ "x$JQPATH" == "x" ]; then
echo "Couldn't find jq executable." 1>&2
exit 2
fi
set -eu
shopt -s nullglob
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active June 23, 2025 13:24
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@tai
tai / gist:f3866b78b74dca413101
Created February 24, 2015 06:23
Quick script to git clone all KiCad libraries (*.lib components and *.pretty footprints).
#!/bin/sh -x
# Quick script to git clone all KiCad libraries (*.lib components and *.pretty footprints).
curl -S 'https://github.com/KiCad?page=[1-5]' | \
(perl -lne 'print $& while s|KiCad/[^/]+.pretty||'; echo KiCad/kicad-library) | \
sort -u | while read i; do test -d ${i#KiCad/} || git clone https://github.com/$i; done
for i in */.git; do (cd $i/.. && git pull); done
@drkarl
drkarl / gist:739a864b3275e901d317
Last active April 29, 2025 20:18
Ask HN: Best Linux server backup system?

Linux Backup Solutions

I've been looking for the best Linux backup system, and also reading lots of HN comments.

Instead of putting pros and cons of every backup system I'll just list some deal-breakers which would disqualify them.

Also I would like that you, the HN community, would add more deal breakers for these or other backup systems if you know some more and at the same time, if you have data to disprove some of the deal-breakers listed here (benchmarks, info about something being true for older releases but is fixed on newer releases), please share it so that I can edit this list accordingly.

  • It has a lot of management overhead and that's a problem if you don't have time for a full time backup administrator.
@sammcj
sammcj / fast_resync
Created March 30, 2015 07:32
2x NVMe Intel DC3600P 1.2TB RAID1, 8x SanDisk Extreme Pro 480GB RAID10
root@s1-san5:~ # cat /proc/mdstat
Personalities : [raid1] [raid10]
md1200 : active raid1 nvme1n1[1] nvme0n1[0]
1172112896 blocks [2/2] [UU]
[=>...................] resync = 8.3% (97620800/1172112896) finish=14.7min speed=1213969K/sec
bitmap: 9/9 pages [36KB], 65536KB chunk
md480 : active raid10 sdh[7] sdg[6] sdf[5] sde[4] sdd[3] sdc[2] sdb[1] sda[0]
1874878464 blocks super 1.2 512K chunks 2 far-copies [8/8] [UUUUUUUU]
[=================>...] resync = 88.9% (1667816576/1874878464) finish=4.5min speed=765789K/sec