Skip to content

Instantly share code, notes, and snippets.

@gisongeorge
gisongeorge / CryptoRandom.cs
Created March 2, 2021 06:42 — forked from niik/CryptoRandom.cs
Buffered CryptoRandom implementation based on Stephen Toub and Shawn Farkas' CryptoRandom
/*
* Original version by Stephen Toub and Shawn Farkas.
* Random pool and thread safety added by Markus Olsson (freakcode.com).
*
* Original source: http://msdn.microsoft.com/en-us/magazine/cc163367.aspx
*
* Some benchmarks (2009-03-18):
*
* Results produced by calling Next() 1 000 000 times on my machine (dual core 3Ghz)
*
@gisongeorge
gisongeorge / HTTPStatusCode.swift
Created October 28, 2020 18:58 — 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
@gisongeorge
gisongeorge / defaultFont.swift
Created April 26, 2020 18:03 — forked from chonnawee4/defaultFont.swift
Set default system font to custom font
struct AppFontName {
static let regular = "CourierNewPSMT"
static let bold = "CourierNewPS-BoldMT"
static let italic = "CourierNewPS-ItalicMT"
}
extension UIFontDescriptor.AttributeName {
static let nsctFontUIUsage = UIFontDescriptor.AttributeName(rawValue: "NSCTFontUIUsageAttribute")
}
@gisongeorge
gisongeorge / universal-framework.sh
Created May 8, 2019 09:58 — forked from cromanderrr/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@gisongeorge
gisongeorge / SeatPlan.json
Last active July 17, 2018 12:01
Theater Seat Plan
{
"StatusCode":10000,
"Status":"Success",
"Data":{
"zones":[
{
"id":5,
"name":"Platinum",
"sort":1,
"startIndex":1,
{"StatusCode":10000,"Status":"Success","Data":{"zones":[{"id":5,"name":"Platinum","sort":1,"startIndex":1,"maxRows":5,"maxColumns":10,"colorCode":"0f0","price":120,"totalSeats":32,"seatsBooked":0,"seats":[{"id":243,"name":"A1","seatKey":"key","rowNumber":1,"columnIndex":1,"bookedStatus":0},{"id":244,"name":"A2","seatKey":"key","rowNumber":1,"columnIndex":2,"bookedStatus":1},{"id":245,"name":"A3","seatKey":"key","rowNumber":1,"columnIndex":3,"bookedStatus":1},{"id":246,"name":"A4","seatKey":"key","rowNumber":1,"columnIndex":4,"bookedStatus":1},{"id":247,"name":"A5","seatKey":"key","rowNumber":1,"columnIndex":7,"bookedStatus":1},{"id":248,"name":"A6","seatKey":"key","rowNumber":1,"columnIndex":8,"bookedStatus":0},{"id":249,"name":"A7","seatKey":"key","rowNumber":1,"columnIndex":9,"bookedStatus":0},{"id":250,"name":"A8","seatKey":"key","rowNumber":1,"columnIndex":10,"bookedStatus":0},{"id":251,"name":"B1","seatKey":"key","rowNumber":2,"columnIndex":1,"bookedStatus":0},{"id":252,"name":"B2","seatKey":"key","rowNu
@gisongeorge
gisongeorge / CoreDataManager.swift
Last active May 10, 2018 13:05
CoreDataManager iOS 10 > & < iOS10
import Foundation
import CoreData
class CoreDataManager {
// MARK: - Core Data stack
static let sharedInstance = CoreDataManager()
private lazy var applicationDocumentsDirectory: URL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named in the application's documents Application Support directory.
-(void)fillCircleCenteredAt:(CGPoint)center
{
UIBezierPath *path = [UIBezierPath bezierPath];
[path addArcWithCenter:center
radius:50.0
startAngle:0.0
endAngle:2.0 * M_PI
clockwise:NO];
[path fill];
}
@gisongeorge
gisongeorge / movies.json
Created August 5, 2017 09:46
Movie list
{
"page": {
"title": "Romantic Comedy",
"total-content-items" : "54",
"page-num" : "1",
"page-size" : "20",
"content-items": {
"content": [
{
"name": "The Birds",
@gisongeorge
gisongeorge / samplejson.json
Last active September 26, 2016 04:31
This page shows example json string
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",