Skip to content

Instantly share code, notes, and snippets.

View ArchieR7's full-sized avatar
👨‍💻

Archie Chang ArchieR7

👨‍💻
View GitHub Profile
{
"campaign": {
"uuid": "ed43c9de-ce4d-4924-a7fe-0714e4ced77e",
"network": "eth", // e.g. eth, polygon, tt, bnb
"name": "campaign name",
"description": "campaign descritpion",
"validated_description": "validated!",
"redeemed_description": "redeemed!",
"image_url": "https://mainnet-cdn.redreamer.io/logo.png",
"contract_addresses": [
struct CustomTableViewCellModel {
let title: String
let content: String?
}
class CustomTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var contentTextView: UITextView!
var viewModel: CustomTableViewCellModel? {
protocol SomeProtocol {
associatedtype SomeType: Decodable
var bar: String { get }
}
struct Foo: SomeProtocol {
struct SomeType: Decodable {
let bar: String
}
var token = "";
function doPost(request) {
if (token != request.parameter.token) {
return;
}
const text = request.parameter.text;
const textForSlack = getAdSenseResponse(text);
const response = {"response_type": "in_channel", "text": textForSlack};
return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);
@ArchieR7
ArchieR7 / UUID+v5.swift
Created September 12, 2018 13:06
UUID initialize with version 3, 5 and namespace
extension UUID {
enum UUIDVersion: Int {
case v3 = 3
case v5 = 5
}
enum UUIDv5NameSpace: String {
case dns = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
case url = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
case oid = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
@ArchieR7
ArchieR7 / html.swift
Created April 11, 2018 16:16
convert to swift NSMutableAttributedString
var htmlString = NSMutableAttributedString()
do {
if let data = self.data(using: String.Encoding.unicode, allowLossyConversion: true) {
htmlString = try NSMutableAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)
}
} catch {
print(error)
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)
public init(type: String, localizedTitle: String, localizedSubtitle: String?, icon: UIApplicationShortcutIcon?, userInfo: [AnyHashable : Any]? = nil)
private func scaleMapImage(_ image: UIImage?, size: CGSize) -> UIImage? {
        guard let image = image else {
            return nil
        }
        UIGraphicsBeginImageContext(CGSize(width: size.width, height: size.height))
if let url = Bundle.main.url(forResource: ImageName, withExtension: ".png"),
let data = try? Data(contentsOf: url,
options: Data.ReadingOptions.uncached) {
let image = UIImage(data: data)
imageView.image = image
}