Skip to content

Instantly share code, notes, and snippets.

View Mehul1437's full-sized avatar

Mehul Akoliya Mehul1437

View GitHub Profile
@twof
twof / ReflectiveDecodable.swift
Created March 3, 2018 05:46
Codable that automatically decodes with default vals
import Foundation
func iterateEnum<T: Hashable>(_: T.Type) -> AnyIterator<T> {
var i = 0
return AnyIterator {
let next = withUnsafeBytes(of: &i) { $0.load(as: T.self) }
if next.hashValue != i { return nil }
i += 1
return next
}
@DmytroLisitsyn
DmytroLisitsyn / country_dial_info.json
Last active November 6, 2024 15:40 — forked from Goles/CountryCodes.json
A JSON dataset of entities containing country name, code, dial (phone) code and flag emoji icon.
[{"name":"Afghanistan","flag":"🇦🇫","code":"AF","dial_code":"+93"},{"name":"Åland Islands","flag":"🇦🇽","code":"AX","dial_code":"+358"},{"name":"Albania","flag":"🇦🇱","code":"AL","dial_code":"+355"},{"name":"Algeria","flag":"🇩🇿","code":"DZ","dial_code":"+213"},{"name":"American Samoa","flag":"🇦🇸","code":"AS","dial_code":"+1684"},{"name":"Andorra","flag":"🇦🇩","code":"AD","dial_code":"+376"},{"name":"Angola","flag":"🇦🇴","code":"AO","dial_code":"+244"},{"name":"Anguilla","flag":"🇦🇮","code":"AI","dial_code":"+1264"},{"name":"Antarctica","flag":"🇦🇶","code":"AQ","dial_code":"+672"},{"name":"Antigua and Barbuda","flag":"🇦🇬","code":"AG","dial_code":"+1268"},{"name":"Argentina","flag":"🇦🇷","code":"AR","dial_code":"+54"},{"name":"Armenia","flag":"🇦🇲","code":"AM","dial_code":"+374"},{"name":"Aruba","flag":"🇦🇼","code":"AW","dial_code":"+297"},{"name":"Australia","flag":"🇦🇺","code":"AU","dial_code":"+61"},{"name":"Austria","flag":"🇦🇹","code":"AT","dial_code":"+43"},{"name":"Azerbaijan","flag":"🇦🇿","code":"AZ","dial_code":"+9
@louisdh
louisdh / NYSKeyboardHelper.swift
Last active March 10, 2023 21:47 — forked from matthiasnys/NYSKeyboardHelper.swift
A Keyboard helper for your Swift Keyboard troubles.
//
// NYSKeyboardHelper.swift
// B-NYS GCV
//
// Created by Matthias Nys on 18/03/2017.
// Copyright © 2017 B-NYS. All rights reserved.
//
import UIKit
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@w-i-n-s
w-i-n-s / gist:2ac5a02237cb32ab93901741e581d24b
Created September 14, 2016 10:54
Instagram-like heartbeat animation using CABasicAnimation & CAAnimationGroup
NSMutableArray *animations = [NSMutableArray array];
// Step 1
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.toValue = @(1.3);
animation.duration = 0.3;
animation.fillMode = kCAFillModeForwards;
[animations addObject:animation];
}
{
@donpironet
donpironet / UINavigation+Extension.swift
Created June 29, 2016 10:56
UINavigationController extension to fix back swipe when having custom back button
extension UINavigationController: UINavigationControllerDelegate, UIGestureRecognizerDelegate {
public override static func initialize() {
struct Static {
static var token: dispatch_once_t = 0
}
if self !== UINavigationController.self {
return
@ashishkakkad8
ashishkakkad8 / AFWrapper.swift
Last active January 13, 2020 07:08
Alamofire - SwiftyJSON Wrapper
//
// AFWrapper.swift
// AFSwiftDemo
//
// Created by Ashish on 10/4/16.
// Copyright © 2016 Ashish Kakkad. All rights reserved.
//
import UIKit
import Alamofire
@viperwarp
viperwarp / ReactNativeJson.java
Created February 24, 2016 03:02
React-Native Module, ReadableMap/Array to Java JSON objects
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
extension UITextField {
func underlined(){
let border = CALayer()
let width = CGFloat(1.0)
border.borderColor = UIColor.lightGrayColor().CGColor
border.frame = CGRect(x: 0, y: self.frame.size.height - width, width: self.frame.size.width, height: self.frame.size.height)
border.borderWidth = width
self.layer.addSublayer(border)
self.layer.masksToBounds = true
@keithics
keithics / RestClient.swift
Created November 26, 2015 13:23
Alamofire Wrapper for iOS
//
// RestClient.swift
// USJ-R Mobile
//
// Created by keithics on 10/7/15.
// Copyright © 2015 Web Ninja Technologies. All rights reserved.
//
import Foundation
import Alamofire