Skip to content

Instantly share code, notes, and snippets.

@RobFreiburger
RobFreiburger / iOS_Battery_Saving.md
Last active May 14, 2020 15:49
How to maximize battery life on an iOS device.

These are all in the Settings app.

  1. Battery > Low Power Mode ON
    If Low Power Mode didn't exist, this list would be much longer. It disables most iOS background features like email fetching, app refreshing, app updates, and iCloud photo syncing. It automatically turns off once your battery is charged to 80%, so you may have to turn it back on again.
  2. Do Not Disturb > Do Not Disturb ON
    Do Not Disturb will prevent the screen from turning on whenever a notification comes in. Double-check the settings here, or you may not get an urgent phone call.
#!/bin/bash
# As of Pi-hole v5.0, this script is no longer needed.
pihole_whitelist_string=""
if [[ $# -eq 0 ]]; then
echo "Please use one or more domains as arguments for this script:"
echo "./"`basename "$0"`" example.com foo.org"
exit 1
@RobFreiburger
RobFreiburger / bf3_rcon.rb
Created September 25, 2013 01:46
Battlefield 3 RCON Protocol implemented in Ruby 2.0.0.
require 'socket'
require 'digest'
def encode_header(is_from_server, is_response, sequence)
header = sequence & 0x3fffffff
header += 0x80000000 if is_from_server
header += 0x40000000 if is_response
[header].pack('<I')
end
@RobFreiburger
RobFreiburger / mcafeeInstall.sh
Last active December 17, 2015 08:49
Example install script for McAfee VirusScan for Mac. Assumes used with JAMF Software Casper Suite. Tested on 10.6 Snow Leopard.
#!/bin/sh
# mcafeeInstall.sh
# Created by Rob Freiburger on 5/19/11
### GET VARS
tmpfolder=/tmp/mcafeeInstall$(/usr/bin/date '+%Y%m%d%H%M%S')
/usr/bin/mkdir $tmpfolder
username=$SUDO_USER
if [ -z $username ]; then
username=$(/usr/bin/users)
@RobFreiburger
RobFreiburger / d20kill.py
Created February 10, 2013 00:53
Destruction 2.0 kill announcer for Battlefield: Bad Company 2 PC servers
#!/usr/local/bin/python
# Majority of code is taken from EA DICE's Server Administrator Docs
from struct import *
import md5
import socket
import sys
import shlex
import string
@RobFreiburger
RobFreiburger / gist:3140839
Created July 19, 2012 04:55
(Securely) Managing a Website using git

Daniel Miessler's directions are very good for setting up git to manage a website. However, they make the assumption that the user pushing the code is the same user that can publish websites. On shared hosting this is probably the case. On dedicated hosting it's probably not. If you're using OS X's built-in Apache server, it's definitely not. The user www has proper rights, and by default it isn't an ssh-able account. So you have to make some modifications to his directions.

Step 4a. Make a git group

  1. Create a group named git. This group contains all users that have permission to read and write to the git repo. In OS X, you can do this via Accounts in System Preferences.
  2. Add users to the group. In OS X, you can use dseditgroup to add non-visible users like www to the group.

Step 5a. Change the repo's permissions

@RobFreiburger
RobFreiburger / dateDeepCopy.js
Created March 23, 2012 01:25
How to Deep Copy a Date Object in JavaScript
// What works
var original = new Date();
var copy = new Date(original);
// What doesn't work
copy = original; // It should work, but it passes by reference so changes to copy also affect original
copy = jQuery.extend(true, {}, original); // Passes a useless object
@RobFreiburger
RobFreiburger / bf3-kick-some-pubbies.py
Created October 25, 2011 17:48
Battlefield 3 RCON "Kick Some Pubbies" Script
#!/usr/bin/python
# "Kick Some Pubbies" script for BF3 server admins
# Script is a modified version of EA DICE's CommandConsole.py from BFBC2
# Confirmed working on Battlefield 3 servers on launch day, 10/25/11
# Go to the configurable variables section to modify to your needs.
# Made to retrieve whitelist from a URL, can be easily changed to local file. See getWhitelist() function.
from struct import *
import binascii
@RobFreiburger
RobFreiburger / removeOffice2011.sh
Created June 16, 2011 04:51
Office 2011 for Mac Uninstaller
#!/bin/sh
# Credit to http://www.officeformachelp.com/office/install/remove-office/
osascript -e 'tell application "Remote Desktop Connection" to quit'
osascript -e 'tell application "Microsoft Document Connection" to quit'
osascript -e 'tell application "Microsoft Messenger" to quit'
osascript -e 'tell application "Microsoft Communicator" to quit'
osascript -e 'tell application "Microsoft Outlook" to quit'
osascript -e 'tell application "Microsoft Excel" to quit'
@RobFreiburger
RobFreiburger / facebook.pl
Created November 13, 2009 13:28
Sort CSV entries like Facebook profile favorites alphabetically.
#!/usr/bin/perl
# Sorts CSVs alphabetically and formats
use strict;
my @csv = split(/,\s?/, join(' ', @ARGV));
@csv = sort @csv;
for (my $i = 0; $i < $#csv; $i++) {
$csv[$i] .= ",";
}