Skip to content

Instantly share code, notes, and snippets.

@Darktt
Darktt / .gitignore
Last active May 11, 2022 00:51 — forked from adamgit/.gitignore
# Created by https://www.toptal.com/developers/gitignore/api/osx,xcode,swift
# Edit at https://www.toptal.com/developers/gitignore?templates=osx,xcode,swift
### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride
******* UIColor catagory ********
+ (NSArray *)colorComponentsFromColor:(UIColor *)color
{
const CGFloat *components = CGColorGetComponents(color.CGColor);
NSString *colorAsString = [NSString stringWithFormat:@"Red : %.0f, Green : %.0f, Blue : %.0f, Alpha : %.0f", components[0]*255.0, components[1]*255.0, components[2]*255.0, components[3]*100];
NSArray *componentsArr = [colorAsString componentsSeparatedByString:@","];
return componentsArr;
}
@Darktt
Darktt / UIAlertControllerBundle.h
Last active October 21, 2015 14:27
UIAlertControllerBundle
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
OBJC_ROOT_CLASS
@interface UIAlertControllerBundle
+ (UIAlertController *)alertControllerForPresentError:(NSString *)errorMessage;
@end
import Foundation
func addition(range: Range<Int>) -> Int
{
var sum = 0
let enumerator: (object: AnyObject, index: Int,stop: UnsafeMutablePointer<ObjCBool>) -> Void = {
(object, index, stop) -> Void in
if let number: Int = object as? Int {
- (void)viewDidLoad
{
UINib *nib = [UINib nibWithNibName:@"GameTableViewCell" bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier:@"GameTableViewCell"];
....
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell = [tableView dequeueReusableCeithIdentifier:@"GameTableViewCell" forIndexPath:indexPath];
@Darktt
Darktt / ACass.m
Last active April 15, 2016 14:24
Class 間的變數傳遞
@implementation AClass
@end
@Darktt
Darktt / AesCrypt.py
Created August 11, 2016 02:18 — forked from pfote/AesCrypt.py
AES256 with PKCS5 padding
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Crypto.Cipher import AES
import base64
import random
import hashlib
import os
class AesCrypt256:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let CellIdentifier: String = "CellIdentifier"
guard let cell: DaTableViewCell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier, forIndexPath: indexPath) as? DTSwipeDeleteCell else {
return UITableViewCell(style: .Default, reuseIdentifier: CellIdentifier)
}
if let textLabel = cell.textLabel {
@Darktt
Darktt / Good IOS RTSP Player.md
Last active May 2, 2018 09:59 — forked from oc2pcoj/Good IOS RTSP Player.md
iOS RTSP player for IP video cameras
public func Group(comment: String = "", execute: @convention(block) () -> Void)
{
execute()
}