Skip to content

Instantly share code, notes, and snippets.

View victoraugustolls's full-sized avatar
🦦
Gopher

Victor victoraugustolls

🦦
Gopher
View GitHub Profile
import asyncio
import httpx
async def do_request(client: httpx.AsyncClient):
try:
await client.get(
url="https://google.com",
)
@victoraugustolls
victoraugustolls / ExampleModel.swift
Created June 12, 2016 21:34
Example of fetching Mapped Object using Realm and Alamofire
import UIKit
import ObjectMapper
import RealmSwift
class Example: Object, Mappable, Meta {
dynamic var id: Int = 0
dynamic var title: String = ""
dynamic var author: String = ""
dynamic var genre: String = ""
@victoraugustolls
victoraugustolls / Dictionary+Extension.swift
Created June 3, 2016 15:10
Swift dictionary type extension.
extension Dictionary where Value : Equatable {
func allKeysForValue(val : Value) -> [Key] {
return self.filter { $1 == val }.map { $0.0 }
}
}
public extension dispatch_queue_t {
final func async(block: dispatch_block_t) {
dispatch_async(self, block)
}
final func async(group: dispatch_group_t, _ block: dispatch_block_t) {
dispatch_group_async(group, self, block)
}
final func sync(block: dispatch_block_t) {
dispatch_sync(self, block)
}
@victoraugustolls
victoraugustolls / gist:0f4b41bef626f26fe205
Created October 30, 2015 15:37
iOS app icons from 2014px image
function mkicns() {
if [[ -z "$@" ]]; then
echo "Input file missing"
else
filename=${1%.*}
mkdir $filename.iconset
sips -z 16 16 $1 --out $filename.iconset/icon_16x16.png
sips -z 32 32 $1 --out $filename.iconset/icon_16x16@2x.png
sips -z 32 32 $1 --out $filename.iconset/icon_32x32.png
sips -z 64 64 $1 --out $filename.iconset/icon_32x32@2x.png
@victoraugustolls
victoraugustolls / DelayWithDispatch.swift
Last active June 11, 2016 20:09
Dispatch_after delay in Swift
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(), closure)
}