Skip to content

Instantly share code, notes, and snippets.

@algb12
algb12 / AppNapToggle.pl
Last active April 18, 2024 09:13
AppNapToggle.pl - App Nap disabler / enabler
#!/usr/bin/perl
use 5.010;
use vars qw($VERSION);
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
Getopt::Long::Configure qw(gnu_getopt);
use Cwd 'abs_path';
use File::Basename;
@0xadada
0xadada / github-latest-release.sh
Created July 8, 2015 15:56
Download latest GitHub project release
curl -LOk `curl --silent https://api.github.com/repos/jasmine/jasmine/releases/latest | /usr/bin/awk '/browser_download_url/ { print $2 }' | /usr/bin/sed 's/"//g'`
@alexwlchan
alexwlchan / safeutil.py
Last active July 18, 2023 07:39
Non-destructive file copying/moving in Python
#!/usr/bin/env python
"""
This is a script designed to be "safe" drop-in replacements for the
shutil move() and copyfile() functions.
These functions are safe because they should never overwrite an
existing file. In particular, if you try to move/copy to dst and
there's already a file at dst, these functions will attempt to copy to
a slightly different (but free) filename, to avoid accidental data loss.
@rtrouton
rtrouton / gist:11bc3f21f47e1a79d099
Last active April 9, 2020 23:03
Downloading the latest release of a project from GitHub
#!/bin/bash
# How to set these variables:
#
# GitHub_Owner
# GitHub_Repo
#
# Example use:
#
# The Linde Group has repos on GitHub available
@allegrem
allegrem / gist:8f1736ed2966d4596779
Created January 6, 2015 20:31
homemade dyndns
#!/bin/bash
# this one mails you the ip if it changes
T1=`curl -s icanhazip.com`
touch old_ip.dat
read T2 < old_ip.dat
if [ "$T1" = "$T2" ]; then
echo "`date` -- ipchange script -- IP is the same: $T1 - doing nothing " | tee -a /var/log/syslog
@afolarin
afolarin / resource_alloc_docker.md
Last active December 22, 2025 22:00
Resource Allocation in Docker

#Container Resource Allocation Options in docker-run

now see: https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources

You have various options for controlling resources (cpu, memory, disk) in docker. These are principally via the docker-run command options.

##Dynamic CPU Allocation -c, --cpu-shares=0
CPU shares (relative weight, specify some numeric value which is used to allocate relative cpu share)

For a linux kernel below 3.2.0-22.25
yum install kernel-devel automake autoconf gcc glib make ncurses-devel ncurses sysfsutils
yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto
yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
yum install newt-devel python-devel zlib-devel
Download sysfsutils-2.1.0.tar.gz
tar xvf sysfsutils-2.1.0.tar.gz
cd sysfsutils-2.1.0
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@lisamelton
lisamelton / transcode-video.sh
Last active June 8, 2026 14:22
Transcode video file (works best with Blu-ray or DVD rip) into MP4 (or optionally Matroska) format, with configuration and at bitrate similar to popular online downloads.
#!/bin/bash
#
# transcode-video.sh
#
# Copyright (c) 2013-2015 Don Melton
#
about() {
cat <<EOF
$program 5.13 of April 8, 2015
@eric-hu
eric-hu / Open iterm tab here
Last active January 7, 2026 22:35
Apple script to open an iterm2 tab from right-clicking on a file or folder in Finder. To use: (1) Open Automator (2) Create a new service (3) Change "Service receives selected" drop downs to "Files or folders" in "Finder" (4) Select "Run applescript" from the sidebar, then paste this script in and save
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set filetype to (kind of (info for my_file))
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer: