Skip to content

Instantly share code, notes, and snippets.

View sc0rch's full-sized avatar

sc0rch

  • Moscow
View GitHub Profile
@sc0rch
sc0rch / xdelta3-iOS-library.md
Last active September 13, 2018 08:25
Build xdelta3 as static libraries to use in iOS applications
@sc0rch
sc0rch / ScrollableViewController.swift
Created April 4, 2018 17:15 — forked from simondec/ScrollableViewController.swift
Recreating something similar to a UIPageViewController with a UIScrollView.
//
// ScrollableViewController.swift
//
import UIKit
class ScrollableViewController: UIViewController, UIScrollViewDelegate {
private let scrollView = UIScrollView()
private var controllers: Array<ViewController> = [
/// Useful class if you want your shared instance to have several delegates stored as weak references
public class MulticastDelegate<T> {
private let delegates: NSHashTable<AnyObject> = NSHashTable.weakObjects()
public func add(delegate: T) {
delegates.add(delegate as AnyObject)
}
public func remove(delegate: T) {
for oneDelegate in delegates.allObjects.reversed() {
@sc0rch
sc0rch / GenymotionWithGooglePlay.md
Last active July 22, 2017 03:43 — forked from udev/genymotionwithplay.md
Genymotion with Google Play Services
@sc0rch
sc0rch / OSMTileLayer.swift
Created September 30, 2016 14:28
Swift 3. OSMTileLayer for Google Maps iOS SDK. With argument retina=true in constructor, tile layer automatically doubles the tiles resolution. It makes OSM tiles more readable on retina-devices.
import Foundation
import GoogleMaps
import UIImage_ResizeMagick
/**
Custom GMSTileLayer which allows us to double tile size for OSM.
Available size of OSM tiles is 256, but for retina devices we need 512x512.
*/
class OSMTileOverlay: GMSTileLayer {
var retina: Bool = false
@sc0rch
sc0rch / Device.swift
Last active September 30, 2016 14:40
Swift 3. Detect device with motion co-processor.
//
// Extension for library:
// https://github.com/Ekhoo/Device
//
// Detect device with motion co-processor.
//
import Device
@sc0rch
sc0rch / MainActivity.java
Created July 9, 2016 01:45
Clear focus on touch outside for all EditText inputs.
public class MainActivity extends Activity
// ... any code
/**
* Clear focus on touch outside for all EditText inputs.
*/
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
@sc0rch
sc0rch / Tuple.java
Last active July 9, 2016 01:46
Simple Tuple-type template for Java.
/**
* Created by sc0rch on 05.07.16.
*/
public class Tuple<L,R> {
private final L left;
private final R right;
public Tuple(L left, R right) {
this.left = left;
this.right = right;
@sc0rch
sc0rch / GsonModule.java
Last active July 9, 2016 01:48
It's a part of Cheat Sheet for common Dagger 2 modules.
/**
* Created by sc0rch on 30.06.16.
* GSON module for Dagger 2.
*/
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Date;