Skip to content

Instantly share code, notes, and snippets.

View gartmeier's full-sized avatar

Joshua Gartmeier gartmeier

  • Pitcher AG
  • Switzerland
View GitHub Profile
@gartmeier
gartmeier / ipfw.sh
Created July 6, 2012 09:07
Mac FireWall (ipfw) Bandwidth Control Script
#!/bin/bash
SUDO_PASSWD='***'
echo $SUDO_PASSWD | sudo -S ipfw pipe 1 config bw $1kbit/s
echo $SUDO_PASSWD | sudo -S ipfw add pipe 1 dst-ip 0.0.0.0/0
read -p "hit enter to flush..." yn
echo $SUDO_PASSWD | sudo -S ipfw flush
@gartmeier
gartmeier / ios.as
Created July 20, 2012 09:33
as3 check iOS device
if (Capabilities.os.indexOf('iPhone') > -1 || Capabilities.os.indexOf('iPad') > -1) {
// iOS
} else {
// other
}
@gartmeier
gartmeier / Unzip
Last active December 31, 2015 05:29
Unzip archives with folders
// unzip if necessary
string ext = Path.GetExtension(fileItem.vUrl).ToLower();
if (ext.Equals(".zip"))
{
StorageFolder destinationFolder = await folder.CreateFolderAsync(Path.GetFileNameWithoutExtension(fileItem.vUrl), CreationCollisionOption.OpenIfExists);
Stream zipMemoryStream = await storageFile.OpenStreamForReadAsync();
// Create zip archive to access compressed files in memory stream
using (ZipArchive zipArchive = new ZipArchive(zipMemoryStream, ZipArchiveMode.Read))
{
// For each compressed file...
@gartmeier
gartmeier / openurl.sh
Last active August 29, 2015 14:04
Shell script to open the folder of a file url
#!/bin/bash
# installation:
# ~$: mv openurl.sh /usr/local/bin/openurl
# ~$: chmod +x /usr/local/bin/openurl
#
# usage: openurl file:///Users/user01/Documents/Workspace/project%201/index.html
#
# credits: urlencode and urldecode copied from https://gist.github.com/cdown/1163649
@gartmeier
gartmeier / pin.php
Last active October 2, 2017 16:48
generates a pin code with numbers next to each other
<?php
$num = [
1 => [2, 4],
2 => [1, 3, 5],
3 => [2, 6],
4 => [1 ,5 ,7],
5 => [2, 4, 6, 8],
6 => [3, 5, 9],
7 => [4, 8],
(function ($) {
var isWin = typeof Ti.App.Platform !== 'undefined'
&& Ti.App.Platform === 'Win';
var currentResourceId = 0,
deferredMap = {};
$.query = function (query, db) {
var id = nextQueryId(),
d = deferredMap[id] = $.Deferred(),
@gartmeier
gartmeier / wp-compensated-links-snippet.php
Created March 9, 2018 06:39
Wordpress Snippet to show compensated links information
@gartmeier
gartmeier / disclosures.js
Last active May 31, 2018 17:10
Adds disclosure slides to custom decks
(function ($) {
var prefix = 'System:ds:';
function uniqueArray(ar) {
var j = {};
ar.forEach(function (v) {
j[v + '::' + typeof v] = v;
});
@gartmeier
gartmeier / pwd.py
Created May 31, 2018 18:19
Generate passwords
import string
import random
for x in range(1000):
print(''.join(random.choices(string.ascii_lowercase + string.ascii_uppercase + string.digits, k=10)))
@gartmeier
gartmeier / event.js
Last active November 23, 2018 09:58
$(function() {
$.fireEvent = function(name, data) {
var deferred = $.Deferred(),
callback = 'cb' + Math.random().toString(36).substring(7);
if (data) {
data.callBackFunc = callback;
data.callBack = callback;
data.source = $.fireEvent.defaults.source;
}