Skip to content

Instantly share code, notes, and snippets.

@staltz
staltz / introrx.md
Last active July 24, 2026 00:55
The introduction to Reactive Programming you've been missing
public Bitmap blurBitmap(Bitmap bitmap){
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(getApplicationContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
@Fuzion24
Fuzion24 / MainActivity.java
Last active August 29, 2015 14:01
Nexus 5 Local DOS - Reboots Phone with zero permissions
package com.nexus5.dos;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class MainActivity extends ActionBarActivity {
@xrigau
xrigau / AndroidManifest.xml
Last active February 6, 2025 22:38
Disable animations for Espresso tests - run with `gradle cATDD`
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.novoda.espresso">
<!-- For espresso testing purposes, this is removed in live builds, but not in dev builds -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
<!-- ... -->
/*
* Copyright 2014 Chris Banes
*
* 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
@saadfarooq
saadfarooq / android_replace_in_manifest.gradle
Last active March 1, 2024 15:47
Gradle function to replace a placeholder string in AndroidManifest.xml with productFlavor package name
replaceInManifest = {variant, fromString, toString ->
def flavor = variant.productFlavors.get(0)
def buildtype = variant.buildType
def manifestFile = "$buildDir/manifests/${flavor.name}/${buildtype.name}/AndroidManifest.xml"
def updatedContent = new File(manifestFile).getText('UTF-8').replaceAll(fromString, toString)
new File(manifestFile).write(updatedContent, 'UTF-8')
}
@hustlzp
hustlzp / permissions.py
Last active February 22, 2019 17:42
Simple permission control in Flask.
# coding: utf-8
from flask import request, g
from functools import wraps
from flask import abort, session, redirect, url_for, flash
from .models import Topic, Attachment
from . import roles
def require_visitor(func):
"""仅允许非登陆用户访问,如signin页面"""
@bomberstudios
bomberstudios / Change Font.sketchplugin
Last active April 10, 2026 10:51
Change font family for all text layers in Sketch
// Change font (ctrl a)
var doc = context.document,
selection = context.selection,
font_name = [doc askForUserInput:"Font name:" initialValue:"Arial"];
function check_layer(layer){
log(layer)
var className = layer.className()
log("Checking layer " + layer + " of klass: " + className)
if (className == "MSTextLayer") {
@hustlzp
hustlzp / process_image.py
Last active January 21, 2018 12:10
将Flask中上传的图片居中裁剪为正方形、缩放、保存
import os
import uuid
from PIL import Image
from flask.ext.uploads import extension
def random_filename():
"""生成伪随机uuid字符串,用做文件名"""
return str(uuid.uuid4())
@jordanbeck
jordanbeck / README.md
Last active December 31, 2015 01:38
Attempting to update versionName and versionCode for gradle buildTypes [and currently failing]

This currently does not work the way I want, but I want to document it for personal reference.

Scenario:

I have an app that uses a library project being build in parallel. I want to have three different build types: debug, internal, release. I want each of those to have it's own package name, app name, version number, and version code. I want to be able to at least automate a build for internal on a nightly basis and upload to HockeyApp.

Problems:

  • First problem I ran into was that buildTypes in gradle do not allow you to specify versionNumber or versionCode. Just suffixes for those properties. So I moved to flavors...
  • Unfortunately, I'm using BuildConfig and with flavors, BuildConfig.java is not found by Android Studios. Everything does work this way (I can run gradle commands from the command line just fine), but without my IDE, it's kind of hard to work. Also, a downside to this approach is that it produces too many apks. If I have the three desired build types and have to have three flavors,