FAQ Database Discussion Community


Code Beautification with angular-ui-codemirror with indention

javascript,jquery,angularjs,codemirror
I generated xml code with jquery by using following code, var _outerBlock = $("<outerBlock>"); for (var i = 0; i < 10; i++) { var _innerBlock = $("<innerBlock>Serial " + i + "</innerBlock>") _outerBlock.append(_innerBlock) } var _tmp = $("<div>"); var $output = _tmp.html(); Now I am getting one line xml...

Check for existing user doesn't go along

mongodb,sails.js,waterline
As the Waterline's unique attribute is ignored for MongoDB, I take up the decision to make a check for existing model entry in my code: var username = req.param('username'); var email = req.param('email'); var asd = ""; // Do check if user already exists User.findOne({username: username}, function (err, user) {...

Reading packets from a client stops after 1 or 2 received

c,linux,sockets,server
I'm writing a server program in C that will read commands from the client. Commands are in the form of 5 byte packets, and the client will be sending a bunch of them in succession. The code I have to read each command is: while(1) { char buffer[1024]; int alreadyread...

From where geocode server Apple API get its information

ios,iphone,swift,core-location
I'm working on backend of my iOS app. I need a list of all countries that CoreLocation might return. i.e If I was in U.S the returned county will be U.S or United State. I searched and find that CoreLocation used geocode API: Link but I didn't find from where...

Protobuf cannot be linked on ubuntu

c++,ubuntu,linker,cmake,protocol-buffers
I try to use protobuf but somehow the linking fails (here just snippet): Linking CXX executable app CMakeFiles/app.dir/msg.pb.cc.o: In function `evoswarm::protobuf_AssignDesc_a_5fto_5fb_2eproto()': msg.pb.cc:(.text+0x133): undefined reference to `google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(google::protobuf::Descriptor const*, google::protobuf::Message const*, int const*, int, int, int, int, int, int)' msg.pb.cc:(.text+0x190): undefined reference to...

PHP - function that both returns and echoes a value

php
I would like to create a function that both returns and echoes a value. But not the two together. Or return or echo. And I am looking for a beautiful way to do it. Almost all functions / class methods in my project must have this option. I can pass...

Should my $PATH be returning anything RVM related?

ruby,osx,shell,zsh
I am running the command echo $PATH which is returning the following information containing RVM /Users/RAI/.rvm/gems/ruby-2.1.1/bin:/Users/RAI/.rvm/gems/[email protected]/bin:/Users/RAI/.rvm/rubies/ruby-2.1.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/RAI/.rvm/bin Should this command only return the following? /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin Note that I am currently using on My Zsh...

Java reflection - get field value

java,reflection,field
I try make class which generate new className.java file using reflection. I have problem with Fields value. Here is my test class. public class ClassTest { @Deprecated private int a; public int[] b; private final String c = "Hi"; ... } Method in which I try generate fields. private void...

function matlab: array initialization for more entity

matlab,simulink,simevents
I need help about a simulink function: I have n entities, in this example only 2. Attribute entity 1: ID = 1 , VALORE = 5 Attribute entity 2: ID = 2 , VALORE = 3 I need to call a function only one time instead of looping and if...

Put a string into a dialog from a slected list item from a expandable list child

android,dialog,expandablelistview
I've been trying to pull details of an item selected, from my strings.xml. To a dialog pop up when i select an item from my expandable list view (child). Sadly with little success. This is the expandable list fragment from my NavigationDrawerFragment. everything works great. the dialog pulls up with...

Precision not respected

visual-studio-2010,fortran
I use Visual Studio (2010 SP1) with Fortran IMSL (2011) and I can't get the right precision for my reals: program prova use, intrinsic :: iso_fortran_env implicit none integer, parameter :: ikind=selected_real_kind(p=8, r=99) real(kind=ikind) :: a=0.79 real(real64) :: b=0.79 real(kind=16) :: c=0.79 real(8) :: d=0.79 print *, a print *,...

Replacing character in the string

c++,string
I am trying to enter in the array two ` backqoutes. But it enters single quote. Could you please help me here ? Input: abc"cde"fgh"ijkl" Ouput: abc``cde''fgh``ijkl'' My code: #include <stdio.h> #include <iostream> #include <cstring> using namespace std; int main() { string mystr; long int i=0,j=0,l; while(getline (cin, mystr)) {...

How to call StyleSelector on PropertyChanges of a row

c#,.net,wpf,xaml,mvvm
I have RowStyleSelector with datagrid. It's called correctly on load of the window. On changes of rows when I call PropertyChange it's not called. <DataGrid Grid.Row="2" ColumnWidth="*" ItemsSource="{Binding TraceItemCollectionViewSource , Mode=TwoWay , UpdateSourceTrigger=PropertyChanged}" EnableRowVirtualization="false" RowStyleSelector="{StaticResource TraceRowStyleSelector}" IsReadOnly="True" Name="TraceDataGrid" Margin="5,5,5,5" Padding="5,5,5,5" AutoGenerateColumns="False"> This is my model: public class TraceDataItem :...

add value to each element in array python

python,python-2.7,numpy
I have an array like this a= np.arange(4).reshape(2,2) array([[0, 1],[2, 3]]) I want to add a value to each element in the array. I want my result return 4 array like array([[1, 1],[2, 3]]) array([[0, 2],[2, 3]]) array([[0, 1],[3, 3]]) array([[0, 1],[2, 4]]) ...

IPv6 address representation in Python

python,ipv6
I was converting IPv6 addresses to the textual representation and noticed a behavior I could not explain: In[38]: socket.inet_ntop(socket.AF_INET6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x7f\x00\x00\x01') Out[38]: '::ffff:127.0.0.1' In[39]: socket.inet_ntop(socket.AF_INET6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x7f\x00\x00\x00') Out[39]: '::ff:ffff:7f00:0' I am surprised to see ::ffff:127.0.0.1, I'd expect it to be ::ffff:7f00:0. Is it standard or at least common? Which IPv6 addresses are...

How to use charAt() and length() to write a whether is substring method

java,string
I want to write a boolean method subString() to judge if string s1 is the substring of s2. The requirement is only to use charAt() and length() methods of String. E.g. Substring("abc","abcd")-> true Substring("at","cat")->true Substring("ac","abcd")->false indexOf() cannot be used. Here is what I got so far. public class Q3 {...

Reading multiple parts of XML

c#,xml
I'm building a Windows app using a XML file with a lot of nesting in it - like this. I need to access an attribute as I go down the nodes. I need to keep doing this for every "route" object available (Which may have multiple destinations and trips). So...

Java - duplicate case label

java,intellij-idea,switch-statement
I found some time ago a function to replace polish characters in text with "normal" version of this character. I used this in some projects earlier without problems, but now, when i just copied it, this doesn't want to work. But when I try to compile old projects in the...

How to sort the cards in each hand from the card values first and then the suits in C?

c,sorting
I want to sort the 5 cards from each hand, by sorting by the card value first (from Ace to King) and then the card suit (from Hearts, then Diamonds, then Clubs and lastly Spades), but it doesn't work. How would you be able to do it successfully? code: #include...

Does Python copy references to objects when slicing a list?

python,list,memory,copy,slice
When a list is sliced, are the references to its contents copied from the original list? I can imagine that this may not be necessary, but I read the opposite (mentioned in passing). This question matters for instance for the following idiom, in the case of a very long my_list:...

Yii2 - mailer - send message to email rows in database

arrays,string,yii2,send,mailer
Greetings, i need to send email to several recipients that are stored in a table named mail which has a field called email. In my controller i created an action that Query the table mail for the emails. Later i tried to use the implode() function separated by comma, but...

Trying to calculate the average in an ArrayList

java,arraylist
I'm trying to write some code which takes in any number of entries and stores it in an ArrayList given a specific condition. What I'm not able to do is find the average of the values stored in the ArrayList. Here's the code written so far: import java.util.ArrayList; import java.util.Scanner;...

Memory error in set resize

c,memory-management
Here's a structure of set that I've written: struct state_set { struct state ***state_array; size_t *slot_sizes; size_t *slot_memory; }; Here's an initializer: struct state_set *state_set_init() { struct state_set *new_set = malloc(sizeof(struct state_set)); new_set->state_array = malloc(ARRAY_SIZE * sizeof(struct state**)); new_set->slot_sizes = malloc(ARRAY_SIZE * sizeof(size_t)); new_set->slot_memory = malloc(ARRAY_SIZE * sizeof(size_t)); for (int...

Using Braintree and Stripe in Android app

android,stripe-payments,braintree
I have developped an Android app and the only thing left is to implement a payment solution to sell goods. I have been searching for a while and found Stripe and Braintree. It seems that they are pretty much the same in many aspects. However, I was wondering which one...

Connecting Python Backend to Android APP

python,xamarin
How to use python as a backend for an Android App that is built using C#? The Python Backend is written using the Flask framework. The Android app is built using xamarin.

Converting multiple strings into JSON arrays

php,json
I have multiple strings that looks like the following: 11-16, 16-12, 14-16 I will have multiple of these, and I need to store them in JSON. I need to store it in the following format: [ { "score_1": 11, "score_2": 16 }, { "score_1": 16, "score_2": 12 }, { "score_1":...

PayPal Developer Account & API ..what happens if account is limited?

api,paypal
I have a hypothetical question about my PayPal developer account. Since the app I developed uses an API Username (myname-facilitator_api1.mydomain.com), API Password and API Signature to do the transactions, I am wondering what happens with the API access if my PayPal account for whatever reason becomes limited? I've had my...

winforms, form has been shown, event handler [closed]

c#,winforms,events
I need to run certain code each time after form has been shown by from.Show(). I tried form_Activated(), form_Loaded(), form.Shown() ... nothing works how I want, it only runs once, the first time. Is there a simple way how to do that? Thank you.

How to pass attrs to forms.DateField?

django,django-forms
In forms.py I have this: date_of_birth = forms.DateField(widget=extras.SelectDateWidget( years=range(datetime.date.today().year - 15, 1920, -1))) to create a select. I want to pass to it, attrs={'class': 'form-control'} I tried in different ways but with no results....

How to sum duplicated values in SQL [on hold]

mysql,data-extraction
The sum of the acquisition price of works of art for each year (for example, if there were two works of art purchased for $1500 and $1000 in 2007, and one work of art purchased for $500 in 2008, then the sums would be $2500 and $500, for 2007 and...

mysql PHP PDO executing 2 queries on a single POST request

php,mysql,pdo
I'm using a standard apache2 LAMP configuration with mysql and php5, only thing I changed is my character encoding onto UTF8. I'm making an AJAX call upon clicking an anchor (the article title), and want to run 2 queries. One gets the article, and the other the comments related to...

How to find the relative path between two directories?

python
I would like to find the relative path between two directories on my system. Example: If I have pathA == <pathA> and pathB == <pathA>/dir1/dir2, the relative path between them will be dir1/dir2. How could I find it in python? Is there a tool I could use? If pathB is...

Initialise thread pool

c,multithreading,pthreads
As part of a HW assignment, I'm about to implement a thread pool in ANSI C using pthreads. I'm having difficulty understanding how to initialise my thread pool. I think the idea is to initialise the pool with thread which sleeps until they get a job to do, however I'm...

Is there any way around saving models that reference each other twice?

django,django-models
My issue is when saving new models that need to reference each other, not just using a related_name lookup, such as this: class Many: owner = models.ForeignKey('One') class One: current = models.OneToOneField('Many') By default, these have null=False and, please correct me if I'm wrong, using these are impossible until I...

VB.Net add count for each

vb.net
I have a function that search for the count of multiple words in a text file. Dim textlog = File.ReadAllText("D:\1.txt") Dim count = Regex.Matches(textlog, "test1").Count Dim count1 = Regex.Matches(textlog, "test2").Count Label1.Text = (count) Label4.Text = (count1) It's working fine, but I want to pass the words as parameter to the...

How can I return the array object from Array's prototype function?

javascript,arrays,inheritance,prototype,chaining
I have a programming exercise to create two prototypes of Array, they are both functions. I have put my code below. One will be called on the other as shown in the last line. I am trying to get the second function to modify the value that would have been...

Android BufferedReader does not read the whole response

java,android,url,bufferedreader
I have a problem with reading a ULR response. On Android it only reads around the half of the response. If I use the same code in a normal Java project everything works fine. try { String _output = null; URL url = new URL("http://example.com"); BufferedReader buffer = new BufferedReader(new...

Extract numbers from a string in java

java,regex,string,numbers
I want to extract numbers from a string like: str="good_mor9ni13ng_23guys "; The output should be an array [9,13,23]. How should I proceed?...

Android- Logic behind setOnClickListener

java,android,onclicklistener
I am new to Java/Android programming and unfortunately I don't fully under stand the logic behind this piece of code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click } }); I have alredy read a whole lot of tutorials about it but unfortunately in no...

PopupWindow overlaps soft buttons on Android 5.0

android
I have a simple PopupWindow that I create with the following code (the code is in C#, the Java code should be basically the same) View popupView = LayoutInflater.From(this.Activity).Inflate(Resource.Layout.LectionFooter, null); var popup = new PopupWindow(popupView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, false) { OutsideTouchable = true, AnimationStyle = Resource.Style.FooterAnimation }; popup.SetBackgroundDrawable(new BitmapDrawable()); popup.ShowAtLocation(rootView, GravityFlags.Bottom,...

Converting a Distance string into a Number

javascript,parsing
When using the Google API for calculating the distance between two location, it returns me the distance in string format. For example: 1,585 KM, 54 KM etc. I want it to be converted to a number. What is the best way to convert a string like 1,525 KM into a...

add files to List(String) in certain order

vb.net
I added a list of files in a directory to List(Of String)(). I need help in putting these files in a certain order. For example if I have files 1, 2, 3,4 in the list, how can I put the files in let say 4,2,1,3 order? Dim aryFi As FileInfo()...

Symfony2 FosUserBundle is loosing session

php,symfony2,fosuserbundle
I am using FosUserBundle to register and authenticate users in my website. But i am having troubles with it cause user session is loosen very soon. Sometimes 5 minutes, sometimes 10 minutes, and then user is redirected to the login form again, causing many users to left my website. This...

Generating a dice game - C Programming

c,dice
I'm following a tutorial on youtube and was doing a dice generator. It basically print out 3 dice result and sum out the dice result. After which, the user will look at the sum, and based on the sum, the user going to guess whether the next roll is going...

Can't create QList with custom class

c++,qt,qlist
I'm trying to create QList of custom class objects, but I got error: error: C2923: 'QList' : 'Read' is not a valid template type argument for parameter 'T' My code (User header): #ifndef USER_H #define USER_H #include <QString> #include <QList> #include "read.h" class User { protected: int id; QString username;...

how to calculate a 2D array with numpy mask

python,arrays,numpy
I have a 2 dimension array and based if the value is greater than 0 I want to do a operation (example with x+1). In plain python something like this: a = [[2,5], [4,0], [0,2]] for x in range(3): for y in range(2): if a[x][y] > 0: a[x][y] = a[x][y]...

Pattern which take input in just positive integer

javascript,html
I want to take input in just positive integer at front end. i also make pattern but it takes input also negative integers but i don't want negative integer in input. kindly help me. echo "<input type=number pattern=[0-9] value='" . $counter_row['counter_balance'] . "' name=new_cash class=input_panel>"; ...

Matlab: How can I store the output of “fitcecoc” in a database

matlab,machine-learning,computer-vision,classification,matlab-cvst
In Matlab help section, there's a very helpful example to solve classification problems under "Digit Classification Using HOG Features". You can easily execute the full script by clikcing on 'Open this example'. However, I'm wondering if there's a way to store the output of "fitcecoc" in a database so you...

766 versus 666 Permissions on an Upload Directory [closed]

php,upload,permissions
Is 766 permissions okay for a directory where my website users can upload images to? I using 766 because when I set the directory to 666, the script returns an error and the file is not uploaded. Please is there any explanation for this? Thanks...

Playframework 2.4 Singletons, Object

playframework-2.4
Before Playframework 2.4 I used create object for singleton class, and now I see than Singletons can be achieved using the @Singleton annotation. But, what is the difference? Is only for using a dependency injection with @Inject() ? I am afraid that Playframework 2.4 with dependency Injection enter in an...

Join Array elements

asp.net,arrays,vb.net
i want to join array elements into string.. i have this code Dim qry(3) As String Dim text As String If (TextBox1.Text <> String.Empty) Then qry(0) = "f_name = '" + TextBox1.Text + "'" End If If (TextBox2.Text <> String.Empty) Then qry(1) = "m_name = '" + TextBox2.Text + "'"...

how to ssh run a tail and then send data to a mysql database

linux,bash,unix,ubuntu,ssh
This code SSH's and then runs a tail command on a remote hots. I would now like to pass that tailed data into a mysql database using a local script called insertPerfmon.sh. How do I pass data generated in a ssh session into the local shell script insertPerfmon.sh. The local...

how to get the key based on value in json using jquery

jquery,json
how to get the key based on value. of i pass value as 'A' i should get the key 'Attributes' { "Employees": { "Attributes": [ "A", "V", "C", "ZZ", "D", "E", "F", "G", "H", "I", "J" ], "Both": [ "XXX", "YYY" ] } } ...

Display multiple rows in html

php,mysql,mysqli,row
I am having an issue with pulling info from the database and displaying it on the page. In the table I have multiple entries in each column. So I need to pull that info and display it in a descending order from the column id. But with this it displays...

How do I associate an Activerecord Object with Em-Websocket connection?

ruby,activerecord,sinatra,em-websocket
I am new to ruby. I am trying to implement a chat client using em-websocket. I have the following code: EventMachine::WebSocket.start(host: '0.0.0.0', port: 8080) do |websock| websock.onopen do puts 'New Connection Opened' cookies = CGI::Cookie::parse( websock.request["cookie"]) person = Person.where(['token = ?', cookies["token"]]).first unless person websock.close(code = nil, body = {Error:...

How does an unpublished extension get weekly users?

google-chrome-extension,chrome-web-store
This is weird. I have an extension that is not available through the webstore because it's marked as private and is still pending review. However, I see the weekly users count increasing. When the counter was at 1, I thought it was somehow tracking my own usage of the locally...

OCaml error in basic loop

ocaml
I'm new with OCaml. I'm making a function working this way : I have "tab" in the scope which represents a 2D map, and three parameters, x, y and u. x and y represent the position of the player, and u the direction of the bomb (right, top left etc.)....

get name from another table while using sub query

sql-server,sql-server-2008
i have a query like this: select F_ExhibitionCode, F_ExhibitorCode from T_ExhibitorLocation where F_ExhibitorCode in ( select F_Exhibitor_Code from T_Exhibitor where F_Exhibitor_Name LIKE '%''%') i have two more tables , one is *T_Exhibition* and another one is "T_Exhibitor, F_exhibiton name is coming form T_Exhibition and F_ExhibitorCode is coming from the T_Exhibitor...

How do I use zoom with a MonadState constraint of a newtype?

haskell,monad-transformers
I have two functions, one with a MonadState constraint of the wrapped type, the other has a MonadState constraint of the unwrapped type. I'd like to seamlessly run the second function within the first. For example: import qualified Control.Monad.State.Strict as MTL import Data.Monoid (Sum) import Control.Lens.Zoom (zoom) import Control.Lens.Wrapped (_Wrapped')...

How to handle user input type in java?

java
If the allowed input in my program is only of type int but they user arbitrarily types in a not-allowed type character such as double or char etc. How do i handle that? I am sure there is so sort of Throw exception sort of thing but i am just...

Fragment's onCreate and onCreateView are not called

android,android-fragments
I'm building an application which receive an action.SEND Intent and display all files in clip data into a ListView. My ListView is inside a ShareFragment which hosted by my MainActiviy. Below is how i implement it. public class ShareFragment extends MFragment { private static final String TAG = "ShareFragment"; private...

datetimepicker. widget doesn't show

javascript,jquery,twitter-bootstrap,datetimepicker
I am trying to repeat example from datepicker documenation on jsfiddle tutorial I have wrote the following html code: <div class="container"> <div class="row"> <div class='col-sm-6'> <div class="form-group"> <div class='input-group date' id='datetimepicker1'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> </div> </div> and following js: $(function...

Delphi - extract string between tags (duplicate tags)

delphi
I'm trying to write a function to extract a string between two tags. The problem is that the first tag is a duplicate in that string with an unknown count e.g. Str := 'Delphi App Hello Hello SomeText here Hello Hello Hello This is a Test!'; What i want exactly...

Search multiple fields in two data Frames in R

r
I have two data frames:DFA and DFB. Data Table: DFA DFB Fields: name job check name job alice analist alice attendant bob attendant carl professor carl professor bob analist daril analist daril analist If two fields are the same in both data tables a third field in DFA should receive...

Large excel data sorting VBA help or function?

excel,vba,excel-vba
I have about 1000 records in an excel spreadsheet in two columns Column 1: - Row 1- Name: - Row 2- Company: - Row 3- Tel. No: - Row 4- Email: - Row 5- Web-address: - Row 6- Name: - Row 7- Company: - Row 8- Tel.No: etc Column 2...

Send data obtained from facebook with form

javascript,php,jquery,html
I am trying to send data to a PHP page from a HTML page. Data is acquired from a JavaScript variable. Scenario: I am trying to create a Facebook login page. I acquired data from a FB script and want to send a name to another PHP page. Here is...

How can I remove delta-homes.com from browsers?

search,registry,malware
whenever I open my browsers, delta-homes.com tab is added to the browser. I try to remove delta-homes.com in all of my browsers(IE,FF,chrome,Opera) by registry in run > regedit, about:config in firefox, changing home page and search engine defaults and reset Internet Explorer(and reinstall it from "Turn Windows features on or...

Is it possible to run Xcode 6.3 on El Capitan?

xcode,swift,osx-elcapitan
I'd really like to try El Capitan but I don't know if it is possible to run old Xcode on it, because it is critical for me now. Has anyone tried it?

Grails: Carry forward params on hyperlink is clicked

grails,redirect,controller
How to carry forward the parameters when hyperlink is clicked? Here is my gsp code: <g:link class="grid_link" controller="user" action="delete" id="${userInstance.id}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure, want to delete?')}');">Delete</g:link> Here is my controller code: def delete() { try { def userInstance = User.get(params.id) //deleting the user //successful. redirect(action: "list",...

FullCalendar event directing to wrong url

javascript,php,mysql,url,fullcalendar
So I have set up FullCalendar to my site. I used this tutorial. Everything works fine except the urls I add to events on my calendar. So when I've added a URL to an event it should direct me to that url when I press on the event. For example,...

MVVM - Validating the model when a field in the viewmodel is changed

c#,wpf,validation,mvvm,ef-database-first
I'm using the MVVMLight libraries with a Database-First EF model. I can't quite figure out how to validate the model when a certain field in my viewmodel has changed. This works fine when I'm updating individual Properties of the model as I have a call to Validate in the set...

multiple random images in let it snow plug-in

javascript,image,random
i've been playing with jason brown's let it snow plug-in. his code only accommodates for a single custom image, and i've been trying to figure out how to change the code so it accommodates multiple custom images within a random range. !function($){ var defaults = { speed: 0, interaction: true,...

combine all vectores into dataframe which starts with specific name in R

r
I have different numeric vectors with the same length and I want to combine those with specific name into dataframe; lets say: I want to combine vectors which starts with "pred" prednn=c(1,2,3,4,5) prednb=c(2,6,4,7,8) nope=c(5,7,5,1,1) predsv=c(55,11,22,33,44) result: dfpred: prednn prednb predsv 1 2 55 2 6 11 3 4 22 4...

How to find top usage of IP pairs in PostgreSQL?

sql,postgresql,select,sum
I have a table with source_ip and destination_ip and usage. now i want to find top usage for ip pairs. My table is like this: source_ip | destination_ip | usage 192.168.1.1 | 192.168.1.2 | 20 192.168.1.2 | 192.168.1.1 | 30 192.168.1.3 | 192.168.1.2 | 20 192.168.1.2 | 192.168.1.3 | 20...

Change layout of EditText on state “selected”

android,android-layout,android-edittext,drawable,android-drawable
I am trying to obtain a EditText changing it's colors and layout when the user clicks on it to type something, and I do that with a custom drawable, but the attributes android:state_enabled="true" android:state_focused="true"> don't work at all, meaning that they don't get called. EditText: <EditText android:id="@+id/field_user_info" android:hint="Nome e Cognome"...

Determine if coordinate is inside region (MKMapView, solve in PHP)

php,mkmapview,latitude-longitude,coordinate-systems
I'm using MKMapView and I send my php program the visible region (center lat, center lon, span lat, span lon). I need to determine if a coordinate is inside that region using php. I'm hoping there's a standard formula somewhere, but I haven't found one. I'll keep trying to come...

Using dom-if for conditionals in arrays

polymer,polymer-1.0
In 0.5 I could use the expressions in the dom-if to select for certain things in arrays while looping through them. How could I achieve the same effect in 1.0?

Detecting individual images in an array of images

algorithm,image-processing
I'm building a photographic film scanner. The electronic hardware is done now I have to finish the mechanical advance mechanism then I'm almost done. I'm using a line scan sensor so it's one pixel width by 2000 height. The data stream I will be sending to the PC over USB...

Object's container field is empty after move and erase

c++,vector,move-semantics,erase
I have two vectors and I want to move an object from one to the other, before I move it I make a pointer to the object. But when I erase the index in first vector then the container within the object is empty if I access it through the...

Elastic4s - how to express “matched_fields”

elastic4s
I want to implement the following query in Elastic4s. Don't see any way to implement the matched_fields clause in the highlighter. Any help? { "query": { "multi_match": { "type": "most_fields", "query": "hello world", "fields": [ "text", "text.human" ] } }, "highlight": { "order": "score", "fields": { "text": { "matched_fields": [...

Get values of given coordinates in Matlab

matlab
If I have the given coordinates [1 2; 4 5] and s = [ 0.0 0.4 0.5 0.6 0.9 0.4 0.0 0.3 0.4 0.5 0.5 0.3 0.0 0.5 0.8 0.6 0.4 0.5 0.0 0.6 0.9 0.5 0.8 0.6 0.0 ] I want the following results: A should contain the values...

R: Multible line in a plot using curveid

r,plot
I'm researcher and not a programmer. I have often used the drc package, to analyze data. There you can define a curveid and it will plot multiple lines in one plot. I need the same thing just for the normal plot, but obviously is my knowledge to little to do...

PHP login, is it secure?

php
I was hoping someone could take a look at my first PHP login script and give me some constructive criticism on what I may of done wrong and if it is actually secure. Thank you. I wasn't sure if I had used the password rehash correctly. if (isset($_POST['submit'], $_POST['username'], $_POST['password']))...

GitHub API returned Url meaning

git,api,url,github,github-api
Take this very simple API as example, https://api.github.com/users/zhuhuihuihui In the JSON formatted response, you'll find something like following, "following_url":"https://api.github.com/users/zhuhuihuihui/following{/other_user}", "gists_url": "https://api.github.com/users/zhuhuihuihui/gists{/gist_id}", "starred_url": "https://api.github.com/users/zhuhuihuihui/starred{/owner}{/repo}", Ok, I know like the following_url, starred_url is something like a sub API which you can call to fetch who that user are following, or what repos...

Program in Python [duplicate]

python,apache-pig
This question already has an answer here: python pig latin converter 2 answers this is the code I have to make a pig-latin translator and I can't seem to get it to translate, anyone have tips to make this work? I think that my issue is within the encode...

How are Strings created and stored in Java?

java,string,memory-management,immutability,hashcode
To understand how String objects are created and stored, I tried the following program and I see output against which I have query. Can somebody please help? package corejava.immutable; public class StringTester { public static void main(String[] args) { // TODO Auto-generated method stub String s1 = "Omkar Patkar"; String...

dict.fromkeys return dictionary in reverse order from a list [duplicate]

python,dictionary
This question already has an answer here: How can I sort a dictionary by key? 12 answers I am adding all the items of a list to a dictionary as keys equal to none. template_vars = headers[1:] kwargs = dict.fromkeys(template_vars) When I print the values of both variables in...

How to store result of type char in pointer?

c,pointers
I want to store result of type char in pointer which I'm passing as argument of function. Like this: #include<stdio.h> void try(char *); int main() { char *result; try(result); printf("%s",result); return 0; } void try(char *result) { result="try this"; } But I'm getting result : (null) Could someone tell me...

When I iterate data from an array using for loop I get only the last string and the above strings are overlapped

objective-c
Name *myName = [[Name alloc] init]; for (int i = 0; i<[nameArray count]; i++) { myName.name = [nameArray objectAtIndex:i]; NSLog(@"Name: %@", myName.name); self.lblName.text = myName.name; } where, Name is NSObject Class. nameArray is a variable where I stored array objects. self.lblName is the outlet connected on view controller. Question is...

php header forwarding issue using Ajax

php,jquery,ajax
Form:- <form name="form"> <div class="formfieldContainer"> <label> Email :</label> <div class="login_wrapper loginContainer"> <span> </span> <input type="email" id="email" required name="user_email" autofocus="autofocus" placeholder="Enter Email Address"/> </div> </div> <div class="formfieldContainer"> <label> Password :</label> <input type="password" name="user_password" placeholder="Enter Password"/> </div> <input type="button" name=...

shared printer error in windows 8 “can’t install the kernel-mode print driver. ”

windows,printing,shared,network-printers,kernel-mode
All other windows 8 pcs can use shared printer via another desktop and its a hp printer. Except one windows 8.1 pc. kernel-mode print driver issue All computers are in a workgroup and withing the same network range.. I can access the printer shared desktop using given credentials and I...

How can I populate comboboxes from arrays?

c#,arrays,wpf,combobox,split
I a text file with names and phone numbers. My lecturer gave me a piece of code to split this into two arrays. Now I'm having trouble populating the name and phone number comboboxes with these arrays. All I get is errors saying array1 and array2 don't exist in the...

JS: Is it possible “something(arg)” and “something.my_method(arg)” at same time

javascript,function,oop,methods
I know how create just a function something(arg) something = function(arg) { console.log('Function result', arg); } I know how create an object with function something.my_method(arg) something = { my_method: function(arg) { console.log('Method result', arg); } } Is it possible to write code, wher both something(arg) and something.my_method(arg) are exists? Like...

flask-security login via username and not email

python,flask,flask-security
I wanted to have the field in User model that through it the user logs in as username instead of email I defined: app.config['SECURITY_USER_IDENTITY_ATTRIBUTES'] = 'username' But I'm still getting: user_datastore.add_role_to_user(name, 'mgmt') File "/Users/boazin/sentinal/sentinel-cloud/.env/lib/python2.7/site-packages/flask_security/datastore.py", line 105, in add_role_to_user user, role = self._prepare_role_modify_args(user, role) File "/Users/boazin/sentinal/sentinel-cloud/.env/lib/python2.7/site-packages/flask_security/datastore.py",...

jQuery FadeOut FadeIn

jquery,fadein,fadeout
I am messing with html, css and jquery, and I've run in this problem. I have a slideshow that gets images using fadeIn and fadeOut from a container, but when I press 'next', it's resetting the page and loads the next image somewhere at the bottom. Can you tell me...

Return to the same view when no image is selected

asp.net-mvc-4,razor,json.net,entity-framework-5,c#-5.0
I have an upload control. But if the user didnt select an image and the press on the upload button, the user will get an message that he/she has to go back and try again, like this: if (isSavedSuccessfully) { return Redirect(Url.Action("Edit", "Account") + "#tabs-2"); } else { return Json(new...

Jquery Time Picker inside ng-repeat is not working

jquery,angularjs,angularjs-directive,angularjs-ng-repeat,datetimepicker
As i am proceeding into my project. In Some place i need to repeat few input fields which contains two time html5 field. Everything was going well when i was testing in Chrome but when i tested in in firefox it is showing as text field. (Firefox does not support...

Om/Clojurescript: Issue rendering a reset application state

clojurescript,om
I am trying to display a component with om, as soon as the data needed for this widget arrives. I came up with the following (roughly): (def data (atom {})) (go (let [response (<! (http/get "../rest/ds" ))] (reset! data (:result (:body response))))) (om/root (fn [app owner] (reify om/IInitState (init-state [_]...

Refresh progress bar

c#,wpf,multithreading,progress-bar
I want to refresh a progess bar in C# WPF. This question sounds very easy and i should be able to google it. But the solutions I have seen unsatisfy me. Assuming that i have to run a very long algorithm with e.g. 5 different steps. I don't know exactly...

Postgres 9.4 jsonb array as table

sql,json,postgresql,indexing,jsonb
I have a json array with around 1000 elements of the structure "oid: aaa, instance:bbb, value:ccc". {"_id": 37637070 , "data": [{"oid": "11.5.15.1.4", "value": "1", "instance": "1.1.4"} , {"oid": "11.5.15.1.9", "value": "17", "instance": "1.1.4"} , {"oid": "12.5.15.1.5", "value": "0.0.0.0", "instance": "0"}]} oid and instance are unique per json array. If I...