Skip to content

Instantly share code, notes, and snippets.

Avatar

Phillip Berndt phillipberndt

View GitHub Profile
@phillipberndt
phillipberndt / update_urlfilter.ini.pl
Created Apr 2, 2011
Update Opera's urlfilter.ini from secure.fanboy.co.nz while preserving custom entries
View update_urlfilter.ini.pl
#!/usr/bin/perl -w
use LWP::Simple;
use Storable;
use strict;
# Configuration
# You can define multiple urlfilter.ini lists to be downloaded
my @remotes = qw(
http://secure.fanboy.co.nz/adblock/opera/urlfilter.ini
);
@phillipberndt
phillipberndt / move_partition.sh
Created Apr 7, 2011
Move a linux partition to use free space before the partition
View move_partition.sh
#!/bin/bash
#
# This script moves a disk's partition. This is useful if you
# want to resize two parititions, making the first one smaller and the second one bigger.
#
# Note that if your partitions are not encrypted, there are GUI tools to
# acomplish this (Gnome's GParted) and if you are using LVM you don't need this
# at all because there is no problem having fragmented partitions with LVM.
# If you can avoid using this script, do it! Using a GUI tool for such delicate stuff
# helps you avoid headaches ;-)
@phillipberndt
phillipberndt / gist:5339943
Created Apr 8, 2013
Patch against Android Base framework, patched with 4.2 OpenPDroid patches from March 2013. Fixes the Cell Tower bug. Tested with an i9100 / cm10.1. This is probably bad coding style, see https://github.com/wsot/openpdroid_support/issues/1 for details.
View gist:5339943
diff --git a/services/java/com/android/server/PrivacyTelephonyRegistry.java b/services/java/com/android/server/PrivacyTelephonyRegistry.java
index 36f2d9e..95a3f58 100644
--- a/services/java/com/android/server/PrivacyTelephonyRegistry.java
+++ b/services/java/com/android/server/PrivacyTelephonyRegistry.java
@@ -44,17 +44,25 @@ public class PrivacyTelephonyRegistry extends TelephonyRegistry{
private static final int PERMISSION_CALL_STATE = 3;
private static final int PERMISSION_SERVICE_STATE = 4;
+
+ private Context _context;
@phillipberndt
phillipberndt / build-i3.sh
Last active Jun 13, 2020
Builder script for i3. Builds the latest i3 from the next branch and its prerequisites. Easily extendable should any dependency be missing from the list.
View build-i3.sh
#!/bin/bash
#
# Build i3 and depencendies.
# by Phillip Berndt, www.pberndt.com, June 2013
#
# The default developer packages from debian based distributions,
# cmake and cairo headers are prerequisites for this script. If
# anything else is missing on your system, this script should be
# easily extendible by inserting further packages into the
# BUILD array below.
@phillipberndt
phillipberndt / determine_dependency_versions.py
Last active Dec 25, 2015
Script to determine the exact versions of the GTK libraries required for pqiv. See https://github.com/phillipberndt/pqiv/issues/13
View determine_dependency_versions.py
#!/usr/bin/env python
# encoding: utf-8
#
# Find minimal required versions of the gtk/gdk/gdk_pixbuf/glib/cairo libs
# for pqiv
#
import re
import sys
import urllib
@phillipberndt
phillipberndt / .htaccess
Created Nov 18, 2013
A push-enabled GIT configuration for Apache / cgi-bin / public-html. Place both files in your `public_html` folder, create a corresponding `.htpasswd` file & enjoy.
View .htaccess
AddHandler cgi-script .cgi
<Files "git.cgi">
Require valid-user
AuthType Basic
AuthName "GIT Access"
AuthUserFile /path/to/.htpasswd.git
</Files>
@phillipberndt
phillipberndt / Fake xinerama
Last active Jan 19, 2021
Fake Xinerama configuration to split the DELL Latitude E7440 two-external monitors into two virtual heads
View Fake xinerama
WHAT THIS IS
------------
The DELL LATITUDE E7440's docking station supports two external displays, and
the notebook's Haswell architecture supports having three displays active at
the same time. It works well, but the two external monitors are merged into one
big display:
$ xrandr
Screen 0: minimum 320 x 200, current 5280 x 1080, maximum 32767 x 32767
eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
@phillipberndt
phillipberndt / build_linux_pqiv.sh
Last active Sep 2, 2018
Script to create a statically linked build of pqiv with dependencies
View build_linux_pqiv.sh
#!/bin/bash
#
# Build a statically linked version of all pqiv prerequisites and some fake
# ones (atk-bridge, epoxy). Then, compile a statically linked version of pqiv.
#
# This script is only useful in Linux. For Windows, use mxe.cc, a great script
# to compile mingw cross compiler environments with all the required
# dependencies and libraries.
#
# The resulting binary works fine at least between libc 2.15 and 2.19 despite
@phillipberndt
phillipberndt / setup.py
Created Aug 18, 2014
Cython test (For SO question 25141838)
View setup.py
#!/usr/bin/env python
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("test.pyx")
)
@phillipberndt
phillipberndt / magic.jl
Last active Aug 29, 2015
Magic squares in Julia
View magic.jl
# These are possibly naïve implementations of magic squares generation
# for a micro-benchmark to compare Julia to Python and Matlab
#
function magic_matlab(n::Int64)
# Works exactly as Matlab's magic.m
if n % 2 == 1
p = (1:n)
M = n * mod(broadcast(+, p', p - div(n+3, 2)), n) + mod(broadcast(+, p', 2p - 2), n) + 1