Skip to content

Instantly share code, notes, and snippets.

@homj
homj / DrawerIconDrawable.java
Last active April 6, 2017 10:11
This Drawable implements the "Drawer-Indicator to Arrow"-Animation as seen in several Material-Design-Apps; NOTE: Mind the updated constructors in Revision 5!
/*
* Copyright 2014 Johannes Homeier
*
* 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
//: Playground - noun: a place where people can play
import UIKit
//initialization
//value types get defautlt initializers , structs and enums
//1- failable and throwing initializers
//What happens if we can't initialize an object? This is a common occurrence if initialization depends on external data. Swift gives us two ways to deal with this - failable and throwing initializers.
@chris95x8
chris95x8 / build.gradle
Created October 28, 2014 14:00
Extended toolbar with two floating-label edit texts. The layout was made according to this image from the Material Design guidelines: http://i.imgur.com/x8QsuxU.png The layout below looks like this: http://i.imgur.com/8sOTv7h.png
dependencies {
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.wrapp.floatlabelededittext:library:0.0.5'
}
@JaviSoto
JaviSoto / SampleViewController.swift
Last active January 23, 2020 09:20
Init based Storyboard View Controller Instantiation
final class SampleViewController: StoryboardBackedViewController {
// Unfortunately this must be an IUO var, so that we can set the value after super.init
private var member: Foo!
// Proper dependency injection in a storyboard backed VC!
init(foo: Foo) {
super.init(storyboardIdentifier: "SampleViewControllerIdentifier")
// We have to set the members *after* calling super.init, since it changes the instance of `self`.
self.member = foo
@natbro
natbro / fixup-old-macos-sdks.sh
Created November 13, 2018 03:10
script to link older macOS SDKs into newer Xcode so you can target older platforms properly
#!/bin/bash
# ---------------------------------------------------------------------------------------------------------
# place as many old macOS SDKs into the directory with this script e.g. if you have
#
# my-macpro:SDKs natb$ ls -ahl
# total 4254792
# drwxr-xr-x 17 natb admin 578B Nov 21 2017 .
# drwxrwxr-x 24 root admin 884B Aug 29 06:46 ..
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.10.sdk
@yoavst
yoavst / TitaniumResourcesExtractor.kt
Created September 9, 2017 12:21
Titanium app resources extractor
package com.yoavst.psychometric
import org.apache.commons.lang3.StringEscapeUtils
import java.io.File
import java.nio.CharBuffer
import javax.crypto.spec.SecretKeySpec
import javax.crypto.Cipher
/**
* Based on https://www.npmjs.com/package/ti_recover
@opsb
opsb / NonMutatingArray.swift
Last active February 17, 2022 15:34
Swift extension to add non mutating methods to Array
extension Array {
func inserted(_ element: Element, at index: Int) -> Array<Element> {
return updated({$0.insert(element, at: index)})
}
func appended(_ element: Element) -> Array<Element> {
return updated({$0.append(element)})
}
func appended(contentsOf elements: Array<Element>) -> Array<Element> {
@bryanstern
bryanstern / OkHttpStack.java
Last active April 24, 2022 03:17
An OkHttp backed HttpStack for Volley
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@lopspower
lopspower / README.md
Last active May 11, 2022 02:47
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@meoyawn
meoyawn / EmptyRecyclerView.java
Created November 1, 2014 11:20
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;