Skip to content

Instantly share code, notes, and snippets.

@Darktt
Darktt / BindingExtension.swift
Last active August 17, 2021 01:39
Binding optional value.
//
// BindingExtension.swift
//
// Created by Darktt on 21/8/17.
// Copyright © 2021 Darktt. All rights reserved.
//
import SwiftUI
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
@Darktt
Darktt / Currency.swift
Created July 30, 2021 09:15
Property wrapper demo
//
// Currency.swift
//
// Created by Darktt on 20/1/9.
// Copyright © 2020 Darktt. All rights reserved.
//
import Foundation
import CoreGraphics.CGBase
//
// OptionalExtension.swift
// DTTest
//
// Created by Darktt on 2019/6/11.
// Copyright © 2019 Darktt. All rights reserved.
//
import Foundation
const mqtt = require('mqtt');
const crypto = require('crypto');
var HOST = 'HOST';
var USERNAME = 'USER_NAME';
var PASSWORD = 'PASSWORD';
var client = mqtt.connect('mqtt://' + HOST, {username: USERNAME, password: crypto.createHash('sha512').update(PASSWORD, "utf8").digest("base64")});
console.log('connected to '+ HOST);
let screenRect: CGRect = UIScreen.main.bounds
let progressOutterView: UIView = {
let frame = CGRect(x: 40.0, y:0.0, width: screenRect.width * 0.8, height: 80.0)
let center = CGPoint(x: screenRect.midX, y: screenRect.height * 0.2)
let view = UIView(frame: frame)
view.center = center
view.clipsToBounds = true
procotol SomeDelegate: class
{
func someMethod(viewController: UIViewController, didCallBack someone: Any)
}
class SomeViewController1: UIViewController
{
weak var delegate: SomeDelegate?
}
public func Group(comment: String = "", execute: @convention(block) () -> Void)
{
execute()
}
@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
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 / 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: