Skip to content

Instantly share code, notes, and snippets.

@ArtFeel
ArtFeel / CALayer+AnimationPlayback.swift
Last active November 15, 2023 23:06
Persistent Core Animations (Swift 4.2). All you need is `self.layer.makeAnimationsPersistent()` 😎
//
// CALayer+AnimationPlayback.swift
// Created by Philip Vasilchenko on 4/27/18.
//
import UIKit
// Pause animations of layer tree
//
// Technical Q&A QA1673:
@jeromeetienne
jeromeetienne / googl.html
Created June 25, 2017 16:02
goo.gl - url shortener - standalone example
<html>
<script type="text/javascript">
// https://developers.google.com/url-shortener/v1/getting_started
//
function load() {
// get your keys from here https://developers.google.com/url-shortener/v1/getting_started#APIKey
gapi.client.setApiKey('XXX-YOUR-KEY-GOES-HERE-XXXX');
@gnumilanix
gnumilanix / KeyboardDismissingRecyclerView.java
Created February 28, 2017 04:57
Implementation of RecyclerView that will dismiss keyboard when scrolling.
package com.lalamove.core.view;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.inputmethod.InputMethodManager;
/**
* Implementation of {@link RecyclerView} that will dismiss keyboard when scrolling.
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
@ArthurHub
ArthurHub / AndroidManifest.xml
Last active July 17, 2017 11:43
Asynchronous Android Crop Camera Image with Custom Progress UI
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.arthu.testandroidcropper"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
import UIKit
extension UIImage {
// colorize image with given tint color
// this is similar to Photoshop's "Color" layer blend mode
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved
// white will stay white and black will stay black as the lightness of the image is preserved
func tint(tintColor: UIColor) -> UIImage {
@AndrewFromMelbourne
AndrewFromMelbourne / wifiscan.cxx
Last active December 20, 2022 02:41
wifi scanning code
// sudo apt-get install libiw-dev
//
// g++ -O3 -Wall wifiscan.cxx -o wifiscan -liw
#include <iwlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/time.h>
@vittorioromeo
vittorioromeo / hello_triangle.cpp
Created October 10, 2015 11:07
SDL2 + OpenGL ES 2.0 - "Hello triangle" example that works both on X11 and Emscripten
#include <exception>
#include <functional>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.media.AudioManager;
import android.media.MediaFormat;
import android.media.MediaPlayer;
import android.net.Uri;
@shekibobo
shekibobo / README.md
Last active March 2, 2020 11:04
Android: Base Styles for Button (not provided by AppCompat)

How to create custom button styles using Android's AppCompat-v7:21

Introduction

AppCompat is an Android support library to provide backwards-compatible functionality for Material design patterns. It currently comes bundled with a set of styles in the Theme.AppCompat and Widget.AppCompat namespaces. However, there is a critical component missing which I would have thought essential to provide the a default from which we could inherit our styles: Widget.AppCompat.Button. Sure, there's Widget.AppCompat.Light.ActionButton, but that doesn't actually inherit from Widget.ActionButton, which does not inherit from Widget.Button, so we might get some unexpected behavior using that as our base button style, mainly because Widget.ActionButton strictly belongs in the ActionBar.

So, if we want to have a decently normal default button style related to AppCompat, we need to make it ourselves. Let's start by digging into the Android SDK to see how it's doing default styles.

Digging In