How can I handle false as null for any primitive or boxed numerical bean property in Jackson?

Uncategorized
Question: I've been struggling with an issue. My endpoint receives a lot of broken API calls from a PHP application where there are often false booleans set for numerical fields. How can I attach a custom deserializer to my ObjectMapper that would convert all false values to null or 0 depending upon the type of the corresponding numerical property in the bean? Here's the JSON:{ "name": "My Name", "image_url": null, "price": false "list_price": false; } Here's an example of the bean:public class Item { public String name; public String imageUrl; public Double price; public double listPrice; } I've only a custom deserializer along the lines of this but this means that I explicitly need to attach this to every field:public class FalseAsNullDeserializer extends JsonDeserializer implements ContextualDeserializer { private final Class…
Read More

Laravel wizard system getting data from db

Uncategorized
Question: I am creating wizard systeem i create taks and wizard. but i want to show the take as stap not all the taks in one stap. @foreach($tasks as $task) index }}]">{{ $task->name } index }}]" value="{{ $task->id }}"> @endforeach But now I get all task in one time, how can I get one by one? Answer: $tasks is an array and you can get array value one by one by key or index for example: $tasks[0]->name display first index of $tasks name or $tasks[0]->id and $tasks[1]->name to get second and ... of course there are many ways to get values , it depends on how do you want to use it for loop or switch or other loops with conditions Read more
Read More

Angular 2 add and remove CSS class names

Uncategorized
Question: I get the data in the JSON format and must and I must to handle which item the user clicked on. I'm write this code and it correctly work. My Example with DOM-usage:@Component({ selector: 'my-app', template: ` {{person.name}} `, styles: ['.active { color: red; }'] }) export class App { toggleIsActive: boolean = false; personsList: any; constructor() { this.personsList = [ { "id": "1", "name": "Alex" }, { "id": "2", "name": "John" } ] } toggleStatus(id){ const span = document.getElementById(`${id}`); if (span.className.indexOf('active') >= 0) { span.classList.remove('active'); } else { span.classList.add('active'); } } } How I can add and remove CSS class names without DOM for a similar case? Answer: Read more
Read More

how to use different sql queries

Uncategorized
Question: hi i am creating an android app for updating different properties. I am having problem in using filter screen Below is the filter activity screenshot. whats happening is when the user selects apply button all the values have been passed to the mainActivity which called the filterActivity using startActivityForResult(); Now my question is how do i use sqlDatabase.query method for Where clause when i don't know which all values will be passed through intents. For egs suppose from filter activity i passed the strings for pocketValue and SectorValue, Now in the MainActivity i would have to use db.query(//entering query for pocket and sector) and now i have to search for area then how do i change the query. Hope you understand the problem Below is the code for MainActivity.java()…
Read More

Insert embedded image in Excel VBA

Uncategorized
Question: I have the following code for inserting images in Excel, but when I sent the file to the users out of the network, they are not able to see the pictures. Is there any way to modify the code, so as it will be not link, but embedded image? Here is the code:Private Sub Worksheet_Change(ByVal Target As Range) If (Target.Count > 1) Or (Split(Target.Address, "$")(1) "A") Then Exit Sub Dim c As Range Dim myPath As String myPath = "P:" Application.ScreenUpdating = False For Each c In Target.Cells If Not Dir(myPath & "*" & c.Text & "*") = "" Then InsertPicture myPath & Dir(myPath & "*" & c.Text & "*"), c.Offset(0, 1) End If Next c Application.ScreenUpdating = True End Sub Sub InsertPicture(thePath As String, theRange As Range) With…
Read More

React navigation adding “more” tab with a pop up list and not navigate to tab

android
Question: I am basically trying to add a "more" button for both iOS and ANDROID, which pops up a list of options to choose from. Something that looks like this (IOS more button) and (ANDROID more button). I am using React Navigation to create the TabNavigator TabBar and I know how to add a new tab, I'm just not sure how to create a small menu list thats generated when i click on the tab button instead of navigating me to the tab button screen. Any ideas on how to go about that? Answer: Read more
Read More

MapBox Navigation

Uncategorized
Question: currently I'm stuck at creating a basic navigation for MapBox sdk. I've successfully able to view a map but unable to display the navigation function as I'm having a hard time finding any tutorial or easy to understand guide for the MapBox documentation, any help would be appreciated and thanks in advance. Here i include my Activity. ACTIVITY public class MapNavigationActivity extends AppCompatActivity implements OnMapReadyCallback, MapboxMap.OnMapClickListener, ProgressChangeListener, NavigationEventListener, MilestoneEventListener, OffRouteListener { private static final int BEGIN_ROUTE_MILESTONE = 1001; // Map variables @BindView(R.id.mapView) MapView mapView; @BindView(R.id.newLocationFab) FloatingActionButton newLocationFab; @BindView(R.id.startRouteButton) Button startRouteButton; private MapboxMap mapboxMap; // Navigation related variables private LocationEngine locationEngine; private MapboxNavigation navigation; private DirectionsRoute route; private Position destination; private Position waypoint; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Mapbox.getInstance(getApplicationContext(), getString(R.string.access_token)); setContentView(R.layout.activity_map_navigation); ButterKnife.bind(this); mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this);…
Read More

lagging mouse bahavior on SVG [duplicate]

javascript
Question: This question already has an answer here:Css hover sometimes doesn't work on svg paths 2 answers I'm working on a tooth selection menu for a web-app I'm building. I found an SVG and I'm modifying it. I tried to simplify the mouse behavior, making only the large areas hoverable ('.parent') and the other stuff {pointer-events:none}. However, there's a major lag. When you move your mouse quickly into one of the teeth, it usually doesn't respond. Only when moving slowly into it. Do you see that also? What can I do? $('.parent').mouseover(function(){ $(this).css('fill', 'red'); }); $('.parent').mouseleave(function(){ $(this).css('fill', 'none'); }); link to the codepen playground Answer: A simple change in the css fixed the issue:svg *{ pointer-events: none; // Disable pointer-events for all elements inside the SVG } svg .parent{ pointer-events:…
Read More

function decoding twitter short url: what if there are several urls?

python
Question: I am coding a function to decode Twitter short urls in the Twitter stream I have captured: def decode_short_url(x):urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', x) for short_url in urls:try:res = urllib.request.urlopen(short_url) actual_url = res.geturl() return(actual_url) except:return(short_url) But when I apply it to the tweets which contain several links :tweets['urls'] = tweets['text'].apply(decode_short_url) I don't get all the urls in my new variable tweets.urls, only the first one. Any idea on how to get all of them? Thanks! Answer: When you return something, that's the end of the function. Instead of returning each URL, add them to a list and then return the list after the loop :) Read more
Read More

How to upload file to amazon s3 bucket using axios?

Uncategorized
Question: first of all, I am very very new to react. I am trying to upload a file to my amazon S3 bucket using axios. I get the signature url correctly but I don't know how to continue.. I tried this but it doesn't work. The error I get is the following: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://xxx.s3.amazonaws.com/wolves.jpeg?AWSAccessKeyId=xxxxxxxxxx&Content-Type=image%2Fjpeg&Expires=1502773987&Signature=ZXQya8d3xZoikzX6dIbdL3Bvb8A%3D. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). import React, { Component } from 'react' import Dropzone from 'react-dropzone' import aws from 'aws-sdk' import axios from 'axios' export default class ImageAWS extends Component{ uploadFile(files){ console.log('uploadFile: ') const file = files[0] aws.config.update({ accessKeyId: 'xxxxxxxxx', secretAccessKey: 'xxxxxxxx' }); var s3 = new aws.S3(); var params = { Bucket: 'xxx', Key: file.name, Expires: 60, ContentType: file.type }; s3.getSignedUrl('putObject', params, function(err,…
Read More

Ionic interceptor utilizing refresh tokens using sqLite async storage

Uncategorized
Question: I have successfully developed an angular2 interceptor utilizing refresh tokens (refreshing the token and then retrying the http request) in which the access_token and refresh_token are both stored in the localStorage. The following is the code for refreshing the token in my "AuthService":refreshToken():Observable { let refToken: string = localStorage.getItem("bdRefreshToken"); let username: string = localStorage.getItem("bdUsername"); let body = "grant_type=refresh_token" +"&client_id=" + Settings.loginInfo.client_id +"&client_secret=" + Settings.loginInfo.client_secret +"&scope=" + Settings.loginInfo.scope +"&username="+username +"&refresh_token="+refToken; let header = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }); let ro:RequestOptions = new RequestOptions({ headers: header }); return this._http.post(Settings.tokenEndpoint, body, ro) //.map(res => res.json()) .map(data => { let d = data.json(); localStorage.setItem('bdAccessToken', d.access_token); localStorage.setItem('bdRefreshToken', d.refresh_token); this.saveRoles(d.access_token); return data; } ) .catch(error => { this.logout(); return Observable.throw(error) }); } And the following is part of my inherited http class which serves as…
Read More