天道酬勤,学无止境

技术分享

How to address multiple API end points using Retrofit?

Question In my Android project I am using the following Retrofit ApiModule for one API end point. Please note, I use Dagger for injecting dependencies. @Module( complete = false, library = true ) public final class ApiModule { public static final String PRODUCTS_BASE_URL = "https://products.com"; @Provides @Singleton Endpoint provideEndpoint() { return Endpoints.newFixedEndpoint(PRODUCTS_BASE_URL); } @Provides @Singleton ObjectMapper provideObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setPropertyNamingStrategy( PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE

2021-06-13 06:51:55   android   rest   retrofit

How to use the un-blocking method of MqttClient

Question When I try the below code to connect to the mosquitto broker, as you know, connecting to the broker might takes few seconds/minutes, and during that time when the button pressed to connect, it remains pressed till the connection established and when the connection established the button released back to its normal state. As far as I know, there are two way for connecting a client using paho java API, the blocking method and unblocking method. my question is, how to use the unblocking method? beow is my attempt to use the blocking method Code_1: //mqttFactory public final class

2021-06-13 06:51:51   mqtt   paho

How to insert an object (Model type object) into Collection Object in Laravel at specific index number?

Question I have read Dayle Rees's Code Bright to know more about Eloquent Collections used in Laravel. Did some other research as well but couldn't find the answer I was looking for. I want to insert an object (Model type object) into a Collection Object at a specific position. For example: This is the returned collection Illuminate\Database\Eloquent\Collection Object ( [0] => Attendance Object ([present_day] => 1) [1] => Attendance Object ([present_day] => 2) [2] => Attendance Object ([present_day] => 4) [3] => Attendance Object ([present_day] => 5) ) As you can see above [present_day] have a

2021-06-13 06:51:47   php   laravel   collections   laravel-4   eloquent

t-sql recursive query

Question Based on an existing table I used CTE recursive query to come up with following data. But failing to apply it a level further. Data is as below id name parentid -------------------------- 1 project 0 2 structure 1 3 path_1 2 4 path_2 2 5 path_3 2 6 path_4 3 7 path_5 4 8 path_6 5 I want to recursively form full paths from the above data. Means the recursion will give the following output. FullPaths ------------- Project Project\Structure Project\Structure\Path_1 Project\Structure\Path_2 Project\Structure\Path_3 Project\Structure\Path_1\path_4 Project\Structure\Path_2\path_5 Project

2021-06-13 06:51:44   sql   sql-server   sql-server-2005   tsql

Where is the “Edit build definition” permission in our TFS 2013 installation?

Question Our environment is a TFS 2013 server (12.0.21005.1 Tfs2013.RTM) which was upgraded from a fresh installation of TFS 2008, with a number of team projects and developers. One thing that our developers regularly need to do is create and edit build definitions. According to both Visual Studio and all documentation I've been able to find, there should be a "Edit build definition" privilege (perhaps along with a few others) which controls access to this. But as you can see in the screenshot, it doesn't exist in our installation: The only workaround I've found is to grant the people in

2021-06-13 06:51:40   tfs

Do I need to acquire wake lock when invoking a BroadcastReceiver

Question In the book Pro Android 4 By Satya Komatineni , Dave MacLean I've found: Android acquires a partial wake lock when invoking a broadcast service and releases it when it returns from the service in the main thread Does it mean that the Android OS ensures that the device will wake up for the time of going through onReceive of BroadcastReceiver? In my case the BroadcastReceiver should get an intent from Google Play Services (GoogleLocationServices and to be precise Geofences api). Where is it documented? EDIT: I've also found it here: because it is guaranteed that the BroadcastReceiver

2021-06-13 06:51:37   android   broadcastreceiver   android-broadcast   android-wake-lock   android-geofence

Why would Mathematica break normal scoping rules in Module?

Question As was pointed out in a recent post scoping does not work as expected inside of Module. An example from that thread is: Module[{expr}, expr = 2 z; f[z_] = expr; f[7]] (*2 z*) But the following works almost as expected. Module[{expr}, expr = 2 z; Set@@{f[z_], expr}; f[7]] (*14*) What language design consideration made wolfram choose this functionality? Edit: See Jefromi's first comment I changed z from being a local variable to not and forgot to change the output. It does not effect the problem. Edit2: Michael Pilat's point seems to be that Block and Module have different functions. I

2021-06-13 06:51:33   programming-languages   wolfram-mathematica

Git command output shows special characters

Question For the past few days, we are seeing a strange behavior on executing Git commands. Command executed: git show 08fcf54adc7bbb75a54b14625fdeea7608d44a23 > sample.patch On opening the file sample.patch through vi editor, we are seeing a lot of special characters; a sample output file looks like: ^[[33mcommit 08fcf54adc7bbb75a54b14625fdeea7608d44a23^[[m Author: Anshul Gupta <anshul.gupta@lnttechservices.com> Date: Wed Nov 26 23:27:20 2014 +0400 Remove redundant logs from EPD driver Change-Id: I078584ddd7a58da1052a8d46fd59af722e11136b ^[[1mdiff --git a/drivers/video/s1d13522/s1d13522fb.c b

2021-06-13 06:51:29   git   special-characters   vi

iccp:Not recognizing known sRGB profile that has been edited

Question The following warning keeps arising in my Xamarin cross platform PCL project: iccp:Not recognizing known sRGB profile that has been edited What should I do ? Answer1 If you have image magick installed http://www.imagemagick.org/script/command-line-processing.php find . -name "*.png" -print -exec convert "{}" "{}" ";" cleaned up the files, and made them smaller in the process. Answer2 I had the same problem with Android studio. Just clean the project and it should work. Answer3 I found a workaround that may help. I downloaded the ImageOptim software: https://imageoptim.com/ (Free) and

2021-06-13 06:51:26   android   xamarin   cross-platform   srgb

Android Video Circular Buffer with Sound

Question I am using Google's Open Source Example: Grafika. I am using it's ContinuousCaptureActivity.java The CircularBuffer's Implementation is demonstrated in this Activity, but there is no audio included in the resultant Video file. I want to add the Audio Recording functionality within this Activity and add the recorded Audio into the Video in the same CircularBuffered Fashion. For achieving this i have explored the MediaCodec Library, which was introduced in 4.3+ versions. I have also used MediaMuxer to capture Video and Audio Streams and Muxed them into a single Video. But, I am not sure

2021-06-13 06:51:22   android   audio   video   android-mediacodec   grafika