Skip to content

Instantly share code, notes, and snippets.

View ifournight's full-sized avatar
👾
Alona!

Song Hui ifournight

👾
Alona!
View GitHub Profile
@ifournight
ifournight / csv
Created February 26, 2015 16:01
py
import csv
# Map row to dictionary (dictionary comprehension)
def player(column_names, row):
return {column_names[column]: data for column, data in enumerate(row) if column < len(column_names)}
# Map CSV file to list of dictionaries (list comprehension)
players = [player(['name', 'position', 'game_info', 'price'], row) for row in csv.reader(open('dk.csv', 'r'))]
def loadAvatarCsv(row):
import flash.geom.Matrix3D;
import flash.geom.Orientation3D;
import flash.geom.Vector3D;
public class Matrix3DUnils {
private static var _raw : Vector.<Number> = new Vector.<Number>(16, true);
private static var _toRad : Number = 0.0174532925199433;
private static var _toAng : Vector3D = 57.2957795130823;
private static var _vector : Vector3D = new Vector3D();
private static var _right : Vector3D = new Vector3D();
@ifournight
ifournight / getElementLeft
Created November 19, 2013 08:48
DOM DIMENSIONS
function getElementLeft(element) {
var actualLeft = element.offsetLeft;
var current = element.offsetParent;
while (current !== null) {
actualLeft += current.offsetLeft;
current = current.offsetParent;
}
return actualLeft;
@ifournight
ifournight / gist:5941943
Created July 7, 2013 01:48
Remove UIWebView Shadow
for (UIView* shadowView in [webView.scrollView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
@ifournight
ifournight / UISearchbarTextAligment.m
Last active October 3, 2019 23:05
UISearchbar Text Aligment
self.searchbar = [[UISearchBar alloc] initWithFrame:CGRectMake(5.0, 0.0, 310.0, 44.0)];
self.searchbar.autocorrectionType = UITextAutocorrectionTypeNo;
self.searchbar.showsCancelButton = YES;
self.searchbar.spellCheckingType = UITextSpellCheckingTypeNo;
[self.searchbar setImage:[UIImage imageNamed:@"SearchBarIcon-Search.png"]
forSearchBarIcon:UISearchBarIconSearch
state:UIControlStateNormal];
[self.searchbar setImage:[UIImage imageNamed:@"SearchBarIcon-Clear.png"]
forSearchBarIcon:UISearchBarIconClear
state:UIControlStateNormal];
#import <Foundation/Foundation.h>
#import "SDocumentCell.h"
#import "SDocumentTag.h"
// Encapsulate all needed datas of Document Cell.
@interface SDocumentCellData : NSObject
// Main label's attributedText.
@property (nonatomic, strong) NSAttributedString *mainAttributedText;
#import <Foundation/Foundation.h>
// Relative path for library's info.plist.
UIKIT_EXTERN NSString *kLibraryInfoPlistPath;
// Relative path for library's NSManagedObjectStore.
UIKIT_EXTERN NSString *kLibraryStorePath;
// Relative path where all library's documents locate.
UIKIT_EXTERN NSString *kLibraryDocumentPath;
#import <Foundation/Foundation.h>
#import "SSearchManager.h"
#import "SSearchNode.h"
// An operation that search all search manager's nodes based on its search string.
@interface SNodeSearchOperation : NSOperation
// Search string.
@property (nonatomic, copy) NSString *searchString;
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
// SNode class is one of the two most important objects throughout the entire Xcode Reader Project.
// Because all documents in every Apple's documentation library, are categorized into two category: Token and Node, and stored in Core Data.
// Token represents reference/ API: OBC C++ Class, Protocol, Method, Enum, Struct, Constant, Function, Macro, Notification...
// Node represents guide/ sample code and all the articles.
// They all have many properties and a graphic stored in Core Data's NSManagedObjectModel.
// Throughout Xcode Reader's workflow, tokens and node will be prefetched into memory from Core Data.
// And Their properties may be used in different context.