Skip to content

Instantly share code, notes, and snippets.

View waynew's full-sized avatar
💭
Making the world a little Saltier - one grain at a time

Wayne Werner waynew

💭
Making the world a little Saltier - one grain at a time
View GitHub Profile
@waynew
waynew / UTTypeForImageData.m
Created August 25, 2016 23:46 — forked from mattt/UTTypeForImageData.m
A quick function for determining an image's file type by its first couple of bytes
@import MobileCoreServices;
static CFStringRef UTTypeForImageData(NSData *data) {
const unsigned char * bytes = [data bytes];
if (data.length >= 8) {
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) {
return kUTTypePNG;
}
}
@waynew
waynew / ftpserver.py
Created October 3, 2018 23:40 — forked from scturtle/ftpserver.py
simple ftp server by python
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
#import traceback
allow_delete = False
local_ip = socket.gethostbyname(socket.gethostname())
local_port = 8888
currdir=os.path.abspath('.')