Skip to content

Instantly share code, notes, and snippets.

@badlands
badlands / gist:9893949
Created March 31, 2014 14:43
UIImageView with rounded corners
// Try this Code For Round Image Import QuartzCore framework simple way to create Round Image
// http://stackoverflow.com/questions/7705879/ios-create-a-uiimage-or-uiimageview-with-rounded-corners
UIImageView *imageView;
imageView.layer.backgroundColor=[[UIColor clearColor] CGColor];
imageView.layer.cornerRadius=20;
imageView.layer.borderWidth=2.0;
imageView.layer.masksToBounds = YES;
imageView.layer.borderColor=[[UIColor redColor] CGColor];
@badlands
badlands / random
Created April 2, 2014 14:42
Random number in Objective-C
// Kudos to: http://stackoverflow.com/questions/160890/generating-random-numbers-in-objective-c
#include <stdlib.h>
#define MAX 10
int r = arc4random() % MAX;
@badlands
badlands / SaveIconsForiOSIcons.jsx
Last active August 29, 2015 14:25 — forked from jeremieweldin/SaveIconsForiOSIcons.jsx
Illustrator automation script for exporting an icon artboard to all the sizes needed for iOS apps.
var destFolder = null;
destFolder = Folder.selectDialog( 'Select the folder where you want to save the exported files.', app.activeDocument.path );
var baseDestName = app.activeDocument.name;
if (baseDestName.indexOf('.') < 0)
{
//nothing
} else {
@badlands
badlands / UINavigationBarExtensions.swift
Created March 17, 2017 22:42
Swift 3 Transparent UINavigationBar
//
// UINavigationBarExtensions.swift
// TransparentNavigationBar
//
// @see http://stackoverflow.com/questions/30545663/transparent-uinavigationbar-in-swift#30545730
// Created by Marco on 17/03/2017.
// Copyright © 2017 Marco Marengo. All rights reserved.
//
import UIKit
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 13,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
static let keypair: EllipticCurveKeyPair.Manager = {
EllipticCurveKeyPair.logger = { print($0) }
let publicAccessControl = EllipticCurveKeyPair.AccessControl(protection: kSecAttrAccessibleAfterFirstUnlock, flags: []) // QUA: kSecAttrAccessibleAlways
let privateAccessControl = EllipticCurveKeyPair.AccessControl(protection: kSecAttrAccessibleAfterFirstUnlock, flags: [.privateKeyUsage]) // QUA: kSecAttrAccessibleAlways
let config = EllipticCurveKeyPair.Config(
publicLabel: "no.agens.encrypt.public",
privateLabel: "no.agens.encrypt.private",
operationPrompt: "",
publicKeyAccessControl: publicAccessControl,
privateKeyAccessControl: privateAccessControl,
/**
* Copyright (c) 2017 Håvard Fossli.
*
* Licensed under the MIT license, as follows:
*
* 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
@badlands
badlands / UIDeviceExtensions.swift
Last active May 24, 2019 12:05
UIDeviceExtension: hasNotch
import Foundation
import UIKit
extension UIDevice {
/// Returns 'true' if the current device has a notch
var hasNotch: Bool {
if #available(iOS 11.0, *) {
// Case 1: Portrait && top safe area inset >= 44
let case1 = !UIDevice.current.orientation.isLandscape && (UIApplication.shared.keyWindow?.safeAreaInsets.top ?? 0) >= 44
@badlands
badlands / SceneDelegate.swift
Created July 2, 2019 22:07
Xcode 11 beta 2 vs beta 3
// MARK: - Beta 2 code
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
@badlands
badlands / node-sqs-send.js
Created April 24, 2020 11:00
How to send messages on a SQS queue with Node.js
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({
accessKeyId: '....',
secretAccessKey: '....',
region: 'eu-central-1'
});