Skip to content

Instantly share code, notes, and snippets.

@alcherk
alcherk / HTTPStatusCode.swift
Created August 30, 2022 09:08 — forked from ollieatkinson/HTTPStatusCode.swift
HTTP status codes as a Swift enum.
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
enum HTTPStatusCode: Int, Error {
/// The response class representation of status codes, these get grouped by their first digit.
enum ResponseType {
/// - informational: This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
case informational
@alcherk
alcherk / generate-ssh-key.sh
Created April 2, 2020 04:52 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@alcherk
alcherk / DownloadHelper.kt
Created July 22, 2019 16:39
DownloadHelper uses Kotlin. Download a file by DownloadManager and normal download
import android.app.DownloadManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Environment
import android.webkit.URLUtil
import android.widget.Toast
import com.example.quicksave.MyApp
@alcherk
alcherk / unzip.swift
Created October 8, 2018 14:24
Unzip file and print logs to the console
private func logs2console2() {
guard let fileUrl = Bundle.main.url(forResource: "logs", withExtension: "zip") else { return }
guard let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
print(documentsUrl.absoluteString)
try! Zip.unzipFile(fileUrl, destination: documentsUrl, overwrite: true, password: nil)
let urls = try! FileManager.default.contentsOfDirectory(at: documentsUrl, includingPropertiesForKeys: nil)
urls.forEach { url in
guard url.absoluteString.contains(".log") else { return }
@alcherk
alcherk / ImageDownloadManager.swift
Created April 16, 2018 09:26 — forked from kittisak-phetrungnapha/ImageDownloadManager.swift
This is Swift 3 image downloader manager (uses Kingfisher) supported with cache that uses image's string url for key.
import Foundation
import Kingfisher
struct ImageDownloadManager {
static let shared = ImageDownloadManager()
private init() {}
// MARK: - Public method
@alcherk
alcherk / P12toPEM.txt
Created March 22, 2018 21:07 — forked from shahdhiren/P12toPEM.txt
Convert P12 file for Push Notification to PEM format
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
@alcherk
alcherk / gist:621026871ec051c56f468b88dc9cc4ec
Created November 5, 2017 11:57 — forked from gingerBill/gist:da32316b488950491189364e97198cd8
Incomplete tokenizer for WIP language
// NOTE(bill): Requires gb.h v0.25a
// TODO(bill): Unicode support
b32 rune_is_letter(Rune r) {
if (gb_char_is_alpha(cast(char)r) || r == '_') {
return true;
}
return false;
}
@alcherk
alcherk / ArrayTransform.swift
Created December 7, 2016 11:34 — forked from Jerrot/ArrayTransform.swift
Transform arrays with ObjectMapper to Realm's List type
// Based on Swift 1.2, ObjectMapper 0.15, RealmSwift 0.94.1
// Author: Timo Wälisch <[email protected]>
import UIKit
import RealmSwift
import ObjectMapper
import SwiftyJSON
class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType {
typealias Object = List<T>
@alcherk
alcherk / LICENSE
Created December 4, 2016 07:01 — forked from chriseidhof/LICENSE
A tiny networking library
Copyright 2015 Chris Eidhof
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@alcherk
alcherk / readme.md
Created November 9, 2016 14:29 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman