on-internet

How to correctly terminate an application?

In the past I've usually added the following line to the KeyDown sub in order to end my applications: If e.KeyCode = Keys.Escape Then End However, upon reading the documentation on what End actually does, it turns out that it probably is one of the worst ways to end the application in terms of releasing resources, etc. So now I'm trying to find the recommended way to terminate the application which will properly handle all resources, etc. I've found these two questions on SO (here and here) but I can't conclude what the right answer actually is. The accepted answer on the first link says that

Join the discussion →

eclipse marketplace proxy authentication

I've downloaded eclipse with the properties described at the appendix below. When I try to download a plugin using the eclipse marketplace, such as Moonrise UI Theme or Color Theme, It doesn't work and prompts "HTTP Proxy Authentication Required" error box. No info other than the plug-in's eclipse website is available. I can not install an eclipse plug-in. --- Appendix--- Eclipse IDE for Java Developers Version: Neon Release (4.6.0) Build id: 20160613-1800 recently downloaded using zip file.

Join the discussion →

Generate UUID and get Least and Most significant bits in Javascript

I need to generate a random UUID in Javascript and get the Least and Most significant bits from it (like in Java's UUID class). I found enough scripts to generate the UUID, but wasn't able to find a script that gets the least and most significant bits. (I don't need the UUID itself, though). Thanks in advance, Chrisstar

Join the discussion →

int object has no attribute __getitem__

I am working on some code to recognises the face and speak someone's name. I am working this code in raspberry pi 3 with opencv 3.1 and python 2.7. This code works fine on windows but when I try it on raspberry, it gives an error: Type error: 'int' object has no attriibute '__getitem__' For the line: if prediction[1]<100: Full code: import cv2, sys, numpy, os, pyttsx, time,picamera haar_file = 'haarcascade_frontalface_default.xml' datasets = 'datasets' engine = pyttsx.init() rate = engine.getProperty('rate') engine.setProperty('rate', rate-40) print('Training...') # Create a list of images and

Join the discussion →

Changing video resolution on HTML 5.0 video with JavaScript

UPDATE: I was using the Fotorama plugin and it seems that the bottom menu was causing the problem. Disabling that menu by putting div-tags around the video-tags made the function for setting resolution work. Thanks for the help and encouragement. For the bottom menu I create a simple one using link buttons that link to a similar page with the next video. I have written JavaScript code that changes the resolution of a video based on input of a option/select-element. It works. The problem is that it stops working when I put exactly the same code inside a function (so that the code can be execute

Join the discussion →

Angular 2 New Router - Routes not displaying in

Pretty new to Angular 2 and not fully up to speed on the new Router. I've followed the example from the Angular Documentation, and while I'm not getting errors, my components aren't displaying in the tag. Here's the router code: import { Routes, RouterModule } from '@angular/router'; import {HomeComponent} from './home.component'; import {FeaturesComponent} from './features.component'; const appRoutes: Routes = [ { path: '', component: HomeComponent },, { path: 'features', component: FeaturesComponent }, { path: '**', component: HomeComponent } ]; export const appRoutingProviders: any[] = [ ];

Join the discussion →

How to display Date-picker in IONIC 2?

I wanted to display the DatePicker as soon as page loads. <DatePicker android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/datePicker" android:layout_gravity="center_horizontal|top" android:headerBackground="?attr/colorPrimary" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> I used Android studio and wrote above code to get the output as in the below image. I wanted to implement the same thing using ionic 2 and wrote below code to get the datepicker. import {Component} from '@angular/core'

Join the discussion →

Update dataGridView when cell value changed

I'm having some problem with refresing cell value in dataGridView. My program in c# set values of some rows on button click, but I allow user to change some value in DataGridView. EG. Column3 = Column2+Column1. Which works correctly when i click button but after it when I change some cell value in Column2 I also want Column3 to change value. I'v tried private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { dataGridView11.Update(); dataGridView1.Refresh(); } And private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { button1_Cl

Join the discussion →

Python currying with any number of variables

I am trying to use currying to make a simple functional add in Python. I found this curry decorator here. def curry(func): def curried(*args, **kwargs): if len(args) + len(kwargs) >= func.__code__.co_argcount: return func(*args, **kwargs) return (lambda *args2, **kwargs2: curried(*(args + args2), **dict(kwargs, **kwargs2))) return curried @curry def foo(a, b, c): return a + b + c Now this is great because I can do some simple currying: >>> foo(1)(2, 3) 6 >>> foo(1)(2)(3) 6 But this only works for exactly three variables. How do I write the function foo so that it can accept any number of varia

Join the discussion →

Upload file to SFTP using PowerShell

We were asked to set up an automated upload from one of our servers to an SFTP site. There will be a file that is exported from a database to a filer every Monday morning and they want the file to be uploaded to SFTP on Tuesday. The current authentication method we are using is username and password (I believe there was an option to have key file as well but username/password option was chosen). The way I am envisioning this is to have a script sitting on a server that will be triggered by Windows Task scheduler to run at a specific time (Tuesday) that will grab the file in question upload it

Join the discussion →

Getting token in Office 365 Oauth2 authentication

I am implementing Oauth 2 authentication for Office 365 account in a java based server side application. After reading the documentation, I have done the following things: I have office 365 subscription. I have created an app in Azure Actve directory, that is necessary to authenticate web app using office 365 account. I have client ID and secret. I have also given all permission to the Azure app. I am requesting authorization code using the Url: https://login.microsoftonline.com/common/oauth2/authorize?client_id={client_id}&response_type=code&redirect_uri={redirect url}&response_mode=query As

Join the discussion →

MVCC & B-Tree & Concurrency

I'm currently reading dbms book and as i've understood Mvcc (Multi version concurrency control) is used for high concurrent read and write transactions. But "concurrency control on search structures" chapter mentions different locking concepts (lock coupling,link technique etc) for B-Trees. Doesn't Mvcc applied on B-Tree's internal and leaf nodes in dbms? Are B-Tree concurrency and MVCC completeley different things?If so how Mvvc is implemented in dbms?

Join the discussion →

Serialize c# object using MsgPack instead of Json using MsgPack Cli

I'm trying to acheive a kind of JSON serialization using MsgPack in c# I'm using MsggPack CLI you can find on https://github.com/msgpack/msgpack-cli According msgpack.org Documentation, serialize the model {"model":"message"} give in hexa 81 a5 6d 6f 64 65 6c a7 6d 65 73 73 61 67 65 but when trying to do the same in c# (certainly with a naive approach) using MsgPack.Serialization; public class Test { public string model { get; set; } } public class Program { static void Main(string[] args) { Test a = new Test(); a.model = "message"; var requestSerializer = MessagePackSerializer.Get(a.GetType()

Join the discussion →

net/http: request canceled (Client.Timeout exceeded while awaiting headers) why/what to do with this?

TL:DR - Look at edit 2 for a C# equivalent of code http client code, resulting in ~same issue, so Go http.Client is not the real problem, but C# Web API once deployed to Azure... I'm getting very bad performance from a C# Web API once deployed to Azure Web App [2x Standard S3]. At first I was asking re: Go's http.Client timeout, but writing a similar client in C# and NodeJs gave same results. This is my http.Client: func getWebClient() *http.Client { var netTransport = &http.Transport{ Dial: (&net.Dialer{ Timeout: 5 * time.Second, }).Dial, TLSHandshakeTimeout: 10 * time.Second, MaxIdleConnsPer

Join the discussion →

Spring Rest Controller with Byte Array file

I am trying to send a byte array of a file content from angular to the rest api. But I am getting Http 403 forbidden. I don't have any security enabled. I am not sure what I am doing wrong. I tried couple of different MIME types. The below is the http post from angular js and the $scope.encoded_file has the file in byte array. $http({ method:'POST', url:'http://localhost:9200/docupload', data:{'content':$scope.encoded_file,'name':'test','type':'pdf'}, headers:{'Content-Type':'application/octet-stream'} }).success(function(){}); }; DocUploadService @RestController public class DocUploadService

Join the discussion →

Linux Command History with date and time

I wants to check on my linux system when which command was fired - at which date and time. I fired commands like this: history 50 It shows me the last 50 commands history, but not with date and time at which it was fired. Does any one knows how to do it?

Join the discussion →

How can we generate sequence diagram in IntelliJ IDEA from Java code which is editable?

I am currently using SequenceDiagram Plugin from https://plugins.jetbrains.com/plugin/8286?pr= to generate Sequence Diagrams. But here the drawback is that I am not able to save them in a format like .uml or any other format so anyone can open this file and edit it. It only allows to export the sequnce diagram as an image. Is there any way to save the sequence diagrams generated so they can be edited later?

Join the discussion →

SAML response and assertion is signed/unsigned?

I have deployed and run spring SAML sample successfully. From SAML Response (IdP -> SP) shown below, can it be identified whether: the SAML response is signed or unsigned? the assertion is encrypted or not? (I guess it's encrypted) the assertion is signed or unsigned? <?xml version="1.0" encoding="UTF-8"?> <samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" Destination="https://MY_SP/spring-security-saml2-sample/saml/SSO" ID="_22bf0c00-9cfa-5dbb-7af7-d34eec7d9b6f" InResponseTo="we3977191e5g4try1b3g52j4f84e43f" IssueInstan

Join the discussion →

Anti-aliasing techniques for OpenGL ES profiles

I've been investigating and trialling different AA techniques in OpenGL on both desktop and ES profiles ( es 2.0 & above ) for rendering 2D content to offscreen FBOs. So far I've tried FSAA, FXAA, MSAA, and using the GL_LINE_SMOOTH feature. I've not been able to find an adequate AA solution for ES profiles, where I've been limited to FSAA and FXAA because of API limitations. For example glTexImage2DMultisample ( required for MSAA ) and GL_LINE_SMOOTH functionality are unavailable. FXAA is clever but blurs text glyphs to the point it's doing more harm than good, its only really suited to 3D sce

Join the discussion →

TypeError: parse() got an unexpected keyword argument 'override_encoding'

Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from weasyprint import HTML >>> HTML('http://weasyprint.org/').write_pdf('/tmp/weasyprint-website.pdf') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 94, in __init__ namespaceHTMLElements=False) TypeError: parse() got an unexpected keyword argument 'override_encoding' >>> I believe I have installed all the dependencies. What is going on here?

Join the discussion →

multiple .doc to .docx file conversion using python

I want to convert all the .doc files from a particular folder to .docx file. I tried using the following code, import subprocess import os for filename in os.listdir(os.getcwd()): if filename.endswith('.doc'): print filename subprocess.call(['soffice', '--headless', '--convert-to', 'docx', filename]) But it gives me an error: OSError: [Errno 2] No such file or directory

Join the discussion →

FaceRecognizer with one class

I'm trying to use opencv to implement a feature in my app. Basically, my app allows users to authenticate by using their face. Live video will be captured and frames are extracted. Using these extracted images, the model is learned. Next time when a user logs in, frames are sent to the model for deciding if this is the authenticated user. I found this example from opencv site which uses FaceRecognizer. However, they use an existing dataset with 10 classes (10 persons). In my case, only one class is considered (Or we can consider two classes including the authenticated user and unknown users).

Join the discussion →

AttributeError: 'ReturnDict' object has no attribute 'pk'

I am trying to design an api for user login and logout. But I am facing an error of AttributeError: 'ReturnDict' object has no attribute 'pk'. What might be creating this error? traceback in detail File "/home/tushant/Projects/nepMart/account/api/views.py", line 61, in post login(request, serializer.data) File "/home/tushant/.virtualenvs/NepMart/lib/python3.5/site-packages/django/contrib/auth/__init__.py", line 102, in login if _get_user_session_key(request) != user.pk or ( AttributeError: 'ReturnDict' object has no attribute 'pk' Serializers.py class UserLoginSerializer(ModelSerializer): toke

Join the discussion →

Doctrine2 ORM - A managed+dirty entity X can not be scheduled for insertion

I've got the following classes (only show partials to reduce amount to read) class Page { /** * @ORM\Column(type="string", unique=true, nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="UUID") * @var string */ protected $id; /** * @ORM\OneToMany(targetEntity="Url", mappedBy="content") * @var Url[] */ protected $urls; public function __construct() { $this->urls = new ArrayCollection(); } } And: class Url { /** * @ORM\Id @ORM\Column(type="string", unique=true, nullable=false) * @ORM\GeneratedValue(strategy="UUID") * @var string The unique identifier for the Url */ protected $id; /** * @O

Join the discussion →

Travel to Agra during layover in Delhi (rail)

I have booked separate Rajdhani Express Rail tickets for Jammu-Delhi and Delhi-Kolkata. I'll reach Delhi from Jammu on 6am of 23th August. My next train for Kolkata will start on 4:30pm. I have a span of around ten hours (assume Trains are on time!) layover at Delhi. Is this sufficient to travel Agra interim? (Just a quick sight seeing at Taj Mahal!)

Join the discussion →

Keep input placeholder always visible

I am trying to style all the inputs in my website in a way that when they have a value or have focus the palceholder becomes the title of the input (it moves to the top of the input) but the default behavior of the browser hides the placeholder when there is data on it. I really want to stay away from JS solutions. Current results : My css : input:focus::-webkit-input-placeholder { transform: translate(-1rem,calc(-100% - 0.8rem)); font-size: 0.9rem !important; opacity: 1 !important; //this doesnt seem to keep the placeholder visible display:block !important; //this doesnt seem to keep the plac

Join the discussion →
Older stories