Skip to content

Instantly share code, notes, and snippets.

Mike Matz pix0r

Block or report user

Report or block pix0r

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View prune-mac-wifi-networks.sh
#!/bin/sh
device="en0"
IFS=$'\n'
networks=`networksetup -listpreferredwirelessnetworks $device | tail -n+2 | sed -e 's/^[[:space:]]*//'`
function usage() {
echo "Usage: $0 [options]"
@pix0r
pix0r / output.txt
Created Sep 25, 2015
unscientific test of different foreach syntax
View output.txt
$ php test.php
Running 10 tests of 5000 iterations
finished 1 of 10
finished 2 of 10
finished 3 of 10
finished 4 of 10
finished 5 of 10
finished 6 of 10
finished 7 of 10
finished 8 of 10
View test-ssl.rb
require "net/http"
require "uri"
require "openssl"
def test_ssl(url, pem_file=nil)
puts "Testing URL: #{url}"
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
@pix0r
pix0r / pre-commit
Created Oct 8, 2014
Pre-commit hook to verify xcode project file has not been converted to XML
View pre-commit
#!/bin/sh
PROJFILE=`find . -path \*xcodeproj/project.pbxproj -not -path \*Pods\*`
if [ "$PROJFILE" = "" ]; then
echo "Unable to locate project file; skipping pre-commit hook"
exit 0
fi
git stash -q --keep-index
@pix0r
pix0r / zoom_level.rb
Created Aug 25, 2014
Ruby implementation of getBoundsZoomLevel JS
View zoom_level.rb
def zoom_level_for_bounds(bounds, map_dim={ height: 1000, width: 1000 }, zoom_max=21)
# See: http://stackoverflow.com/a/13274361/72
return zoom_max if bounds.min_x == bounds.max_x and bounds.min_y == bounds.max_y
world_dim = { height: 256, width: 256 }
def lat_rad(lat)
sin = Math.sin(lat * Math::PI / 180)
rad_x2 = Math.log((1 + sin) / (1 - sin)) / 2
View gist:a670efa812a7f69fec33
#include <stdio.h>
int test() {
static int val = 0;
val += 1;
return val;
}
int main() {
printf("val: %d\n", test());
View replace-string-across-all-objects.rb
def all_models
Rails.application.eager_load!
ActiveRecord::Base.descendants
end
def replace_string_across_all_objects(old, new)
all_models().each do |model|
print "Checking #{model} models\n"
model.all.each do |o|
o.attributes.each_pair do |name, value|
View test_tree.py
import sys
import unittest
import logging
from tree import Tree, tree, max_depth, max_depth_lr
logging.basicConfig(level=logging.DEBUG)
class TestInitTree(unittest.TestCase):
View keybase.md

Keybase proof

I hereby claim:

  • I am pix0r on github.
  • I am pix0r (https://keybase.io/pix0r) on keybase.
  • I have a public key whose fingerprint is 24AF 484F 9A25 4A45 EC2B 1A3E 94C0 FC62 8BC3 39FD

To claim this, I am signing this object:

@pix0r
pix0r / UnityView.mm
Last active Dec 21, 2015
UnityView.mm that uses rotation notification
View UnityView.mm
#include "UnityView.h"
#include "iPhone_View.h"
#include "iPhone_OrientationSupport.h"
#include "Unity/UnityInterface.h"
#include "Unity/GlesHelper.h"
#include "Unity/DisplayManager.h"
extern void UnitySendTouchesBegin(NSSet* touches, UIEvent* event);
extern void UnitySendTouchesEnded(NSSet* touches, UIEvent* event);
You can’t perform that action at this time.