on-internet

Kafka Consumer to read from multiple topics

I am very new to Kafka. I am creating two topics and publishing on these two topics from two Producers. I have one consumer which consumes the messages from both the topics. This is because I want to process according to the priority. I am getting a stream from both the topics but as soon as I start iterating on ConsumerItreator of any stream, it blocks there. As it's written in documentation, it will be blocked till it gets a new message. Is any one aware of how to read from two topics and two streams from a single Kafka Consumer? Map<String, Integer> topicCountMap = new HashMap<String, Integ

Join the discussion →

Cast field in JPA Query

In my sql-server, the field DATE are saved in float format (es: DATADOC = 42155) I want to import the field in mysql DB as DATETIME. I try on sql-server to cast the field with this query: SELECT CAST(DATDOC as DATETIME) -2 FROM FATTURE where id=25460; And the result is correct. Now, I want to translate it in JPA Query: TypedQuery<DateTime> convFattura = emI24.createQuery(" SELECT CAST(dataFattura as DATETIME) -2 FROM FatturaI24 f where f.id = :idFattura", DateTime.class); But I obtained this error: 09-06-2015 14:32:00 ERROR: org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler

Join the discussion →

Split string into several substring using indexes

I have this string and hash: Input data: my $string = 'GATGCAGTTAGGCGTAGCAGAGTGAGACGACGACGATATTAGGACCCGGTAAGGCACAATATAGC'; my %coord_colors = ( 10 => "red", 48 => "orange", 60 => "purple", ); I want to "open" the string at each hash key position, and insert the key-value. See the desired output to have an idea about what I'm trying to explain: Desired output: GATGCAGTTAredGGCGTAGCAGAGTGAGACGACGACGATATTAGGACCCGorangeGTAAGGCACAATpurpleATAGC I know about the substr and split functions, but I'm not sure about how to divide a string into several parts "simultaneously" and then introduce another str

Join the discussion →

Shell script to check a log file and print the errors that are found in it

I am pretty new to shell scripting . I am trying to write a script to check for logfile for errors (error strings are hardcoded), and i have to print the lines containing the error . i am able to write the logic but need pointers to read a file from user input. Appreciate the help thanks. Logic: Accept the logfile patch from user Check if the logfile is present or not If present search the file for lines containing the error string (eg. Error, ORA) Print the lines containing error strings , also write the output to a logfile Read the log file from user Set error strings search="ERROR" set a pa

Join the discussion →

Runtime Error '5941' The Requested Member of Collection Does Not Exist

When running the macro I am getting the following error: "Runtime Error '5941' The Requested Member of Collection Does Not Exist" The line below is highlighted in Yellow; This Macro works on the majority of users and the error has only been reported off two users. Windows(DestTemplateName).Document.Bookmarks("fCustomer").Range.Fields(1).Result.Text = Windows(SourceTemplateName).Document.Bookmarks("fCust").Range.Fields(1).Result.Text Any Help Would Be Much Appreciated. Sub PopulateBookingForm() Dim SourceTemplateName As String, DestTemplateName As String ' Set Method Statement Name SourceTempla

Join the discussion →

How to call a stored procedure from a Spring Batch Tasklet?

It is mentioned that a TaskletStep in Spring Batch can be used to call a stored procedure. Could anyone provide an example of how to invoke a Stored Procedure from a TaskletStep? So far I have done this but it throws an exception saying "Configuration problem: The element [callStoredProcedure] is unreachable" <job id="job1"> <step id="step1"> <tasklet ref="myTasklet"/> </step> </job> <bean id="myTasklet" class="MyClass"> <property name="dataSource" ref="dataSource"/> <property name="sql" value="call stored_procedure()"/> </bean> Java Class class MyClass implements Tasklet{ @Override public Rep

Join the discussion →

How to detect the terminal that is running python?

I've already tried sys.platform, platform.system() and os.name but none of them return something related to cygwin (I always get win32, Windows and nt as output). Maybe because my python was installed on windows (8.1) and not through cygwin. I need to detect if my python file is being executed by cygwin or cmd.

Join the discussion →

How to make an Auto Clicker with Java?

So I wanted to make a program that holds down the mouse button for me. So far I've got this: http://pastebin.com/UTJwdHY7 What I'm wondering is how I can stop it. Also, what I realise is that stopping the button makes no sense as I wouldn't be able to click it anyway. Also some tips on how I've done so far would be nice. Edit (Adding code): package main; import javax.swing.*; import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.beans.PropertyChangeListener; public class cl

Join the discussion →

How to list Docker mounted volumes from within the container

I want to list all container directories that are mounted volumes. I.e. to be able to get similar info I get from docker inspect --format "{{ .Volumes }}" <self> But from within the container and without having docker installed in there. I tried cat /proc/mounts, but I couldn't find a proper filter for it.

Join the discussion →

Save worksheet as PDF on Mac

I am working on a macro to save the active sheet as a PDF file with a special name. The macro I created runs but saves every sheet in several PDF and puts the name of the sheet at the end of the file name. Sub PrintPDF() Dim wksSheet As Worksheet Dim strFile As String Set wksSheet = ActiveSheet 'strFile = Format(Now(), "yyyymm") _ & ".pdf" strFile = "blabla" _ & "_" _ & Format(Now(), "yyyymm") _ & "_" _ & "name2" _ & " " _ & Replace(Replace(wksSheet.Cells(1, 2).Value, " ", ""), ".", "_") _ & ".pdf" strFile = ThisWorkbook.Path & ":" & strFile wksSheet.SaveAs Filename:=strFile, FileFormat:=xlPDF

Join the discussion →

How to implement the jQuery mcustomscrollbar plugin to create a parallax effect

I wanted to add parallax effect (different scroll speed) to jQuery custom scroll bar plugin (mCustomScrollbar). I'm combining two examples of code: http://codepen.io/JTParrett/pen/BkDie - different scrolling speeds http://manos.malihu.gr/tuts/custom-scrollbar-plugin/full_page_demo.html - Full page scroller See also - http://manos.malihu.gr/jquery-custom-content-scroller/ (plugin callbacks / functions) I have managed to make both examples work separately, but not together, I have end up with this: j(window).load(function(){ j("body").mCustomScrollbar({ scrollButtons:{ enable:true }, callbacks:{

Join the discussion →

C# Post JSON with Authentication Header

I have problem with post JSON with authentication/Authorization.. Below is my code.. opponent said that they didnt receive the header...and i have no idea why... ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes(stringData); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serverURL); req.Method = "POST"; req.ContentType = "application/json"; req.ContentLength = data.Length; req.Headers.Add("Authentication", merchantID); req.Headers["Authentication"] = merchantID; Stream newStream = req.GetRequestStream(); newStream.Write(data, 0, data.Length); newStream.Close

Join the discussion →

Networkx Finding communities of directed graph

I am currently graphing and visualizing a directional social network. There is a statistic (modularity) in an open source visualization tool called Gephi (http://gephi.github.io/) that allows me to partition nodes by separating them into communities. I'd like to accomplish this task (finding communities) with my graph before I visualize it with Gephi so that I can run various statistics on each community that the algorithm finds. However, each community algorithm that I have found does not operate on directed graphs. I found two different algorithms to work with that won't work with diGraphs:

Join the discussion →

JQuery Datatables not working on ASP.NET MVC 5

I've used the nuget Package Manager Console with the command install-package jquerydatatablesmvc to install jquery datatables to my MVC 5 project and it installed version 1.9.4. However, after including the required scripts and css files, the data table is not still working. Here is what I've added to the page: <link href="~/Content/DataTables-1.9.4/media/css/jquery.dataTables.css" rel="stylesheet" /> <script src="~/Scripts/DataTables-1.9.4/media/js/jquery.js"></script> <script src="~/Scripts/DataTables-1.9.4/media/js/jquery.dataTables.js"></script> And the jquery code: <script type="text/java

Join the discussion →

Rails environment how to find out in code?

Are there any solutions how I can find out in which environment my application is running? I have some rake calls which need to have the environment like this: system "RAILS_ENV=development rake crons:dosomething" But this should not only work in development I want to use this in test production and development? how can I do this? second task where I need this is in config/schedule.rb the should also run in all environments rake "crons:dosomething", :environment => :development rake "crons:dosomething", :environment => :production this doesn't work

Join the discussion →

.htaccess redirect + rewrite: Prefix uri with language code while keeping initial uri

I am trying to rewrite/redirect incoming requests so that they will always be prefixed by a language code but would like to keep the originally requested path: example.org/de/ -> rewrite to example.org?lang=de example.org -> redirect to example.org/de/ which will then be rewritten to example.org?lang=de example.org/en/ -> rewrite to example.org?lang=en example.org/foo/bar -> redirect to example.org/de/foo/bar which will then be rewritten to example.org/foo/bar?lang=de These were my thoughts on this: RewriteBase / # No 'lang' key in query string RewriteCond %{QUERY_STRING} !lang=(en|de) # AND r

Join the discussion →

MDX Group Dimensions y new Dimension

I'm brand new in Cube world and I need to do a query extending some values form dimensions. For example: Having dimension [time].[Numeric Month], with values [time].[Numeric Month].&[1]..[time].[Numeric Month].&[12] What I need is group that values like this [time].[Numeric Month].&[1]...[time].[Numeric Month].&[4] = A [time].[Numeric Month].&[5]...[time].[Numeric Month].&[12] = B (is an example) and perform a query which result show be like this on Rows A |->1 |->2 |->3 |->4 B |->5 |->6 |->7 |->8 |->9 |->10 |->11 |->12 I could do the grouping but when I tried to use the same hierarchy used fo

Join the discussion →

How to replace a fragment and change TextView in the new one in the same procedure?

I am not a native English speaker, so hope you understand me anyway. In my application I have an activity with a RelativeLayout which I use as Fragment-container. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout android:id="@+id/fragmentContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" /> </FrameLayout> At the time I have two different Fragments, one will be sh

Join the discussion →

How to optimize collection subscription in Meteor?

I'm working on a filtered live search module with Meteor.js. Usecase & problem: A user wants to do a search through all the users to find friends. But I cannot afford for each user to ask the complete users collection. The user filters the search using checkboxes. I'd like to subscribe to the matched users. What is the best way to do it? I guess it would be better to create the query client-side, then send it the the method to get back the desired set of users. But, I wonder : when the filtering criteria changes, does the new subscription erase all of the old one? Because, if I do a first sear

Join the discussion →

Difference between Application servers and standalone frameworks

I would like you guys to give me some feedback, on my understanding about the difference between Application Servers such as JBoss and frameworks such as Axis and CXF. CXF is a standalone, web-app based framework that implements JAX-RS, JAX-WS API which, in turn, are part of the larger API set of JEE. Being a web-app based implementation, it can only be used to host "SOAP on HTTP" services even if the standard JAX-WS defines other possible channels for SOAP messages, such as SMTP. Application servers, such as JBOSS, instead implement JAX-WS as well as all the other JEE APIs in a more "native"

Join the discussion →

Seamless Handover in Windows CE 5.0 and higher using WLAN and VPN over GPRS

I have a little tricky problem using network under Windows CE with .net compact framework. I will try to describe... First of all there are three types of connections established while starting my application. First one is a WLAN Connection to company network Second one is a GPRS connection Third one is a OpenVPN connection that should use GPRS underlying. Default way is that the user is in WLAN area and connects to company network. But some times the user has to leave WLAN area but needs network connection, so the connection should seamless switch to GRPS over OpenVPN. If the user enters the

Join the discussion →

VBA Class : Collection.item member is a collection . How to retrieve sub collection item elements

I have this template data Header of file ((string1, string2...) group1 header (string1, string2...) group1/line1 (string1, string2...) group1/line2 (string1, string2...) group2 header (string1, string2...) group2/line1 (string1, string2...) group2/line2 (string1, string2...) Note: The data belonging to group header and group line are different type even if they are on the same 'column' (raw data comes from text file) I create my main class (populate collection) and data class (populate item : cData_Nomination), everything works individually BUT I need to create: -1 file collection (I have mult

Join the discussion →

Access Violation Error when TChart is docked

I get an AV when I dock a Form, which contains a TChart, into another Form. The error does not occur when the AutoPaint property of the TChart is set to True. I have tested this with C++Builder XE6, XE7 and Delphi Builder XE6 with the standard version of TeeChart. Steps to reproduce: Create a new application with two Forms (Form1 and Form2). Both Forms should be shown. In the constructor of Form1 set DockSite = true Paste the following code in the constructor of Form2: DragMode = dmAutomatic; DragKind = dkDock; TChart* Chart1 = new TChart(this); //don't forget to delete Chart1->Parent = this;

Join the discussion →

Draggable blocks glued with each other

Here is the sample on codepen. I use rails application and mongoDB at back end, jQuery and Draggability library at front end. Every time dragEnd or focusout events are triggered app tries to save card data to DB via ajax request. If there an error it return 422 code status with error message which it displays in alert. In that sample I emulate error message from app so that alert is always shown when focusout triggered from the input in the new card. Problem: Add a new card Write some test name And then click to other card to trigger focusout Click 'OK' in alert Click back to the previously ad

Join the discussion →

LEFT JOIN with WHERE in a first table's field OR second table's field

SELECT COALESCE(tb2.number_new, tb1.number_original) as number FROM tb1 LEFT JOIN tb2 ON tb2.id = tb1.id WHERE tb1.number_original = <PARAM> OR tb2.number_new = <PARAM> The above query generates a full table scan. How to optimize it? EXPLAIN: +----+-------------+-------+-------+----------------+----------------+---------+------+----------+----------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+----------------+----------------+---------+------+----------+------------------

Join the discussion →

Which would be an efficient way to work with an array of polynomials?

I have a function which given two polynomials, p and q, calculates the integral of p/q between the real numbers a and b. The function I have is$\phi$: import numpy as np def integrate_pdivq(a, b, P, Q, r): """ Calculates the definite integral of P(x)/Q(x) between a and b, assuming gr P<gr Q and that Q have all different roots, all of which have nonzero imaginary part. Parameters: P: list with coefficients of polynomial P. Q: list with coefficients of polynomial Q. r: list with the roots of Q. """ Q_deriv = np.polyder(Q) fracc = ( np.polyval(P, r)/np.polyval(Q_deriv, r) ) inte = ( 0.5 * np.log(

Join the discussion →

Primary key design and partitioning for large sets

I'm currently designing a database for SQL server and I need to handle a large set of data. The context is the following one I have: substrats composed of 4680 chips as a unique ID each chip is composed of 66 spots and has a pass/fail Boolean each spot as 3 values (x,y,radius) So every 20 minutes I need to insert 1 substrat which correspond to 308'880 spots and this 24/24h 7/7d for 10 years resulting in 8bn spots (I know it sounds a lot..) I thought about using composite key like this: SUBSTRAT(INT ID) CHIP(INT FK_SUBSTRATID, ROWNUMBER INT, COLNUMBER INT) SPOT(INT FK_SUBSTRATID, CHIPROWNUMBER

Join the discussion →

How to increase ng-repeat performance using Smart-Table?

I have a problem of performance and I haven't found the solution. Context: I need to display a lot of data (500 lines, 8 columns) in a table. To displayed this data I chose to use Smart-table because it offers good functionality but the problem is that I have a lot of data and the time of displaying data is very long (5 - 9 second, this depends on device performance). Important thing: I need to display all data so I don't want pagination method, limit filter. So this code is working: <ion-scroll class="scrollVertical" direction="xy" overflow-scroll="true" > <table st-table="tableaux" class="ta

Join the discussion →
Older stories