Skip to content

Instantly share code, notes, and snippets.

View cypres's full-sized avatar

Hans Arnholm cypres

View GitHub Profile
@cypres
cypres / skipjack.php
Created December 16, 2011 22:41
SkipJack32
<?php
/**
* A 32-bit block cipher based on skipjack.
* In common: F-table, G-permutation, key schedule.
* Different: 24 round feistel structure.
*
* Ported to PHP from C implementation at:
* http://www.qualcomm.com.au/PublicationsDocs/skip32.c
*
* Might not work as expected on 32-bit processors due to PHP lacking a unsigned 32-bit integer.
@cypres
cypres / zfs_report.sh
Created December 19, 2011 21:35
ZFS scripts
#!/bin/sh
echo "ZFS listing:"
/sbin/zfs list
echo
echo "ZFS compression ratio:"
/sbin/zfs get compressratio | /usr/bin/grep -v @
echo
@cypres
cypres / BackButton.m
Created February 8, 2012 10:57
ios, manual end caps
#import "BackButton.h"
@implementation BackButton
-(void) awakeFromNib {
[self setBackgroundImage:nil forState:UIControlStateNormal];
}
-(void) drawRect:(CGRect)rect {
@cypres
cypres / RedButton.h
Created February 8, 2012 14:27
advanced manual 9 patching
//
// RedButton.h
// SkidtApp
//
// Created by Hans Duedal on 2/8/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@cypres
cypres / Actions.as
Created February 25, 2012 19:13
Tradeshow Light Control
/*
* Frame 1
*/
// Initialize the Arduino and set up event handlers
var arduino:ArduinoControl = new ArduinoControl("127.0.0.1",5331);
arduino.addEventListener(Event.CONNECT, onArduinoConnect);
arduino.addEventListener(IOErrorEvent.IO_ERROR, reconnect);
function onArduinoConnect( event:Event ):void
@cypres
cypres / php-fpm.conf.default
Created April 18, 2012 22:40
bsd php-fpm defaults
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/local). This prefix can be dynamicaly changed by using the
; '-p' argument from the command line.
; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
@cypres
cypres / blocksize.c
Created May 21, 2012 11:38
Solaris Drive Blocksize Inspect
/*
* Credit goes to:
* http://solaris.kuehnke.de/archives/18-Checking-physical-sector-size-of-disks-on-Solaris.html
* Compile: gcc blocksize.c -o blocksize
* Use: ie. ./blocksize /dev/rdsk/c0t5000C5004A918814d0
*/
#include <sys/types.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/dkio.h>
@cypres
cypres / AppDelegate.h
Created May 24, 2012 14:24
TestFlight integration
//
// AppDelegate.h
// SkidtApp
//
// Created by Hans Duedal on 1/31/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@cypres
cypres / topqueries.sql
Created June 1, 2012 17:20
top 10 longest running mssql queries
-- Clear query stats: DBCC FREEPROCCACHE
SELECT DISTINCT TOP 10
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime,
s.creation_time AS LogCreatedOn,
ISNULL(s.execution_count / CAST(DATEDIFF(s, s.creation_time, GETDATE()) AS FLOAT), 0) AS FrequencyPerSec
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
@cypres
cypres / vega-img-fix.sh
Last active December 12, 2015 06:39
Imagemagick conversions of vega images
# Find best replacement for Quality 60
find . -type f -name "*-ipad.jpg" -print0 | xargs -0 -n 1 identify -format "%f Q:%Q" | awk '/Q:60/ { H=substr($1,0,20); F=system("test -f " H "-fullscreen.jpg"); print F ? H ".jpg" : H "-fullscreen.jpg" }' > replacements.txt
# Generate the commands required for conversion
awk '{H=substr($1,0,20); print "convert " $1 " -quality 90 -profile sRGB.icm +profile '\''!iptc,!xmp,!icc,*'\'' -define jpeg:optimize-coding=on " H "-ipad.jpg" }' replacements.txt > replacement.sh
awk '{H=substr($1,0,20); print "cp " H "-ipad.jpg " H "[email protected]" }' replacements.txt >> replacement.sh
# Run the commands
chmod +x replacement.sh
sh replacement.sh
# Make a list of non-Quality-60 images