public interface ViewWithActivity {
// Using android-gradle-plugin 3.0, which has the desugar step for default methods on interfaces
default Activity getActivity() {
// https://android.googlesource.com/platform/frameworks/support/+/03e0f3daf3c97ee95cd78b2f07bc9c1be05d43db/v7/mediarouter/src/android/support/v7/app/MediaRouteButton.java#276
Context context = getContext();
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Download latest apktool version. | |
2. Download the batch file and aapt.exe. | |
3. Create a folder anywhere in the PC and put all the apktool.jar, aapt.exe and the batch script in that folder. | |
4. Open command prompt. | |
5. Navigate to the folder where you placed apktool.jar, batch script and the aapt.exe. | |
6. Now, you need to install the file using the " IF " command. | |
7. Type the following command. | |
apktool if name-of-the-app.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Perlin { | |
public int repeat; | |
public Perlin(int repeat = -1) { | |
this.repeat = repeat; | |
} | |
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) { | |
double total = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.* | |
String password = "toto\n" | |
MessageDigest sha1 = MessageDigest.getInstance("SHA1") | |
byte[] digest = sha1.digest(password.getBytes()) | |
System.out.println(new BigInteger(1, digest).toString(16)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2014 The Android Open Source Project | |
* | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Declaring the inputs and outputs of a task | |
//build.gradle | |
task transform { | |
ext.srcFile = file('mountains.xml') | |
ext.destDir = new File(buildDir, 'generated') | |
inputs.file srcFile | |
outputs.dir destDir | |
doLast { | |
println "Transforming source file." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
configurations.all { | |
resolutionStrategy { | |
eachDependency { DependencyResolveDetails details -> | |
//specifying a fixed version for all libraries with 'org.gradle' group | |
if (details.requested.group == 'org.springframework') { | |
details.useVersion "$springVersion" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $1 ] | |
then | |
echo Processing file $1; | |
else | |
for var in `find *.png`; | |
do | |
echo Processing file $var; | |
sips -Z $(($(sips -g pixelWidth "$var" | cut -s -d ':' -f 2 | cut -c 2-) / 2)) "$var" --out "resized_$var" &> /dev/null |
NewerOlder