Skip to content

Instantly share code, notes, and snippets.

@codingricky
codingricky / robovm-callback.java
Last active June 17, 2019 14:05
robovm callback/bind selector
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.foundation.NSDictionary;
import org.robovm.apple.uikit.UIApplication;
import org.robovm.apple.uikit.UIApplicationDelegateAdapter;
import org.robovm.apple.uikit.UIBarButtonItem;
import org.robovm.apple.uikit.UIBarButtonSystemItem;
import org.robovm.apple.uikit.UIColor;
import org.robovm.apple.uikit.UINavigationController;
import org.robovm.apple.uikit.UIScreen;
import org.robovm.apple.uikit.UITableViewController;
@ph0b
ph0b / app_build.gradle
Last active November 20, 2019 09:21
config example on Multiple APK support and mixing gradle-stable and gradle-experimental plugin, for NDK-enabled Android projects. To support AS 2.0 debug, just add lib/build/intermediates/binaries/release/obj/[abi] to Symbol directories
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.example.yourapp"
minSdkVersion 16
targetSdkVersion 23
@licvido
licvido / App.swift
Last active December 31, 2019 00:37
SWIFT: Get application version and build
let version : AnyObject! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString")
let build : AnyObject! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleVersion")
println("Version: \(version)")
println("Build: \(build)")
@davidlondono
davidlondono / VideoMerge.swift
Created May 17, 2016 21:50
this is the inspiration original gist https://github.com/jai/VideoMerge
//
// VideoMerge.swift
// David Alejandro
//
// Created by David Alejandro on 5/12/16.
// Copyright © 2016 David Alejandro. All rights reserved.
//
// inpired by https://github.com/jai/VideoMerge
@bnickel
bnickel / Queue Playground.swift
Last active June 23, 2020 16:33
Swift retry operation playground
import Foundation
protocol Completable {
func addCompletionOperation(on queue: OperationQueue, complete: @escaping (Self) -> Void) -> Operation
}
extension Completable where Self: Operation {
func addCompletionOperation(on queue: OperationQueue, complete: @escaping (Self) -> Void) -> Operation {
let completionOperation = BlockOperation {
@AndroidT
AndroidT / GlideImageGetter
Last active December 30, 2020 12:55
GlideImageGetter uses Glide Image Library to load GIFs/JPG/PNG in HTML <img> tags into TextView
package com.example.name;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.Html;
import android.view.View;
import android.widget.TextView;
@DaveWoodCom
DaveWoodCom / String+Email.swift
Last active February 28, 2021 16:45
Swift method to check for a valid email address (uses Apples data detector instead of a regex)
extension String {
func isValidEmail() -> Bool {
guard !self.lowercaseString.hasPrefix("mailto:") else { return false }
guard let emailDetector = try? NSDataDetector(types: NSTextCheckingType.Link.rawValue) else { return false }
let matches = emailDetector.matchesInString(self, options: NSMatchingOptions.Anchored, range: NSRange(location: 0, length: self.characters.count))
guard matches.count == 1 else { return false }
return matches[0].URL?.scheme == "mailto"
}
}
@kciter
kciter / RxAlamofire+ObjectMapper.swift
Created August 11, 2016 02:52
RxAlamofire+ObjectMapper
import UIKit
import RxSwift
import RxAlamofire
import ObjectMapper
class Post: Mappable {
var id: Int = 0
var title: String = ""
required init?(_ map: Map) {
@felangel
felangel / main.dart
Last active May 11, 2021 13:36
showDialog sample
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bloc/bloc.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@phatmann
phatmann / BackgroundTask.swift
Created April 15, 2015 03:14
Encapsulate iOS background tasks in a Swift class
class BackgroundTask {
private let application: UIApplication
private var identifier = UIBackgroundTaskInvalid
init(application: UIApplication) {
self.application = application
}
class func run(application: UIApplication, handler: (BackgroundTask) -> ()) {
// NOTE: The handler must call end() when it is done