FAQ Database Discussion Community


Calling Helper functions within functions - Haskell

haskell,functional-programming
I have 3 functions, the first one is a toList :: Tree -> [Integer] the second is sumTree :: Tree -> Maybe Integer which sums a the elements in a tree, filtering for some edge cases. My main function is treeSum :: Tree -> Maybe Integer which I want to...

how to remove the index.php from the url in laravel 4

laravel,laravel-4
I wish to remove the index.php in the url of a laravel 4.2 site. But i don't know how to do that. Without index.php/ the pages are not loading. My routes.php contains Route::get('/', '[email protected]'); Route::get('login','[email protected]'); Route::get('forgotpassword', '[email protected]'); Route::post('loginprocess', '[email protected]'); Route::group(array('before' => 'auth'), function() { Route::get('locations','[email protected]');...

Convert a Laravel Builder response to a Collection

php,mysql,laravel
I've got 3 tables - challenge, challenge_users, and climbs with the following definitions: table challenge id, name, start_date, end_date table challenge_users id, challenge_id, user_id table climbs id, user_id, date I want to pull a list of climbs that fall within the dates of the challenge for any user in the...

App stopped responding in android [closed]

java,android
i am creating a simple android application, but when i run it, app stopped working(responding). i am attaching code of my application. please help me. this is MainActivity.java package com.example.guessit; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.Button; public class MainActivity extends Activity { Button play,help,about;...

oledb exception syntax error in insert into statement (0x80040E14) in C#

c#,oledb
I'm having and exception in my insert into statement.But the data is inserting to the table correctly. can someone please show me the error in this code. private void btnAddNewSale_Click(object sender, EventArgs e) { string StrQuery; connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; for (int i = 0;...

css style for display inline

html,css,html5,css3
I want to display a <h1> tag and button tag in same line, but the button appear slightly below. I marked In green where I want to display it: h1{ display:inline-block; } .log { width:60%; height: 30%; position: absolute; border: 1px solid #f9f2f2; border-radius: 10px; background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff...

Authenticate signup in devise in ruby on rails

ruby-on-rails,ruby-on-rails-3,devise
I have 7 models of login after using devise name as 1- super admin 2- admin 3- branch 4- faculty 5- student 6- parent 7- user I want to follow a process where a super admin should have an authority to go to signup and create admin account and a...

logic in sql statement

php,mysql,sql
connect1($db_host,$db_username,$db_password,$db_name1); $q="SELECT DISTINCT bizinfo.dbiz_id, bizinfo.company_name, bizinfo.company_industry, bizinfo.company_sub_industry FROM bizinfo Inner Join biz_feedback ON bizinfo.dbiz_id = biz_feedback.biz_id AND biz_feedback.on_industry = bizinfo.company_industry ORDER BY bizinfo.dbiz_id ASC"; $rs_q=mysql_query($q); while($row=mysql_fetch_assoc($rs_q)) { $dbiz_id=$row['dbiz_id']; $company=$row['company_name']; $company_industry=$row['company_industry'];...

Create a new type of array in C#

c#
Is it possible to create a new type in C# from an existing type. This is possible in C quite easily, but I cannot figure out how this is done in C#. Something like this: type Map int[,] ...

Percent-encoding entire PHP string into numbered ASCII values for obfuscation

php,html,url,obfuscation,percent-encoding
I'd like to somehow obscure the contents of $url = "http://blah.somedomain.com/contents/somefolder/somefile.htm"; so I can use them for links but so that the URLs are not easily read by humans when looking at the page source. The obfuscated URL still needs to work in a browser when clicking on it though...

Haskell bitfields and bit level protocols

haskell
I am working on generating and parsing an existing binary format (Xilinx FPGA bitfiles) using Haskell. At the moment my data structures and operations look like this: getCode = fromIntegral.fromEnum getName = toEnum.fromIntegral -- 1 1 1 1 1 1 -- 5 4 3 2 1 0 9 8 7...

java.lang.NullPointerException Error [duplicate]

java
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers This is CD.java public class CD { // Fields (or instance data members) private String title; // CD's title private String artist; // CD's artist private double cost;...

Can't find file error in Middleman site on Heroku

ruby-on-rails,heroku,middleman
I've setup a Middleman site as per this guide (http://www.randomerrata.com/articles/2013/middleman-on-heroku/) for deploying to Heroku. When I load the site in a browser though an error appears: Rack app error: #<Errno::ENOENT: No such file or directory - 404.html> Everything seems to be setup correctly, I've provided a screenshot of my source...

Yii2 Pjax not working

yii2,pjax,yii2-advanced-app
I want to refresh the gridview using Pjax but somehow it is not working. Here is the code: _search.php <?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\widgets\Pjax; $this->registerJs(" $('#btnAjaxSearch').click(function(){ $.ajax({ type: 'get', data: $('.bank-search form').serializeArray(), success: function (data) { $.pjax.reload({container:\"#bank\"}); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert('error'); } }); return...

Sublime Text 3 not Rails/Ruby highlighting syntax

ruby-on-rails,sublimetext3
I've been trying to get Sublime Text 3 set up to learn Ruby and RoR. Everything I've read has said to set it up with Railscasts Colour Scheme. I was under the impression that this would provide syntax highlighting. Unfortunately, all I have is white text on a dark gray...

doubly linked list in nasm assembly

assembly,x86,nasm
I wanted to do a double linked list in Nasm . I have this structure for Node struc node left: resd 0 right: resd 0 data: resd 0 endstruc I do this when i want to use malloc push dword [node_sz] call [malloc] add esp, 4 * 1 Where: node_sz...

Why is my app deployed on Heroku has its database reset periodically?

python,heroku,flask
I have a very simple web app on Heroku. The app has a sqlite3 database file with some prepopulated data. After I deploy the app, I can insert/delete records through the web app. Why is it after some time, let's say 10 hours, when I visit my web app again,...

How to minimize requested image using jquery cropit plugin?

javascript,c#,jquery,asp.net,image
My code is cropping an image but cropped image is very large. I'm using the Cropit jQuery plugin. My View has an div mask on the image. When the form post, the hidden input has cropped image through the following script. <div class="image-editor" style="margin-left:120px; margin-bottom:25px; margin-top:25px;"> <input id="fileinput" type="file" name="filex"...

Last 3 values using foreach loop in php

php,foreach
I have a foreach loop. There has uncountable value. I want to print last 3 values. foreach($arr as $key=>$value) { //print last 3 value. } ...

how to make a sliding up panel like the Google Maps app?

ios,objective-c
I'm looking for something like AndroidSlidingUpPanel for iOS. I found MBPullDownController, but it requires two ViewControllers to use, and requires a big change to the architecture of the app I'm working on to implement. I just want something that adds a subview in an existing view controller. How would I...

Jquery function is not working for dynamically added rows in gridview

javascript,jquery,asp.net,gridview
I have a gridview with dynamically added rows. I need to do some calculation using jquery when textbox changed. Below is my jquery function .But it is not firing . Is there any other method to find the controls. Please help <script> $(function () { $('#<%=gvConsumableUsageAdd.ClientID %>').find('input:text[id$="txtQuantity"]').keyup(function () { debugger;...

using an epoch unix timestamp in a mysql query

php,mysql,phpbb
I'm trying to mark accounts inactive (user_type = '1') which haven't signed in (user_lastvisit) within the last 90 days as inactive. user_type tells phpbb if the account is 0 = active or 1 = inactive user_lastvisit is the last time the user signed into the phpbb board. It is stored...

display more that one category from mysql

php,database
When I put an item in the database I can chose different "Used" categories . For example I have Used, Barely Used, Rough. I am wanting all them to display on the same page. Right now I have this code $SQL_GetEquipment = "SELECT * FROM `new_equip` WHERE `condition`='Used' $SQLCat $Limit";...

Apps that do not perform as advertised by the developer will be rejected when sandbox mode

objective-c,xcode,itunesconnect
My app is rejected by 2.3 Apps that do not perform as advertised by the developer will be rejected It said that the file copied into "~/Library/Fonts" failed. It works when test by myself, I find that it will get permission fail when using the sandbox mode, did Apple reviewer...

Faster way of performing this SQL query

php,mysql,sql,optimization,innodb
I have a large SQL table that stores an added item id that the user added to their profile and the rating they gave it. The thing is, I need to quickly count how many times an item has been added AND also need to get the total ratings it...

jQuery keyboard shortcuts for website for focus goes to previous or next element using left n right keys [closed]

javascript,php,jquery,ajax
i am new in php and jQuery, can anyone please help me about keyboard shortcuts for website. means when we are on webpage and feeling registration form and we want to go to previous textbox using keyboard using left keypress..then how to focus goes on previous element.. m using below...

Figuring out how to do this with php and mysql

php,mysql
I have a variety of fields. id | lat1 | lon1 | lat2 | lon2 | I need a way to check if data on lat1 is null, and if is null then put data in it. I was trying this: $selec2 = "SELECT lat1 FROM usuarios WHERE androidid='$Id'"; $checklat...

How to get div columns to be same height?

html,css,css3
I'm trying to understand how to put two div's next to eachother inside a wrapper and have them both column div's to match heights at all times, even if one has more content than the other, all without applying a strict height to the column. I've tried using height:100% and...

When to use CallNonvirtualObjectMethod and its related methods?

java,c++,jni
It seems like CallStaticObjectMethod, CallObjectMethodMethod and etc... are all you need. According to the docs CallNonvirtual<type>Method families of routines and the Call<type>Method families of routines are different. Call<type>Method routines invoke the method based on the class of the object, while CallNonvirtual<type>Method routines invoke the method based on the class, designated...

Why is it that when using JQuery, when I hover, there's no smooth animation?

javascript,jquery,html,css,animation
I have the following in my script.js file: $(document).ready(function(){ $( '.elementoBarra1').hover( function(){ $(this).addClass('lineaBarraActive'); }, function(){ $(this).removeClass('lineaBarraActive'); } ); }); There is a change in color (based on the instructions I'm giving in the stylesheet), but there's no animation (or transition). It just passes binarily to the other color, there's no...

Consistency guarantee of file system regarding sequential write

io,language-agnostic,consistency,os-agnostic
My program (only 1 process and 1 thread) sequentially write n consecutive chunks of data to a file on a HDD (regular kind of HDD) using plain old write system call. It's like some kind of append-only log file. After a system crash (power failure, not HDD failure), I read...

how to grab variable from php into a new php file

php,html,forms,http-method
I have a form index.html <form action="action_page.php" method="post"> <select name="race" style="width: 180px;"> <option value="White">White</option> <option value="Asian">Asian</option> // </select> <input type="submit" value="submit" name="submit"></form> action_page.php <?php $varRedirect = "results.php"; $varRace = $_POST["race"]; function redirect($url, $statusCode = 303) { header('location: ' .$url, true, $statusCode); die(); } redirect($varRedirect); ?> results.php...

Laravel 4.2 Interface confusion

php,laravel,laravel-4
The default User Model in Laravel 4.2 implements both UserInterface and RemindableInterface but upon looking the definition of my User model, those methods defined on both interfaces are not implemented on the User model. use Illuminate\Auth\UserTrait; use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableTrait; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface {...

2d Vector Insertions in C++

c++,vector
Currently working on a graph representation using a vector of vectors. I am attempting to insert a vector of edges at a specific location within adjacencies. adjacencies is defined as adjacencies = new std::vector< std::vector<Edge*>* >; I am running into an issue with the vector not inserting at the specific...

Reading from text file skips first line

c,file,pointers,text,while-loop
I'm using strtok to read from a file that looks like this. Thanks to the answer of my last question, the seg fault went away. However, I'm now having a problem of the the read in file, not being read on the first line Once again: I have a file...

Groovy string replace

regex,replace,groovy
I'm working on some Groovy code to take text that's meant to be a Tweet, and turn all hashtags into web-links to the Twitter hashtag. In fact, I have that code working, but it fails when there's a bare # in the text that's meant to be read as a...

How do I inherit a variable from a parent class? [duplicate]

java,variables,inheritance,parent-child,subclass
This question already has an answer here: Why does Eclipse require me to set (arbitrary) brackets in java code? 5 answers I have a subclass that needs to inherit a method and a variable, and I want to be able to make several instances of the subclass. However, I...

Permutation algorithm [duplicate]

algorithm,permutation,powerset
This question already has an answer here: Fast permutation -> number -> permutation mapping algorithms 9 answers I have a Hashmap called H1. There are n Hashmap keys for H1. For H1 hashmap, the program will create all the permutations of the powerset {1,2,3,4,...n}. So in other words, if...

Change Z-Index of a label control in code [duplicate]

c#,controls,z-index,styling
This question already has an answer here: Bring Winforms control to front 4 answers So I'm trying to create a label with the following code : Label letter = new Label(); String key = Convert.ToString(e.KeyChar); letter.Text = key; letter.ForeColor = textColor; letter.Size = new Size(10, 20); letterSpacing = letterSpacing...

How to count all users where group id

php,mysql,codeigniter
Can I use this $this->db->where() with codeigniter count_all() Have i got the code correct below? public function getTotalUsersByGroupId( $user_group_id ) { $this->db->where('user_group_id', (int) $user_group_id); return $this->db->count_all($this->db->dbprefix . 'user'); } ...

java multithreading program 4 [closed]

java,multithreading
I have been asked a question from one of my interview quiz the question follows: A task uses a master thread (not shown here) to share the work of scanning DNA among multiple threads. * The master thread invokes the scanDNA method (below) on all of the other threads at...

Removing a view from within its own view class

android,view,interface
Here is the view class that I have created. public class WorkoutView extends LinearLayout implements View.OnClickListener { public Spinner spinnerDifficulty, spinnerTime, spinnerMuscleGroup, spinnerSets, spinnerReps; public EditText etWorkoutName; public Button btnRemoveWorkout; String workoutName, muscleGroup, sets, reps; LayoutInflater inflater; Context mContext; ButtonPressInterface buttonPressCallback; public WorkoutView(Context context) { super(context); Log.e("WORKOUTVIEW", "1"); mContext =...

How do I create a dynamic scope where I can pass in an object if possible?

ruby-on-rails,ruby-on-rails-4
I have these two scopes: scope :posted_yesterday, -> { where(created_at: (Time.now.midnight - 1.day)..Time.now.midnight)} scope :num_posted_yesterday, -> { posted_yesterday.count } What I want to happen is, I would love to be able to calculate many versions of posted_yesterday. i.e. posted_num_days_ago(n). There anyway for me to create dynamic scopes to allow this,...

Polymorphism and Interfaces in C#

c#
Create three small classes unrelated by inheritance—classes Building, Car and Bicycle. Write an interface ICarbonFootprint with a GetCarbonFootprint method. Have each of your classes implement that interface, so that its GetCarbonFootprint method calculates an appropriate carbon footprint for that class (check out a few websites that explain how to calculate...

Can't Override onPostExecute() method in AsyncTask Class

android,android-asynctask,return,return-value
I know there are several question which are quite similar to this one, but they didn't helped me so far. I'm still not able to override this AsyncTasks. Can you hel me? I already made sure that doInBackground() devlivers some type that onPostExecute() requires (Boolean in the first and JSON...

How to stop infinite loop when character is pressed in place of int?

c
Here, user is asked to press respective key to perform particular function, but suppose I pressed any character value such as "g", it goes into an infinite loop. How to solve this issue? int item,choice; clrscr(); while(1) { printf("QUEUE SIMULAtOR"); printf("\n1:Insert"); printf("\n2:Delete"); printf("\n3:Display"); printf("\nEnter your choice: "); scanf("%d",&choice); switch(choice) {...

Accessing elements in the shadow DOM

python,selenium,selenium-webdriver,shadow-dom
Is it possible to find elements inside the Shadow DOM with python-selenium? Example use case: I have this input with type="date": <input type="date"> And I'd like to click the date picker button on the right and choose a date from the calendar. If you would inspect the element in Chrome...

How to check if more than 5 checkbox is checked in android?

android,checkbox
As the title says, I want to check if more than 5 check box is checked in android. What I want to do is to check 5 checkbox and if I enter more or less than 5 checkbox it will show a alert . How will I do this ?...

javascript merge array elements that are the same

javascript,jquery,arrays
I have this array: I was wondering how can I remove the duplicate arrays elements regardless of the position of the elements inside the array example array1 = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4]]; //the [0,1],[1,0] will be counted as the same element, so...

How to convert 2 signed 32 bit numbers to 64 bit in C

c,64bit
a and b are upper half and lower half of the same number. Now I have to save this number to a 64 bit register. lets say a = -1(Higher bytes) and b = -50. How can I do this ? I am using the following which works for positive...

How to stop execution process in MVC 5 with C#?

c#,asp.net,asp.net-mvc,model-view-controller
Anyone can help me, what line of code help. My application code is. /// <summary> /// Override onAuthorization filter is use for authorization use request. /// </summary> /// <param name="filterContext"></param> protected override void OnAuthorization(AuthorizationContext filterContext) { AuthorizationManager authorizationManager = new AuthorizationManager(); string FilePath = Convert.ToString(filterContext.HttpContext.Request.FilePath); if (!authorizationManager.IsAuthorized(_userSession, FilePath)) {...

count repeated occurrence of 0 & 1 in a string

php,regex,preg-match
Return false if the repeated occurrence of 0's or 1's in the string is greater than number($k). I have written a function which works, but I need to optimize it: <?php function satisfied($str, $k){ $stream = $last = $str[0]; for($i = 1; $i <= strlen($str)-1; $i++){ if($str[$i] != $last) $last...

unable to get the difference between two numbers AND keep getting invalid amount when entering [closed]

java
This program will generate a random number and ask user to disperse the correct amount of change. If user has entered the wrong amount the program will say Incorrect by : +difference... mine refuses to work... */ // ---------1---------2---------3---------4---------5---------6---------7 // 1234567890123456789012345678901234567890123456789012345678901234567890 import java.util.Scanner; import java.util.Random; public class ChangeGame9 {...

Blocking queue with task

c#,.net,task-parallel-library
Problem: I have filesystem where files appear and i want to upload them over WCF. What i want is to limit maximum number of parallelism to some ThreadMaxConcurrency Idea is to utilize Producer-Consumer pattern in blockingQueue. Producing part is - UploadNewFile,CreateFolder etc... What i am blind of is that consumer...

How can I get data from a specific cell in an HTML table in python?

python,html,parsing,beautifulsoup
This link contains the table I'm trying to parse. I'm trying to use BeautifulSoup in Python. I'm very new to BeautifulSoup and HTML. This is my attempt to solve my problem. soup = BeautifulSoup(open('BBS_student_grads.php')) data = [] table = soup.find('table') rows = table.find_all('tr') #array of rows in table for x,row...

Error in showing alert dialog while clicking on a list view item

android,sqlite,android-alertdialog
Error in showing alert dialog while clicking on a list view item. The code is given below.. this is a program done in android sqlite.The data retrieved is shown in the list view but the alert dialogue does not working properly for edit and delete. please help me with the...

Scheduled task running under user with concurrent sessions

windows,scheduled-tasks
If I make a scheduled task that checks if a particular window is open, and it runs under a user (e.g. user "foo") with multiple sessions (e.g. 3 people are logged on the server as user "foo" at the same time), would that task check for the window in all...

Advatanges of using prototype object to add custom properties and methods to a javascript object

javascript
What is the advantage of using prototype object for adding custom properties and methods against the usage of this property ? For example, this code from http://www.javascriptkit.com/javatutors/proto3.shtml //First, create the custom object "circle" function circle(){ } circle.prototype.pi=3.14159 // create the object method function alertmessage(){ alert(this.pi) } circle.prototype.alertpi=alertmessage Isn't the above...

Compositing premultiplied images using ImageMagick

imagemagick,premultiplied-alpha
I have two images. One is background with no alpha. The other is a white cloud. The alpha of the cloud image is premultiplied with black. When I composite them the white cloud has black in it, so it looks grey instead of white like it should. I'm doing: convert...

Parsing Uneven data/ json object using ng-repeat

javascript,json,angularjs
fiddle here http://jsfiddle.net/prantikv/1nvdzv24/9/ i have some uneven data like so [{ "fname": "Tonja", //common "lname": "Mize", "tel": "(963)784-1098", "address": "3999 Quis Ln", "city": "Sebring", "state": "MI", "zip": 76593 }, { "fname": "Stella", //common "Othername": "Lester", "mobile": "(936)898-2886" }]; notice only the fname property is common between the two objects so...

Missing crashlytics reports for app crashes. When should Crashlytics.start() be called?

android,performance,crashlytics
I've recently started using Crashlytics to monitor my app performance, however, I've noticed several occasions where my app would crash, but no crash report was sent to my dashboard. This article says that it's okay to call Crashlytics.start() inside a Base activity class, but doesn't suggest it as a best...

How to initialise and create object of UITableViewController?

ios,uitableview,uistoryboard,viewcontroller
I want to create object of UITableViewController and want to pass values from ViewController to UITableViewController. But It gives error like "UITableViewController is not key-value coding-compliant for the key superclass." I tried this but won't help: [[MytableViewController alloc] initWithNibName:[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"MytableViewController_identifier"] bundle:[NSBundle mainBundle]]; ...

C++ OpenCL matrix library with temporary elimination

c++,templates,matrix,opencl,viennacl
The armadillo matrix library writes Armadillo employs a delayed evaluation approach to combine several operations into one and reduce (or eliminate) the need for temporaries. Where applicable, the order of operations is optimised. Delayed evaluation and optimisation are achieved through recursive templates and template meta-programming. This means that you can...

IIS UrlRewrite with optional parameters

c#,asp.net,url-rewriting
I want to rewrite a url like: /categories/optional-sub-cat/product or /categories/optional-sub-cat/optional-2nd-sub-cat/product How should I write the regular expression to include optional parameters? <rule name="Products" enabled="true" stopProcessing="true"> <match url="/(.+)/optional-sub-cat/optional-2nd-sub-cat/product" /> <action type="Rewrite" url="products.aspx?cat={R:1}&amp;sub=..." /> </rule> ...

Which node should I push data to in a cluster?

nginx,apache-kafka
I've setup a kafka cluster with 3 nodes. kafka01.example.com kafka02.example.com kafka03.example.com Kafka does replication so that any node in the cluster can be removed without loosing data. Normally I would send all data to kafka01, however that will break the entire cluster if that one node goes down. What is...

How to return the index position and not the value?

c++,return
I have the following int index = 0; for (int i = start; i < end; ++i) { cout << spot.at(i) << ' '; // prints 190 2 94 if (spot.at(i) > spot.at(index)) // finds the greatest value which is 190 so gives back 0 bc spot.at(0) has the highest...

loading other webpage in my site with jquery is not working

javascript,php,jquery,html,css
<script> $(document).ready(function(){ $("#My-page").load("http://www.google.com"); }); </script> <div id="My-page" style="width:900px; height:900px; position: absolute;overflow-x:hidden !important;-webkit-overflow-scrolling:touch !important;"> </div> actually i have tried with iframe to load embed code of my site in another webpage it is working fine in android mobiles and windows pc , when come to ios it is not working ,...

Max function in PHP fails on strings?

php
Given this list.txt file: 9 10 19 Guess what? max(split("\n",$file_handle)) gives me 9 max(explode(PHP_EOL,$file_handle)) gives me 9 Now, on a string: $string = "9 10 19"; max(split("\n",$string)) gives me 19 Updated: When reading from a file, I get strings and max() can't seems to find the correct max when comparing...

R: How to order a data frame by month

r
I've this data frame: year Mes Sesiones 1 2014 Abril 25721 2 2014 Agosto 14851 3 2014 Diciembre 71359 4 2014 Enero 2244 5 2014 Febrero 3149 6 2014 Julio 11540 7 2014 Junio 18648 8 2014 Marzo 10738 9 2014 Mayo 19151 10 2014 Noviembre 149655 11 2014 Octubre...

Large number of operations on double data type producing zero as result

java,floating-point,double
I have a program which multiplies a probability over 500 times, but when I am doing so the output is zero. Should I use some other data type? Please help. Here is the code I am using: double d = 1/80000d; for (int i = 0; i < 500; i++)...

How to change default MVC layout page

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
I'm doing some development where I need to implemented a login form in MVC. I have already created an MVC project in VS2013 which works OK. When creating it, VS already include the forms and configuration to use the LogIn as well as the register views. the thing here is...

Combinations of elements in a dict in python

python,dictionary,itertools
Suppose I have a Ordered Dict of the form d = OrderedDict([('x1', ['x1_0', 'x1_1']), ('x2', ['x2_0', 'x2_1','x2_2'])]) How do I get combinations of the form [('x1_0', 'x2_0'),('x1_0', 'x2_1'),('x1_0', 'x2_2'),('x1_1', 'x2_0'),('x1_1', 'x2_1'),('x1_1', 'x2_2')] P.S. Here I am showing the result for only two variables here but I am looking for a...

How to avoid transparent_hugepage/defrag warning from mongodb?

linux,mongodb,linux-kernel
I'm receiving the following warning from mongodb about THP 2015-03-06T21:01:15.526-0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2015-03-06T21:01:15.526-0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' But I did manage to turned THP off manually [email protected]:~$ cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] [email protected]:~$ cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never]...

How to bring a selected application window from a listbox to front

c#,winforms,c#-4.0,listbox,double-click
I have a windows form application. In which in a listbox, I am showing title of all the opened windows. I have done up to this. Now I want to double click on a title in the listbox.. and this will activate that window and will show upfront. My code...

How to covert .ipynb to slides using nbconvert?

terminal,ipython,ipython-notebook,google-api-python-client
I created ipython notebook and I am be able to convert it to HTML and PDF. But when I tried to convert to it slides it turned out just like HTML on one file. Here is the code I use from a terminal prompt: $ ipython nbconvert --slides Testing.ipynb --post...

how to add / route advertisements into posts and comments on a web application in the form of sponsored links?

ruby-on-rails,ruby
Very new to programming and ruby on rails, working on a CRUD exercise in an app tutorial. The application has posts and comments that are showing properly. The next task is to add native advertising to the posts and comments through sponsored links. Posts and comments are working on the...

css style for div tag height

html,css,html5,css3
I am setting all my div tags' height in pixels. I am having some problems and I think that if I set height in % it will help me. % is working for width, but unfortunately I can't set my div height in %. Here is my CSS where I...

Android RecyclerView Item Separator

android,xml,android-styles,recyclerview,android-recyclerview
I am using RecyclerView with rounded corner, to make it rounded corner I used below XML: view_rounded.xml:- <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#008f8471"/> <stroke android:width="2dp" android:color="#ffffff" /> <corners android:radius="10dp"/> </shape> fragment_main.xml:- <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view"...

Picture File on RESULT_CANCELED

java,android,camera,google-glass
I want to be able to track image file names when a picture has been taken with the default Camera Glassware. This is so I can delete them when finished. I have the following code: ... Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, TAKE_PICTURE_REQUEST); } @Override protected void onActivityResult(int requestCode, int...

How to use Gmail API for sending email in android development

android,email
I need to send email in android. Initially I used android intent for sending email. But every time it is asking me to select the email client. So I moved to the JavaMail API concept. But this API asking username and password in code itself. So my friend suggest me...

Get row count for all tables across dbs and pivot sql server 2012

sql,sql-server,sql-server-2012,pivot-table
I am using the following script to get a row count for all databases These databases are all identical in structure. USE [MyTestDb1]; SELECT 'MyTestDb1'as [Database Name], so.name AS [Table Name], rows AS [RowCount] FROM sysindexes AS si JOIN sysobjects AS so on si.id = so.id WHERE indid IN (0,1)...

Tomcat 8 embedded - ERROR {org.apache.catalina.core.ContainerBase} - A child container failed during start

java,tomcat,java-8,tomcat8,embedded-tomcat-8
I'm using tomcat embedded and when I try to star the server following error get occurred. I'm using tomcat 8.0.20 and jdk8 ERROR {org.apache.catalina.core.ContainerBase} - A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/]] at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at...

how to make json request in haskell?

python,json,haskell
I have a server which accepts json requests and they work fine with python client. I am trying to do the same thing in haskell. For instance my python client has following code conn = JSONRPCProxy("XXX.XX.XX.XX", 5050, "2.0", 120) print conn.request('show_attrs', [{"shortcode":"CODEWORD1","fx":'CD2'}, ["?queryattr", "queryname"]]); I want to send out the...

Emualtor on Android Sutdio and Windows Phone

visual-studio-2012,windows-phone-8,android-emulator,hyper-v,haxm
i think i have a huge problem...actually I'n developing on Android and Windows Phone, first whith Android Studio i dont have nay problems... but with de WP emulator (VS Express 2012 SDK) I have problems with de Hyper-V... I update my OS to Windows 8.1 to solve it...but now Android...

How to update content of one column of a row by another column of another row in Mysql

mysql
I have two tables which have following structure-- table propiedad-- codigo codpropietario 14 17 15 16 16 15 17 8 another table wp_posts ID codigo 1001 17 1002 16 1003 15 1004 8 I want to update codpropietario column of table propiedad with ID column of table wp_posts if condition...

Check if an ember-data model is a subclass of another model

ember.js,ember-data
How do I check if a class is a subclass of another given I only have access to the constructor not the instance? //models/animal.js export default DS.Model.extend({}); //models/dog.js import Animal from './animal' export default Animal.extend({}); Now I need to check if an object is of type Animal. var Animal =...

How to spliit a NSString in iOS [duplicate]

ios,nsstring
This question already has an answer here: Split an NSString to access one particular piece 6 answers I have a NSString like this. 00:03:45 I want to get only this 03:45 part and show in a UILabel How can I do that? Please help me Thanks...

How to set a single background for all panels in CardLayout? [closed]

java,image,swing,jpanel
I am designing an application in Netbeans using CardLayout & I want to use the same background for all of my JPanel objects. I have already tried to accomplish what I want using the method discussed in How to add an image to a JPanel?, however I haven't figured out...

java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.support.v4.app.Fragment

android-fragments,tabs,classcastexception,fragmentpageradapter,pagerslidingtabstrip
I get this error java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.support.v4.app.Fragment when I try to open my activity CuteCollection.java in my app. The strange part is that when I click on the first line (FragmentPagerAdapter.java:122) in the logcat error, it shows me a line from a file in the v4.support...

Python Multithreading - where does keyboard interrupt go

python,multithreading
I'm having trouble with some seemingly simple code which basically starts a thread to read a serial device, and then in the main thread writes some data to the device. The intended shutdown mechanism is a keyboard interrupt, but that doesn't seem to be caught how I expect. readData =...

Brackets code editor doesn't let me close h1 class

html,adobe-brackets
I apologise in advance if I'm missing something very obvious. I'm just getting started on web development. I'm using Brackets and I'm trying to apply a class to h1 using this code: <h1 class="floatright">A Message from the Chief</h1> The problem is, when I type the closing " in floatright, the...

Adding additional IF Functions to formula

excel,excel-formula
=IF(J2325<1,"1",(((J47*J48)+(J426*J427)+(J805*J806)+(J1184*J1185)+(J1563*J1564)+((IF(J1942<1,".0001",(J1942*J1943)))))))/(J2325) I am having trouble adding additional IF functions as needed. I need a formula that can replicate the following portion of the function. IF(J1942<1,".0001",(J1942*J1943) I need to replicate this for J47, J426, J805, J1184, and J1563....

Wait for cmd command to end before continuing

c#,cmd
I run a command from the command window like this: System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C " + command + "> " + userProfile + @"\cmdoutput.txt"; process.StartInfo = startInfo; process.Start(); The next line of code reads the...

Javascript, find index of object by key

javascript,underscore.js
I have an arrya ob objects like so myobj= [{"item1" : info in here},{"item2" : info in here}, {"item3" : info in here}] And I'm trying to modify one with only having it's key to find it. So I'll get send "item1" and I need to pinpoint that object so...

SKAction.runBlock -> missing argument for completion in call

ios,swift,sprite-kit,skaction
I'm quite new to Swift. I'm trying to run a block of animation code forever. What am I doing wrong here? It keeps complaining about "missing argument for completion in call". func randomCGFloat() -> CGFloat { var temp = CGFloat(arc4random_uniform(UInt32(10)))/10 println(temp) return temp } ...

How to Repeat Music in Swift

swift,avfoundation,music
I would like to know how can I replay my background music forever, right now when the app loads the music begins but when it ends all is quiet, how can I make it to replay all the time. I am using AVFoundation Framework. Declaration: var BackgroundMusic = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath:...

Generate context free grammar for the following language:

grammar
The set of string from the alphabet {j,k} where the string can be reversed and then all j's changed to k's and all k's changed to j's. For example "jjkk" would be in the language because when you reverse it: "kkjj" and when you flip all of the characters to...

Output( ) from a Set class with Singly Linked List Hash Table

java,set,hashtable,singly-linked-list
I have code that I have been working on going on 10 hours now, and for the life of me, I am unable to get the output( ) of my Set.java to work. Unfortunately I am not allowed to just import the Iterator or HashTable classes from java library. Any...

How to retain page labels when concatenating an existing pdf with a pdf created from scratch?

pdf,itext
I have a code which is creating a "cover page" and then merging it with an existing pdf. The pdf labels were lost after merging. How can I retain the pdf labels of the existing pdf and then add a page label to the pdf page created from scratch (eg...

Trouble Parsing Text using BeautifulSoup and Python

python,selenium,web-scraping,beautifulsoup,phantomjs
I am trying to retrieve the comment section on regulations.gov pages. An example is the paragraph "Restrictions on Proprietary Trading... with free market driven valuations." on http://www.regulations.gov/#!documentDetail;D=OCC-2011-0014-0032. I am using BeautifulSoup and Python and have the following code: from bs4 import BeautifulSoup from selenium import webdriver driver = webdriver.PhantomJS() driver.get(http://www.regulations.gov/#!documentDetail;D=OCC-2011-0014-0032)...