Skip to content

Instantly share code, notes, and snippets.

View Bresiu's full-sized avatar
🥷

Michał Brewczak Bresiu

🥷
View GitHub Profile
private void getRotationVectorFromGyro(float timeFactor) {
System.out.println("getRotationVectorFromGyro");
// Calculate the angular speed of the sample
float omegaMagnitude = (float) Math.sqrt(Math.pow(gyroscope[0], 2)
+ Math.pow(gyroscope[1], 2) + Math.pow(gyroscope[2], 2));
// Normalize the rotation vector if it's big enough to get the axis
if (omegaMagnitude > EPSILON) {
gyroscope[0] /= omegaMagnitude;
@Bresiu
Bresiu / gist:43f231c339bafeff8a2c
Created August 20, 2014 04:56
Guice + Even Bus
public class ApplicationModule extends AbstractModule {
private final EventBus eventBus = new EventBus("Default EventBus");
@Override
protected void configure() {
bind(EventBus.class).toInstance(eventBus);
bindListener(Matchers.any(), new TypeListener() {
public <I> void hear(TypeLiteral<I> typeLiteral, TypeEncounter<I> typeEncounter) {
typeEncounter.register(new InjectionListener<I>() {
public void afterInjection(I i) {
---> HTTP POST http://test.web-anatomy.com/bastek/Sknerus/public/pl/api/oauth
07-17 03:00:51.571 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ Content-Type: application/json
07-17 03:00:51.571 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ Content-Length: 188
07-17 03:00:51.574 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ {"client_id":"mobile_app","client_secret":"d3wf4eg5rh6tj7y","device_os":"android","device_token":"324567","grant_type":"password","password":"xxx","response_type":"token","username":"xxx"}
07-17 03:00:51.575 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ ---> END HTTP (188-byte body)
07-17 03:00:51.981 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ <--- HTTP 404 http://test.web-anatomy.com/bastek/Sknerus/public/pl/api/oauth (406ms)
07-17 03:00:51.983 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ Date: Fri, 17 Jul 2015 07:00:25 GMT
07-17 03:00:51.983 12096-12156/pl.sknerus.sknerusapp.dev D/TEST﹕ Server: Apache/2.2.22 (Debian)
07-17 03:00:51.983 12096-12156/pl.sknerus.sknerusapp.dev D/TE
public class RxTest {
public static void main(String[] args) {
String str = "sty";
getDoubledString(str).subscribe(new Subscriber<Integer>() {
@Override
public void onCompleted() {
System.out.println("on complete");
}
String jsonArray = "[\"A\",\"B\",\"C\",\"D\"]";
Gson gson = new Gson();
Type type = new TypeToken<ArrayList<String>>() {}.getType();
ArrayList<String> arrayList = gson.fromJson(jsonArray, type);
System.out.println(arrayList);
AbstractCommandExecutor.execute
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at com.good.android.gdmdm.command.executor.commandhandlers.blackwhitelist.SamsungBlackWhiteListAdapter.scanBlacklistedApps(SamsungBlackWhiteListAdapter.java:122)
at com.good.android.gdmdm.command.executor.commandhandlers.blackwhitelist.BlackWhiteListHandler.onBlackWhiteListSettingReceived(BlackWhiteListHandler.java:139)
at com.good.android.gdmdm.command.executor.device.SetBlackWhiteListSettingPackagesExecutor.executeCommand(SetBlackWhiteListSettingPackagesExecutor.java:38)
at com.good.android.gdmdm.command.executor.AbstractCommandExecutor.execute(AbstractCommandExecutor.java:42)
at com.good.android.gdmdm.command.manager.CommandManager.processCommand(CommandManager.java:37
11-26 13:41:08.941 D/GA-BLACK_WHITE_LIST: BlackWhiteListHandler.scanPackages
11-26 13:41:08.956 D/GA-BLACK_WHITE_LIST: SamsungBlackWhiteListAdapter.scanBlacklistedApps
11-26 13:41:09.026 D/GA-BLACK_WHITE_LIST: SamsungBlackWhiteListAdapter.disableApplication Disabled package = com.popularapp.fakecall - false
11-26 13:41:09.046 D/GA-BLACK_WHITE_LIST: SamsungBlackWhiteListAdapter.disableApplication Disabled package = com.popularapp.sevenmins - false
11-26 13:41:09.081 D/GA-BLACK_WHITE_LIST: BlackWhiteListHandler.onAppInfoReceived flipboard.boxer.app
11-26 13:41:09.081 D/GA-BLACK_WHITE_LIST: SamsungBlackWhiteListAdapter.handleNewPackageInfo flipboard.boxer.app
11-26 13:41:09.096 D/GA-BLACK_WHITE_LIST: BlackWhiteListHandler.onAppInfoReceived com.android.printspooler
11-26 13:41:09.096 D/GA-BLACK_WHITE_LIST: SamsungBlackWhiteListAdapter.handleNewPackageInfo com.android.printspooler
11-26 13:41:09.106 D/GA-BLACK_WHITE_LIST: BlackWhiteListHandler.onAppInfoReceived com.sec.android.app.minimode.res
11-26 13:41:09.106
@Bresiu
Bresiu / dd
Created February 15, 2016 20:04
as
/**
* Port from {@link https://github.com/ReactiveX/RxSwift}
*/
RxTextView.textChanges(mSearchbar.getEditTextSearch())
.subscribeOn(AndroidSchedulers.mainThread())
//delay 500ms
//debounce and throttle will use different thread after
.throttleWithTimeout(300, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.distinct()
.filter(new Func1() {
@Bresiu
Bresiu / patchMainDexClasses.gradle
Created May 12, 2016 13:12
Gradle script to trim android main-dex classes when 65k limit is reached using standard multi-dex components.
// A blacklist of absolute package path directories that will be excluded from the main dex list. ex: 'com/company/package/path'
// the package name can be partial, since class names encountered that start with any of the given package names will be discarded.
ext.packagesToDiscardFromMainDexFile = []
def shouldDiscardClass(String className) {
packagesToDiscardFromMainDexFile.any { className.startsWith(it) }
}
def patchMainDexKeepList(Project proj, String variantName) {
Task collectTask = proj.tasks.findByName("collect${variantName.capitalize()}MultiDexComponents")
@Bresiu
Bresiu / mininal-maven-pom.xml
Created June 28, 2016 18:16 — forked from torgeir/minimal-maven-pom.xml
A minimal maven pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gd.wa</groupId>
<artifactId>minimal-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>