Skip to content

Instantly share code, notes, and snippets.

@shayne
shayne / gist:1001050
Created May 31, 2011 18:53
PeepOpen Xcode 3 script
#!/bin/sh
open "peepopen://%%%{PBXFilePath}%%%?editor=Xcode"
@shayne
shayne / gist:3086902
Created July 10, 2012 23:27
Add Mac OS X user to "wheel" group (no more sudo passwd)
sudo dscl . -append /groups/wheel GroupMembership <username>
# now `sudo visudo` and remove comment from: %wheel ALL=(ALL) NOPASSWD: ALL
//
// CGViewController.swift
// Banksy
//
// Created by Shayne Sweeney on 11/1/14.
// Copyright (c) 2014 App Couture. All rights reserved.
//
import UIKit
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Not needed
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let indexPath = self.tableView.indexPathForSelectedRow()!
let destinationController = segue.destinationViewController as ProductDetailViewController
destinationController.productData = products[indexPath.row] as PFObject
}
@shayne
shayne / json_grammar.pl
Created April 1, 2016 18:49
Perl 6 JSON Grammar - playing with Perl6
use LWP::Simple;
grammar JsonGrammer {
token TOP { <object-value>|<array-value> }
token any-value { \s* <string-value>|<numeric-value>|<null-value>|<object-value>|<array-value> \s* }
token object-value { '{' <property> [\s* \, \s* <property> \s*]*'}' }
token array-value { '[' <any-value> [\s* \, \s* <any-value> \s*]*']' }
token property { \s* <key> \s* ':' \s* <any-value> \s* }
token key { \" \w+ \" }
token any-quotes { <["']> }

Keybase proof

I hereby claim:

  • I am shayne on github.
  • I am shayne (https://keybase.io/shayne) on keybase.
  • I have a public key ASDyQYKTQTZgsHIJo_wBxC2EaPPYCE8QkkBHk4BdK-w0jgo

To claim this, I am signing this object:

@shayne
shayne / gtk-clip
Created October 8, 2016 05:31
[fix] deepin-screenshot clipboard not working
#!/bin/bash
# REPLACE EXISTING FILE WITH THIS
# /usr/share/deepin-screenshot/src/gtk-clip
# source: http://unix.stackexchange.com/a/266761
command -v xclip >/dev/null 2>&1 || { echo "Need command xclip. Aborting." >&2; exit 1; }
[[ -f "$1" ]] || { echo "Error: Not a file." >&2; exit 1; }
TYPE=$(file -b --mime-type "$1")
xclip -selection clipboard -t "$TYPE" < "$1"
@shayne
shayne / gist:47bf6dcec6d13653e4cbfeaab7f2e1b8
Created October 12, 2016 05:11
Copy terminfo to host
infocmp | ssh $remote "cat > $TERM.ti ; tic -o ~/.terminfo $TERM.ti"
sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target
@shayne
shayne / usbreset.c
Created December 1, 2016 02:22
reset usb bus linux
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
void main(int argc, char **argv)
{
const char *filename;
int fd;
filename = argv[1];