FAQ Database Discussion Community


Does log4py work with chainsaw?

logging,log4j
We use log4cxx and it works great with apache chainsaw but does log4py work with chainsaw as well?

Add and remove class

javascript,jquery,html
I have a basic HTML using bootstrap, container > row > col > div ID > panel in that order, the class is placed in div ID, the thing is that I need to remove that class from that DIV and put it in another DIV(the one you click on),...

How do I send [only] the shift key in Javascript?

javascript,shift
Is there a way to send just the shift key (not in combination with another key) in Javascript? I know I can detect the shift key with evt.shiftKey, but how do I send only the shift key? I have tried: $.event.trigger({type:'keypress', which : character.charCodeAt(16) }); My console.log gives me: Uncaught...

getting autosuggest from a url using javascript

javascript,html
i have an auto-suggest url from that i need to write a JavaScript code through which i will be able to see the auto-suggest data. i tried the below code but i am not able to get through it. <!DOCTYPE html> <head> <script> var xmlhttp = new XMLHttpRequest(); var url...

Referencing Class properties with variables in Python 2.7

python,class,variables
I'm working on a text based game, but I haven't found a very efficient solution to my fighting system yet. I currently have my statements set up sort of like this: class Weapon1: damage = 4 price = 5 class Weapon2: damage = 4 price = 5 class Enemy1: damage...

Transparency in GDI DCs

c++,winapi,gdi
I have the "simple" goal of drawing a bitmap with some transparency around it on the screen. That bit wasn't so hard: #include <windows.h> #include "BBKG.h" HINSTANCE hInst; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static int wH = 156; static int wW = 166; HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent) {...

PowerShell Function multiple SQL queries output as CSV

sql,sql-server,tsql,powershell,csv
I'm having problems getting PowerShell to run multiple SQL queries and export the results as CSV. I'm trying to accomplish this using a Function but the problem occurs in the Process block when I expect two queries to run and output two CSV files. I tried creating one function to...

How to better display this plot in ggplot2

r,graphics,plot,ggplot2
I am using ggplot2 to produce the attached file. My question is how can I use R+ggplot2 in order to make this plot less busy and easier to see what is going on in the data? There are about 1000 observations and each observation has between 1 and 15 data...

Recursion in PROLOG?

prolog
Given the following Prolog facts: f(a, [b]). f(b, [c]). f(c, [d]). f(d, [e]). f(e, []). I need to create a query xyz(a,Y) so that I get Y = [e,d,c,b], since a depends on b, which depends on c, etc. My current query is: xyz(X,Y):- f(X,P), member(Y,[P]). However, this query for...

Doctrine one-to-many relationship AND many-to-one

php,symfony2,doctrine2,cascade,relationships
I have two tables. I want to set up a one-to-many relationship, but also a many-to-one relationship. A Page can have one Background - this is the background of the page. A Page can also have many Backgrounds - this is a collection of user-uploaded backgrounds from which one will...

jQuery selecting by name attribute only selects first matched element

javascript,jquery
The following event only fires when the first drop-down with the name merchant category is changed (different option selected). I need it to happen for any select element with this name. I thought this would be the behaviour of the selector below. What am I doing wrong ? $('select[name=merchant-category]').change(function(){ console.log('called');...

Change “Key word” (true/False) to “Yes/no” -Boolean C#

c#
I'm trying to change the "Keyword" of a boolean (true/false), I mean when I write at console. For example: What I want: Q: Was this song bought? R: Yes What I have: Q: Was this song bought? R: True I don't want to write "true" I want to write "yes"...

How to load page content by URL using JavaScript

javascript
I was asked during an interview to write a piece of code to highlight the url if the content of the url contains a certain keyword. I honestly do not know how I can do that with JavaScript...

pointer initialization does not produce stable result

c,pointers
I wrote a little program to understand better about pointers. #include<stdio.h> int main(){ char buf[4] = {0, 1, 2, 3}; int i; char ** ptr1; for (i = 0; i < 4; i++) { printf("------------------\n"); printf("i = %i\n", i); printf("buf = %p\n", buf+i); ptr1 = (char **)&buf[i]; printf("ptr1 = %p\n",...

Rails 4 using controller concern to DRY update methods

ruby-on-rails,ruby-on-rails-4
I have a rails app where many of the models are editable using best_in_place, so I have a lot of controllers that look partially like this: before_action :find_objects, except: [:new, :create] def update @object.update_attributes(object_params) respond_to do |format| format.json { respond_with_bip @object} end end private def object_params params.require(:object).permit(:foo, :bar) end def...

how to allow delete only if user is admin in php

php,mysql
how to allow delete if username is admin. i want to allow delete only admin person to delete a record please help me to fix this issue thanks...... session.php <?php // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysql_connect("localhost", "root", ""); //...

Cannot fix Heroku H10 error

ruby-on-rails,ruby,heroku,puma
I have read every single SO answer I can find on H10 errors, and am still unable to fix the issue. My app works fine in dev, but in production I get the useless "Application Error" message, and the logs only give me a tiny amount of information. The app...

How to implement a function change_value_at_index that takes in three parameters: a tuple, an index, and a new value?

python-3.x
Implement a function change_value_at_index that takes in three parameters: a tuple, an index, and a new value, and changes the value at the index to the new value. The function should return the modified tuple. If index is out of range, return the original tuple. for example, change_value_at_index((1, 2, 3),...

Stripe - PHP Fatal error: Class 'Stripe\Charge' not found

php,class
I've been following the Stripe documentation and I am unable to create a "charge". Charge.php require('/var/www/stripe-php-2.1.1/lib/Stripe.php'); \Stripe\Stripe::setApiKey("KEY_HERE"); \Stripe\Charge::create(array( "amount" => 400, "currency" => "usd", "source" => "TOKEN_HERE", // obtained with Stripe.js "description" => "Charge for [email protected]" )); ?> I'm able to process the first command "\Stripe\Stripe::setApiKey("KEY_HERE");" but receive an error...

Error inflating class fragment ListFragment

android,android-fragments
When I try to include a List Fragment to my Activity I get stuck on this error 03-04 02:58:09.740: E/AndroidRuntime(1777): FATAL EXCEPTION: main 03-04 02:58:09.740: E/AndroidRuntime(1777): Process: com.example.health, PID: 1777 03-04 02:58:09.740: E/AndroidRuntime(1777): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.health/com.example.health.PatientMain}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment 03-04...

Form does nothing, send nothing php [closed]

php,mysql,forms,login
i'm kind of new in this and could use some help. You see, i have a form in a login page, but when i click the button it does nothing, not even an error message. It should send me to the page called "formulario.php". I just can't find the error...

How do I create a list with several identical variables without typing each one?(python)

python,list
I need a list that represents the zodiac calendar. It is part of a small program that accepts user input of birth month and day. Is there a way to do this? I am still in logic diapers and probably still in the womb when it comes to python. I've...

Java: Pass actual class. (Generics Problems)

java,generics
I've made my own EventExecutor class, which has the type <T extends Event>. public interface EventExecutor<T extends Event> { ... public abstract void execute(Event event); } and I know right now that this up here is wrong, because I'm wanting to pass in: public abstract void execute(T event); I've been...

Cannot properly reset JFrame

java,swing,jframe,minesweeper
I am a java Beginner and I'm working on a MineSweeper project now. I encountered a strange problem where I cannot reset the level properly when clicking the "New" button.(Although it could work for the first few times). I think it might have something to do with Swing EDT but...

Flipping image vertically

image
I'm trying to flip an image vertically (in C). This is what I've done so far. I think it works in theory, but when I run it I get segmentation fault. I somehow managed to fix this error a few days ago, but I didn't save it. This function that...

How to append Template Data to another Template based on Button Click in Meteor JS?

meteor
One template have button and another template have contains one text field.When ever button clicked that text filed append to the button template at the same time not remove the previous text fields that means the button clicked in 4 times 4 text fields add to the button template. See...

Questions about Python 'yield' keyword that I have not found answers elsewhere, and its specific use in a code I am working on

python,class,methods,return,yield
I am facing a python script that was handed over to me that works. I understand the purpose of that script and its role in the big picture of how it interacts with other modules, as well as its internal architecture pretty well in most places. However, I have to...

Converting a negative fraction to IEEE 754

ieee-754
I'm trying to convert -0.25 in decimal to IEEE 754 8-bit floating point. This means the signed bit is 1 bit, the exponent is 3 bits and the mantissa is 4 bits. Since it's a fraction my first digit is 0. For my next digits .25 * 2 = **0**.5...

Is there a way to adjust decimal points on weight in magento?

magento,decimal,weight
The default decimal points are 4 digits "1.0000" is there a way i can adjust it on front end that would only show 2 decimal points? like: "1.00" Thanks!...

Generating apple-touch-icon using Rails

ios,ruby-on-rails,mobile-safari,favicon
I am trying to add the apple-touch-icon link to my application head so that it will be displayed on homescreen bookmarks. The Rails guides state the following: Mobile Safari looks for a different link tag, pointing to an image that will be used if you add the page to the...

What's the equivalent of app delegate file for apple watch app?

appdelegate,watchkit,apple-watch
I want to set the initial view controller for the watch app base on different type of notification received on the watch. But I don't know where's to set it. This is the answer for an iOS app Multiple entry points to a storyboard...

syntax error in composite primary key android

android,android-sqlite
String CREATE_FINANCE_TABLE = "CREATE TABLE " + TABLE_FINANCE + "(" + FIN_USERID + " INTEGER PRIMARY KEY" + " REFERENCES " + TABLE_USER + "("+ USER_ID +")," + FIN_CARID + " INTEGER," + FIN_TOTALPRICE + " REAL, " + FIN_DOWNPAYMENT + " REAL," + FIN_BALANCE + " REAL, " +...

invalid convertion in std::accumulate

c++,c++11,accumulate,stdarray
I have a class representing a point in N dimensions with a min static function (minimum field by field) template<typename T, std::size_t N> class Point : public std::array<T,N> { public: template<typename... Args> Point(Args&&... args) : std::array<T,N>{{args...}} {} // ... static Point min(const Point&, const Point&) { // ... } };...

How to extract in php this type of XML format?

php,xml
How to extract in php this type of XML format? i try 'simplexml_load_file' function but its not work, it work only normal xml format. Thanks in advance :) <?xml version="1.0"?> <a:p> <a:r> <a:rPr strike="noStrike" u="none" b="0" cap="none" baseline="0" sz="1400" lang="en-US" i="0"> <a:solidFill> <a:srgbClr val="595959"/> </a:solidFill> <a:latin typeface="Arial"/> <a:ea typeface="Arial"/> <a:cs...

When I add a row of a certain cell id to a UITableView, it returns an empty row

ios,objective-c,uitableview
I have a custom UITableView with different cell ID's. What I'm trying to do is add a row when the button is selected. Here is my code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cellID; ... else if ([indexPath row] == 5) { cellID = @"rowFive"; } else if...

Spring Data JPA Transaction - No Transaction in progress - Spring Data Neo4j

spring,spring-boot,spring-data,spring-data-jpa,spring-transactions
I think i'm missing something obvious. Iam trying to make a entity persist into a database via a JUnit Test case, however it doesnt seem to be persisting due to no active transaction. Configuration: @Configuration @EnableTransactionManagement public class TransactionConfig { @Inject private EntityManagerFactory entityMangerFactory; @Bean public JpaTransactionManager transactionManager(){ return new...

Run function while UIButton is pressed

ios,objective-c,iphone,uibutton
I am building a remote control car using my iPhone as the controller. I built a simple button as seen below: -(void)moveArduinoForward { UInt8 buf[3] = {0x01, 0x00, 0x00}; buf[1] = 50; buf[2] = (int)num >> 8; NSData *data = [[NSData alloc] initWithBytes:buf length:3]; [self.bleShield write:data]; } -(void)stopArduino { UInt8...

Concern module not available in model despite being included (NoMethodError)

ruby-on-rails,ruby-on-rails-3,elasticsearch
I'm migrating my app from solr to Elasticsearch for document searching. The recommended pattern for deploying Elasticsearch is to include the Elasticsearch functionality (ie Elasticsearch::Model and Elasticsearch::Model::Indexing) in a Rails concern and then include this module in your model. I've implemented this as such. (Some methods temporarily commented out as...

Composite unique index

javascript,indexeddb,composite-key
I have an object store which contains 3 indices, which are name,value and userid. How can I create a composite unique index from name and userid? This is what I tend to do: var objectStore = database.createObjectStore('data',{keyPath : ['name','userid']}); objectStore.createIndex('name','name'); objectStore.createIndex('value','value'); objectStore.createIndex('userid','userid'); Is keyPath good enough? Do I need to...

Casting void pointer to long type, not pointer long?

c,pointers
int cmpLong(void *a, void *b) { long aa = (long)a; long bb = (long)b; return aa - bb; } I don't really understand the purpose of this piece of code what is it comparing? When a void pointer is casted as a long is it an arbitrary number or...

How to mock socket.io with Angular and Jasmine

angularjs,socket.io,jasmine,angular-mock
I'm having trouble figuring out how to correctly mock Socket.io in an Angular application using Jasmine and Karma. Here are the files found in karma.conf.js: 'bower_components/angular/angular.js', 'bower_components/angular-mocks/angular-mocks.js', 'bower_components/angular-ui-router/release/angular-ui-router.js', 'bower_components/angular-socket-io/socket.js', 'bower_components/socket.io-client/socket.io.js', 'bower_components/angular-socket-io/mock/socket-io.js', 'public/javascripts/*.js', 'ng_tests/**/*.js',...

Setting a bool if a value in List is equal to a given value

c#,.net,struct
The code below will return true or false based on the last Items ID in the sList. I'm stumped beyond that point, what I wanted to find out was if any one sList[i].getID = 1 then it would set the bool value = true but if all of the values...

chaining AND EXISTS/AND NOT EXISTS in SQL

sql
So I have this thing I have to do in SQL and I don't know why the logic is eluding me. Say I have a query that already exists and works: SET someValue = 1 --let's say someValue is 0 before this query WHERE EXISTS (SELECT 1 FROM a_tbl WHERE...

how to convert xml data to Json. PS: I have a CDATA content as well

xml,json,xslt
I have used XML to JSON conversion in xslt. I used following xslt to convert my xml to json. Problem is my CDATA content is lost. <?xml version="1.0" encoding="UTF-8" ?> <Error> <ECId>fc14e3645c3065f2</ECId> <ErrorNumber>SYS003</ErrorNumber> <ErrorDescription>Technical Error</ErrorDescription> <Timestamp>2015-03-03T17:50:18.185+10:00</Timestamp> <UserId>1212</UserId> <ServiceName>POP</ServiceName> <OperationName>XA_Call</OperationName>...

Angular JS - Filtering on ng-repeat

javascript,angularjs
I am very new to AngularJS. My problem is filtering - with a custom function. I am trying to obtain the following: checkboxes for product categories checkboxes for product sub-categories product showcase When the user clicks on a category , the sub-categories must update ( be enabled, selected) and then,...

Create a graph in Excel 2010 using 3 columns of data

excel,graph,datatable,excel-2010
I have been looking online tirelessly for a solution to the following problem but to no avail. I am trying to create a seasonal plot for the table below. My goal is to plot sales against quarter, classified by year. Any help would be much appreciated! Thank you....

Java regex to split string with variable spaces and delimiter

java,string,split,pattern-matching
Given a one-line string like a b c d => e f g 1 2 with dual delimiters (space and =>) the pattern " +( +|\\=> *)?" produces the following 9 fields as the output of String.split() in Java: a, b, c, d, e, f, g, 1, 2 However, if...

double free or corruption error on free

c,malloc,free,memcpy
this is the piece of code i use to create my char array on heap int currentArraySize = 10; char **finalArray = malloc(sizeof(char*)*currentArraySize); char buf[6] = "hello"; for(int b=0; b<currentArraySize; b++ ) { char * tmpString = (char*)malloc(sizeof(char)*6); //copy the contents of buf to newly allocated space tmpString strncpy(tmpString,buf,6); finalArray[b]...

Can I use https with Varnish Cache

https,varnish
Can I use varnish cache with https or will this have little to no performance gain? What are the pros and cons? I've set up my vcl for http only. I want to try this with https now. I've read this but it's from 2011: https://www.varnish-cache.org/docs/trunk/phk/ssl.html...

How to launch different screen of apple watch app from different notification?

push-notification,watchkit,apple-watch
Problem: How to launch different screen of apple watch app from different notification? This is my setup: I have 2 static WKUserNotificationInterfaceController: 1) awardsCategory 2) otherCategories This is my PushNotificationPayload.apns file for "awardsCategory" notification: { "aps": { "alert": { "body": "Hello world!", "title": "Optional title" }, "category": "salaryCategory" }, "WatchKit...

Django 1.6: Displaying two models in template using SingleObjectMixin & ListView

python,django,django-class-based-views
Working on an application were I have a Many to One relationship where I have many Products and a few particular products will be related to only one Brand. In my Detail View I have the logic set to display specific information about each brand in the designated template based...

How to count null row with $_GET in PDO

php,mysql,pdo
I'm now trying to count a click to get Popular Post Counter from reader, but I get problem with How to count it since previous row has no value or null. Here's my codes: <?php error_reporting(0); include("conndb.php"); if (isset($_GET['id'])){ $idClick=$_GET['id']; } $qryClick = $mydb->prepare("SELECT * FROM ra_articlez WHERE id=:$idClick"); $qryClick->execute();...

Generate Machine Key using Power shell

powershell
I am trying to generate machine key to share between a few machine, after a quick google search i found this article KB 2915218, Appendix A . I copied the code and save as .ps1 extension which i believe is power shell extension. Open power shell Move to the location...

Using XPath expressions inside SQL Server stored procedure

sql-server,xpath
I am trying to use an XPath expression to select nodes or node-sets in an XML document inside a SQL Server stored procedure. I am trying to do something similar to code in c# XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(response.GetResponseStream()); XmlNode contact = xmlDoc.SelectSingleNode("//users/user/contact"); string strContact = contact.InnerText.Trim(); The XML...

How to print all the additions and multiplications of a Galois Field in Sage

python,enumeration,sage,galois-field
My command line takes two inputs, a prime p and a positive integer n. I put them in a Galois Field in the form of GF(p^n). My goal is to print out all the elements of the field, the additions, and multiplications. I can print out the elements of the...

JQuery Datatables not showing its data

json,datatables
Here's my JSON data: { "0": { "counthigh": 33, "loc": "Barangay 7", "countmedium": 25, "countlow": 31 }, "1": { "counthigh": 27, "loc": "Barangay 6", "countmedium": 31, "countlow": 15 }, "2": { "counthigh": 17, "loc": "Comagascas", "countmedium": 38, "countlow": 10 }, "3": { "loc": "Barangay 3", "countmedium": 3, "countlow": 16 }...

“Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index” in ASP.net

c#,asp.net,gridview
I want to display the "NDA ID" in a label When the user click on the select link in the grid view. But it gives the error as "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index". Here is my...

Does Lightswitch HTML support full-fledged web application development?

visual-studio-lightswitch
When LightSwitch first came out I was very intrigued by it, but after an initial evaluation, I learned that you couldn't build a complete browser-based business application with it using standards like HTML5, jQuery, CSS. It only supported Desktop apps with Silverlight and then when the HTML Client came out,...

How do I get rid of “.” at the end of a token when using solr whitespacetokenizer and worddelimiterfilterfactory

solr,lucene
I have this text to tokenize : "let's buy a PowerShot-100 camera." I am using whitespace tokenizer and then word delimiter factory . The worddelimiterfilterfactory is creating tokens like "lets", "let's", "buy" , "a" ,"Power" ,"PowerShot", ,"Shot", "100" , "PowerShot100","camera." and also "camera" . when I try to run a...

how to print when you have left a recursive call

java,recursion,printing
How can I print to the screen after leaving a recursive call. For example when doing the ackermann function bellow. acker(1,2); public int acker(int m, int n){ System.out.println("Entered acker"); if(m == 0) return n + 1; if(n == 0) return acker(m-1,1); return acker(m-1, acker(m, n - 1)); } I can...

Javascript looped nested variable

javascript,variables,for-loop,nested
Bit confused how this piece of code actually works, mainly because I have never seen a variable being used like this in my first language (Python) function arrayToList(array) { var list = null; for (var i = array.length - 1; i >= 0; i--) list = {value: array[i], rest: list};...

Map of String to Method in Java 8, passing parameters

java,dictionary,methods,lambda,java-8
Ok, I have been trying to find an answer to this and I just can't wrap my head around the new java 8 lambdas and Method references. I am writing an SVM decoder. I have the model, created by libSVM and can get all the relevant information like kernel type...

deleting odd values in linked list java

java
I'm trying to delete odd values in a linked list. My function is called removeOdds. What am I messing up? I am calling cur.next within that if statement. Shouldn't that do the trick? Here is my code: public class SLinkedList { public void editAtIndex(int index, int newElement) { if (index...

How do i map one shortcut key to a sequence of tags (tasks) in lighttable?

lighttable
Say, for example, I want to bind a key "ctrl+d" to duplicate current line in LightTable. For that, to emulate duplication of the current line, I want to run a series of actions like [:editor.select-line :editor.copy :editor.selection.clear :editor.new-line-indent :editor.line-start :editor.paste] How do I achieve this? Note: I am aware of...

Finding where element meets top of scrollable div

javascript,jquery,html,css
I have a scrollable div container fits multiple "pages" (or div's) inside of it's container. My goal is to, at any given moment, figure out where inside my red container does it reach the top of my scrollable container. So it can be a constant on scroll event, or a...

Display csv file data in tabular format using jsp

java,jsp,csv
Here is my code, <table cellspacing='0' class="tablesorter" > <thead><tr> <th>Name</th> <th>Description</th> <th>Instance-id</th> <th>Region</th> <th>Public_DNS</th> </tr></thead><tbody> <% String fName = "c://list_win_instances.csv"; String thisLine; int count=0; FileInputStream fis = new FileInputStream(fName); DataInputStream myInput = new DataInputStream(fis); int i=0; while ((thisLine = myInput.readLine()) != null) { String strar[] =...

How do I set the scope of this MySQL UPDATE operation?

mysql
Standard disclaimer: I'm a total know-nothing when it comes to MySQL. The way I'm trying to do things is almost certainly not clever, and I'm open to suggestions for improvement. I have two databases: wordpress and wordpress3. wordpress3 is a copy of wordpress, converted to UTF-8. In the process of...

IOS SWIFT-call code block based on uibutton image

ios,swift,uibutton,uiimage
Here is the code I have tried to get this to work. My goal is to call a block of code based on what the image is for the button. The button changes image based on the previous image. @IBOutlet weak var startFuncAButton: UIButton! let navBtn = UIImage (named: "ArrowStraight")...

How can my @Rule work together ExpectedException rule?

junit,rule
I created a @Rule similar to @RunWith parameterized.class so that all testcase can repeat tests with different parameters (I cannot use parameterized.class directly becase my test class already has @Runwith for other purpose). However, the @Rule does not work when testing the following method: @Test public void fooTest() { /*exception...

Linq To Sql Entity Framework Getting Nested Entities

entity-framework,c#-4.0,linq-to-sql
I'm trying to do an include of a nested entity. I assumed the below code would work but it does not recognize the CapitalMailOrders entitycollection. Can anyone point me in the right direction to include these? var result = db.Contacts .Include(a => a.IDXPageLinks) .Include(b => b.ReboGatewayLoginInfoes) .Include(c => c.SocialMedias) .Include(d...

Add number of observations per group in ggplot2 boxplot

r,ggplot2
Following this question: How to add a number of observations per group and use group mean in ggplot2 boxplot?, I want to add number of observations per group in ggplot boxplot too. But I have added a colour into aes mapping. The existing answer shows how to adjust text position...

Getting full indexes of a patch using libgit2 / git2go

git,go,patch,libgit2,pygit2
git2go's git.Patch or libgit2's git_patch returns a String value of the following format: "diff": "diff --git a/test b/test index 9daeafb..dced80a 100644 --- a/test +++ b/test @@ -1 +1,3 @@ test + +test" Notice that index 9daeafb..dced80a 100644 is not the full index. Is there anyway using libgit2 / git2go to...

Is acceptable Entity circular reference in domain model?

java,oop,design
I've seen a lot of domains designed with circular reference. The image below describes a simple example for understand the question: A company has employees and departments and a department has employees, who belong to a department. Logically, the model allows a employee who works for a company be related...

Installing pygame for python 3.x, getting difficulties

python,pygame
I have just installed the latest version of python, 3.4.3 32 bit and the corresponding pygame. I get this error when importing pygame >>> import pygame Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import pygame File "C:\Python34\lib\site-packages\pygame\__init__.py", line 127, in <module> from pygame.base import * ImportError:...

Error: No more request expected with Karma using Restangular from within a Service

angularjs,restangular,karma-jasmine,httpbackend
I have an AngularJS service and service name is User. I use it for authentication. Inside this service, I have an authenticate() function which uses Restangular to make a REST call to our API. It's perfectly working in my Angular application. I just started using karma so I can including...

How to achieve equal layout_width and layout_height

android,xml,android-layout,android-linearlayout
What I am trying to achieve is to put 4 buttons next to each other, with some margins, and make them square (without supplying fixed sizes) I basically have a wrapper LinearLayout that holds 4 buttons, which I want them to be square shaped. <LinearLayout android:id="@+id/photos_photoWrapper" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orienation="vertical">...

Android Rect set() method missing

java,android,graphics,2d,rect
I'm using Android Studio 1.1.0 and am trying to use the Rect .set() method in some code to set the edges of a newly-created rectangle, and I'm getting the message "Cannot resolve symbol 'set'" even though I imported android.graphics.Rect as prompted. When I declare a new Rect and define its...

This.color in css? [duplicate]

css,sass,less
This question already has an answer here: Sass - Manipulate inherited property? 2 answers Or maybe there's preprocessor solution. Suppose you have 20 buttons. Each with a different color. The colors are set like this: button { background: red; } So you can write something like this button:hover {...

How to access linq group results

c#,linq
This might seem silly but I spend enough to time and I guess I need more exposure to linq. I have linq expression which results a group (key=int, list=string) What I want is simple. I want to assign group list to List<string> variable based of a key. excerpt from sql...

lapply undoes my previous function, but I don't know why

r,lapply
I want to split a dataframe by the year column into a list of 33 different dataframes. Then I want to change it so that each year column in the list reads "2015". Then I want to write each dataframe to a file with files labeled by the name of...

Unable to reflectively alter field inside Spring Controller in test

java,spring,spring-mvc,reflection
My senior developer and I hit this weird problem yesterday trying to test a Spring controller with a mocked service. We are not using Mockito as this is a legacy system that we can't be bothered adding Mockito too. The strangeness began when we attempted to use Reflection to change...

jQuery DataTable - How to set aoColumnDefs without creating a new DataTable object?

javascript,jquery,datatable
I know how to set column names by using: var table = $('#'+String(response.chartID[i])).DataTable({ stateSave: true, aoColumnDefs: aryJSONColTable, processing: true, serverSide: true, bDestroy: true, "scrollX": true,})) But is it possible to set oaColumnDef inside DataTable object? For example on specific callbacks, I can set oaColumnDef to another set of names. The...

Bootstrap pop over form not submitting using AJAX

php,jquery,twitter-bootstrap,popover,bootstrap-popover
I have a bootstrap popover form which has couple of input text fields and a submit button. The popover is displayed fine with the input text fields but when clicking the submit button the default action is not prevented at all. I have also tried to log in the form...

Javascript: Subtract time with another fixed time

javascript,datetime,time
Consider I have following date and time in 24 hours format. Example 2015/04/02 12:00 2015/03/02 14:00 I have to subtract the above time with 9 hours so that I will get 2015/04/02 -> 3 (hours) 2015/03/02 -> 5 (hours) HTML <form name="formName" onsubmit="return checkDate(this)"> <input type="text" value="" name="date1" /> <input...

Generating two random prime numbers in JAVA

java,random
I'm trying to generate two random prime numbers in JAVA, however, I want the loop to keep repeating itself until both of those two variables are prime numbers, and then they output themselves. The p and q variables are randomized by the Math.random() function and are in the range of...

Spring-Boot @RequestMapping and @PathVariable with regular expression matching

regex,spring,spring-mvc,spring-boot,webjars
I'm attempting to use WebJars-Locator with a Spring-Boot application to map JAR resources. As per their website, I created a RequestMapping like this: @ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/webjars-locator/{webjar}/{partialPath:.+}") public ResponseEntity<ClassPathResource> locateWebjarAsset(@PathVariable String webjar, @PathVariable String partialPath) { The problem with this is that the partialPath variable is supposed...

Python: Insert two sets of chars into a matrix

python,matrix,fill,chars
Working with the Playfair cipher. I have two sets of chars: a keyword and the rest of the alphabet without the characters within the keyword. Example (Due to the nature of the Playfair cipher, 'i' is not taken into account to work with 25 characters, good fit for a 5x5...

spark - eager loading and caching RDD while executing on localhost master

java,apache-spark,hdfs
First question, is there anyway I can eagerly load RDD before applying any reduce function? If not I'll have to do dummy reduce function as I am trying to cache RDDs during my rest application startup! Second, I dont see any caching happening even after running reduce function. I am...

Java Integer.highestOneBit in C#

java,c#,integer,int
I have been trying a lot to find an exact replacement for the Java's Integer.highestOneBit(int) in C#. I even tried finding its source code but to no avail. JavaDocs tells that this function: "Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost")...

Meteor - Ckeditor Integration

javascript,jquery,meteor,ckeditor
I'm not sure if there has been a change in the way Meteor loads items, or the way it handles jquery, but I'm having an awful lot of trouble getting ckeditor to come up. Main Template (Iron-router): <template name="layout"> <head> <script type="text/javascript" src="js/ckeditor/ckeditor.js"></script> <script type="text/javascript" src="js/ckeditor/adapters/jquery.js"></script> </head> ..... </template> Independent...

Execute multiple statements and CTE in stored procedure in SQL Server 2012?

sql-server,tsql,stored-procedures,sql-server-2012,common-table-expression
I'm newish to SQL server 2012, and I'm trying to create a stored procedure that should: Delete previous data from a table, based on a parameter, then Insert new data on that table. But I need to use CTEs for performance and other reasons (please don't get hung up on...

Getting SizeOfImage and EntryPoint of dylib module

c++,osx,memory,process,dyld
I'm writing a cross-platform memory analysis library and one of the functions I provide is GetProcessModules. On windows I use EnumProcessModules to get a list of all modules loaded in a process along with GetModuleInformation to retrieve the Address, SizeOfImage and EntryPoint of the module. Translating this to OSX I...

Wild card matching pattern in Haskell

haskell,pattern-matching
OCaml provides wild card matching pattern when every other case fails: let imply v = match v with (true,false) -> false | _ -> true;; What's the equivalence in Haskell?...

java.lang.NullPointerException: Attempt to invoke interface method on a null object reference error on OnPostExecute

android,android-asynctask,nullpointerexception
I am trying to get a result from an asyncktask to shown in my search activity. I had a example from a previous app, that was made with help from a collegue(i was an intern there). I adjusted the example to the needs of this app, but now im getting...

How to get the time difference in seconds? [duplicate]

java,datetime,jodatime
This question already has an answer here: Java-How to calculate accurate time difference while using Joda Time Jar 2 answers I have used Jodha Library and tried to get the difference between two dates in seconds. But it is only accurate up to the date. Not to the seconds....

Why is Javascript disabled in an SVG?

javascript,svg,gecko
Why is having Javascript enabled in an SVG considered insecure? I.e. why was Javascript disabled in SVG (in Gecko)? What are the security implications if it were not disabled?

PHP - create thumbnail image from url

php,image-processing
I need a way (using built-in PHP libs) to pull down an image from URL and save it to local disk with resized/scaled WIDTH to 150px. I have been trying this: Creating a thumbnail from an uploaded image function makeThumbnails($updir, $img, $id) { $thumbnail_width = 134; $thumbnail_height = 189; $thumb_beforeword...

JQuery carousel track looping

javascript,jquery,html,css
I am having trouble making the images inside the slider loop around. I want track to loop around from either sides after they are hidden. here is the the jsfiddle for what I have now. http://jsfiddle.net/V2x6s/3/ Here's Javascript setInterval(function() { var left1 = parseInt($('#track1').css('left')), left2 = parseInt($('#track2').css('left')), left3 = parseInt($('#track3').css('left'));...

End a multiplayer game on finishMatch

android,google-play,google-play-services,google-play-games
I am developing a turn based multiplayer game in Android using Google Play Game Services. I have successfully ended the game when the user clicks the Finish Button: Games.TurnBasedMultiplayer.finishMatch(mGoogleApiClient, mMatch.getMatchId(), mMatch.getData(), creatorResult, opponentResult) .setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() { @Override public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) { processResult(result); } }); The current player's game gets...

Permission Error When Trying To Install Rails (OSX)

ruby-on-rails,ruby,ruby-on-rails-3,osx,permissions
I am new to programming and am trying to get rails installed on my terminal. I have been following instructions from a friend, installing the xcode command line tools, homebrew, git, rbenv, ruby-build, ruby gems, ruby, and postgres. But whenever, I try $gem install rails, I get the following: Russell-Silvers-MacBook-Pro:~...