Skip to content

Instantly share code, notes, and snippets.

@shiweifu
shiweifu / view category
Created July 17, 2016 09:52
load NSView from nib file
extension NSView {
class func loadWithNibNamed(nibNamed: String, loadClass: AnyObject, tag: Int = 0) -> AnyObject? {
var topLevelObjects: NSArray?
let nib = NSNib(nibNamed: nibNamed, bundle: NSBundle.mainBundle())!
nib.instantiateWithOwner(nil, topLevelObjects: &topLevelObjects)
for object: AnyObject in topLevelObjects! {
if(object.isKindOfClass(loadClass.classForCoder)) {
//
// Created by shiweifu on 1/21/15.
// Copyright (c) 2015 SF. All rights reserved.
//
#import "SFResourceManager.h"
#import "HexColor.h"
@interface SFResourceManager()
@shiweifu
shiweifu / tobase64.py
Created December 8, 2014 04:25
covert binary file to base64 and save
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#author: shiweifu <[email protected]>
import base64
import argparse
def to_base64(data):
return base64.b64encode(data).decode()
@shiweifu
shiweifu / get_app_bundle.m
Created October 9, 2014 08:38
获取所有安装的App 的bundle
#include <objc/runtime.h>
Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];
NSLog(@"apps: %@", [workspace performSelector:@selector(allApplications)]);
@shiweifu
shiweifu / gist:907df809e482114d0ba8
Created July 21, 2014 03:47
SVHTTPRequest 的修改
//
// SVHTTPRequest.m
//
// Created by Sam Vermette on 20.09.11.
// Copyright 2011 samvermette.com. All rights reserved.
// Modify by shiweifu 2014.7.11
//
// https://github.com/samvermette/SVHTTPRequest
//
@shiweifu
shiweifu / 0_reuse_code.js
Created May 9, 2014 07:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from weibo import Client
import webbrowser
import json
def get_token():
try:
s = open("token").read()
license
bbbb