Skip to content

Instantly share code, notes, and snippets.

View akrabat's full-sized avatar

Rob Allen akrabat

View GitHub Profile
let digs: Set<Character> = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
extension String {
var firstNum: Int? {
return self
.characters
.indexOf(digs.contains)
.map(characters.suffixFrom)
.flatMap { cs in
Int(String(cs.prefixUpTo(cs.indexOf { c in !digs.contains(c) } ?? cs.endIndex)))
@asgrim
asgrim / pre-commit
Created December 31, 2015 11:46
Never commit a broken test again...
#!/bin/bash
echo -n "Running phpunit... "
vendor/bin/phpunit --stop-on-failure --stop-on-error > /dev/null
if [ $? -ne 0 ]
then
echo "[FAILED]"
exit 1
fi
import Glibc
// Swift 3 version here: https://gist.github.com/erica/7aee99db9753a1636e0fbed8d68b5845
/*
Did a bunch of tweaks this morning:
removed == true (sorry Kametrixom!)
cleaned up both stringFromBytes and bytesFromString
changed fperror check to guard
replaced use of 1024 in several places with a single constant
@brbsix
brbsix / README.md
Last active December 27, 2021 22:33
Networking Troubles with Vagrant Box ubuntu/wily64

Networking Troubles with Vagrant Box ubuntu/wily64

For some reason, the network interfaces in ubuntu/wily64 fail to configure at boot. The interfaces are renamed during boot, with dmesg reporting things like udev renamed network interface eth0 to enp1s0. This is apparently the result of a change in systemd. You can read about it here:

Starting with v197 systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, WLAN and WWAN interfaces. This is a departure from the traditional interface naming scheme ("eth0", "eth1", "wlan0", ...), but should fix real problems.

http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/


@sgolemon
sgolemon / gist:0e1ea13a16d21098e73f
Last active August 29, 2015 14:23
Questionable use of GitHub APIs

Over-reacted to second hand info and misinterpreted docs.

I do think OAuth providers (like Github, Twitter, Facebook, etc...) should do more to discourage apps from requesting write access. It PARTICULARLY disturbs me that admin:public_key is even an option in Github's Scopes. So the potential for disasterous outcomes certainly exists when granting access to apps via Github's OAuth system, but provided that you carefully read what you're granting access to, it's not necessarily as bad a my original post (left intact below) made it out.


During a twitter conversation[1] this morning, I discovered that in order for an application to get something as simple as your name during a single-sign on, it has to ask for full user profile information. That's a bit scary by itself, but when asking for full profile information, it also has to ask for read and WRITE permissions.[2]

Yes, in order to use single-signon to a 3rd party site, I have to give that site the rights to modify my email addr

@listrophy
listrophy / Glob.swift
Created June 25, 2015 17:14
Wrap glob(3) in Swift
//
// Glob.swift
//
// Created by Brad Grzesiak on 6/25/15.
// Copyright © 2015 Bendyworks Inc.
// Released under the Apache v2 License.
//
import Foundation
@lrytz
lrytz / z-automator.png
Last active February 4, 2023 21:20
Shortcut for Syntax Highlighting in Keynote
#!/usr/bin/env ruby -wKU
# Comments added 6 March 2014.
# Implementation of the MetaWeblog API for my personal Ruby static blog generator.
# This is not even nearly idiomatic Ruby. There are all kinds of issues.
# (What's with the method interiors all being mushed-up together?)
# But -- it's also worked flawlessly for five years without my having to edit it.
# It won't work for anyone else as-is — but if it helps anyone
# to do a MetaWeblog API implementation, then cool.
@weierophinney
weierophinney / SoapController.php
Created February 12, 2014 16:46
Example of creating a SOAP controller for handling both WSDL and SOAP requests in ZF2.
<?php
namespace Soap\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\Soap\AutoDiscover as SoapWsdlGenerator;
use Zend\Soap\Server as SoapServer;
class SoapController
{

Development Contract Killer

A fork of the popular open-source contract for web designers and developers by Stuff & Nonsense, reworded for developers


Between us [company name] and you [customer name]