Skip to content

Instantly share code, notes, and snippets.

View 128keaton's full-sized avatar

Keaton Burleson 128keaton

View GitHub Profile
@buechner
buechner / UIImageView+fixVectorTemplate.swift
Created August 2, 2016 10:01
Fixing a bug in XCode, where a vector image set as template can not be tinted in Interface Builder: http://openradar.appspot.com/18448072
import UIKit
// fixing Bug in XCode
// http://openradar.appspot.com/18448072
extension UIImageView {
override public func awakeFromNib() {
super.awakeFromNib()
self.tintColorDidChange()
}
}
@marmelroy
marmelroy / UIViewPropertyAnimator.swift
Last active November 9, 2022 02:28
A quick example of UIViewPropertyAnimator
// 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
})
#!/usr/bin/python
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 == '0.0.0.0': # ARP Probe
print "ARP Probe from: " + pkt[ARP].hwsrc
print sniff(prn=arp_display, filter="arp", store=0, count=10)
@bgreenlee
bgreenlee / flashScreen.swift
Created April 1, 2015 23:31
Flashing the screen in Swift. Sticking this here because it took me a while to work out the right variable types and casting.
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
bwhiteley / gist:049e4bede49e71a6d2e2
Last active March 17, 2024 13:10
Initialize Swift subclass of UIView, designed in .xib
// 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)
self.commonInit()
(* 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 (http://johnnyb.tumblr.com/post/25716608379/spotify-offline-playlist) *)
(* The idea of using delayed tagging/filename updating is from a guest user on pastebin (http://pastebin.com/rHqY0qg9) *)
(* 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 (http://sourceforge.net/projects/kid3/) and copy '%{artist} - %{album} - %{track} - %{title}' from file name to Tag 2 *)
@subudeepak
subudeepak / WebSockets.md
Last active November 2, 2022 00:04
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
Dinnerbone / gist:5662824
Created May 28, 2013 13:38
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…
{
"//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": [
1,
{"index": 2, "time": 4},
3,
4
],
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @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)