FAQ Database Discussion Community


iOS swift - how to draw an ellipse with touch event

ios,swift,drawing,ellipse
currently I am trying to port my old windows phone app to iphone. The UI looks like this: I want to know how to do the following: Draw a solid ellipse on a specific position, e.g. at position x = 0, y = 0; The ellipse change its color upon...

Can't format datetime in carbon

laravel,php-carbon
When I try to format my $date to d/m/Y it's work fine $date = '20/4/2015'; Carbon::createFromFormat('d/m/Y', $date) But when I try to format my $date to d/M/Y $date = '20/4/2015'; Carbon::createFromFormat('d/M/Y', $date) I got an error like the following, The separation symbol could not be found Trailing data What does...

Deleting row in table with Jquery in mvc project

jquery,asp.net-mvc
I generate the following html code <table> @for (int i = 0; i < Model.listUsers.Count; i++) { <tr> <td> @Html.DisplayFor(m => m.listUsers[i].Name)</td> <td> @Html.DisplayFor(m => m.listUsers[i].Phone) </td> <td> <button type="button" id="delete" data-id="@Model.listUsers[i].ID">Delete</button> </td> </tr> } </table> I want to delete a row, <script> $(document).ready(function () { $("#delete").on("click", function () {...

Update data in mysql with html form inside jquery dialog

javascript,php,jquery,html,mysql
I need a help in making a page where you can see data from a mysql query. Every row is echoed as a div with a unique id. <div class="columm" id="<?php echo $row['id']; ?>"> It has the same id as the data in the mysql database. Every div contains an...

Escape characters in bash

bash
I have a line in my script here: "echo 'CONF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"' >> /home/$USER/tachyon-0.5.0/conf/tachyon-env.sh" The portion CONF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" has to be written as it is onto the tachyon-env.sh file. I have tried many combinations of escape characters,...

JDBC implementation: error with regard to parameters

java,sql-server,stored-procedures,jdbc,inner-join
I am working on creating a JDBC program that will show a list of grades that a selected student has in their respective classes. However, I keep getting the error "Procedure or function 'getStudentHistory' expects parameter '@studentId', which was not supplied." Here is my stored procedure in SQL Server: CREATE...

Declaring variable and assignment [closed]

java,class,variable-assignment,variable-declaration
I was just practicing java program in eclispe following is the code: import java.util.*; class Problem7 { public static void main(String args[]){ int num,sum=0,mod_num,count;//Syntax error on token ";", { expected after //this token. Ques=Why? System.out.println("Enter a 5 digit number"); try(Scanner n1 = new Scanner(System.in)) { num = n1.nextInt(); } for(count...

Activity with fragment who can take two differents fragments and rotation of device

java,android,android-fragments,android-activity,fragment
I'm almost new about android, java, ... and new about fragment. I have an activity (A) that shows a list using fragment (B). Selecting an item of this list, the same fragment is changed to show another lis using fragment (C). It works except when i rotate the device while...

Changing the visibility of views one at a time with a button

java,android,android-view,android-button,android-looper
I have three views which visibility is currently set to view.setVisibility(view.GONE) and I have a button which I want to change the visibilities to visible one at a time as the user keeps clicking the button. I think I have to use a for loop centred on the button click...

Simple web SPA with API and MONGOOSE (issue with id's)

javascript,html,angularjs,express,mongoose
I am creating a very simple AnjularJS SPA connecting to Mongoose via API. The app will just take in a new member, display the new member and if I click on the members name in the list I should be able to edit the member in another screen. But when...

delete a comment in a post with FOREIGN KEY

mysql,sql
I have a post and comment structure, and I change it adding a foreign key: posts: CREATE TABLE IF NOT EXISTS `posts` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `user` varchar(40) NOT NULL, `text` varchar(500) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; post's comments: CREATE TABLE...

Behavior of entrySet().removeIf in ConcurrentHashMap

java,multithreading,java.util.concurrent,concurrenthashmap,concurrentmodification
I would like to use ConcurrentHashMap to let one thread delete some items from the map periodically and other threads to put and get items from the map at the same time. I'm using map.entrySet().removeIf(lambda) in the removing thread. I'm wondering what assumptions I can make about its behavior. I...

Sort java map by value (which contains a set)

java,sorting,dictionary
I have a map which looks like Map<Word, Set<Word>> tupleMap = new HashMap<Word, Set<Word>>(); The Word class is nothing special, it contains a few Strings like value and so on. I am trying to sort this map by the number of elements of the associated set. So the Word which...

Python one exception multiple handlers

python,exception,coding-style,programming-paradigms
I want to do this: try: raise A() except A: print 'A' except (A, B): print 'A,B' Which I hoped would print both A and A,B. That doesn't work (only the first except is executed). It makes sense for the first except to swallow the error, in case you want...

Form writing to mysql database

php,html,database,mysqli
I'm currently working on writing a form to a database, still a beginner. I attempted a form that i will show below but it seems to give me errors. If anyone could help me find out what is wrong with my PHP code then it would be great. Thanks in...

Provide link to open in different browser

html,ios,facebook
I have a webapp which is running perfectly well in most browsers, but I'm still trying to work out a few bugs which is preventing it from working correctly in iOS Facebook's in-app browser. Until I've got these sorted, I'd like to provide a message to give users the option...

C++ Field holding objects with different template arguments

c++,templates
I have the following setup: // N is the number of rooms template <size_t N> class House { void printNumberOfRooms(); } House<1> house1; House<2> house2; Now I want to have a field that can hold both house1 and house2 and on which I can call house.printNumberOfRooms(). House house; house.printNumberOfRooms(); Gave...

Multiple Data Binding Objects in Eclipse Jface MVC

java,model-view-controller,jface
I'm facint some problems regarding a jFace TableViewer and its bindings. I'm using the following example code for the TableViewer: public class AppPersonViewer extends TableViewer { public Table table; public AppPersonViewer(Composite parent, int style) { super(parent, style); table = getTable(); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); table.setLayoutData(gridData); createColumns();...

Why and when to use optional perl parameters in R

regex,r,perl
Out of curiosity, I have a general question about the optional perl parameter in R funtions like grep. As the title says in the title, i'd like to know why and when one should use this option. Is it a general thing to do if possible? In addition to that...

Does Picasso library save image to the cache?

android,image,picasso
I work on an android application, and I would like to clarify, does Picasso library save the processing image to the cache? If it does not, how can I force Picasso to save the image to the cache?...

Split code by semicolon

php,regex,explode
I would like to parse a source code. I read it line by line, but one line can contain more than one command. I wonder if it is possible to split line by semicolons, but only by those, which aren't in a '...' or "..." blocks....

Animating a circle border to fill up [closed]

javascript,jquery
How would you go about animating (and creating) the circles as shown in the image with javascript? I'm not sure what to call this, so I just said "border"....

PHP read a large file line by line and string replace

php,string,replace,large-files
I'd like to read a large file line by line, perform string replacement and save changes into the file, IOW rewriting 1 line at a time. Is there any simple solution in PHP/ Unix? The easiest way that came on my mind would be to write the lines into a...

How to go to the merge menu if I already close it once in intellij idea?

git,intellij-idea,merge
I use idea git integration to use git. I merged my brabch into develop branch and I saw a lot of conflicts. I cloased the merge window and Now I see following file content: <<<<<<< HEAD //For unregistered users with unfilled email if (userService.findUserByEmail(newEmail) != null) { return new ResponseEntity<>(...

Very large table JOIN with GROUP BY

mysql,sql,join,group-by,query-performance
I need to combine information from a 27 millions lines table with a 7 millions lines table and do some filtering. CREATE TABLE event_participation ( place_id int(4), person_id varchar(12), event_id varchar(10), event_description varchar(230), .... and more fields about that specific participation ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE INDEX IDX_1 ON event_participation...

How to display database in php in order to show it in android app

php,android,mysql
I have a problem displaying a mysql database running in XAMPP server, I typed a code which connect perfectly but it doesn't show anything in the php page which didn't let me retrive the data to android app. Here's my sql query: CREATE TABLE `products` ( `id` VARCHAR ( 32...

border-radius not working with border-image output

html,css,html5,css3,keyframe
I'm creating a CSS3 loading icon effect instead of using GIF. I have created the loading icon effect but I'm unable to make it circle. It is revolving in square instead of circle. Border-radius not working with border-image property ? HTML <div id="progress"> <span class="spinner-icon"></span> </div> CSS #progress { pointer-events:...

Setting width of SeekBar to make “swipe to unlock” effect

java,android,xml,swipe,android-seekbar
I am attempting to make a swipe to unlock feature using a SeekBar. The look I am aiming for is shown here: This is composed of two images, a background, and a button. I put both the background and the SeekBar in a FrameLayout so that the SeekBar should sit...

Approach to finding the context free grammar of more complicated languages

context-free-grammar,pushdown-automaton,context-free-language
I'm having problems approaching the following problem. Give a context free grammar for the following language: {x#y | x,y in {0,1}* and |x| != |y|} What is the best way to approach this question? At the moment I'm just using intuition to solve questions like these but are there useful...

Python Error; UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026'

python,csv,encoding,utf-8
I am trying to extract some data from a JSON file which contains tweets and write it to a csv. The file contains all kinds of characters, I'm guessing this is why i get this error message: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' I guess I have to convert...

How to replace an image tag with an video tag in jsp

javascript,html,jsp
How do i replace an image tag with an video tag in JSP? I am trying to display an video after series of images on the same position as image with an time interval 1 sec. The JSP code is below: <%-- Document : index Created on : Apr 22,...

error printing Integer with strings

python,python-3.x
I am a beginner with python trying to write this but not working. Any help? CP=input("enter the cost price: ") SP=input("enter the sale price: ") if (SP>CP): print ("Congratulations !! you made a profit of ", + SP-CP) print("Congratulations!! you made a profit of %f" % SP-CP) elif (CP>SP): print("you...

How to hide the object of the OLE controler?

vb6,media-player,ole,visible
I'm working with the OLE object using VB6. I use it to play a sound when a certain condition is true. The OLE class is MPlayer. The problem is that I don't want the player to be visible. I know that I can set the Visible property of the OLE...

Intellij - Hide file paths from Favorites window

intellij-idea,phpstorm,pycharm,webstorm
I organized my project files in the Favourites window according to the programming language e.g. python, javascript etc. However, the path to each file takes a lot of space and requires you to horizontaly scroll the window. Is there a way to hide path from the Favourites, so only file...

Best way to find Users with certain associations

ruby-on-rails
Lets say I have a User model and each user has an association called user_logins which is created every time they login, storing information about their login. What I need to do is find all users that have 5 user_login records, where the fifth record was created today. Something like...

Prepare multi-databases with play framework

database,playframework
I want to prepare my application to be compatible with many databases types. To try it i've used H2, MySql and Postgresql. So 'ive added into build.sbt : "mysql" % "mysql-connector-java" % "5.1.35", "org.postgresql" % "postgresql" % "9.4-1201-jdbc41" and i've added conf/prod.conf with all configuration without database configuration, and 3...

Modifying records sourced in a joined query

access-vba,ms-access-2010
I cannot update records on a form which it's record source in a simple SQL select query (containing 2 joined tables linked to a combo box value). I have ensured that all the properties of each field and the form itself are set for editing but unfortunately when I go...

Change the icon for php files in directory

php
How can I change the file icon of my directory index? I want to change the icon of php files so whenever my directory is requested it should display my own icon. how can I do this?

Cloning a private Github repo as a collaborator when I have multiple accounts

git,github,git-clone,repositories,multiple-accounts
I have 2 GitHub accounts: account1 account2 In account2 I'm added as collaborator of a certain repo: account_notmine/repo_xyz I've created and added a new ssh key for the second account, and also added it on github. Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa Host github-new HostName github.com User git...

Tag lose its background after page reloads

javascript,jquery,html,css
i'm trying to assign a background to my elements with javascript, but the tags keep the background only during the page reloading, for then switching back to their normal background. Here is my code: Javascript: $(document).ready(function(){ $(".container_menu ul li a").click(function() { $(this).addClass("active").siblings().removeClass("active"); }); }); Css: .container_menu ul li a.active{ background-color:...

Count duplicates within observableArray and Display them

jquery,knockout.js
I have an observable array With the following Data ["Volkswagen", "Toyota", "Volkswagen", "Toyota", "Audi", "Volkswagen", "Toyota", "Audi"] I would like to know how I can count the duplicate values and display them within my select box. Something like: Volkswagen (3) Audi (2) Toyota (3) What is the best way to...

minimize the runtime or the performance time of a code

performance
I was wondering how i can minimize the runtime of the following code int j = 0; while (j < n) { int i = 0; while (i < m) { cout << i*j; i++; } j++; } ...

Datetime parser function keeps returning days on Tuesday

javascript
For some reason, my datetime parser keeps returning dates as Tuesday, any idea why? For Example: <div class="datetime">2015-06-04 16:00:00</div> <div class="datetime">2015-06-05 13:00:00</div> Output Tuesday 04 June - 16:00 Tuesday 05 June - 13:00 Code HTML <div class="datetime">2015-06-04 16:00:00</div> <div class="datetime">2015-06-05 13:00:00</div> JS $('.datetime').each(function () { var value = $(this).text().trim().split(' '),...

List of all artifacts from Nexus repository

rest,maven,nexus
Within my application I deploy generated artifacts to a certain (hosted) Nexus repository. From another instance of my application I want to know all artifacts that have been deployed to that repository. I studied the Nexus REST API but couldn't find a way to get that information. Does anybody know...

PHP: Using the ternary operator for something else than assignments – valid use case?

php,ternary-operator
Unfortunately I haven't found any official resource on this. Is it allowed to use the ternary operator like this, to shorten and if/else statement: (isset($someVar) ? $this->setMyVar('something') : $this->setMyVar('something else')); In the PHP documentation, the ternary operator is explained with this example: $action = (empty($_POST['action'])) ? 'standard' : $_POST['action']; This...

Angular-material md-select with images or svg

angularjs,svg,angular-material
I am using angular material, I want to use md-select but with images/svg; I am using md-option together with ng-repeat and the list of options works, but when I select something I see the text. Is it feasible? Thanks <md-select ng-model="mkt.bookmaker" placeholder="Select a bookmaker"> <md-option ng-value="opt" ng-repeat="opt in mkt.selected.matchInfo.bookmakers"> <md-icon...

python freezes with many repeated pandas calls

python,pandas,time-series,freeze
I'm trying to compute the variance of a time series for many sampling frequencies (the so called signature plot), I used the resample method looping on a set of frequencies but python stops before completing the task (no errors, just freezed). Here the code is var_list = [timeseries.resample(rule=str(int(freq))+'min',how='first').var() for i...

AngularJS Custom Filter orderBy sortPredicate not working

javascript,angularjs,sorting,angular-filters,angularjs-orderby
The problem is that I have an array of recipe objects. Each recipe object has some comments on it. I want to sort the array in angularJS controller using the $filter service provided by angular. $scope.recipes = $filter('orderBy')($scope.data, function(recipe) { return recipe.comments.length; }); But its not giving the required results....

How to detect if there is a leap second when using the tm struct?

c++,c++98
According to this struct tm documentation, the value tm_sec can be 0 - 61 and the extra range is to include leap seconds in some systems. How can I detect if there is a leap second in a system generally and in my openSUSE 13.2 machine specifically?

How to use log4j2 JMSAppender with ActiveMQ

java,jms,activemq,jndi,log4j2
I am struggling to write a simple POC program that logs messages to a Queue. All tutorials and Q&As I find (here and here) use log4j version 1.2 and they put messages onto a Topic and not onto a queue. My requirement is to log to a queue. I followed...

MySQL error - incorrect DOUBLE value: 'chests'

java,mysql,sql
I am trying to add a value to a specific user what is called chests when I execute this method: public void addAmm(Player player, int amount, DataType type) { try { Statement sql = mySql.getConnection().createStatement(); sql.executeUpdate("UPDATE `playerinfo` SET `chests`= '" + amount + "' + 'chests' WHERE Username='" + player.getName()...

How to pass variables from one PHP file to another using HTML links?

php,mysql,reference
//DB CONNECTION $sql = "SELECT `city`,`country` from infotab"; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { echo $row["city"].$row["country"]"<a href='order.php'>order</a>"; } Table output: This code will select data. Additionally, there is reference to order.php on every line. When the user clicks on reference( <a href> clause), it opens order.php and...

Why won't my program work in python?

python-2.7
Hi I am 11 yrs old and I am teaching myself how to code. I set myself a task to make a times table quiz that asks 10 questions and inputs random numbers. However, my code is not working and I do not know why. I am using python 2.7.5....

Kafka high-level consumer: Can partitions have multiple threads consuming it?

multithreading,apache-kafka,kafka-consumer-api
Can messages from a given partition ever be divided on multiple threads? Let's say that I have a single partition and a hundred processes with a hundred threads each - will the messages from my single partition be given to only one of those 10000 threads?

Splitting a line into token with find()

c++,split,find
I want to split this line : cmd1; cmd2; cmd3 Into 3 strings I will stock into a list. like cmd1 cmd2 cmd3 So I made this code : main.cpp #include <string> #include <iostream> #include <list> int main() { std::string line("cmd1; cmd2; cmd3"); std::list<std::string> l; size_t pos = 0; size_t...

Print Vector elements using Boost.Bind

c++,boost
I need to print the values inserted in the vector using Boost.Bind. Please find the code snippet below: Please let me know what I am missing here? class Test { int i; public: Test() {} Test(int _i) { i = _i; } void print() { cout << i << ",";...

Empty return value from swift function containing closure

ios,xcode,swift
I created a function that should return a dictionary filled with data that are retrieved (using json, based on Ray Wenderlich tut) online. That code is in a closure. The problem is that an empty dictionary is returned first, and only afterwards it gets filled. Don't know if this is...

Handle large number of PUT requests to a rest api

asp.net,performance,asp.net-mvc-5,httpwebrequest
I have been trying to find a way to make this task more efficient. I am consuming a REST based web service and need to update information for over 2500 clients. I am using fiddler to watch the requests, and I'm also updating a table with an update time when...

Send stderr/stdout messages to function and trap exit signal

bash,shell,unix,stdout,stderr
Im working on error handling and logging in my bash script. Below I have included a simplified code snippet that exemplify the use case. I want to achieve following in my script: trap exit signals which should trigger onexit() function in the code below stderr and stdout should be sent...

How can i remove overlaping circles after Hough Transform segmentation

matlab,image-segmentation,hough-transform
I'm working in image segmentation, testing a lot of different segmentation algorithms, in order to do a comparitive study. At the moment i'm using Hough transform to find circles in the image. The images that i'm using have plenty objects, so when Í count the objects the result is hudge....

Sort by number of subdocuments mongoid

mongodb,mongoid
I have a model Person that has many Comments How could I sort people collection by number of comments Something like Person.desc(:"comments.count") ...

How to get (only) author name or email in git given SHA1?

git,commit,sha1,author
I would like to check for author's e-mail and name, surname to verify who's pushing to my repo. Is there any way that I can come up with a command in git to show commiter's name/e-mail given only SHA1 of the commit? This is what I came up with but...

How to draw line graphs in Swift?

swift
For a new app I need to draw a line graph. That graph needs to consist of two references lines, and one line based on measurements per day (min 14 days, max 32 days). Up to the current date, that line based on measurements needs to be solid. From the...

R: print line when column value matches value from other file

r
In R, I have a list of 11 dataframes named list1. Every dataframe has the same structure: names col2 col3 name1 1 10 name2 2 22 name4 3 40 I have another dataframe called table1 looking like this names col4 col5 name1 ... ... name2 ... ... name3 ... ......

How to create multidimensional array with multitype?

c#,arrays,multidimensional-array
I used to create this kind of arrays in PHP: $myarray[0]["my_string_1"] = "Toto"; $myarray[0]["my_string_2"] = "Tata"; $myarray[0]["my_int_1"] = 25; $myarray[0]["my_int_2"] = 28; $myarray[1]["my_string_1"] = "Titi"; $myarray[1]["my_string_2"] = "Tutu"; $myarray[1]["my_int_1"] = 12; $myarray[1]["my_int_2"] = 15; My question is: Is it possible to do the same thing in C#?...

laravel - get value from url

php,laravel,twitter-oauth
I know that this might be a off question or can be duplicate but after searching a lot I decided to post this question. I am using Socialite with laravel and I am still a newbie to it. I decided to have twitter login. I did everything but at last...

How to stop Eclipse / Scala IDE from uploading all my projects at once?

java,eclipse,git,scala,workflow
[EDIT]: I dont have a git console installed and therefore only use the git-plugin for eclipse. I have several projects in my Eclipse / Scala IDE like this: project 1 project 2 project 3 ... It can happen that I work on i.e. project 1 and do some changes. After...

Display text only for a couple seconds

java,time
I have made a simple register and login page. After the user successfully registered or logged in, a message will display the result. This is working fine, but I want it that the text is only displayed for a couple seconds. So after 5 seconds the text is gone. int...

GroupBy results to dictionary of lists

python,pandas,xlrd
I have an excel sheet that looks like so: Column1 Column2 Column3 0 23 1 1 5 2 1 2 3 1 19 5 2 56 1 2 22 2 3 2 4 3 14 5 4 59 1 5 44 1 5 1 2 5 87 3 And I'm...

Matlab P file opening in Octave

matlab,octave
I use Octave and have a Matlab made P file (protected function file). How can I open it, use it with Octave? Are there any method to convert it maybe or get content from it?

Is node.js better behind a reverse proxy for sending json?

node.js,apache,nginx
I have to make a web service who can handle many R&W requests (up to 50/seconds) and I think have a static server (Who host Angular.js App, and heavy resources like video and image) Is it a good idea to have my node.js server behind a reverse proxy like Nginx...

Set font face in android

android,android-fonts
I want to change some textview font-face to external font and i do something like this : typeFace = Typeface.createFromAsset(getAssets(),"fonts/bkoodak.ttf"); tv1.setTypeface(typeFace); tv2.setTypeface(typeFace); tv3.setTypeface(typeFace); ... But this form is't nice to me. Is there some way to do this better?...

htaccess 404 Stopped Working

apache,.htaccess,mod-rewrite
I had a custom 404 error redirect page working just fine through htaccess. However, after adding new code to htaccess, it stopped working. What's causing the conflict and how can I fix it? EDIT: I've tried putting the ErrorDocument line at the top of the page and it still doesn't...

Best program to create Java games? [closed]

java,3d,ide,programming-languages,2d-games
Not much to it Java Windows 8.1 32 bit Still beginner 2D Thanks...

Sharing vm machine between applications

google-app-engine,jenkins,google-compute-engine
I have production GAE application - myapp. I've created also second app - myapp-staging to have separate, staging environment. In myapp I've created Jenkins machine to get Build pipeline. It's easy to run test and deploy jobs on the same app. But there is a problem with deploy version from...

How to keep some columns and rows of jagged array and remove unwanted columns and rows in c#

c#,arrays
I have following jagged array int[][] dists1 = new int[][] { new int[]{0,2,3,5,2,4}, new int[]{2,0,1,3,5,3}, new int[]{3,1,0,4,4,3}, new int[]{5,3,4,0,2,4}, new int[]{2,5,4,2,0,2}, new int[]{4,3,3,4,2,0} }; and I learned how to delete one specific column and row (for example 3). Here's a link. Now I want to have dynamic programming as follows:...

Copy Files and directories with su command on rooted device

android,root,su
Similar Questions are often asked here, but I can´t figure out, what exactly I have to do. This is not a duplicate, because the solutions on many threads here are not what I am looking for or doesn´t work for me. I want to copy files and directories to a...

SQL join some tables

mysql,hibernate,join
I have this four tables: User(userId,username,password) Book(id,title,author,isbn,cost) Orders(orderID,orderDate,userId) (manyToOne to User , oneToMany to OrderItem) OrderItem(id,quantity,totalPrice,Book_id, order_orderID) (manyToOne to Order , manyToOne to Book) I ma going to retrieve title , cost, author , orderID , Quantity where userID=1 Here is my query: SELECT book.title, book.cost, book.author, orders.orderDate, orderitem.quantity, orderitem.totalPrice...

python curl execute command with parameter

python,subprocess
I need to execute the following command curl -v -H 'X-Auth-User: myaccount:me' -H 'X-Auth-Key: secretpassword' http://localhost:8080/auth/v1.0/ when I run this from terminal it works perfectly. and gives me result like following * About to connect() to localhost port 8080 (#0) * Trying ::1... * Connection refused * Trying 127.0.0.1... *...

Should syslog's openlog() be called before or after seteuid/setegid

c,permissions,syslog
The code I have calls openlog() once, before altering the effective uid/gid of the program (a daemon). From a security standpoint, or a predictability standpoint, would calling openlog() after setting the effective uid/gid be better? I'm guessing on most platforms openlog() will open a Unix Socket to syslogd? Are permissions...

Why is map.values().stream() much slower than Array.stream(array)

java,arrays,hashmap
Creating two constructs for University second semester computer science to count words in a text. One implementation uses an Array with Word-Objects which save the word as string and its frequency as int. The other uses as HashMap with the Word as key and the frequency as value. Now their...

what is the purpose of protected variable and method in java [duplicate]

java
This question already has an answer here: In Java, what's the difference between public, default, protected, and private? 16 answers I am new to Java, could you please tell me - "what is the purpose of the protected variable and method in Java". Thanks in advance. JP....

Parse error: syntax error, unexpected end of file in [duplicate]

php,html,mysql,xml
This question already has an answer here: PHP Parse/Syntax Errors; and How to solve them? 10 answers I have code id PHP for export to XML, and i dont know, where is problem ? <?php $data=mysql_query("SELECT * FROM ``"); while($zaznam=mysql_fetch_array($data)){ $select = "select * from `` WHERE ID=".$zaznam['ID'].""; $proved...

ensure all prerequisite components in .js file // example page malfunction

javascript,fullpage.js
I tried to setup just the basic index.html page, but seems that it's completely broken. I can't find any questions where people had similar issue. The page renders looking as if it's merely ill-formatted HTML. Maybe I have to include some additional libraries? Link something in a different way? In...

Can't load SVG from URL

fabricjs
I want to load different shapes in FabricJS based Canvas using loadSVGFromURL(), but can't. Documentation is also not complete on this. I just want a complete example. I can load it from string, but string creates spaces which creates problems when rendering. Here is my code: var canvas = new...

Event-B, formal modelling : How to affect all the elements of a set to a relation

modeling,event-b
I'm having quite a lot of troubles with Event-B.. I'd like to make a relation from a group of client to a client number each I have a relation of that type : cli(PERSON) = NAT1 (Person is a finite set) and in an event I have a subset of...

Add time to 9-hours days

java,date,calendar
I'm working on a basic project that manages tasks. Working days are from 8:00 to 17:00. A task has a start time and an estimated duration. This estimated duration is in minutes. I want to calculate the end time. I've figured out how to add days to the start time...

This expression was expected to have type xxxx but here has type unit

f#
The following code has a type error for both of the printfns. How should I fix it? I'd like the Seq.map loop to continue even if one of the items fails. // files should be a Seq of record let files = seqOfStrs |> Seq.map(fun s -> match s with...

Count from 100 to 1 with a different interval

xcode,swift,nstimer,countdown
I'm trying to make a countdown in Swift which do not rely on any specific time, but a time interval i choose. For an example i want the countdown from 100-99 to take approximately 4 hours. Is that possible in any way?

Access node based on attribute value

xml,xslt
Within my XML document, each lead or passenger has a pickup and dropoff attribute, which has a matching waypoint id. <r:rides> <r:ride> <r:lead pickup="1" dropoff="2"> </r:lead> <r:passengers> <r:passenger pickup="1" dropoff="3"> </r:passenger> </r:passengers> <r:waypoints> <r:waypoint id="1"> <a:place>Hall</a:place> </r:waypoint> <r:waypoint id="2"> <a:place>Apartments</a:place> </r:waypoint> <r:waypoint id="3">...

angular templating: ng-repeat comma-separated links

javascript,angularjs,templates,angularjs-directive
I got really disappointed with angular... I'm trying to do a quite simple presentation-layer stuff and I can see no good solution while browsing the web (and stack overflow as well). The case is: I've got a list of elements that I will generate links to, all of them will...

xslt copy only certain descendants

xml,xslt
I am trying to copy some descendant elements without a certain attribute. I cant figure out the right way to do this. Here the file: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <itemlist> <item> <subitem id="g0b86bn6"/> <subitem> <subitem/> <subitem id="8967698"/> </subitem> <subitem> <subitem/> <subitem id="9868966n7"/> <subitem> <subitem id="9896"/> <subitem> </subitem> </item> </itemlist> The...

C++. Avoiding cross-linking in multple files project

c++,linux,g++
I've been building many C++ projects for my university recently. They were consisted of multiple files with one Makefile. All in a prj folder with Makefile within, the source files in src folder and headers in inc folder. Makefile compiled it to object files in obj folder and than linked...

How to install/compile SDL2 C code on Linux/Ubuntu

c,linux,sdl
I'm currently doing some C programming and I actually want to use the SDL library. I want to build a Small 2D game in C on Linux to sharp my skills a bit. My issue is I'm not a super Makefile user nor library on Linux super user, I just...

How can I perform element-wise multiplication for Ruby arrays? [closed]

ruby,arrays,elementwise-operations
courses, credits and points are Ruby arrays with an equal size. gpa = (([credits, courses, points].transpose.map {|x| x.reduce(:*)}).inject{|sum,x| sum + x }).round(2) This method prompted an error message when I was trying to run it. Error message: in 'each': undefined method '*' for nil:NilClass (NoMethodError) ...

Sendgrid System.ArgumentException: Unknown element: html

c#,asp.net-mvc,sendgrid
I've just update the following packages to their latest version: a) SendGrid.SmtpApi updated to 1.3.1 b) SendGrid update to 6.0 and suddenly the WebTransport.Deliver method is not there anymore - no problem, I've switched to DeliverAsync method but now I get a very strange error, that it's supposed to be...

linq query 'orderby' using multiple fields at SQLite plugin by MvvmCross doesn't work

linq,sqlite,xamarin,sql-order-by,mvvmcross
The query is the following: var query = from c in _db.Table<Contact>() where c.FirstName.Contains("Alex") orderby c.Priority, c.FirstName, c.LastName select c; Is it a limitation of SQLite, MvvmCross plugin? Should I go with .Syntax as a result? Error CS1936: An implementation of `ThenBy' query expression pattern for source type `Cirrious.MvvmCross.Community.Plugins.Sqlite.ITableQuery<Contact>' could...

Merge two MongoDB aggregates into one pipeline

json,node.js,mongodb,aggregate-functions
I have a collection of population census and I still don't dominate the “aggregate” function to get the results with just one query. The collection has this format (plus a ISO 8601 timestamp). This way, each time a census is conducted we can register the current ages and counts (which...

c++ typedef/type substitution for enumeration class

c++,c++11,enums,typedef,enum-class
As far as I am aware at the moment it is not possible to do a typedef of the C++11 enum class. I would like to know if there is any other way I can reduce the length of the name of an enum variable when referring to it outside...

Toggle text in JavaScript

javascript
Is there a easier way to toggle 2 or more text visibility? When I've used a .toggle() method, the text jumps up and down, because they are toggled at the same time. With .fadeIn() and .fadeOut() its working correctly, but the code is messy. var triggerTitle = function() { var...