This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---@param input string | |
---@return table<string> | |
local function parse_raw(input) | |
local res = {} | |
local is_key = true | |
local is_value = false | |
local key_t = {} | |
local value_t = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---@class OrderedMap | |
local OrderedMap = {} | |
OrderedMap.__name = 'Map' | |
local keys_key = setmetatable({}, { | |
__tostring = function() return "<___keys___>" end | |
}) | |
local vals_key = setmetatable({}, { | |
__tostring = function() return "<___vals___>" end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
from urllib.parse import urlparse | |
edge_config_id_prefix = "ecfg_" | |
class EdgeConfigError(Exception): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Sequence { | |
func mapAsync<T>(_ handler: @escaping (Element) async -> T) async -> [T] { | |
return await withTaskGroup(of: (Int, T).self) { group in | |
var results: [Int: T] = [:] | |
for (index, item) in self.enumerated() { | |
group.async { (index, await handler(item)) } | |
} | |
for await (index, transformed) in group { | |
results[index] = transformed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func printerSeries(for name: String) -> Int32 { | |
switch name.uppercased() { | |
case "TM-M10": | |
return EPOS2_TM_M10.rawValue | |
case "TM-M30": | |
return EPOS2_TM_M30.rawValue | |
case "TM-P20": | |
return EPOS2_TM_P20.rawValue | |
case "TM-P60": | |
return EPOS2_TM_P60.rawValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* Returns the cheapest way to colonize the given species | |
* The first argument is an Array of species, and the second argument | |
* is an array of discounts. | |
* | |
* A single species in the array, accesed like species[0], has 2 properties: | |
* - cost: Int - the cost to bring 1 of these species without a discount | |
* - needToBring: Int - the number of species I need to bring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Dispatch.swift | |
// | |
// Created by Andrew Barba on 8/25/15. | |
// | |
import Foundation | |
public struct Dispatch { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xcode-fast: | |
rm -rf Pods | |
rm -rf *.lock | |
rm -rf *.xcworkspace | |
rm -rf ~/Library/Caches/com.apple.dt.Xcode/* | |
rm -rf ~/Library/Developer/Xcode/DerivedData/* | |
pod install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example: UIColor *teal = UIColorMake(9.0, 171.0, 161.0, 1.0) | |
*/ | |
CG_INLINE UIColor* | |
__UIColorMake(CGFloat r, CGFloat g, CGFloat b, CGFloat a) | |
{ | |
return [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:a]; | |
} | |
#define UIColorMake __UIColorMake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @updated: 2014-07-29 | |
* @source: http://stackoverflow.com/questions/6052966/phone-number-formatting | |
*/ | |
-(NSString*)phoneNumberString | |
{ | |
static NSCharacterSet* set = nil; | |
TL_DISPATCH_ONCE(^{ | |
set = [[NSCharacterSet decimalDigitCharacterSet] invertedSet]; | |
}); |
NewerOlder