Skip to content

Instantly share code, notes, and snippets.

View ValCanBuild's full-sized avatar

Valentin Hinov ValCanBuild

View GitHub Profile
@ValCanBuild
ValCanBuild / drawer_layout_preview.xml
Created September 10, 2015 09:35
Android preview DrawerLayout NavigationView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
// DisposeBagProvider.swift
import RxSwift
import UIKit
/*
// Just make a class conform to it like this:
class MyClass : DisposeBagProvider {
}
// And then just use that "disposeBag" variable
//
// ControllerAware Protocol
// Shows how to have view controller instances which implement
// a specific protocol have it's method called on viewDidLoad.
import UIKit
protocol ControllerAware {
func onViewDidLoad()
}
@ValCanBuild
ValCanBuild / ReachabilityAware.swift
Last active January 25, 2016 23:41
Constrained View Controller extension which displays a "No Internet Connection" message when reachability is lost. To use it simply extend your existing ViewController and make it implement ReachabilityAware and call the startMonitoryReachability() method.
// Constrained View Controller extension which display a "No Internet Connection" message when reachability is lost.
// This implementation depends on ReachabilitySwift (https://github.com/ashleymills/Reachability.swift).
// It can easily enough be adapted to other frameworks.
// Assumes you have a localized string with the key "warning.no_internet_connection" in one of your .strings files.
// Call startMonitoringReachability() in viewWillAppear and stopMonitoringReachability() in viewDidDisappear
import ReachabilitySwift
protocol ReachabilityAware {
func startMonitoringReachability()
@ValCanBuild
ValCanBuild / Podfile
Created March 3, 2016 11:39
Using variables in your Podfile
platform :ios, '9.0'
use_frameworks!
$rxVersion = '~> 2.2.0'
target 'MyProject' do
pod 'RxSwift', $rxVersion
pod 'RxCocoa', $rxVersion
end
@ValCanBuild
ValCanBuild / BranchDeleter.sh
Last active July 25, 2017 08:32
Deletes all merged git branches older than the provided date.
#!/bin/sh
cd ../..
date=$1 #Format: 2015-01-15
root_branch=$2 #Format: origin/branchName e.g. origin/release/1_6
DRY_RUN=$3
numberDeleted=0
@ValCanBuild
ValCanBuild / GetCpuTempAndroid.java
Created January 9, 2017 21:04
A way to get the CPU temperature from an android device by using the sys/class/thermal/temp command
public float getCpuTemp() {
Process p;
try {
p = Runtime.getRuntime().exec("cat sys/class/thermal/thermal_zone0/temp");
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
float temp = Float.parseFloat(line) / 1000.0f;
@ValCanBuild
ValCanBuild / TypicalUseCase.java
Created February 20, 2017 20:49
TypicalUseCase
view.showLoadingIndicator();
loadFromServer()
.compose(applySchedulers())
.subscribe(data -> {
view.hideLoadingIndicator();
view.showData();
}, throwable -> {
view.hideLoadingIndicator();
@ValCanBuild
ValCanBuild / cl_guidline_barrier_bug.xml
Created October 9, 2017 10:00
ConstraintLayout 1.1.0 beta2 guideline barrier bug
<!-- This works in 1.1.0-beta1 but breaks in 1.1.0-beta2.
textView3 is always constrained to textView1, even when the barrier should clearly be at the guideline -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView