FAQ Database Discussion Community


android how have the value of edittext auto format itself and calculate-able at the same time

android
I have 2 edittexts and 1 textview. 1 edittext for input the price another one the percentage and the textview will display the result of them both (the price * percentage/100) and i want to make the 1st edittext input(for the price) will change the format of the input and...

How to crop text around a searchword exluding HTML-tags

php,html
What I have is a string containing HTML and Text, also theres a searchword. I want to get some cropped Text "around" the $searchword. Example Text: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua....

Personal git ignore not working

git
In GIT in the command line I see I have a modified file: # modified: sites/sites.php I want to not commit this, but I want this file to only be excluded locally. Ive opened the file called exclude in .git/info and added this line: sites/sites.php Ive reverted the modifications to...

Android security app ask for permission when recording audio

android,audio,permissions,record
When recording audio on android phone. I already add permission in the manifest file I can recording audio on most of the device, but can not recording on some device. The device pop-up window and ask for permission, if I click yes, then I can recording. I guess this is...

ElasticSearch and index strategy

iis,logging,elasticsearch,kibana
We are currently setting up an ELK stack to consume our various logs. Currently we are just using an index per day and only have logs from various applications we develop (approx 100m docs). Next step is to look at other types of logs from e.g. IIS, event logs from...

label matplotlib imshow axes with strings

python,matplotlib
I want to create multiple imshows via plt.subplots. The axes of each imshow should be labeled with strings, not with numbers (these being correlation matrices representing correlations between categories). I figured out from the documentation (very bottom), that plt.yticks() returns what I want, but I seem not to be able...

Cordova doesn't add data to URL (AJAX)

android,jquery,ajax,cordova,url
I'm sending an Jquery.Ajax request to a server which is hosting a .asmx web service. jQuery.ajax({ type: 'GET', url: 'http://IP-destination/myFolder/WebService.asmx/LogonUser', cache: 'true', data: { 'username':get_cookie('username'), 'password':get_cookie('password'), 'environment':get_cookie('environment') }, dataType: 'jsonp', beforeSend: function(){$.mobile.loading('show', 'a', 'Laddar...', false); alert("go");}, error: function(a, b, c){ $.mobile.loading('hide','a'); alert(a + b+ c); }, success: function(response){...

Do I use myServlet.java or myServlet.class

java-ee,servlets
I am trying to develop a web application but I don't understand should I put myServlet.java or the binary version myServlet.class under /WEB-INF ? Thank you for your help.

c# format objects for querystring

c#,jquery,asp.net,rest
I am writing some extensions to a shop flow where I need to make some calls to a REST service. Because of many places from which I need to call this, I need to do it from c# (this being said for the suggestions to use jquery or other ideas...

Python end parent process from thread

python,multithreading,timer,multiprocessing
My aim is to create a new process which will take a number as input from user in a loop and display the square of it. If the user doesn't enter a number for 10 seconds, the process should end (not the main process). I'm using threading.Timer with multiprocessing. Tried...

Warning: trim() expects parameter 1 to be string, array given in wp-includes/class-phpmailer.php on line 973

php,wordpress,wordpress-plugin-dev
I am trying to send an email from my wordpress website using the function wp_mail and I am getting this error: Warning: trim() expects parameter 1 to be string, array given in /var/www/html/wp-includes/class-phpmailer.php on line 973 0 I don't really understand why I am getting it. This is my current...

How to refactor for loop, which calls a function with multiple arguments, to `*apply`?

r
Please help me in simplifying the below for loop into an *apply function. I want to avoid the explicit for loop, but am unable to figure out where to put the extra arguments. The below code works absolutely fine, but I am interested in improving it. rankall is my function...

ARM Cortex-M heap alignment

heap,memory-alignment,cortex-m,eabi
After being bitten by stack alignment problems I started wondering whether the heap should be aligned to 8-octet boundaries, as well. The ARM Cortex EABI states that for all calls to external functions the stack has to be 8-aligned. I could not find any information on whether there are any...

NullPointerException when passing object from jsp to Servlet

java,jsp,servlets,nullpointerexception
I am trying to pass the my DTO object from jsp to servlet using session object but i'm getting null pointer exception initially i tried with request object which is giving same error hence i moved to session object. in first servlet request.getSession().setAttribute("datadto", dataDTO); request.getRequestDispatcher("success.jsp").forward(request, response); in jsp <% DataDTO...

Automatic Scroll of Cell inside CollectionView in SWIFT

ios,objective-c,swift,apple
How can I scroll inside a collection view such that I will always see one cell at a time, occupying the whole screen? Like what you do when browsing individual photos in your iPhone's gallery. Let's say (cell 1 ) |space| ( cell 2) when I scroll to the left...

A string variable becomes a tuple

python
Update: Fixed the problem. I have commas behind my strings because I copied an pasted them over a dictionary. I have a config.py file with some string variables inside like MAIL_SERVER='email-smtp.us-east-1.amazonaws.com', However, when I import it into another class, the variable becomes a tuple. type(config.MAIL_SERVER) # result <type 'tuple'> Can...

Form button not working in IE11

html,forms,internet-explorer
I have created a form with a submit button, the submit button is outside the actual form but its targeting the form using the form attribute for example. <form id="myform"> </form> <button form="myform"></button> I apologize for the week example. This is working accross all browsers except IE 11. IE 8-10...

I m trying to fetch data from database and the while loop is keep on iterating unable to find the outcome help me to get rid of that

php,mysqli
I created a Connect.php file for connection to database. I also created a php.ini file. <?php session_start(); $_SESSION['user_id']= '1'; include 'db/connect.php'; include 'func/articles.php'; include 'func/like.php'; ?> Also an article file to get specific data from database and table: article.php <?php function get_articles() { include 'core/db/connect.php'; $articles = array(); $quere="SELECT article_id,article_title,...

My algorithm doesn't work [closed]

algorithm
Im pretty new to Android but I have worked with Java before. I dont understand why my algorithm doesn't work. The result I get is 0.0%. txtInfo.setText(Double.toString((RadioProgress/255)*100)+"%"); txtInfo is a TextView. I can see in my graphic that my RadioProgress gets the right value. But still I get 0.0% all...

Cannot construct tkinter.PhotoImage from PIL Image

python,tkinter,resize,python-imaging-library,resize-image
I try to show a image in a label when I push a button, but the image are too large and I have tried to resize the image. I have created this function: def image_resize(imageFile): width = 500 height = 300 image = Image.open(imageFile) im2 = image.resize((width, height), Image.ANTIALIAS) return...

Razor hide / show div onchange select

asp.net-mvc,razor
I am new to MVC C# Razor, I have done this in PHP and I tried to use my previous code in Jquery (as shown below) <script> $(document).ready(function(){ $('.CurrentStatus').change(function () { if(this.value == "Non-Teaching") { $('#div-CurrentTDepartment').fadeOut('fast'); $('#div-CurrentTPostion').fadeOut('fast'); $('#div-CurrentNTDepartment').fadeIn('fast'); $('#div-CurrentNTPostion').fadeIn('fast'); } else if (this.value == "Teaching") { $('#div-CurrentTDepartment').fadeIn('fast'); $('#div-CurrentTPostion').fadeIn('fast');...

How to get new width and height after an image has been rotated with imagerotate()?

php
How do I actually get the new width and height that is set after image is rotated? $ps['product_angle'] = 77; //Could be any angle $filename = 'test.png' //filename to the original product list($source_width, $source_height) = getimagesize($filename); $source_image = imagecreatefromjpeg($filename); $angle = $ps['product_angle']; if (intval($angle) <> 0) { $source_image = imagerotate($source_image,...

Calculate total of 2 different variables to 2 decimal places

jquery
How can I make the outcome of the following sum be to 2 decimal places? 114.95 + 6.95 = 121.90 This is what I have tried, but the outcome of this code is 114.956.95 var Bezorgkosten = this.options[e.target.selectedIndex].value; var Subtotaal = <?= $l_TotaalPrijs ?>; var Totaalkosten = parseFloat(Subtotaal).toFixed(2) + parseFloat(Bezorgkosten).toFixed(2);...

Why do I get an extra null terminating character when converting from WCHAR to char?

c,winapi
I'm investigating the null termination of strings with this C code. #include <Windows.h> #include <stdio.h> int wmain(int argc, WCHAR *argv[]) { WCHAR *wstr = argv[1]; int wlen, len, written; char *strA; DWORD nOut = 0; wlen = lstrlenW(wstr); printf("wlen: %d\n", wlen); if (wstr[wlen] == 0) printf("wstr[%d] == 0\n", wlen); if...

Installing optipng with homebrew: command not found (rbenv?)

osx,terminal,rubygems,homebrew,rbenv
I've successfully installed optipng: $ brew install optipng ==> Downloading https://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.5/optipng-0.7.5.tar.gz Already downloaded: /Library/Caches/Homebrew/optipng-0.7.5.tar.gz ==> Patching patching file src/optipng/osys.c ==> ./configure --with-system-zlib --prefix=/usr/local/Cellar/optipng/0.7.5 --mandir=/usr/local/Cellar/optipng/0.7.5/share/man ==> make install 🍺 /usr/local/Cellar/optipng/0.7.5: 6 files, 156K, built in 2 seconds but when I use the command it...

Rails: Mail::Message object isn't showing the message_id attribute but

ruby-on-rails,ruby,lazy-loading
I've a Mail::Message object that's created by the following way: mail_message_object = mailer.send(method_symbol, *parameters) Here the method_symbol specifies it the type of the mail. Now, my problem is that when try to use this particular mail_message_object's message_id, it shows me a nil. mail_message_object.message_id --> nil But if I do this...

PHP suppress errors when checking existence + value of boolean?

php,coding-style,refactoring
I have a PHP script that uses an array of options: $opts[] $opts can contain 0 or more key value pairs. All values are boolean. When checking for existence of a key, and then that the value is true, I have been doing the following: if(isset($opts['small']) && $opts['small']) $classes .=...

Dispose some forms all around another form [some code already given]

javascript,jquery,html,css,forms
The idea I want to realize is that : those are searchbars made like this (not necessary) <form action="/index" class="form-wrapper cf"> <input type="text" placeholder="Search here..." name="searchbox" > <button class="searchbutton" type="submit">Search</button> </form> So i want to dispose them in a circle the result would be similar to what you see here...

Move emails to SQL Server

.net,sql-server,email,exchange-server
I'm looking to write an application, in .net that will scan a mailbox and put new items into a SQL Server database. Just wondering what the best way to achieve this would be, in terms of an API. Is there an exchange specific one or a 3rd party one I...

How can i convert JSON data present in a URL into a JSON string in java or android?

java,android,json
I tried the code in android below:- HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet("http://echo.jsontest.com/key/value/one/two"); String text = null; try { HttpResponse response = httpClient.execute(httpGet, localContext); HttpEntity entity = response.getEntity(); text = getASCIIContentFromEntity(entity); JSONArray jsonObj = new JSONArray(entity); System.out.print("message is"+jsonObj); } catch (Exception...

Error :Undefined function 'kernelpca_tutorial' for input arguments of type 'double'

matlab,pca
I have rum this code http://www.mathworks.com/matlabcentral/fileexchange/27319-kernel-pca/content/kernelpca_tutorial.m But I get the error as kernelpca_tutorial(input,5) Undefined function 'kernelpca_tutorial' for input arguments of type 'double'. where input is input = 2.5000 3.5000 1.0000 1.5000 7.5000 9.0000 4.5000 8.0000 9.0000 What cud be the error..Any help wud be appreciated!...

Can SWTBot recognize Action Buttons?

java,junit,swt,eclipse-rcp,swtbot
I have an RCP Application with a ViewPart that has a toolbar with some Actions on it. These Actions are put on the toolbar by the system as simple Buttons with an icon and a tooltip. The Action looks like this: public class MyAction extends Action { public static final...

jQuery return links false if it has li has children li

jquery
i have unordered list i wrote a jQuery code to disable the link if its li has children (ul li), but its not working jQuery code $(document).ready(function() { $('.sidebarnew > ul > li > a').click( function(){ maincat = $(this).parent(); if (maincat.children('li').length){ maincat.find('>a')(function(){ return false; }); } }); }); HTML <div...

Cassandra connection fails

java,maven,ubuntu,cassandra,telnet
Error is Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /172.17.1.XX:9160 (com.datastax.driver.core.TransportException: [/172.17.1.XX:9160] Cannot connect)) at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:196) at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:80) at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1145) at...

SQL Server 2008: DROP PROCEDURE error

sql,sql-server-2008,table,delete,ssms-2014
I'm a very noobie to SQL Server, so sorry for any stupid questions. I try to execute this command: IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'dbo.njams_test_sql_2.[PROC_CHECK_TRACE_SETTINGS]') AND type in (N'P', N'PC')) DROP PROCEDURE dbo.njams_test_sql_2.[PROC_CHECK_TRACE_SETTINGS] GO But I'm getting this error: Msg 166, Level 15, State 1, Line...

how to remove the part of image except highlighting part in ios

ios
hi i have done getting image from Gallery or camera.and i have button when i click that button getting image again from gallery or camera in which when i touch some part that is highlighting that should be only display in to anotherView.remaing part should be removed.please anybody assist me...

Insert Javascript variable into Html.Partial ViewDataDictionary ASP.NET MVC

javascript,asp.net-mvc
I have a javascript function and when it is called I want to insert a partial into a div. All is working fine, but, when I want to pass some javascript into Html.Partial ViewDataDictionary, it isn't passing the rendered javascript. <script> function addExperience() { @{var uid = @MvcHtmlString.Create("new Date().getTime()");} console.info(@uid);...

Why does deque::pushback fail to allocate when there is still memory available?

c++,dynamic-memory-allocation,deque
I'm running 64-bit Windows 7 on a machine with 16GB of RAM but when I execute the following code: #include <deque> #include <iostream> using namespace std; struct Packet { unsigned char* m_buffer; int m_bufferSize; public: Packet() : m_buffer(nullptr), m_bufferSize(0) { } Packet(const Packet& rhs) : m_buffer(new unsigned char[rhs.m_bufferSize]), m_bufferSize(rhs.m_bufferSize) {...

Spring Filter not getting invoked

spring,filter
I added a CORS filter to my application, but it does not seem to be executed (no prints). The filter is this: @Component public class SimpleCORSFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) throws ServletException, IOException { System.out.println("EXECUTING"); HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*");...

What is node in a tree?

data-structures,tree,nodes,treenode
According to wiki, everything in a tree is a node. Terminologies used in Trees Root – The top node in a tree. Parent – The converse notion of child. Siblings – Nodes with the same parent. Descendant – a node reachable by repeated proceeding from parent to child. Ancestor –...

How to consume REST with Angular.js?

javascript,angularjs,rest
I'm new to angular, so I was following Recipes with Angular.js, more specifically "Consuming RESTful APIs" part. I have working REST service at localhost:8080/test/categories which returns this JSON: [{"id":1,"name":"name1"},{"id":2,"name":"name2"},{"id":3,"name":"name3"}] This is my web page: <!doctype html> <html lang="pt-BR" id="ng-app" ng-app="categories"> <head> <title>REST TEST</title> <script src='/resources/js/jquery-2.1.3.min.js'></script> <script...

Design a email daily digest feature with spring integration

spring,aggregate,spring-batch,spring-integration
I currently have a SI project that listen on a JMS queue do some processing and depending on the messages send emails, write files, ... Now I want to add a daily digest feature on the sending emails part. I want email messages to be stored somewhere and that once...

Elasticsearch wont apply not_analyzed into my mapping

php,mysql,apache,laravel,elasticsearch
When I try to apply "not_analyzed" into my ES mapping it doesnt work. I am using this package for ES in Laravel - Elasticquent My mapping looks like: 'ad_title' => [ 'type' => 'string', 'analyzer' => 'standard' ], 'ad_type' => [ 'type' => 'integer', 'index' => 'not_analyzed' ], 'ad_type' =>...

How to get ItemIndex of RepeaterItem from ImageButton-Click?

c#,asp.net,vb.net,repeater
i want to convert this vb.net code to c#: Protected Sub btnDilSil_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Dim index As Integer = CType(sender.Parent, RepeaterItem).ItemIndex End Sub i write code block below instead of the code line above but it gives error "Invalid Cast Exception", please help, thanks in...

css for adding background color to div tag

html,css,css3
I want to add background color to div tag.Now background color appears only in the center of the div.I want to display it for whole div tag I have one outer div box and marked it as 'b'.With in box div tag I have emp div.within emp div I created...

shell 'SED' - use variabels

linux,shell
I´m looking for a way to remove the entry in /etc/passwd. So I did this sed -i /$user/d /etc/passwd but looks like I can´t use variabels in sed. I tryed this too: sed -i "/"$user"/d /etc/passwd" but did not work. Thanks for any help!...

Inject a string with quotes from PHP to javascript

javascript,php
I'm facing a problem when trying to inject a string from PHP (using the Laravel framework) into javascript. The string is like [{"foo1": bar1}, {"foo2" : bar2}]. When I inject this string to javascript using something like var test = '{{ $var }}' the " are converted to &quot;. The...

Javascript arrays: Given array[n], get array[n*m]

javascript,arrays,dictionary
I'd like to know which would be the best way to solve this problem using javascripts native array methods(map,reduce,etc.). Given an array of n objects I want to create another array that will contain m objects for each element in the original array. I can do it using common "for"...

case statement if table present

sql,sql-server
I am having problem in finding table from different database (table sometimes get dropped due to procedure) if the table is present then condition else direct ans as 1 select (case when exists (select * from SysSet.INFORMATION_SCHEMA .TABLES where TABLE_NAME = 'CHQPASS') then ( case when left(tranm.docu_no,1) <>'3' or tranm.docu_dt...

Dynamic columns in DataGridView control (ASP.NET)

c#,linq,datagridview,dynamic-controls
I have a List which contains records in the following template. Date | User | Question | Answer(Option) For which the records will be like 02/02/2015 | Harry | What is..? | 5 02/02/2015 | Harry | How..? | 4 02/03/2015 | Alice | What is..? | 3 02/03/2015 |...

Should a subroutine always return explicitly?

perl,function,oop,subroutine,perl-critic
If perlcritic says "having no returns in a sub is wrong", what is the alternative if they really aren't needed? I've developed two apparently bad habits: I explicitly assign variables to the '$main::' namespace. I then play with those variables in subs. For example, I might do.. #!/usr/bin/perl use strict;...

Best Way to Replace UserControl Loaded in TabControl TabItem

wpf,xaml,user-controls,tabcontrol,tabitem
I currently have a TabControl loaded in MainWindow.xaml, which has three tabs. Let's name them Tab1, Tab2 and Tab3. The individual tabs have views (usercontrols) supplied and they all work as expected. Code as follows. I am using MahApps Metro TabControl here. <Controls:MetroAnimatedSingleRowTabControl Grid.Row="0" Grid.ColumnSpan="4" x:Name="MainTabControl"> <TabItem Header="Tab1"> <view:Tab1View DataContext="{Binding}"...

How to make changes in marshalled output in Java web service client

java,xml,jaxb,cxf,jax-ws
I am trying to interact with a third party web service, who requires me to send a security token as a part of each request. The token is a node by itself, and I acquire it from the response of an initial call. The web service endpoint is dotNet, and...

loop through list box in vb and get a total amount

vb.net,loops,listbox
I’m trying to loop through a list of prices on a list box and print the total in a textbox on the form. The loop I have works, but the figures it produces are all wrong!. can any one help me?? the figures look ok but then when i add...

Migrating from 2.3 to 3.0 paginated results have OrderedDict in JSON

django-rest-framework
I am attempting to upgrade Django REST Framework from 2.3.14 to 3.0.5 My functional tests are failing because 3.0 is not returning correct JSON. In 2.3 I get {'results': [{'id': 2}, ... but in 3.0 the JSON is not rendered correctly leaving an OrderedDict {'results': [OrderedDict([('id', 2), ... I'm using...

SQL query get count item for report per day of the month?

sql,sql-server,sql-server-2008
i need sql query for report from table item per day(fix day1-day31 as column) of the month when i input month and year. This is my table (item)   ID   |   NAME  |   DATE ---------------------------------------------------    1   |   ITEM A |   2015-2-25 13:37:49    2   |   ITEM A |   2015-2-25 14:37:49...

Android Edittext number only

android,android-input-method
I have a a Edittext field that is dynamically created I have it so that the input method is number only. However it is still possible to paste text into the field. Is there anyway of preventing this without having to do post validation? My code to for input method...

Join in unidirectional association

java,jpa,querydsl
Association between School and Student is unidirectional. How can I create query from Student with a join to School using JPA criteria or Querydsl? class School{ @OneToMany private List<Student> students; } class Student{ private String name } ...

Weird issue with text-transform

jquery,css
This works - each menu item has the first letter uppercased $(function() { $("#navcontainer").append('<ul class="nav">\ <li><a href="#">beverages</a></li>\ <li><a href="#">meats</a></li>\ <li><a href="#">cheeses</a></li>\ <li><a href="#">vegetables</a></li>\ <li><a href="#">fruit</a></li>\ </ul>' ); window.console&&console.log($("#navcontainer").html()); }); #navcontainer ul { margin: 0;...

NodeJS, Facebook GraphAPI: exchange token for access_token

node.js,facebook,facebook-graph-api
I'm looking into "exchange code for access token" section in nodejs package's documentation. In the first sample code snippet, it mentions code: 'code'. FB.api('oauth/access_token', { client_id: 'app_id', client_secret: 'app_secret', redirect_uri: 'http://yoururl.com/callback', code: 'code' My understanding of this is to get a value to replace 'code'. To get the value, I...

Python 2.7 : Remove elements from a multidimensional list

list,python-2.7
Basically, I have a 3dimensional list (it is a list of tokens, where the first dimension is for the text, second for the sentence, and third for the word). Addressing an element in the list (lets call it mat) can be done for example: mat[2][3][4]. That would give us the...

Will we be able to migrate TypeScript to Google AtScript?

angularjs,typescript,atscript
Google is developing AtScript and - if I'm right - it will be introduced with Angular 2.0. Now, I am wondering if we will be able to migrate our TypeScript files to AtScript and continue with that new syntax. O, can someone, with enough reputation, create the tag AtScript? Thanks!...

F# cryptic generic constraint error message

f#
Just for fun I've been playing around with emulating typeclasses in F#, using the ideas shown here. I created a Next typeclass to represent values that have a "successor" e.g. next 1 = 2, next today = tomorrow etc: type Next = Next with static member (++) (Next, x:int) =...

Laravel 5: Best way to validate form with Javascript

laravel,laravel-5
I want to validate forms in the client side in Laravel. It's there any easy way to do it?

How to use re module in python to extract information?

python,html,regex
I write a little script to use collins website for translation. heres my code: import urllib.request import re def translate(search): base_url = 'http://www.collinsdictionary.com/dictionary/american/' url = base_url + search p = urllib.request.urlopen(url).read() f = open('t.txt', 'w+b') f.write(p) f.close() f = open('t.txt', 'r') t = f.read() m = re.search(r'(<span class="def">)(\w.*)(</span>]*)',t) n =...

How to Cancel a AlertDialogue from another method?

android,alertdialog,runnable
I have an Alert Dialogue Box and I want it to be accessible from a runnable method. The goal is to cancel the dialogue box once it reaches a certain criteria. Below is the code for creating the AlertDialogue: public void perm_dialogue() { final WifiManager wifiManager = (WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE); LayoutInflater li...

Use ternary operator to check for successful INSERT in database?

php,pdo,ternary-operator
Is it acceptable practice to use PHP's ternary operator to check for successful INSERT in database (or more generally, the return value of any function)? The PHP manual seems to be cautious on stacked ternary operators, and I have some embedded in my writeData function. #pseudocode variables to give context...

regexp to extract multiple occurrences of a pattern in a string

sql,regex,hadoop,hive
I'm running hive 0.13. I have a column that has various strings that look like this: a:ABC,b:SDSD,c:213123#a:SDS,b:UIOU,c:89797#a:TYRQQQW,b:UIOUIOYYO,c:546654 a:DFSS,b:TYRTTN,c:12323#a:HJH,b:YTUUUTYUTYT,c:67890 a:TYY,b:OPIUIU,c:86768 They could of any length, one set a,b,c values will always be separated by a '#'. Now, what I'm trying to do is, extract only the b column, like: b:SDSD,b:UIOU,b:UIOUIOYYO b:TYRTTN,b:YTUUUTYUTYT...

Python loop over iterator of list whose length is changed during the loop

python,loops
Let's say I would like to do the following: I have a list l and at each step I would like to check some condition between l[i] and l[i+1] and if it is satisfied, I will update l[i] based on l[i+1] and delete l[i+1], then I will check condition between...

why readLine() works, and readUTF() always throws IOException

java
I send a post request to an address, and this address will return a xml format data back. I can print out the data byreadLine(), but when i use readUTF(), it always throws IOException. below is the code DataInputStream input = new DataInputStream(urlCon.getInputStream()); String inputLine = ""; if((inputLine = input.readUTF())...

Meaning of variables in mongodb logs

mongodb
Can anyone explain to me about the logs in mongodb like what each variable in logs are defined for and what they mean? 2015-02-26T16:05:24.112+0100 [conn1359] command xxx.$cmd command: { fsync: false, j: false, w: 1 } } keyUpdates:0 numYields:0 reslen:55 4045ms 2015-02-26T16:05:24.114+0100 [conn1296] update xxx.users query: nscanned:2015 nscannedObjects:2015 nMatched:1 nModified:1...

SAPUI5 My fragment gets closed

fragment,sapui5
I'm Developing SAPui5 APP. I create a fragment xml with a sap.m.Popover, In Content of Popover I add 2 sap.m.MultiCombobox. When I close the selection of multicombobox my popover gets closed. Any solution? Fragment code: <core:FragmentDefinition xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:core="sap.ui.core"> <Popover class="sapUiPopupWithPadding" title="Filtro Asignación" placement="Top" > <l:VerticalLayout> <Label text="Fecha" ></Label> <DatePicker...

Why do event handlers use Object Sender when being automatically created in Visual Studio

c#,events,visual-studio-2013,eventhandler
For example if I had: Initialize Control MyControl mc = new MyControl(); mc.MouseUp += mc_MouseUp; Event Handler void mc_MouseUp(object sender, MouseButtonEventArgs e) { //annoying cast... MyControl control = (MyControl)sender; //Do some stuff to MyControl } is it not implicit that sender will always be a MyControl object? but yet the...

Filter by count in elasticsearch

elasticsearch,aggregate-functions,aggregate
Consider the following data POST programming/languages/1 { "name":"java", "type":"general_purpose" } POST programming/languages/2 { "name":"javascript", "type":"scripting" } POST programming/languages/3 { "name":"c", "type":"general_purpose" } GET programming/languages/_search { "query": { "match": { "type":"general_purpose" } } } If I need to find the docs which has more than one match of the field type,...

How to modify TFS build automation workflow without .Net Complier, need to use Team Developer's Language complier

tfs,msbuild,tfs2010,tfsbuild
I am trying build automation for a project developed using legacy language called Team Developer 6. where each file needs to be compiled as an exe. also need to do some filter activity before building exes. there are 300 exes. this process I could do in simple .Net utility which...

load a local css file into a webview

html,ios,css,webview
I built a simple ios app that loads a html downloaded from a server into a webview. [self.webView loadHTMLString:notif.html baseURL:nil]; This works perfect. The problem is that i nedd to apply a local css file to the webview and I dont know how to do it. I tried doing it...

How to remove this JavaScript null error?

javascript
I'm using the following to create an if statement based on the last word of the url after the slash: // Sticky var match = location.search.match(/(\w+)$/)[0]; if (match === 'complete') { $('p:has(audio)').addClass('sticky-child'); $('p:has(audio)').appendTo('.lesson_lang_switch'); } The problem is, the front page doesn't have any word at the end of the URL...

Producing smmary tables for very large datasets

r,data.table
I am working with migration data, and I want to produce three summary tables from a very large dataset (>4 million). An example of which is detailed below: migration <- structure(list(area.old = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L,...

Android Java regexp pattern

java,android,regex
I ping a host. In result a standard output. Below a REGEXP but it do not work correct. Where I did a mistake? String REGEXP ="time=(\\\\d+)ms"; Pattern pattern = Pattern.compile(REGEXP); Matcher matcher = pattern.matcher(result); if (matcher.find()) { result = matcher.group(1); } ...

Converting a timestamp in miliseconds in Postgres

sql,postgresql,timestamp
I have a timestamp in miliseconds: 1420066991000 That translates into UTC: Wed Dec 31 2014 23:03:11 and local time: Thu Jan 01 2015 00:03:11 However if I try to convert it into a timestamp in Postgres, using to_timestamp, it gives me a wrong datetime: select to_timestamp(1420066991000); 46970-02-17 13:03:20+00 Since to_timestamp,...

Unterminated string constant during @Html.Partial from javascript object

javascript,html,asp.net-mvc,single-page-application
var html = '@Html.Partial("_mypartialview")'; $("#container").html(html); I am working in a single page application and I don't want to hide the container div element; instead I want to load the html content into my javascript object. But I get the error: Unterminated string constant. I have tried various methods without any...

use time and date in logrotate ext?

linux,system-administration,logrotate
I need to use time and date as an extension of rotated logs. Right now i'm using dateext. but problem with dateext is that I can't achieve rotation more than once on same date/day. and I have to do rotation on hourly basis, I have created cronjob for this. Here...

Trigger input file click event in AngularJS

javascript,html,angularjs
I am trying to emulate a click event on a file input in AngularJS. I have seen working jQuery examples, but I don't want to use jQuery. 'use strict'; angular.module('MyApp', []). controller('MyCtrl', function($scope) { $scope.click = function() { setTimeout(function() { var element = angular.element(document.getElementById('input')); element.triggerHandler('click'); $scope.clicked = true; }, 0);...

How does angular resolve controllers defined in modules?

javascript,angularjs
Looking at the angular documentation for controller there's something that confuses me. Let's say someone does this: angular.module('foo').controller('controller1', ['$scope', function($scope) { }); and: <div ng-app='app' ng-controller='controller1'> </div> How does angular know that 'controller1' resides in module 'foo'? And furthermore if someone does this in addition: angular.module('bar').controller('controller1', ['$scope', function($scope) { });...

IAR inline assembly using global C variable

c,assembly,arm,inline,iar
I'm using IAR Embedded Workbench for ARM 6.50.4 Functional Safety Version 6.50 and I can't seem to get an assembly inline instruction working. For the background: I'm trying to implement a context switch on an ARM7TDMI using the PIT Interrupt. When saving the current context I have to get the...

How to determine which button is pressed out of Button grid in Python TKinter?

python,tkinter
I am writing a GUI with Python TKinter where I have a grid of some 24 buttons which I have created using a loop (not individually). Is there any way in which I can get the Text of the button that I pressed. Since it is in loop, a callback...

php code to load javascript array from database

php,mysql,pdo
I try to load auto populate textbox from javascript array function plz suggest me how to fetch data in javascript function based php pdo sql. I need to load this tags from sql database..plz suggest me how to do this... this is my php code. <?php $book_no2 = $load_book["book_no"]; $receipt...

Android AssertJ 1.0.0 with Android gradle 1.1.1

android,gradle,android-gradle,assertj,android-assertj
Here is part of my build.gradle that has conflict: ... dependencies { classpath 'com.android.tools.build:gradle:1.1.1' } ... testCompile( 'com.squareup.assertj:assertj-android:1.0.0' ) ... The issue that I see in log: WARNING: Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (21.0.3) and test app (20.0.0) differ. Apparently it removes conflicting dependency from the classpath....

Is it OK to run GC.Collect in a background thread?

c#,.net,multithreading,winforms,garbage-collection
Following this SO answer, I'm doing: ThreadPool.QueueUserWorkItem( delegate { GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }); My goal is to do a garbage collection run after I close a large WinForms form with lots of images/PictureBox controls to ensure I have no images in memory anymore. (I do believe I follow the instructions...

How to sort the select2( plugin ) options alphabetically?

javascript,jquery,jquery-select2
I want to sort the select2 options in alphabetical order. I have the following code and would like to know, how can this be achieved. <select name="list" id="mylist" style="width:140px;"> <option>United States</option> <option>Austria</option> <option>Alabama</option> <option>Jamaica</option> <option>Taiwan</option> <option>canada</option> <option>palau</option> <option>Wyoming</option> </select> $('#mylist').select2({...

How to check if user is authenticated in Web API 2

c#,asp.net,asp.net-web-api2
I have a Web API 2 service. In ApiController I create some different methods. One of these methods is used for user Login. In this method I can check user name and password hash selected from DB, and if they are correct, I can generate SessionID for current user session...

angular service injection in controller with multiple methods

javascript,angularjs,ionic
I'm trying to build a ionic object-oriented controller properly and am getting trouble with Service Injection... angular.module('app.controllers', ['ionic', 'app.services.myservice']).controller('myCtrl', MyCtrl) function MyCtrl($scope, $ionicLoading, MyService){ this.scope = $scope; this.ionicLoading = $ionicLoading; this.MyService = MyService; } MapCtrl.prototype.method1 = function($scope, $ionicLoading, MyService) { //$scope, $ionicLoading and MyService are undefined } MapCtrl.prototype.method2 = function(){...

Expression that factors S into Y so X evaluates to either Y or -Y?

javascript,math,expression
How do I write an expression that factors s (either 0 or 1) into y (any value) so x evaluates to either y or -y? e.g. y is 180 if s is 0, x should be 180 if s is 1, x should be -180...

Local variable unused in a using statement

c#
When implementing a using block for the benefit of dispose, such as using (var window = new DialogWindow(Dialogs.MyDialogType)) { //Some action here } I get an obvious resharper / visual studio warning that the local variable window is never used, since it is not mentioned in the using body. This...

How do i Count based on multiple Conditions

sql,select,sql-server-2008-r2,counter
I have current 4 Columns Id, A, B and C A B C 243 3 1 243 3 2 243 3 3 243 3 1 243 3 2 243 3 3 243 3 1 243 3 2 243 3 3 185 3 1 185 3 2 185 3 3 185...

Creating log file for program [closed]

java,log4j
I'm not sure I'm able to ask this question here, if I can't I appologize. I'm creating simple class which will connect to database and I want to log the exceptions into file. My question is should I just append the exception into a file or use Apache log4j I...

Efficient way to build collections from other collections

scala
In Scala, as in many other languages, it is possible to build collections using the elements contained in other collections. For example, it is possible to heapify a list: import scala.collection.mutable.PriorityQueue val l = List(1,2,3,4) With: val pq = PriorityQueue(l:_*) or: val pq = PriorityQueue[Int]() ++ l These are, from...

Store captured video in specific folder and play the video in a video view [closed]

java,android,video
I required a simple code to store a video and display in videoview I required a simple code to store a video and display in videoview . Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO); I am a new developer. I create apps. I am required to store the video in...

How to run a function periodically with Flask and Celery?

python,flask,celery
I have a flask app that roughly looks like this: app = Flask(__name__) @app.route('/',methods=['POST']) def foo(): data = json.loads(request.data) # do some stuff return "OK" Now in addition I would like to run a function every ten seconds from that script. I don't want to use sleep for that. I...

Get rows where value change from 0 to 1

mysql,sql
I have table: id date default(bool) 1 2015-01-01 0 2 2015-01-02 0 3 2015-01-03 1 4 2015-01-04 1 5 2015-01-05 1 6 2015-01-06 0 7 2015-01-07 0 8 2015-01-08 1 9 2015-01-09 1 10 2015-01-10 0 I want only rows where ordered by date rows change default column from 0...