Saturday, September 30, 2017

Angular - Add option to select using Jquery

Leave a Comment
I have a directive that adds new options to a select. For that i'm using: let opt: any = angular.element( '<option value="' + opcion.valor + '">' + opcion.texto + '</option>' ); this.element.append(this.$compile(opt)(scope)); I don't want to use templates because I don't want a new scope. The options get added to the list on the view. But when I select some of them, the ng-model of the select doesn't get updated. It gets value null. How can I make angular to refresh with...
Read More

Making video from UIImage array with different transition animations

Leave a Comment
I am following this code to create Video from an UIImage Array. While transitioning from one image to another, there is no animation here. I want to add some photo transition effect like these : TransitionFlipFromTop TransitionFlipFromBottom TransitionFlipFromLeft TransitionFlipFromRight TransitionCurlUp TransitionCurlDown TransitionCrossDissolve FadeIn FadeOut These animations can be done via UIView.transition() & UIView.animate(). But how to apply these transition animations while making a video from an UIImage...
Read More

Tcl script started from jenkins turns the command to lowercase

Leave a Comment
I'm having a strange issue when running a tcl command in jenkins. The tcl script has the following lines (pay attention to the uppercase I in Id): foreach name $docker_names { set name "TestName" puts $name set command "docker inspect --format='{{.Id}}' ${name} > /home/temp/id.txt" send -- "$command\n" expect "$" } In the jeknins log I see that the job fails because what is sent in the second iteration of the loop is the command above but in lowercase. I need the I in Id to be uppercase. This is what is...
Read More

Friday, September 29, 2017

save a web view content as pdf file

Leave a Comment
Notice: I working with swift 4 for osx. I would like to generate a pdf file from a WebView. At the moment my WebView load a html-string and show this successfully. If I press a button, the print panel will open and is ready to print my WebView content in the correct format. This is my print code: var webView = WebView() var htmlString = "MY HTML STRING" override func viewDidLoad() { webView.mainFrame.loadHTMLString(htmlString,...
Read More

Embed plotly graph in a Sphinx doc

Leave a Comment
I tried using nbsphinx to embed a Jupyter notebook containing plotly plots, but the plots don't show up in the documentation, even though they look fine on the Jupyter notebook. How can I embed a plotly graph in Sphinx documentation? I could include them as images, but is there a better way? It'd be nice to have the interactivity! What I want to do is replicate this page. It has Jupyter notebook style in and out blocks, and it shows interactive plots made using plotly. How can I do that? 0 Answe...
Read More

Returning File() returns more bytes

Leave a Comment
Consider the following code: //get bytes var query = await _storage.Get(attachment.Id, General.ContainerType.Uploads); //just for the sake of debugging var mem = new MemoryStream(query); //return the uploaded file return File(mem, MimeTypesMap.GetMimeType(attachment.FileName), attachment.FileName); After uploading a .jpg image of 67kb and then downloading it with this method, the returned image is 107 kb. I have checked whether the bytes are stored and retrieved correctly and they indeed are constistent with what I have...
Read More

How to improve accuracy of Tensorflow camera demo on iOS for retrained graph

Leave a Comment
I have an Android app that was modeled after the Tensorflow Android demo for classifying images, https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android The original app uses a tensorflow graph (.pb) file to classify a generic set of images from Inception v3 (I think) I then trained my own graph for my own images following the instruction in Tensorflow for Poets blog, https://petewarden.com/2016/02/28/tensorflow-for-poets/ and this worked in the Android app very well, after changing the settings...
Read More

Django: Uploading multiple files. List of files needed in cleaned_data['file']

Leave a Comment
I followed the pattern of the docs, to upload several files with one forms.FileField: https://docs.djangoproject.com/en/1.11/topics/http/file-uploads/#uploading-multiple-files Unfortunately cleaned_data['file'] does contain one file, not both files. What needs to be done to have all uploaded files on cleaned_data['file']? Here is the code from the docs: forms.py from django import forms class FileFieldForm(forms.Form): file_field = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True})) views.py...
Read More

TableView Auto Scrolling misbehaving after adding cells

Leave a Comment
View Setup: My TableView has 3 sections with 4 or 9 cell each. Each Cell has a Label and TextField. On Starting to edit a cell at index 2 of each section, I reload the section which will now consist of 9 cells(update model to dequeueCell so that 5 more cells will be added). Problem: The tableView scrolls as expected(brings textfield to visible part of the screen) for the unexpanded state of the section. But after I add cells by...
Read More

Why is the jQuery FileTree showing files when not set to?

Leave a Comment
I'm using the jqueryfiletree plugin, and it seems established and fairly smooth, but I have some issues: Despite the options being set as follows: $(function() { $("#sourceFileTree").fileTree({ onlyFolders: true, root: "C%3a%5cProjects%5cBMW%5cCode%5cFileTransfers.Web", script: "/FileTree/Tree", multiFolder: false, multiSelect: false, preventLinkAction: true }); }); onlyFolders seems to be ignored, and any folder opened also shows files it contains. The same goes...
Read More

Thursday, September 28, 2017

How to trace errors in asp.net core

Leave a Comment
I noticed that when you create a default asp.net core project in visual studio, there is an Error action that looks like this: public IActionResult Error() { ViewData["RequestId"] = Activity.Current?.Id ?? HttpContext.TraceIdentifier; return View(); } The error page shows that RequestId properly, however, I don't know how to check the details of that error if my user sends me a screenshot of that error. Where is this stored? 2 AnswersAnswers 1 Nobody store any "details" for you. This...
Read More

Unable to get double click event in OpenCV for python

Leave a Comment
OpenCV with python(MAC OS X EL Capitan) I'm creating a demo project to track mouse events in openCV. using standard mouseCallback from openCV. following is my code for the same. drawWithMouse.py #!/usr/local/bin/local/python3 import numpy as np import cv2 as cv #Mouse callback function def draw_shape(event,x,y,flags,param): print("event : ",event) if event == cv.EVENT_LBUTTONDBLCLK: cv.circle(img,(x,y),100,(255,0,0),-1)...
Read More

Devise: override current_user (set different Class for user)

Leave a Comment
I want to do this: application_controller.rb: class ApplicationController < ActionController::Base alias_method :devise_current_user, :current_user private def current_user if params[:user].blank? puts "!found user" devise_current_user else puts "found user" user = User.find_by(email: params[:user][:email]) return detect_role(user) end end def detect_role(user) roles = user.roles_name user = if roles.include?("mentor") user.becomes(Mentor)...
Read More

Raspberry Pi optimized backtrace()

Leave a Comment
Is there any Raspberry Pi optimized/specific backtrace() implementation? I'm using standard backtrace() code but looking forward for more detailed output from my_backtrace function. void my_backtrace(){ void *stack[10]; int n = backtrace(stack, 10); std::cout << "Last frames==" << n << std::endl; backtrace_symbols_fd(stack, n, STDOUT_FILENO); } 1 AnswersAnswers 1 //--There is list of options: //a) backtrace in combination with abi::__cxa_demangle //b) GDB //c) [libunwind][1],...
Read More

Cordova IOS video player

Leave a Comment
I am using webRTC streaming via RTCMultiConnection. I created a cordova application and get the blob url from server in video tag. In android and browsers works well. In IOS, video plays but control buttons does not work. Also video's position is static on application. I change page in application but video always stay. When i try to pull page, it looks like here : My HTML code : <video webkit-playsinline playsinline class="screen-video"...
Read More

Wednesday, September 27, 2017

Why do I get invalid byte sequence in UTF-8

Leave a Comment
Why do I get this error ? invalid byte sequence in UTF-8 for loading an image in: = image_tag 'features_home/show1.png' EDIT I've notice that this issue occurred only after I did bundle update, the error occurs with any image.. I will try to add details here: Stacktrace: Rendered home/home.html.haml within layouts/application (229.9ms) Completed 500 Internal Server Error in 1047ms invalid byte sequence in UTF-8 excluded from capture: DSN not set ActionView::Template::Error (invalid byte sequence in UTF-8): ...
Read More

How to allow / workaround nested composite Gradle builds

Leave a Comment
I'm running into the same issue as reported here: I have a Java project A which depends on project B (module), and project B dependes on project C (another module). For project A I would like to setup "includeBuild ../projectB" and for project B I would like too setup "includeBuild ../projectC" so that I could develop everything in Eclipse + Buildship 2.0 without the need to run Gradle for every small change in each of the projecta A, B and C. But if I setup this I get: "Included build '%s' cannot have...
Read More

Authenticate users from more than two tables in laravel 5

Leave a Comment
As I know Auth::attempt is used to authenticate users from users table, but i want to authenticate another users from managers table and admin from admins table. I know there are laravel-multiauth plugin already exist. But can we create our own AuthServiceProvider for authenticating users from multiple tables..? 6 AnswersAnswers 1 Try my idea if you want to. I'm expecting that different table has different users. Because it won't work if you have the same user in other tables. Choose your priority table (e.g. users)...
Read More

Java: How to make API call with data?

Leave a Comment
I want to make API call similar to below curl command: curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 1djCb/mXV+KtryMxr6i1bXw" -d '{"operands":[]}' https://ads.line.me/api/v1.0/authority_delegations/get What I am trying public void send_deligation_request(String details[]) throws Exception{ System.out.println(Arrays.toString(details)); URL line_api_url = new URL("https://ads.line.me/api/v1.0/authority_delegations/get"); String payload = "{operands:[]}"; HttpURLConnection...
Read More

Solr Index-Time Document Boosts not working

Leave a Comment
I can't find any solid documentation on using index-time document boosts, aside from how set the boost and that omitNorms needs to be set to false on the field types you're querying. I'm really at a loss as to what's happening here. (again -- SIMPLE query, no filters or anything else) Assuming I do a simple search for title:scissor or even just "scissor", I get back 5 results. If I set a boost of anything between 1.1-1000 on any of these results besides the first result, I would expect this result to have a higher score...
Read More

Tuesday, September 26, 2017

Spotify SDK Missing token refresh service?

Leave a Comment
i am trying to void popup grant permission for user every time session expired in Spotify for SDK , after one hour maybe a popup appear to grant permission again to user so he can play tracks from Spotify on my app , the Error i am getting when try to renew the session : [PLAYER][PLAY][SPOTIFY] Error renew Session Optional(Error Domain=com.spotify.auth Code=0 "Missing token refresh service." UserInfo={NSLocalizedDescription=Missing token refresh service.}) [PLAYER][SPOTIFY] Session could not be renewed,popup login ...
Read More