Skip to content

Instantly share code, notes, and snippets.

@izotx
izotx / upload.swift
Last active September 23, 2018 22:58
Uploading Image to Server
static func uploadImage(image:UIImage,token:String, imageType:String, callback:((message:String?, error:String?)->Void))->NSURLSessionTask{
var imageData = UIImagePNGRepresentation(image)
var request = NSMutableURLRequest(URL: NSURL(string:APIKeys.url.rawValue)!)
request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData
var session = NSURLSession.sharedSession()
request.HTTPMethod = "POST"
import AWSS3
class S3Uploader: NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate {
var urlSession: NSURLSession?
var uploadTask: NSURLSessionUploadTask?
var url: String?
var filename: String?
var callback: ((Bool, String?) -> Void)? = nil;
//This needs to Deinit when unwind segue, but right now it only deinits sometimes !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@wariw
wariw / mpv.conf
Created April 28, 2015 19:48
mpv.conf
# Video
#vo = opengl-hq,direct3d
# vo=opengl-hq:interpolation:scale=ewa_lanczos:cscale=ewa_lanczos:tscale=mitchell:scaler-resizes-only:dither-depth=8:temporal-dither:waitvsync:pbo
vo=opengl-hq:interpolation:scale=haasnsoft:cscale=haasnsoft:source-shader=[D:\Documents\mpvhq\deband.glsl]:tscale=mitchell:dscale=triangle:scaler-resizes-only:dither-depth=8:temporal-dither:waitvsync:pbo
# Audio
ao = wasapi,dsound,openal
alang = jpn,jap,jp,Japanese,en,eng,English
# Subtitles
@pudquick
pudquick / heyheyhey.py
Last active April 13, 2019 05:08
Example of using nibbler to make an annoying window that re-focuses itself to the front every second
from nibbler import *
from Foundation import NSTimer, NSObject
from AppKit import NSApplication
n = Nibbler('/Users/frogor/Desktop/sweet.nib')
def test2():
print "hi (politely quit)"
n.quit()
@pudquick
pudquick / receipts.py
Created August 18, 2016 17:14
Programmatically access package receipt information using the OS X PrivateFramework PackageKit (same one pkgutil uses) with python and pyobjc
import objc
packagekit_bundle = objc.loadBundle('PackageKit', module_globals=globals(), bundle_path='/System/Library/PrivateFrameworks/PackageKit.framework', scan_classes=False)
PKReceipt = objc.lookUpClass('PKReceipt')
receipts = PKReceipt.receiptsOnVolumeAtPath_('/')
first_receipt = receipts[0]
# Things you can look up:
# installPrefixPath
@pudquick
pudquick / pyobjc_keychain.py
Last active February 28, 2020 17:09
Manipulating the Keychain in macOS via python and pyobjc
from Foundation import NSBundle
import objc, array
# from CoreFoundation import CFGetTypeID
Security = NSBundle.bundleWithPath_('/System/Library/Frameworks/Security.framework')
# First we need the CF TypeIDs to build some signatures
functions = [
('SecKeychainGetTypeID', 'I'),
]
#include <stdio.h>
#include <string.h>
#include <windows.h>
static CALLBACK DWORD discard_thread(void *arg)
{
HANDLE pipe = arg;
OVERLAPPED ol = { 0 };
ol.hEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
ldapdb = collections.namedtuple("namespace", ['person', 'group', 'share', 'maillist'])
ldapdb.person = ldap_to_pandas(ldap.search(filter="(&(objectClass=univentionPerson))", base=common.ucs_access.base_dn()))
ldapdb.group = ldap_to_pandas(ldap.search(filter="(&(objectClass=univentionGroup))", base=common.ucs_access.base_dn()))
ldapdb.share = ldap_to_pandas(ldap.search(filter="(&(objectClass=univentionShare))", base=common.ucs_access.base_dn()))
ldapdb.maillist = ldap_to_pandas(ldap.search(filter="(&(objectClass=univentionMailList))", base=common.ucs_access.base_dn()))
@Dregu
Dregu / instant-replay-playlist.lua
Last active October 1, 2020 00:49
OBS-studio script to play instant replays and/or automatically add replays to VLC playlist for later
obs = obslua
source_name = ""
vlc_name = ""
scene_name = ""
replaying = false
autoclear = false
addall = false
replaylength = 10
instant_hotkey_id = obs.OBS_INVALID_HOTKEY_ID
add_hotkey_id = obs.OBS_INVALID_HOTKEY_ID
@nitaku
nitaku / README.md
Last active October 6, 2020 07:33
Cola.js layout

A simple exercise with cola.js. A node-link diagram is displayed, based on positions computed by cola's fast-converging constraints-based layout algorithm. Handling of more than one connected component, node dragging and non-overlapping constraints are also shown.

Compare with a similar example using native d3.js force-directed layout.