Skip to content

Instantly share code, notes, and snippets.


Keaton Burleson 128keaton

View GitHub Profile
buechner / UIImageView+fixVectorTemplate.swift
Created Aug 2, 2016
Fixing a bug in XCode, where a vector image set as template can not be tinted in Interface Builder:
View UIImageView+fixVectorTemplate.swift
import UIKit
// fixing Bug in XCode
extension UIImageView {
override public func awakeFromNib() {
marmelroy / UIViewPropertyAnimator.swift
Last active Apr 11, 2021
A quick example of UIViewPropertyAnimator
View UIViewPropertyAnimator.swift
// Create a UIViewPropertyAnimator object. Here's a simple one with a UIKit animation curve:
let colorChange = UIViewPropertyAnimator(duration: 0.3, curve: .easeIn, animations: { [weak self] in
self?.view.backgroundColor = UIColor(red: 255.0/255.0, green: 80.0/255.0, blue: 43.0/255.0, alpha: 1.0)
// There's also support for easy spring-based animations - all you need to set is a damping ratio (a value between 0 and 1). Alternatively, you can create your own curves by adopting the UITimingCurveProvider protocol.
let alphaChange = UIViewPropertyAnimator(duration: 0.3, dampingRatio: 0.6, animations: { [weak self] in
self?.circleView.alpha = 0.0
import sys
import time
import socket
import struct
import logging
import binascii
import subprocess
from scapy.all import *
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].psrc == '': # ARP Probe
print "ARP Probe from: " + pkt[ARP].hwsrc
print sniff(prn=arp_display, filter="arp", store=0, count=10)
bgreenlee / flashScreen.swift
Created Apr 1, 2015
Flashing the screen in Swift. Sticking this here because it took me a while to work out the right variable types and casting.
View flashScreen.swift
func flashScreen() {
let inDuration: CGDisplayFadeInterval = 0.5
let outDuration: CGDisplayFadeInterval = 0.5
let color = NSColor.redColor()
var fadeToken: CGDisplayFadeReservationToken = 0
let colorToUse = color.colorUsingColorSpaceName(NSCalibratedRGBColorSpace)!
let err = CGAcquireDisplayFadeReservation(inDuration + outDuration, &fadeToken)
if Int(err) != Int(kCGErrorSuccess.value) {
NSLog("Error acquiring fade reservation")
bwhiteley / gist:049e4bede49e71a6d2e2
Last active Sep 30, 2020
Initialize Swift subclass of UIView, designed in .xib
View gist:049e4bede49e71a6d2e2
// Create CustomView.xib, set File's Owner to CustomView.
// Link the top level view in the XIB to the contentView outlet.
class CustomView : UIView {
@IBOutlet private var contentView:UIView?
// other outlets
override init(frame: CGRect) { // for using CustomView in code
super.init(frame: frame)
View Spot the Hijack
(* Script to record and tag spotify tracks, by Lloyd Moore *)
(* Modified by Tiffany G. Wilson to resolve audio splitting issues, automate starting/stopping, and add recording customization *)
(* Snippets for controlling Spotify are from Johnny B on tumblr ( *)
(* The idea of using delayed tagging/filename updating is from a guest user on pastebin ( *)
(* The only thing to change in the script is the output format; you must change the file extension and the recording format to match *)
(* Run this script once a song you want to record is queued (stopped at beginning) or playing *)
(* Running the script will initiate hijacking, recording and audio playback *)
(* To stop script, pause Spotify or wait for album/playlist to end*)
(* To set id3 tags, use application Kid3 ( and copy '%{artist} - %{album} - %{track} - %{title}' from file name to Tag 2 *)
subudeepak /
Last active Feb 14, 2021
The problems and some security implications of websockets - Cross-site WebSockets Scripting (XSWS)

WebSockets - An Introduction

WebSockets is a modern HTML5 standard which makes communication between client and server a lot more simpler than ever. We are all familiar with the technology of sockets. Sockets have been fundamental to network communication for a long time but usually the communication over the browser has been restricted. The general restrictions

  • The server used to have a permanent listener while the client (aka browser) was not designated any fixed listener for a more long term connection. Hence, every communication was restricted to the client demanding and the server responding.
  • This meant that unless the client requested for a particular resource, the server was unable to push such a resource to the client.
  • This was detrimental since the client is then forced to check with the server at regular intervals. This meant a lot of libraries focused on optimizing asynchronous calls and identifying the response of asynchronous calls. Notably t
Dinnerbone / gist:5662824
Created May 28, 2013
As an essential step towards the Minecraft modding API, and also for sanity's sake in our own code, we're removing Texture Packs and replacing them with a new Resource Pack system. Ultimately, every mod/plugin will be its own resource pack, vanilla will be a resource pack by itself, and users will be able to apply multiple resource packs at once…
View gist:5662824
"//comment": "All metainfo files will be ORIGINAL_FILE.mcmeta. For example, textures/blocks/portal.png.mcmeta. The format is, of course, JSON.",
"animation": {
"//comment": "This block will be required for animated textures. It can be an empty block, but it will be needed to detect an animation.",
"frames": [
{"index": 2, "time": 4},
sekati /
Created Jul 24, 2012
Xcode Auto-increment Build & Version Numbers
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)