Skip to content

Instantly share code, notes, and snippets.

View expose's full-sized avatar
📱
Focusing

Miłosz Milewski expose

📱
Focusing
View GitHub Profile
@joshbetz
joshbetz / Webview.swift
Created February 12, 2020 15:36
A simple SwiftUI Webview
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
Webview(url: URL(string: "https://google.com")!)
}
}
struct Webview: UIViewRepresentable {
func RCTLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
RCTSwiftLog.error(message, file: file, line: line)
}
func RCTLogWarn(_ message: String, _ file: String=#file, _ line: UInt=#line) {
RCTSwiftLog.warn(message, file: file, line: line)
}
func RCTLogInfo(_ message: String, _ file: String=#file, _ line: UInt=#line) {

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
@johnny77221
johnny77221 / openBLESetting
Created October 24, 2016 07:07
opening iOS BLE setting from app
NSURL *bluetoothURLOS8 = [NSURL URLWithString:@"prefs:root=General&path=Bluetooth"];
NSURL *bluetoothURLOS9 = [NSURL URLWithString:@"prefs:root=Bluetooth"];
NSURL *bluetoothURLOS10 = [NSURL URLWithString:@"Prefs:root=Bluetooth"];
if ([[[UIDevice currentDevice] systemVersion] intValue] >= 10) {
Class<NSObject> workSpaceClass = NSClassFromString(@"LSApplicationWorkspace");
if (workSpaceClass) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
id workSpaceInstance = [workSpaceClass performSelector:NSSelectorFromString(@"defaultWorkspace")];
SEL selector = NSSelectorFromString(@"openSensitiveURL:withOptions:");
@hkondo
hkondo / CGDisplayCreateImage.m
Created June 14, 2014 22:31
Capture Screen Images
//
// main.m
// Screenshot
//
// Created by Hideki KONDO on 2014/06/14.
// Copyright (c) 2014年 Hideki KONDO. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
<?php
function my_strftime($format,$time=null) {
global $my_locale; //this is set in the header as either en_US or es_ES
if($time == null) $time = time(); //if the time isn't passed in, then use the current timestamp
if($my_locale == "en_US") return strftime($format,$time); //If it's american english, just format the time as requested
else { //in my case, the only other option is es_ES, but this could be changed for whatever purposes you have
global $es_locale_string;
// we only care about day names and abbreviations and
@tc
tc / EncodeAndMuxTest.java
Created September 5, 2013 21:26
OpenGL to video on Android, 4.3 API 18
/*
* Copyright 2013 The Android Open Source Project
*
* 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
@oliland
oliland / gist:5416438
Created April 18, 2013 21:37
An example of using CIFilters to mess with UIViews on iOS.
- (void)viewDidLoad
{
[super viewDidLoad];
// Great tutorial: http://www.raywenderlich.com/22167/beginning-core-image-in-ios-6
// Official docs: https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185-CH1-TPXREF101
// Alt-click on function names for more!
// Make any old label, with our frame set to the view so we know it's there.
UILabel *label = [[UILabel alloc] initWithFrame:self.view.frame];
@tmash06
tmash06 / CodecCapabilitiesReader.java
Created August 18, 2012 05:59
Show CodecCapabilities on Android Low Media Codec API
import android.media.MediaCodecInfo;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecList;
public class CodecCapabilitiesReader {
private static String colorFormatToString(int colorFormat) {
String ret = "not found(" + colorFormat + ")";
switch (colorFormat) {
case CodecCapabilities.COLOR_Format12bitRGB444:
@joshkurz
joshkurz / app.js
Created August 9, 2012 03:21
AngularJs-twitterBootstrap-wysiHtml5
var demoApp = angular.module('demoApp', ['ngResource'], function($locationProvider) {
$locationProvider.hashPrefix('');
});
function MainCtrl($scope, Serv) {
$scope.selectedItem = {
value: 0,
label: ''
};
$scope.Wrapper = Serv;