Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
@andr3a88
andr3a88 / DecodingError.swift
Created March 22, 2019 14:04
Catch the decoding error
let decoder = RPJSONDecoder()
do {
let response = try decoder.decode(BaseDataArrayResponse<T>.self, from: json)
completion(response.data, nil)
} catch let DecodingError.dataCorrupted(context) {
completion(nil, DecodingError.dataCorrupted(context))
print("codingPath:", context.codingPath)
} catch let DecodingError.typeMismatch(type, context) {
completion(nil, DecodingError.typeMismatch(type, context))
print("Type '\(type)' mismatch:", context.debugDescription)
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@staltz
staltz / introrx.md
Last active April 20, 2024 14:15
The introduction to Reactive Programming you've been missing
@tyvsmith
tyvsmith / dex-count.sh
Created July 22, 2013 18:45
"`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH." Use this to keep track of methods and fields in your apk. They are both limited to 65536. Example use: $ source dex-count.sh; $ dex-field-count classes.dex; Original method scrip…
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
@willurd
willurd / web-servers.md
Last active April 23, 2024 04:35
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
import urllib2, urlparse, sys, webbrowser
itags = {'45': 'webm_720p',
'44': 'webm_480p',
'43': 'webm_360p',
'38': 'mp4_3072p',
'37': 'mp4_1080p',
'36': 'phone_mp4_240p',
'35': 'flv_480p',
'34': 'flv_360p',
@pudquick
pudquick / webclip.py
Created November 22, 2012 10:09
Create webclippings in Pythonista
import uuid, BaseHTTPServer, select, types, clipboard, console
from SimpleHTTPServer import SimpleHTTPRequestHandler
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
global mobile_config_str
mobile_config_str = ''
@adamgit
adamgit / .gitignore
Last active April 8, 2024 12:58
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx