Skip to content

Instantly share code, notes, and snippets.

@jk
jk / install_php.sh
Created June 13, 2014 13:45
Small workflow script to install a new php version via php-build
#!/bin/bash
# Test user == jenkins
PHP_VERSION=5.4.16
PHP_DIR=~/.phpenv/versions/$PHP_VERSION
PHP_INI_DIR=/var/lib/jenkins/.phpenv/versions/$PHP_VERSION/etc/php.ini
TEMP_DIR=~/tmp/$PHP_VERSION
echo "Install PHP ${PHP_VERSION} into ${PHP_DIR}"
cd ~
// Playground - noun: a place where people can play
import Cocoa
struct Regex {
let pattern: String
let expressionOptions: NSRegularExpressionOptions
let matchingOptions: NSMatchingOptions
init(pattern: String, expressionOptions: NSRegularExpressionOptions, matchingOptions: NSMatchingOptions) {
@jk
jk / composer.json
Last active August 29, 2015 14:01
Test shell script to update composer.json via POST API call on versioneye.com
{
"require": {
"phpmd/phpmd": "~1",
"squizlabs/php_codesniffer": "dev-master",
"phpunit/phpunit": "~4",
"pdepend/pdepend": "~2@dev",
"phpspec/phpspec": "~2",
"phing/phing": "~2",
"composer/composer": "1.0.0-alpha8"
},
@jk
jk / Bootstrap.php
Created May 15, 2014 15:22
Patch some configuration capabilities into PHPUnit
<?php
$prefixPath = 'tests';
/*
* Load the user-defined test configuration file, if it exists; otherwise, load
* the default configuration.
*/
if (is_readable($prefixPath . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
require_once $prefixPath . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
} else {
require_once $prefixPath . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
@jk
jk / smart-truncate.php
Created April 27, 2014 14:00
Smart Truncate
<?php
header('Content-type: text/plain; charset=utf-8');
/**
* Found on:http://stackoverflow.com/a/1193598/408150
*/
function printTruncated($maxLength, $html, $isUtf8=true)
{
$printedLength = 0;
$position = 0;
@jk
jk / UnitTestPrivateMethods.php
Last active August 29, 2015 13:58
Helper method to test private and protected methods with PHPUnit (it's not bound to PHPUnit what so ever)
<?php
class PHPUnitHelper {
/**
* Helps testing private and protected methods on SAC objects
* @param object $class_instance class instance object
* @param $method Method name
* @return mixed method return value
*/
public static function invokePrivateMethod($class_instance, $method_name) {
$method = new ReflectionMethod(get_class($class_instance), $method_name);
Pod::Spec.new do |s|
s.name = 'NSDate+Helper'
s.version = '1.0.0'
s.summary = 'A category to extend Cocoa\'s NSDate class with some convenience functions.'
s.description = 'This is a category for the NSDate class that provides some convenience methods for working with NSDate objects and displaying formatted and relative strings.'
s.homepage = 'https://github.com/billymeltdown/nsdate-helper'
s.license = {
:type => 'Modified BSD License',
:text => 'Copyright © 2009, 2010, ZETETIC LLC
All rights reserved.

Keybase proof

I hereby claim:

  • I am jk on github.
  • I am jkohl (https://keybase.io/jkohl) on keybase.
  • I have a public key whose fingerprint is 8212 F197 EDA0 533B F03E 0153 6497 9564 EBE7 4D76

To claim this, I am signing this object:

@jk
jk / fix-xcode
Created January 17, 2014 15:33 — forked from rnapier/fix-xcode
#!/usr/bin/python
# fix-xcode
# Rob Napier <[email protected]>
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs:
Pod::Spec.new do |s|
s.name = 'SYCache'
s.version = '1.0'
s.license = 'MIT'
s.summary = 'Fancy caching with on-disk persistence'
s.homepage = 'https://github.com/Synthetic/SYCache'
s.author = { 'Sam Soffes' => '[email protected]' }
s.source = { :git => 'https://github.com/Synthetic/SYCache.git', :commit => 'origin/master' }
s.source_files = 'SYCache.{h,m}'
s.description = 'Simple in memory and on disk cache. It\'s backed by an NSCache in memory, ' \