Skip to content

Instantly share code, notes, and snippets.

View vlondon's full-sized avatar
😉
Night worker

Vladimirs Matusevics vlondon

😉
Night worker
View GitHub Profile
@vlondon
vlondon / README.md
Created January 4, 2016 16:51 — forked from magnetikonline/README.md
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.
let mList = "[{\"content\":\"hello\"},{\"content\":\"hi\"},{\"content\":\"how are you?\"}]"
let JSONData = mList.dataUsingEncoding(NSUTF8StringEncoding)!
var json: Array<AnyObject>!
do {
json = try NSJSONSerialization.JSONObjectWithData(JSONData, options: NSJSONReadingOptions()) as? Array
} catch {
print(error)
}
var resultArray = [String]()
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@vlondon
vlondon / Swizzling.swift
Created March 21, 2017 10:54
Swizzling in Swift 3
import Foundation
// Swizzling
extension NSObject {
class func swizzleMethods(origSelector: Selector, withSelector: Selector, forClass: AnyClass) {
let originalMethod = class_getInstanceMethod(forClass, origSelector)
let swizzledMethod = class_getInstanceMethod(forClass, withSelector)
method_exchangeImplementations(originalMethod, swizzledMethod)
struct ContentView: View {
@State private var isSubtitleVisible: Bool = false
var body: some View {
VStack {
Text("Title")
if isSubtitleVisible {
Text("Subtitle")
} else {
struct ContentView: View {
@State private var isSubtitleVisible: Bool = false
var body: some View {
VStack {
Text("Title")
Text("Subtitle").isHidden(isSubtitleVisible)
Text("Body")
Spacer()
struct ContentView: View {
var body: some View {
VStack {
Text("Title")
Text("Subtitle")
Text("Body")
Spacer()
}
}
}
@vlondon
vlondon / UIView+RoundedCorners.h
Created July 15, 2020 23:16 — forked from bobmoff/UIView+RoundedCorners.h
Add rounded corners to any view using layer mask.
#import <UIKit/UIKit.h>
@interface UIView (RoundedCorners)
- (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size;
@end
@vlondon
vlondon / Apple_mobile_device_types.txt
Created April 13, 2021 12:39 — forked from adamawolf/Apple_mobile_device_types.txt
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@vlondon
vlondon / ImageToGrayscale.swift
Last active October 22, 2021 12:15
Convert image to grayscale
func convertImageToGrayScale(image: UIImage) -> UIImage {
// Create image rectangle with current image width/height
let imageRect: CGRect = CGRectMake(0, 0, image.size.width, image.size.height)
// Grayscale color space
let colorSpace: CGColorSpaceRef = CGColorSpaceCreateDeviceGray()
// Create bitmap content with current image size and grayscale colorspace
let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.None.rawValue)
var context = CGBitmapContextCreate(nil, UInt(image.size.width), UInt(image.size.height), 8, 0, colorSpace, bitmapInfo)