Tuesday, July 31, 2018

fsockopen(): unable to connect not work with PHP (Connection timed out)

Leave a Comment
I have this code: $domain = 'massag.com'; $hosts = array(); $mxweights = array(); getmxrr($domain, $hosts, $mxweights); var_dump($hosts); var_dump($mxweights); $host = gethostbynamel($hosts[0])[0]; var_dump($host); $f = @fsockopen($host, 25, $errno, $errstr, 10); if(!$f) { var_dump('NOT CONNECTED'); } It is not connected to smtp server but when I use command smtp:217.196.209.9 on mxtoolbox.com it is connected. Am...
Read More

Monday, July 30, 2018

215 error while requesting Token from Twitter oAuth API

Leave a Comment
I'm trying to Implement Twitter login in my NodeJS app. As per the documentation from Twitter, I need to pass the below parameters to this url via POST request. URL: https://api.twitter.com/oauth/request_token PARAMETERS: oauth_nonce=, oauth_signature=, oauth_callback="http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback", oauth_signature_method="HMAC-SHA1", oauth_timestamp="currentTimestamp", oauth_consumer_key=“myKEY”, oauth_version="1.0" I'm passing a random string for oauth_nonce parameter....
Read More

How to forecast using the Tensorflow model?

Leave a Comment
I have created tensorflow program in order to for the close prices of the forex. I have successfully created the predcitions but failed understand the way to forecast the values for the future. See the following is my prediction function: test_pred_list = [] def testAndforecast(xTest1,yTest1): # test_pred_list = 0 truncated_backprop_length = 3 with tf.Session() as sess: # train_writer = tf.summary.FileWriter('logs', sess.graph) tf.global_variables_initializer().run() counter = 0...
Read More

How to quantize all nodes except a particular one?

Leave a Comment
I am using tensorflow Graph Transform Tool to quantize the graph using input_names = ["prefix/input"] output_names = ["final_result"] transforms1 = ["strip_unused_nodes","fold_constants(ignore_errors=true)", "fold_batch_norms", "fold_old_batch_norms","quantize_weights" ] transformed_graph_def = TransformGraph(graph.as_graph_def(), input_names,output_names, transforms1) I use the option quantize_weights to quantize the weights in graph, I know that certain nodes can remain unquantized by changing threshold minimum_size...
Read More

Android force compress sqlite with jpg extension

Leave a Comment
I have an old class in an Android app which copies a pre-generated sqlite database. Up to Android 2.3 we needed to change the sqlite extension to an extension which won't be compressed (like jpg as in this question). As we stop the support for Android prior to 4.1 this is no longer needed. I want to reduce the apk size, but I want to avoid changing the database's filename. Is there a way to mark the file so it will be compressed when creating the apk although it has the jpg extension? 2 AnswersAnswers 1 Which filetypes...
Read More

Spring - Construct new modelAndView from existing BindingResult and Model

Leave a Comment
I am trying to improve my Spring MVC application to use a global exception handler to catch various persistence exceptions across all my controllers. This is the controller code that runs when the user tries to save a new StrengthUnit object for example. All the validations work perfectly fine and the form is correctly returned with an error message underneath the name field when the PersistenceException is thrown. The resulting page also correctly contains the strengthUnit attribute and is able to bind the field (this...
Read More

Assigning DIVs to php variables and looping on multiple hidden inputs

Leave a Comment
I have a CMS that I've built allowing users to create a 'Page' made up of different panels each with their own content. I've made this work so that a user can create a page with one panel and one textarea of content but I still can't figure out how to do this for multiple panels/content. Currently, if the page load gets the value of '1' from the URL value, it loads html templates with a fullwidth div and halfwidth div. I'm trying to set the panel type of each with hidden input types and they each have their own tinymce...
Read More

Laravel mail with g suites and XOAUTH2

Leave a Comment
I have a g suites account and applications associated with my e-mails. I was looking at the Laravel mail functions but I do not see any option to log in to gmail smtp with xoauth auth type. I was using PHPMailer with codeigniter and I had to use clientId, clientSecret and refreshToken to send emails via smtp.gmail.com Is there any chance I can authenticate using xoauth with native laravel swiftmailer? 1 AnswersAnswers 1 Since Laravel doesn't have available configuration to set AuthMode then we need to tweak it a...
Read More

Is it possible pause & resume for Retrofit multipart request?

Leave a Comment
We are using Retrofit multi-part for file uploading process. We want pause/resume when file uploading. I want to know its possible or not? Code for multi-part file upload RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file); // MultipartBody.Part is used to send also the actual file name MultipartBody.Part body =MultipartBody.Part.createFormData("image", file.getName(), requestFile); Call<ResponseBody> call= api.uploadFile(body); 2 AnswersAnswers...
Read More

How can I pass a command to a template and have it execute in my back end code and pass the parameter?

Leave a Comment
I have this template: <?xml version="1.0" encoding="utf-8"?> <Grid Padding="20,0" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:Japanese;assembly=Japanese" x:Class="Japanese.Templates.DataGridTemplate" x:Name="this" HeightRequest="49" Margin="0"> <Grid.GestureRecognizers> <TapGestureRecognizer Command="{Binding TapCommand, Source={x:Reference this}}" ...
Read More

asp.net while first request processing allow second request on click

Leave a Comment
In Asp.net Web Form app, I have Generate Report button and a Cancel button to cancel report generation process, if it takes a long time. When I Click Generate Report it does the heavy task, after 3 seconds I try to cancel this heavy task by clicking the Cancel button. But the server side code for Cancel button click is called after some time delay. I even tried window.stop() in JavaScript to stop page loading and hit server code fast, but still, there is a delay. Code: protected void btnExportExcel_Click(object sender,...
Read More

Executing a js file returned inside an ajax response

Leave a Comment
I have a HTML5 application which is using jquery 3.2.1. In part of the application - a search feature - I make an ajax request. The response from the ajax request is HTML, and this includes a <script> tag which links to a js file which is hosted on the same server as the application. So the ajax code looks like this - for making the ajax request and writing the response to a div with the ID #ajaxContent: $.ajax({ url:...
Read More

Compare keys of dictionary with values of another dictionary

Leave a Comment
I have two dictionaries, both of type Dictionary<string, List<List<string>>. I want to select the range of entries from dictionary 1 which match the values/entries from dictionary 2. E.g. dictionary 1 has the keys 01, 01.1 and dictionary 2 has the matching values 01, 01.1. at key 1 First I get the entries from dictionary 2 at key 1 like this: var dictList = (from entry in DbDict where entry.Key == id.ToString() // id = 1 select entry).ToList(); I tried to select these...
Read More

Sunday, July 29, 2018

Password flag doesn't work to log into mongo

Leave a Comment
I created a mongo daemon. Then, I did: $ mongo --port 27017 > use admin > db.createUser({ user: "AzureDiamond", pwd: "hunter2", roles: [{ role: "readWrite", db: "test_db1" }] }) >^D Then I tried to log into Mongo with the new account (exactly as in section 7 of Mongo's utorial): $ mongo --port 27017 -u "AzureDiamond" -p "hunter2" --authenticationDatabase "admin" This is the weird part. It still prompted me for my password, and...
Read More

JS HTML5 Drag and Drop: Custom Dock Effect Jumping Around in Chrome

Leave a Comment
Situation: I'm using HTML5 drag-and-drop to place tiles in a game I'm writing. I'd like to add an effect where the two tiles that I'm about to drop a new tile between move slightly apart to indicate that this is where you're dropping (similar to the Mac OS dock). My Approach: I have a flexbox into which I'm dropping these tiles. I wrote a function that essentially returns one period of a sine wave and I'm using it to update the dropped...
Read More

How can I fix “[App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction”?

Leave a Comment
When I rotate the device in the simulator, I receive the following message in the console: [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction. There is plenty of information about how to suppress the warning, such as in this question. However, it seems like that is just side stepping the problem without actually solving anything. What exactly does the warning mean and how do I fix it? 1 AnswersAnswers 1 "What exactly does the warning mean?" Unfortunately, I don't...
Read More

How to remove new Notifications from banner?

Leave a Comment
Is there any way to handle remote notification payloads before they’re delivered and display in notification centre? 1 AnswersAnswers 1 With push notifications of default type there is no way to filter out notifications if the app is not in foreground. The possible solution to this is to use VoIP push notifications in conjunction with PushKit. VoIP pushes are always waking up the application, however they are not presented to the user and don't modify app badge value, so it's up to the developer to show a local...
Read More