Skip to content

Instantly share code, notes, and snippets.

@boopathi
boopathi / README.md
Last active September 25, 2025 20:45
Creating a Swift-ReactNative project

Settings

  1. Create a project in XCode with the default settings
    • iOS > Application > Single View Application
    • Language: Swift
  2. Under project General settings, add ReactKit to Linked Framework and Libraries
    • + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
  3. Now ReactKit would have been imported. Link it by choosing it from the list.
    • + > lib.ReactKit.a
  4. Under project Build Settings,
@imkevinxu
imkevinxu / Device.swift
Last active March 4, 2023 16:09
iOS device checks for OS version and screen size in Swift
//
// Device.swift
// imHome
//
// Created by Kevin Xu on 2/9/15. Updated on 6/20/15.
// Copyright (c) 2015 Alpha Labs, Inc. All rights reserved.
//
import Foundation
@paulofierro
paulofierro / wkwebview_disable_magnification.swift
Created January 27, 2015 14:26
Disable magnification in WKWebView using Swift
// Remember to @import WebKit at the top of the class
// Javascript that disables pinch-to-zoom by inserting the HTML viewport meta tag into <head>
let source: NSString = "var meta = document.createElement('meta');" +
"meta.name = 'viewport';" +
"meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" +
"var head = document.getElementsByTagName('head')[0];" +
"head.appendChild(meta);";
let script: WKUserScript = WKUserScript(source: source, injectionTime: .AtDocumentEnd, forMainFrameOnly: true)
@joemasilotti
joemasilotti / About.md
Last active March 26, 2020 09:35
Building NSURL Queries with NSURLQueryItems and NSURLComponents
@sebmarkbage
sebmarkbage / react-terminology.md
Last active June 5, 2025 23:13
React (Virtual) DOM Terminology
@m1entus
m1entus / dateFormatter.swift
Created July 23, 2014 08:01
Swift NSDateFormatter singleton
class var userDateFormatter : NSDateFormatter {
struct Static {
static let instance: NSDateFormatter = {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
return dateFormatter
}()
}
return Static.instance
}
@ankushg
ankushg / ArrayExtensions.swift
Created June 12, 2014 23:12
removeObject extension for Array in Swift
import Foundation
extension Array {
func indexOfObject(object : AnyObject) -> NSInteger {
return (self as NSArray).indexOfObject(object)
}
mutating func removeObject(object : AnyObject) {
for var index = self.indexOfObject(object); index != NSNotFound; index = self.indexOfObject(object) {
self.removeAtIndex(index)
@ikesyo
ikesyo / gist:0c556e5fa116663583e2
Last active May 20, 2017 06:52
How to use Associated Object in Swift
import Foundation
class ABC {}
let abc = ABC()
// in-out expression can be used for CConstVoidPointer parameter.
var key: Void?
objc_setAssociatedObject(abc, &key, "value", UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
@frozzare
frozzare / int.swift
Last active October 17, 2018 06:32
Example of how to create own extension on int type in Swift
extension Int {
func times (iterator: () -> Void) {
for _ in 0..self {
iterator()
}
}
func downto (to : Int, iterator: (Int) -> Void) {
var num : Int = self
@natelandau
natelandau / .bash_profile
Last active September 20, 2025 16:13
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management