input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Functions and List Index Out Of Range <p>I'm working on a simple yahtzee style dice game for class but I keep running into issues. Namely right now I'm having an issue with lists. I keep getting </p>
<pre><code> File "C:/Users/u1069284/Desktop/HW3_LandonShoaf.py", line 90, in scoring
counts[value] = counts[value]... | <p>Try this : </p>
<pre><code>counts = [0]*7
for value in dice:
counts[value] += 1
</code></pre>
|
having issues with school assignment <p>there are some crash bugs in this code that i am supposed to find but i am having issues finding them i have spent quite awhile looking. i am sure that it is something easy that i am missing. when i run the code in visual studio 2012 i get and array subscript error </p>
<pre><co... | <p>You declared a</p>
<pre><code>array <Wheel, 3> slotMachine;
</code></pre>
<p>Afterwards you iterated through this array as follows:</p>
<pre><code>for (int i = 1; i < 4; i++)
{
slotMachine[i].position =
</code></pre>
<p>This code will access <code>slotMachine[1]</code> through <code>slotMachine[3]</... |
Analyzing Graham Scan Algorithm of Convex Hull <p>I have made a code to implement Graham Scan algorithm of convex hull. I have tested the program by generating some test cases. In all cases it gives accurate result. But My question is, is it possible to generate some tricky test cases when the program may fail to give ... | <p>As Sascha answered in a comment, it is impossible to help you generate tricky test cases or to know if that is possible without knowing how you implemented the algorithm.</p>
<p>The algorithm itself is of course proven to be correct and to solve the problem. So it's only about testing that your implementation does ... |
What ? SDL won't open window? <pre><code>#include <iostream>
#include <SDL2/sdl.h>
int main(int argc, char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWindow("Fen", 640, 480, 640, 480, SDL_WINDOW_SHOWN);
... | <p>Actually, your window has been created. You can see the cmd application icon in OS X dock. </p>
<p>The real problem you can't get a positive feedback is that this window is empty and displays nothing. The following codes will fill it white.</p>
<pre><code>SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWi... |
Inserting data into a Table row using Django ORM <p>I am currently learning about django orm and playing with this structure</p>
<pre><code>class Album(models.Model):
artist = models.CharField(max_length=128, unique=True)
title = models.CharField(max_length=128, unique=True)
genre = models.CharField(max_le... | <p>you can get an instance of saved object by </p>
<pre><code> model_obj = Album.objects.get(artist ="Madona")
</code></pre>
<p>and after getting an object you can create Song object and save it.</p>
<pre><code> song_obj = Song(album=model_obj, title="SongA")
song_obj.save()
</code></pre>
|
How to make interactive option buttons <p>This is what I'm trying to achieve: <a href="http://i.stack.imgur.com/ji2JO.png" rel="nofollow">buttons</a>.</p>
<p>I can't figure out how to make the buttons contain form data and have only the selected button post to PHP when I click submit.</p>
<p>Here's what I have so far... | <p>The problem is that your buttons have an <code>onclick</code> listener but the listener is also triggered by events on child elements.
So you can click the button but not the checkbox and it changes its color without modifying the value.</p>
<p>You should use an label instead and with CSS3 you can make it without J... |
Python: Theory as to why I can't Do: print(i.extend(j)) <p>Python Theoretical Question
I'd like to learn theory behind why "print(i.extend(j))" DOESN'T work.
It's OUTPUT is: "None".
print(j) DOES work (It's OUTPUT is: "[4, 5, 6, 7, 8, 9]")</p>
<pre><code>i = [1, 2, 3]
j = [4, 5, 6]
k = [7, 8, 9]
# I'd like to learn... | <p>The answer is simple - </p>
<p>extend doesn't return anything, and any function that doesn't return a value is taken to have returned None.</p>
|
Symfony3 - multiple Entity Managers and Connections <p>I tried to create an entity from a table in a pre-existing database :</p>
<pre><code>php bin/console doctrine:mapping:import --force AppBundle yml --filter="someTable"
</code></pre>
<p>But a message showed up stating :</p>
<blockquote>
<p>Table someTable has n... | <p>Sorry, I goofed on my previous answer.
How about you try the command like this instead:</p>
<pre><code>php bin/console doctrine:mapping:import "AppBundle" yml --em=forMapping --filter="someTable"
</code></pre>
<p>Does it make a difference? I see from a command line using the --help, it show in that order.</p>
|
Prevent browser freezing and crashing for long time calculation <p>I need check in my database names who are duplicated and change this name to avoid duplicates. I using script suggested by @Jefré N. </p>
<pre><code>function eliminateDuplicates() {
var repeats = {};
var error = false;
//cache inputs
... | <p>here is a solution using OODK-JS to calculate the sum of an array of 1.000.000 entries through webworkers.</p>
<p>This solution implements the producer/consumer design pattern using the SynchronizedQueue foundation class: the producer (main thread) generate a task for each chunk of the array and add it to queue. Th... |
jonesforth segmentation fault <p>System I'm on:</p>
<pre><code>/tmp/jonesforth $ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
</code></pre>
<p>This is a 32-bit system.</p>
<p>Clone from the annexia repository:</p>
<pre><code>git clone git://git.annexia.org/git/jonesforth.git
</code></pre>
<p>The build goes OK:</p>
<pr... | <p>Removing <code>-Wl,-Ttext,0</code> from the Makefile entry for <code>jonesforth</code>:</p>
<pre><code>jonesforth: jonesforth.S
gcc -m32 -nostdlib -static $(BUILD_ID_NONE) -o $@ $<
</code></pre>
<p>seems to help. The build succeeds:</p>
<pre><code>/tmp/jonesforth $ touch jonesforth.S
/tmp/jonesforth $ mak... |
Android - OkHTTP requests <p>I am using HttpUrlConnection for doing requests to my mysql db using webservices. With HttpUrlConnection I can execute all my requests in background so the main thread don't get overloaded and start skipping frames.</p>
<p>With okHttp how does this is achieved? How do I make a request with... | <blockquote>
<p>With okHttp how does this is achieved? </p>
</blockquote>
<p>Typically, you let it handle the background thread for you, using <code>enqueue()</code> for asynchronous operation:</p>
<pre><code> private final OkHttpClient client = new OkHttpClient();
public void run() throws Exception {
Reque... |
How do I loop through a complicated array of JSON objects with arrays inside it and dynamic keys? <p>How do I loop through this <code>filteredResults</code> observableArray given that all the first keys e.g. Basic Information and Guarantees and Debt Subordination are dynamic and each key is a reference to an array of o... | <p>It works here:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>self = {};
self.filteredResults = ko.observableArray([
{
"Basic Information": [
{
... |
JavaScript text wont display <p>I've been working on a simple matching puzzle game for a little while now. Currently I have been able to have a countdown time and the number of matching tiles displayed as a text and I'm trying to create one for the best time completed (basically how fast the person completed the puzzle... | <p>Apparently the issue I was having was that the x and y position of the text was causing it to appear behind everything else.</p>
|
StapleofLife.com is currently unable to handle this request. HTTP ERROR 500 <p>Can anyone please check what the problem is with the domain- <a href="http://stapleoflife.com/" rel="nofollow">http://stapleoflife.com/</a>??</p>
<p>Home page is not accessible but subdirectory when typed is loading fine.
Example: <a href="... | <p>The Problem is solved.
It was due to bad template.
I see online a lot of googlers searching for this problem.</p>
<p>The problem is either from the recent plugins or theme installation.</p>
<p>Hope it helps for few facing the problem.</p>
<p>P.S : try to Deactive suspected themes or plugins and it shall work.</p... |
How to use different package names between flavors? <p>I'm trying to create a single project with 2 flavors: free and pro (versions).</p>
<p>My app is already in PlayStore with different packages (E.g.: com.example.appfree and com.example.app)</p>
<p>This is my build.gradle:</p>
<pre><code>defaultConfig {
applica... | <p>With the new Android Gradle build system, you can easily build multiple different versions of your app; for example, you can build both a "free" version and a "pro" version of your app (using flavors), and these should have different packages in the Google Play store such that they can be installed and purchased sep... |
How to revert MySQL database update (PHPMyAdmin) <p>I accidentally inserted the same value in the same field for many rows as illustrated in the image below:</p>
<p><img src="http://i1283.photobucket.com/albums/a553/brett_miller2/pic_zps1zfiknus.png" alt="mysql problem"></p>
<p>I updated my table and the same file na... | <p>Generally what I like to do when doing a <code>delete</code> statement that isn't by primary key is to select the result first..</p>
<p><code>SELECT * FROM table WHERE name='Sprouts';</code> </p>
<p>If that result set is correct, then you can feel fairly safe swapping in the <code>delete</code> </p>
<p><code>DELE... |
gulp-concat seems to be doing nothing <p>I am attempting to concat a few javascript files as part of my gulp build. I am following the "documentation" as much as possible, but there aren't many answers there. Here are the commands I am using.</p>
<pre><code>gulp.task('concatMe', function ()
{
console.log('I am in ... | <p>In your gulp file, have you included the below line?</p>
<pre><code>var plugin = require("gulp-load-plugins")();
</code></pre>
<p>Then you need to modify your code to:</p>
<pre><code> return gulp.src(['/app/core/threejs/*.js'])
.pipe(plugin.concat('new.js'))
.pipe(gulp.dest('./dist/'));
</code></pre>
<p... |
threading.Lock() performance issues <p>I have multiple threads:</p>
<pre><code>dispQ = Queue.Queue()
stop_thr_event = threading.Event()
def worker (stop_event):
while not stop_event.wait(0):
try:
job = dispQ.get(timeout=1)
job.waitcount -= 1
dispQ.task_done()
ex... | <p>About the only way to "optimize" threading would be to break the processing down in blocks or chunks of work that can be performed at the same time. This mostly means doing input or output (I/O) because that is the only time the interpreter will release the Global Interpreter Lock, aka the GIL.</p>
<p>In actuality ... |
Getting two issues while using stored procedure in MySQL <p>Below is the sample code of my Stored Procedure in which I am working on for interest calculation. This code is not executable because according to finding its getting issue while defining creating temporary table block before the cursor declaration but if I d... | <p>Some notes about what is possible with <code>AUTO_INCREMENT</code> setup:</p>
<pre><code>create table t1
( ai int not null auto_increment,
b int primary key
)ENGINE=InnoDB;
-- Error 1075: AI must be a key
create table t2
( ai int not null auto_increment,
b int primary key,
key(ai)
)ENGINE=InnoDB;
... |
pip install jupyter: "Unable to locate finder for 'pip._vendor.distlib'" <p>I'm trying to install <code>jupyter</code> to use the IPython Notebook under Windows. However, if I run <code>pip install jupyter</code> I'm getting</p>
<pre><code> Using cached pyzmq-15.4.0.zip
Requirement already satisfied (use --upgrade to... | <p>Try uninstalling pip and installing get-pip.py. It appears to be a bug in the 3.6 version for Windows. <a href="https://github.com/pypa/pip/issues/3964" rel="nofollow">https://github.com/pypa/pip/issues/3964</a></p>
|
How to edit many objects at the same time in django? <p>Well, usually, when I like edit one object I using instance and get_object_or_404, something like this:</p>
<pre><code>question = get_object_or_404(Question, id = id)
form = FormQuestion(request.POST, instance=question)
if request.method == 'POST':
if form.i... | <p>First place, is much better you develop in CBV(Class Based Views), where you will do the view more easily.</p>
<p>I had a problem around your problem, follow how do it:
<a href="http://stackoverflow.com/questions/39534543/django-inlineformset-factory-how-to-edit">Django - inlineformset-factory (How to Edit)</a>
And... |
Optimizing Durandal's build process <p>The <a href="https://github.com/RainerAtSpirit/HTMLStarterKitPro" rel="nofollow">HTML starter kit pro</a> for Durandal contains the following grunt task for optimizing a build:</p>
<pre><code>durandal: {
main: {
src: ['app/**/*.*', 'lib/durandal/**/*.js'],
opt... | <p>Yes, You are right that <code>main.js</code> includes everything needed to run the app. The reason You are getting <code>require is not defined</code> is because, if you closely look at the <code>index.html</code> file you will see that the <code>index.html</code> refers looks for the file in <code>/lib/require</cod... |
Android Annotations EActivity isn't getting one of the Extras <p>I'm using Android Annotations on my <code>NavControllerActivity</code> which has two <code>@Extras</code>. One extra is a parcelable custom class, <code>BaseEntity</code> and the other is a <code>java.lang.Class</code> object (which is Serializable). Howe... | <p>I made some code changes which fixed the problem and here's my assumption about what was really going wrong.</p>
<p>The error I made was in my Parcel in/out code. I was writing 20 fields to the Parcel, but when reading from the Parcel I was only reading 15 fields. Making sure my in-code matched my out-code made the... |
counting substring in a string <p>Python Infant here.
Trying to count no. of times 'jam' occur at the string "s".
The output is supposed to be 3 here, but I only see 1.What am I doing wrong here?</p>
<pre><code>s='jamrejaminjam'
word ='jam'
count =0
for letters in s:
if letters in word:
count =+1
print(cou... | <p>Try this.</p>
<pre><code>s='jamrejaminjam'
word ='jam'
count =0
for index, letters in enumerate(s):
if word == s[index:index+len(word)]:
count += 1
print(count)
</code></pre>
|
Microsoft.Net.Http library conflict between MVC project and PCL <p>I am using Microsoft HTTP Client Libraries 2.2.29 for my WebApp and PCL.</p>
<p>Here is the link: <a href="https://www.nuget.org/packages/Microsoft.Net.Http/" rel="nofollow">https://www.nuget.org/packages/Microsoft.Net.Http/</a></p>
<p>PCL is using <s... | <p>I know this is not a proven solution but, I had to remove projects from solution one by one and add back in. Then I re-mapped project dependencies by right clicking on projects and choosing dependencies on them. It seems like working right now. It might be a problem with VS build order when more than 3 projects are ... |
c# bringtofront() and senttoback() not working <p>I am new to c# and I'm trying to understand z-index concept. So far I have a simple form created using ConsoleApplication project in visual studio. There are 3 cs files. Here's the code:</p>
<p>In Algorithm.cs (inherited from UI.cs):</p>
<pre><code>using System;
us... | <blockquote>
<p>Why doesn't it appear on the bottom panel even after I used bringtofront() ?</p>
</blockquote>
<p>Because you've placed it outside the visual boundary of the panel:</p>
<pre><code>test.Location = new Point(0, 800);
</code></pre>
<p>That sets the position of the button to a horizontal offset of <cod... |
why two points can't show in the figure (matplotlib)? <p>Figure1 show data points<a href="http://i.stack.imgur.com/j7b9r.png" rel="nofollow">1</a></p>
<p><a href="http://i.stack.imgur.com/j7b9r.png" rel="nofollow">1</a>:<a href="http://i.stack.imgur.com/j7b9r.png" rel="nofollow"><img src="http://i.stack.imgur.com/j7b9... | <p>With the help of Andras Deak, I use <code>plt.ylim([0, max(r)+1])</code>to solve this problem.Thanks.</p>
|
Redirecting all requests to a static page with nginx <p>I'm trying to redirect all the requests hitting my page to an image. Inside my default.conf I have this:</p>
<pre><code>server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
tr... | <p>The location section must account for root such that : </p>
<pre><code> location / {
root /usr/share/nginx/html/;
try_files $uri /10343632.jpeg;
}
</code></pre>
<p>and it'll work! </p>
|
create string array with leading spaces <p>Is there a way where I can initialize an empty string array and then later ask for an input from user which is saved into the string array leaving the empty leading spaces if the input is smaller.
I am planning on using a longer string array with addition spaces so that I can ... | <p>Your question is inconsistent, you ask about leading whitespace but your example shows trailing whitespace. If you mean trailing whitespace, you could do it this way:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#define BUFFER_SIZE 25
int main() {
char string[BUFFER_SIZE];
memset(st... |
HTML5 <section> tag clarification with example <p>I've read up a lot on the usage of <code><article></code> and <code><section></code>. I think I get the <code><article></code> part. But with <code><section></code> there is still confusion. I've read <a href="http://html5doctor.com/the-section-e... | <p>The <code><section></code> element is used to represent a group of related content. This is similar to the purpose of an <code><article></code> element with the main difference being that the content within a <code><section></code> element doesnât necessarily need to make sense out of the context... |
undefined method `number' for nil:NilClass <p>I am having problems display an attribute in a belongs_to relationship. Lease belongs_to Unit. Unit has a column "number" in the db. When I try to display this attribute on the lease show page, it gives me an error of undefined method `number' for nil:NilClass. I feel like ... | <p>Your model may have unit_id attribute, but how about <code>units</code> that does not have that record with <code>id = 1</code> have You checked?</p>
<p>Quick (dirty) fix:</p>
<pre><code><%= @lease.unit.number unless @lease.unit.nil? %>
</code></pre>
|
User permissions per directory in static cloud storage based website <p>My issue is that I want to host my website in a bucket on either Amazon S3 or Google Cloud Storage. In my website, each user has his/her own directory that they should have read/write permissions to. But I don't want each user to have read/write pe... | <p>For scenario #1 on Google Cloud Storage, you can try out <a href="https://cloud.google.com/compute/docs/load-balancing/http/using-http-lb-with-cloud-storage" rel="nofollow">Google Cloud Load Balancer's support for Google Cloud Storage</a>, currently in Alpha. You would have individual buckets per user with the right... |
Android project with an encapsulated project <p>I don't know if is possible to realize what I'm going to write, but I will try to explain as better as I can.</p>
<ol>
<li><p>Create an Android Project with its Activities, we can call it, for example, <strong>ModuleProject</strong></p></li>
<li><p>Create a second Androi... | <p>Remove the applicationId variable from the library's build.gradle file.</p>
|
Installation of xamarin in windows 7 failed <p>I am trying to install xamarin on my system, But got the below error:</p>
<p>My System details:
OS - Windows 7 (64 bit)
Visual Studio - 2015 community edition</p>
<blockquote>
<p>Installation of 'Intel® HAXM' failed with more than one exception (attempt 3)
Errors wh... | <p>You can download and install HAXM from Intel directly,</p>
<p><a href="https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager" rel="nofollow">https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager</a></p>
<p>and then re-run the Xamarin... |
Tidy nested json tree <p>This comes up a lot when dealing with API's. </p>
<p>Most of the time, to do real analysis, I'd like to get my dataset tidy, but typically, this requires a solution for each type of tree, rather than something more general. </p>
<p>I figured it would be nice to have one function that generate... | <p>I struggled in similar situations, but the <code>tidyjson</code> package has bailed me out time after time when dealing with nested JSON. There's a fair amount of typing required, but the <code>tidyjson</code> functions return a tidy object. Documentation here: <a href="https://github.com/sailthru/tidyjson" rel="nof... |
Search for a particular string, extract a number and add few strings below containing that number <p>This is how my text file looks:</p>
<pre class="lang-none prettyprint-override"><code>!
hello_group serial_1234
hello-domain serial_1234
!
!
hello_group serial_2345
hello-domain serial_2345
!
</code></pre>
<hr>
<p>Th... | <h3>Using sed</h3>
<p>Try:</p>
<pre><code>sed -E 's/hello-domain serial_([[:digit:]]+)/&\nmy_content xxxx.\1\nmy_another_content yyyy.\1/' file
</code></pre>
<p>For example, with your input data:</p>
<pre><code>$ sed -E 's/hello-domain serial_([[:digit:]]+)/&\nmy_content xxxx.\1\nmy_another_content yyyy.\1/... |
javascript interpreter of native executable <p>I'm wondering about running Windows or gnu/Linux executables from within a webpage. Just to be clear, I am NOT talking about any sort of Remote Desktop thing. What I am envisioning is a user fetching the website, which will come with a hidden file that is executable code... | <p>As @Tibrogargan mentioned in the comments, this is indeed asking about building a VM in Javascript. <a href="https://en.wikipedia.org/wiki/Fabrice_Bellard" rel="nofollow">Fabrice Bellard</a>, the one behind FFMpeg and QEmu, has written a VM in Javascript. You can play with it at <a href="http://bellard.org/jslinux/"... |
How to develop and deploy a back-end server for my Android application? <p>I am developing a voting application based on Android. This app will be used to create user accounts, receive notifications and caste vote.
I want to develop a back-end server for this application which will also have an Administrator interface ... | <p>The scope of your project is far too large if you're wanting sessions, administration views, E-mail integration, encryption, etc., without even knowing how it would all interact, or even what language to use.</p>
<p>As for what languages / services you would need, it varies for each task:</p>
<ul>
<li><p>For admin... |
Grub config, and error on duall boot Ubuntu + MacOS <p>I am folowing the post <a href="http://askubuntu.com/questions/623767/duel-boot-ubuntu-and-hackintosh?newreg=ead77f77ede84f3f9202a5a76d8ab8c3">askubuntu.com</a></p>
<p>And everything appears normal, no errors on set up, including Grub Boot Screen, that shows opti... | <p>I would recommend using Clover instead for dual/multi booting. If you want to boot MacOS from grub you need to boot to MacOS loader first (Clover, Chameleon) and then from one of them you will boot macOS. <a href="http://www.tonymacx86.com/" rel="nofollow">http://www.tonymacx86.com/</a> might help a lot in this rega... |
Set variable to return of callback listener <p>I'm using firebase to handle auth in my application. Firebase has a listener that executes a callback anytime the authentication status changes. I have that in a firebase utils file:</p>
<pre><code>export default {
...
authChanged: (callback) =>{
retur... | <p>You can only use <code>yield</code> inside a generator function. And unlike variables and functions, <code>yield</code> is not available inside a nested function, which your callback function is.</p>
<p>You can just dispatch the actions with normal dispatch. </p>
|
Utilizing meta-data in Elasticsearch <p>Can Elasticsearch utilize meta-data to improve queries? For example,</p>
<ul>
<li>popularity of an object (number of people who requested it)</li>
<li>remembering previous search term (e.g. if someone searched doggg then chose the dog page, then the next time someone searches do... | <p>This kind of metadata can be used in a positive feedback system to improve search but Elasticsearch does not by itself store this kind of data; you will need to build a system to do this. As a couple of examples:</p>
<blockquote>
<p>popularity of an object (number of people who requested it)</p>
</blockquote>
<p... |
iOS10 WKWebview - evaluateJavaScript("document.height") return nil <p>I'm developing a application for iOS(Swift2.3).</p>
<p>I'm afraid my expressions may be rude or hard to read, because I'm not so good at English. Sorry for any inconvinience I may cause you.</p>
<hr>
<p>In my app, I need to get height of webpage. ... | <p>try this:</p>
<pre><code>let javascriptString = "" +
"var body = document.body;" +
"var html = document.documentElement;" +
"Math.max(" +
" body.scrollHeight," +
" body.offsetHeight," +
" html.clientHeight," +
" html.offsetH... |
T-SQL multiple pivot statements without cartesian result <p>I have the T-SQL statement below where I am trying to pivot on 2 different data elements, studentname and instrumentname. The results should have only 1 line per school and the students should be pivoted across the top along with their instruments.</p>
<p>Unf... | <p>This works, but is a little messy, especially to dynamically create, I was hoping for a cleaner option. I can't even think of how to do this with case statements, not sure if that would be much cleaner or not. Correct answer is still up for grabs if someone has a cleaner more readable solution. Thanks.</p>
<pre><co... |
How to force pandas read_csv to ignore semicolon in between actual delimiter? <p>In a csv you have the following - as you can see in the third row the second column has a semicolon -</p>
<pre><code> /path/to/file,2,9/15/2016
/path/to/file,3,9/15/2016
/path/to/file,2;3,9/15/2016
</code></pre>
<p>So pandas read... | <p>Can you also provide your code?
I've created the following csv and py files, there is no delimiter in the code and it worked.</p>
<p>info.csv</p>
<pre><code>path,number,date
/path/to/file,2,9/15/2016
/path/to/file,3,9/15/2016
/path/to/file,2;3,9/15/2016
</code></pre>
<p>test.py</p>
<pre><code>import pandas
t = p... |
section_id: nil WHEN IT SHOULD BE section_id: 1 <p>I'm following a LYNDA.COM tutorial with Kevin Skoglund. I was following along in the "Many-to-many" associations: Rich" video when I had a problem. The last line I ran (<code>section.section_edits</code>)
resulted in the following:</p>
<pre><code>SectionEdit id: 6, ad... | <p>Checking your console, clearly here is a problem:</p>
<pre><code>irb(main):003:0> section = Section.create(:name => "Section One", :position => 1)
(1.0ms) BEGIN
(1.0ms) ROLLBACK
=> #<Section id: nil, page_id: nil, name: "Section One", position: 1, visible: false, content_type: nil, content: n... |
How can I get two form-group div align in vertically? <p>How can I get these two divs to align vertically?
No matter what kind of col-ms-sizing I do the two input groups will not align on the vertical line.
<a href="http://i.stack.imgur.com/0Lurv.jpg" rel="nofollow">pls check the image here.</a></p>
<p>Here's my code ... | <p>Bootstrap has a default padding on the col-xx-xx that you use..
so col-md-6 used twice will have more padding than col-md-12 used once..
you could adjust the padding by simply adding an additional inline style.</p>
<p>Just use <code>padding-left:10px</code> in your case.. the default is 15 px</p>
<p><a href="https... |
Rails 4 HTTParty Docusign api invalid base 64 string <p>Any and all help is greatly appreciated! </p>
<p>I am sending an envelope request post using HTTParty to the Docusign api and keep getting an error that states:
<code>The input is not a valid Base-64 string as it contains a non-base 64 character</code></p>
<p>He... | <p>You are setting <code>"Content-Transfer-Encoding" => "Base64"</code>, in your headers. Remove that.</p>
|
Why can I create impossible intersection types in Typescript? <p>The below type definition is unimplementable, but the compiler gives me no warnings when defining it. </p>
<pre><code>// No type error
type impossible = 0 & string[] & 'anything'
</code></pre>
<p>A value cannot be a number and string[] and a... | <p>Anders Hejlsberg <a href="https://github.com/Microsoft/TypeScript/pull/3622" rel="nofollow">provided</a> the following rationale:</p>
<blockquote>
<p>It is possible to intersect primitive types (e.g. <code>string & number</code>), but it is not possible to actually create values of such types (other than <co... |
Python: Counting words from a given file starting with 'L' <p>I am new to python.I want to know how to count the number of words <strong>starting with a particular letter say 'L'</strong> from a text file.</p>
| <p><a href="https://docs.python.org/2/library/stdtypes.html" rel="nofollow">str.startswith(prefix[, start[, end]])</a> </p>
<p>Give this a shot but import your file there are also a few other ways. </p>
<pre><code>list = ["apple", "bannana", "custard", "shoe", "ant", "police", "python"]
newList = []
for word in list... |
Prediction of 'mlm' linear model object from `lm()` <p>I have three datasets:</p>
<p>response - matrix of 5(samples) x 10(dependent variables)</p>
<p>predictors - matrix of 5(samples) x 2(independent variables)</p>
<p>test_set - matrix of 10(samples) x 10(dependent variables defined in response)</p>
<pre><code>resp... | <p>You are stepping into a poorly supported part in R. The model class you have is "mlm", i.e., "multiple linear models", which is not the standard "lm" class. You get it when you have several (independent) response variables for a common set of covariates / predictors. Although <code>lm()</code> function can fit such ... |
Errors in assets -- js and css -- when running a phoenix/elixir app with the default setting with brunch <p>I have a lot of "Uncaught ReferenceError:" and "jquery.waypoints.min.js:7 Uncaught TypeError: Cannot read property" kinds of errors in my phoenix/elixir app. This is because of the wrong order in which the js fil... | <p><strong>Option 1:</strong></p>
<p>If you want to change the order the files are concatenated, you can do this inside your <code>brunch-config.js</code>:</p>
<pre><code>exports.config = {
files: {
javascripts: {
joinTo: "js/app.js"
order: {
before: [
"web/static/vendor/js/jquery-... |
Wrapping a reoccuring collection of elements in a div <p>This is kind of a two part question - I have an HTML page where I need to take reoccurring groups of elements such as:</p>
<pre><code><h2>1</h2>
<p>foo</p>
<p>bar</p>
<h2>2</h2>
<p>fizz</p>
</code></pre... | <p>You can use <code>Array.from()</code>, <code>.forEach()</code> loop to iterate <code>h2</code> elements collection, check if <code>.nextElementSibling</code> <code>.tagName</code> is <code>"P"</code> in <code>while</code> loop, if <code>true</code>, push elements to an array. </p>
<p>Use <code>.forEach()</code> on ... |
Android - How can I convert a date/time string into date and time integers? <p>I am trying to convert back a stored date/time string in the format of (MM dd, yyyy, HH:mm [AM/PM]), I followed this <a href="http://stackoverflow.com/questions/7363112/best-way-to-work-with-dates-in-android-sqlite">post</a> to create the st... | <p>First you have to parse the date string with the current pattern and then format it with your desired pattern.</p>
<p>For Example, if your current date string is like this [10/10/2016 14:30].</p>
<pre><code>String curDate = "10/10/2016 14:30";
SimpleDateFormat curDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm... |
Why const void* still be updated in C? <p>I have some code with <code>const void*</code> as below:</p>
<pre><code>#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main()
{
const int p = 10;
char s[] ="I am newbie";
const void *vp;
vp = &p;
*(int*)vp = 11... | <p>You effectively removed the <code>const</code> when you got a pointer to your <code>int</code>, cast the <em>pointer</em> to something without the <code>const</code>, and then changed the value of what <em>that</em> points to.</p>
<pre><code>*(int*)vp = 11;
</code></pre>
<p>You can cast a pointer type to any other... |
How to detect multiple screen touches with Processing for Android <p>I am using the Processing platform to prototype an app for Android, but I am having trouble detecting multiple screen touches at the same time. How does one detect the locations of two screen touches that happen simultaneously? </p>
| <p>The first thing you need to do is some research. Try googling "Android Processing multitouch" for a ton of results, including these:</p>
<ul>
<li><p><a href="http://stackoverflow.com/questions/17166522/can-processing-handle-multi-touch">Can Processing handle multi-touch?</a></p></li>
<li><p><a href="https://forum.p... |
JavaScript Variable wont stop reverting back to 0 <p>I'm currently working on a small tile matching game and have made it so that each time you complete the game the variable "bestTime" will store the amount of time you took to complete the session. The variable "bestTimeTxt" will then take the value and display it in ... | <p>In your code, inside gameover method, I see you are using history.go(0) on play again link.</p>
<p>Technically, history.go(0) means to refresh the page and all your variables no matter the scope are set to the initial values.</p>
<p>If you want to retain the best score for the session and continue, use the replay ... |
Unregistered member of array in length property JS <p>I came across this code that is used to keep both forward and reverse reference in an array:</p>
<pre><code>var arr = [];
arr[arr['A'] = 0] = 'A';
arr[arr['B'] = 1] = 'B';
// On node interpreter
arr // [ 'A', 'B', A: 0, B: 1 ]
arr["A"] // 0
arr["B"] // ... | <p>Storing a value with a string key into an array does not actually modify the array. It only adds a dynamic field to the <code>Array</code> object, unlike storing with a numeric index, which actually pushes a value into the array.. <code>Array.length</code> only reflects the number of elements in the array, as manage... |
How to use native-base icons in react-native-navigation <p>In my current react native app.</p>
<p>I am using react-native-navigation for general app navigation.</p>
<p>On the other hand, I would like to use native-base for some basic UI elements.</p>
<p>My question is, how do I pass a <code><Icon name="ios-search... | <p><code>getImageSource</code> function will be added to the Icon in next version of Native Base.</p>
<p>For now, you can import any Icon family directly from react-native-vector-icons and use <code>getImageSource</code> from there.</p>
<pre><code>import Ionicons from 'react-native-vector-icons/Ionicons';
...
...
ge... |
Declare many functions as friends of a class <p>How to conveniently declare many template functions as friend function of a template class?</p>
<p>Example:</p>
<pre><code>template <typename T>
void funct1(MyClass<T> & A); //1.forward declaration.
template <typename T>
class MyClass{
protect... | <p>Yes! You can make them <code>static</code> member functions of a <code>class</code>, and make that <code>class</code> a <code>friend</code>. </p>
<pre><code>template <typename T>
class MyClass{
protected:
T a;
friend class MyFunctions;
}
</code></pre>
|
swift 3 CGPathAddCurveToPoint <p>I'm trying to update code to swift 3 but I can't find anything about CGPathAddCurveToPoint, how can I fix the error?</p>
<p>path is a CGMutablePath</p>
<pre><code>CGPathAddCurveToPoint(path, nil, 10, 10, 20, 20, 30, 30)
</code></pre>
<p>error: nil is not compatible with expected argu... | <p>Please read the CGMutablePath docs:</p>
<p><a href="https://developer.apple.com/reference/coregraphics/cgmutablepath" rel="nofollow">https://developer.apple.com/reference/coregraphics/cgmutablepath</a></p>
<p>You will find:</p>
<pre><code>func addCurve(to end: CGPoint, control1: CGPoint, control2: CGPoint,
t... |
Regular expression can be used to express all kinds of lexical parser requirements? <p>I'm learning Compilers Principles recently. I notice all examples from text books describes a language lexcial parser using "lex" or "flex" with regular expressions to show how to analyze input source files. </p>
<p>Does it indicate... | <p>Most lexemes in most languages can be identified with regular expressions, but there are exceptions. (When it comes to parsing computer languages, there are always exceptions. Without exception.)</p>
<p>For example, you cannot match a C++ raw string literal with a regex. You cannot tell without syntactic analysis w... |
Facebook Like Button With "Large" Property Renders as Small on Mobile <p>So via the <a href="https://developers.facebook.com/docs/plugins/like-button" rel="nofollow">Facebook Like Button Configurator</a> I generated the code to use a large facebook Like button with a counter.</p>
<pre><code><div class="fb-like" dat... | <p>Turns out this had nothing to do with mobile, but rather with being logged into facebook or not. I just happen to not be logged into facebook on my mobile browsers at the time of testing.</p>
<p>Users who are not logged into facebook may see the old like button which didn't support the new "large" parameter. An off... |
combine two php script into single one <p>Good morning, Everybody...</p>
<p>I want to combine two php code into single one, in order to reduce php multiple queries.</p>
<p>My first PHP script is like this:</p>
<pre><code><?php
include('wp-config.php');
$q = "SELECT CONCAT(a1,a2,a3,' x ',a,' x ',a4,a5,a6) FROM t... | <p>I think you're looking for "UNION ALL" :</p>
<pre><code>$q = "SELECT
CONCAT(a1,a2,a3,' x ',a,' x ',a4,a5,a6)
FROM
table1
UNION ALL
SELECT
CONCAT(a1,a2,a3,' x ',a,' x ',a4,a5,a6)
FROM
table2
ORDER BY id DESC LIMIT 1"
</code></pre>
<p>That will co... |
Python3 change string to byte <p>I'm using Python3.5 and I want to change <code>\xe1BA\x06\xbe\x084</code> into <code>b'\xe1BA\x06\xbe\x084'</code></p>
<p>But using <code>'\xe1BA\x06\xbe\x084'.encode('ascii')</code> or <code>'\xe1BA\x06\xbe\x084'.encode('utf-8')</code>doesn't work.</p>
<p>In <code>.encode('utf-8')</c... | <p>Use the <code>latin1</code> codec.</p>
<pre><code>>>> '\xe1BA\x06\xbe\x084'.encode('latin1')
b'\xe1BA\x06\xbe\x084'
</code></pre>
<p>The reason why this works (and is the way it is) because originally those bytes sequences were defined to be those characters by the <a href="https://en.wikipedia.org/wiki/I... |
How to remove white background of an image - java <p>I would like to remove white background of an image and save it as another image.
I have wrote a code which extracts the background but it leaves some of the pixel value.
Checkout original Image : <a href="http://i.stack.imgur.com/aYPvl.jpg" rel="nofollow"><img src="... | <p>If you examine the image with any decent image editor you will find that pixels near the model's head, left hand and right elbow are not pure white (0xFFFFFF).</p>
<p><a href="http://i.stack.imgur.com/yOD5z.png" rel="nofollow"><img src="http://i.stack.imgur.com/yOD5z.png" alt="enter image description here"></a></p>... |
Getting Error 401 while requesting JQuery <p>I am trying to hit API in javascript but getting error code 401 but on postman it is working fine. </p>
<p>Here is my javascript code </p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Co... | <p>I don't know how your server processing authorization, but looks like you didn't pass it. 401 means - Unauthorized: Access is denied due to invalid credentials.
To my mind, you have to specify Authorization header. </p>
<pre><code>var ah = "Basic "+atob("administrator"+":"+"Expert111");
</code></pre>
<p>And set th... |
AngularJs filter with "or" condition? <p>The code is available here: <a href="https://plnkr.co/edit/gbbsEnXxVpLsxvtKsDxw?p=preview" rel="nofollow">https://plnkr.co/edit/gbbsEnXxVpLsxvtKsDxw?p=preview</a>. The filter <code>filter: { a : 'x' }</code> works and only one row is shown. </p>
<p><strong>Question:</strong></p... | <p>As suggested by @Valery using custom Filter is the best solution around this.</p>
<p><a href="https://plnkr.co/edit/8bhJOQmy1TvBNXzzQqlI" rel="nofollow">Here is fork using custom filter(multiple conditions)</a></p>
<p>dashboard.component.js</p>
<pre><code>.filter("optionalFilter",function(){
//console.log("filt... |
"No default constructor found" using Spring MVC with Yahoo Finance API <p>This will be probably a stupid question but I can't figured out a possible solution by myself.
Basically I'm trying to create a simple Java web application using Spring MVC and Yahoo Finance API.
My goal was to create a simple form where I will ... | <p>This is an example of why it's a good idea to decouple your data transfer objects (DTOs), which you use for your external API, from your backend data model. Instead of trying to push the Yahoo <code>Stock</code> class all the way to your UI, create a new <code>AddStockForm</code> that has just the properties needed ... |
Why does box-sizing doesn't contain the margin <p>Sizing to border-box, so that I can give my grid some gutters, but it surprisingly didn't fit into the row any more, even though the columns span 12 rows altogether. I actually thought that setting the box-sizing to border-box will add up both padding, margin and border... | <p>Since <a href="https://developer.mozilla.org/en/docs/Web/CSS/box-sizing" rel="nofollow"><code>box-sizing</code></a> doesn't include <code>margin</code>, here is a simple way (this is also how <em>bootstrap</em> etc do to make it work)</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" ... |
np arrays being immutable - "assignment destination is read-only" <p>FD** - I am a Python newb as well as a stack overflow newb as you can tell. I have edited the question based on comments.</p>
<p>My goal is to read a set of PNG files, create Image(s) with Image.open('filename') and convert them to simple 2D arrays w... | <p>Check if the array is writable with</p>
<pre><code>>>> img.flags
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : False
ALIGNED : True
UPDATEIFCOPY : False
</code></pre>
<p>If <code>WRITEABLE</code>is false, change it with</p>
<pre><code>img.setflags(write=1)
</code></pre>
|
using node module in cordova <p>I am working on a node module I'd like to use in Cordova.
I am using the syntax</p>
<pre><code> myModule.prototype.myMethod = function(){};
module.exports = new myModule();
</code></pre>
<p>but I am getting a "module is not defined" error.</p>
| <p>Here is a possible solution</p>
<pre><code>if (typeof module !== 'undefined' && typeof module.exports !== 'undefined'){
module.exports = new myModule();
} else{
window.myModule = new myModule();
}
</code></pre>
|
springboot : how to return error status code in prehandle of HandlerInterceptor <p>I am using <code>HandlerInterceptor</code> in Spring Boot for processing common types of requests.
But while executing <code>preHandle</code>, I want to return error status code to user if conditions are not met.
If i throw the exception... | <p>If conditions are not met, you can use <code>response.setStatus(someErrorCode)</code> to set the response status code and return <code>false</code> to stop execution. To send custom body you can use the following method: <code>response.getWriter().write("something");</code></p>
<p>Here is the full example... |
Babel does not convert ES6 to JavaScript that is understandable by browsers <p>I use Gulp as task manager and Babel for convert my ES6 program to a version that is understandable for browsers, not for Node!</p>
<pre><code>const gulp = require('gulp');
const babel = require('gulp-babel');
gulp.task('default', () =>... | <p>Babel's job is to <em>transpile</em>. Combining and minifying scripts is a separate task.</p>
<p>You need to add <a href="http://browserify.org/" rel="nofollow">Browserify</a>, <a href="https://webpack.github.io/" rel="nofollow">Webpack</a>, <a href="http://www.requirejs.org/" rel="nofollow">RequireJS</a>, or simil... |
python can draw figure like this?Which package or function should be used? <p>If python can visualizate data matrixs like this? I search for it, but just find in R. I want to know whether python can do this. And which package or function should be used?
<a href="http://i.stack.imgur.com/PrHQT.png" rel="nofollow"><img s... | <p>Have a look at matplotlib's gallery:</p>
<p><a href="http://matplotlib.org/gallery.html" rel="nofollow">http://matplotlib.org/gallery.html</a></p>
<p>Especially:</p>
<p><a href="http://matplotlib.org/examples/pie_and_polar_charts/pie_demo_features.html" rel="nofollow">http://matplotlib.org/examples/pie_and_polar_... |
req.file is undefined multer <p>This is driving my crazy. I've tried to search, but all the solutions being offered aren't working.
I am trying to create a simple file upload using multer, but can't seem to get it to work since req.file seems to always be undefined.</p>
<p>Any ideas? Completely stumped.. nothing is w... | <p>If you are using <code>upload.single()</code> (which your code shows), then the result will be in <code>req.file</code>, not in <code>req.files</code>. So change this:</p>
<pre><code>create: function(req, res) {
console.log(req.files);
}
</code></pre>
<p>to this:</p>
<pre><code>create: function(req, ... |
How to create a horizontal hidden scrollbar <p>I am actually trying to replicate the horizontal scrolling menu you normally see in mobile apps. </p>
<p>I really dont understand why it shouldn't work, though to me it just would seem logical to hide the vertical scrollbar and scroll with horizontal. I know there are num... | <p>To avoid having a vertical scrollbar, simply make sure the height of your content doesn't exceed the height of your container. This can be done by ensuring elements between the scrolling container and children are utilizing the maximum height (100%) instead of some hard-coded value.</p>
<p><code>overflow: auto</cod... |
Can JSRT be used on Windows 7 with IE9+, or do I need to redistribute ChakraCore? <p>Several projects, like react-native-windows, make use of the JSRT wrapper API that interfaces to Chakra installations on Windows 10.</p>
<p>Since Chakra started shipping in Internet Explorer 9, can I use that same JSRT wrapper on Wind... | <p>Matt you will need to redistribute chakracore with your application. the version of chakra that shipped in windows 7 through 8.1 was packaged in jscript9.dll. starting with windows 10 Microsoft forked the old JSRT API and stripped out all the legacy code from it and created chakra.dll. chakracore is a subset of what... |
When i was allocate new memory in heap in J meter ,Memory Leak was happen <p>My question is how should i release memory from the heap?</p>
<p>"My c drive had more than 40 GB space but now it showing less than 3 GB"
C:\Windows\system32>java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"<... | <p>When your disk space fills up you need to find the files you don't need and clean them up. </p>
<p>If you have produced a heap dump I suggest you look for a large file in the directory where your program ran. </p>
<p>BTW When a program exits, all the resource it used are freed up except any files it leaves behind... |
How to process base64 image in webpack? <p>I'm using webpack in my project. I'm trying to use <a href="http://codeseven.github.io/toastr/" rel="nofollow">toastr</a></p>
<p>Toastr css file uses base64 in url like the following:</p>
<pre><code>#toast-container > .toast-success {
background-image: url("data:image... | <p>This problem is solved.</p>
<p>I was excluding node_modules. Since the css-loader is configured to exclude node_modules, it was not able to process the toastr.css file. Just eliminate the <code>exclude: /node_modules/</code>.</p>
<p>The correct configuration in this case is the following:</p>
<pre><code>loaders: ... |
SVG in Android Studio for every screen resolution <p>There is something I don't really understand in android when it comes to SVG files.
I've been working lately with SVG files, what I usually do is create a vector asset (XML layout file) in the drawable directory from the original SVG file. By doing this, I can easily... | <p>You don't need to alter the VectorDrawable. Just specify a width and a height in the ImageView and, if necessary, an appropriate <code>scaleType</code>.</p>
|
neo4j build relationship within same label <p>I have data like below in .csv files</p>
<pre><code>uid fid
1 2
1 3
2 3
</code></pre>
<p>How can I create </p>
<ol>
<li>nodes based on uid</li>
<li>bidirectional relationship in a label called "user" besed on the uid and fid</li>
</ol>
<p>with cypher?</p>
... | <p>1) The neo4j has no concept of a bi-directional relationship, it always has a one direction (The direction can be ignored if it is not important for the application).</p>
<p>2) Do not use the property <code>fid</code>. Use only one property for all nodes: <code>uid</code>.</p>
<p>3) To exclude the creation of extr... |
HTML5 canvas not showing redrawn content during mouse drags <p>I have <a href="http://algorithmicassertions.com/quirk" rel="nofollow">a circuit simulator that redraws as you drag things around</a> on an HTML5 canvas.</p>
<p>I've noticed that, sometimes, it fails to redraw during drags. It holds the last drawn frame un... | <p>Check for other draw loops.</p>
<p>I noticed that the profiler's stack trace is showing the wrong redraw code. The program had a dialog that contains a canvas that sometimes needs to animate. That code was spamming <code>requestAnimationFrame</code> despite the dialog not showing. Somehow this was interfering with ... |
Scheme/Racket: Expected a variable, but found a number error <p>I have a function in the form
(define (name x y z) (function...)) </p>
<p>I enter the parameters on a new line in the form
(define (name int1 int2 int3))</p>
<p>and for some reason, I get the error message:
define: expected a variable, but found a numbe... | <p>Here is an example of how to define a function and how to use it after the definition.</p>
<pre><code>(define (add-them x y z) ; note x, y, and, z must me names
(+ x y z))
(add-them 1 2 3) ; no define when add-them is used.
</code></pre>
<p>The result is 6.</p>
|
How to do the blending in Volume Rendering using GLSL? <p><a href="http://www.codeproject.com/Articles/352270/Getting-started-with-Volume-Rendering" rel="nofollow">This</a> introduces the method of Volume Rendering using obsolete API of OpenGL. But now, I want to complete the Volume Rendering using GLSL and I have fini... | <p>It is natural to do the computations in premultiplied alpha color-space. It fits better with the emission-absorption of the volumatic phenomena. The corresponding equations are:</p>
<pre><code>C = Cs + (1 - As)*Cd
A = 1 - (1 - As)*(1 - Ad) = As + (1 - As)*Ad
</code></pre>
<p>Although it is possible to do the calcu... |
Can I safely do inference from another thread when using tf.train.Optimizer(use_locking=True)? <p>I have several threads that run operation on the same TensorFlow graph. The operations are either inference or optimization of a neural network. I can use the <code>use_locking</code> parameter for the optimizer to prevent... | <p>Do your inference calls need to be on an up-to-date version of the graph? If you don't mind some delay, you could make a copy of the graph by calling sess.graph.as_graph_def on the training thread, and then create a new session on the inference thread using that graph_def periodically.</p>
|
Datatables: How to get variable value from another function <p>I facing small issue. How to get variable value from another function in Datatables.</p>
<p>My Javascript code:</p>
<pre><code>var id = "";
var type = "";
show = function(id, type){ //id=5, type=3
id = id;
type = type;
}
var pTable = $("... | <p>Change show function like this:</p>
<pre><code>show = function(_id, _type){
id = _id;
type = _type;}
</code></pre>
|
In django how can I make the result of the background program as a record and then insert it to mysql <p>In django, I want to make the result of the program in server as a record and then insert it to the mysql, how can I do this?</p>
| <p>If your program is part of django, you can just follow <a href="https://docs.djangoproject.com/en/1.10/topics/db/queries/#creating-objects" rel="nofollow">Creating objects</a>, if not, you can do something in your program settings:</p>
<pre><code>import django
os.environ['DJANGO_SETTINGS_MODULE'] = 'your_django_pro... |
What is the best approach to write Java code to simulate discrete time and tasks being done? <p>Assume I need to write a simulator with discrete time from [0, 1, 2, 3..., n].
I am a given a list of workers that will start a task at a certain time and take a specified amount of time to do so.
After a task is done, it is... | <p>I would use a <a href="https://docs.oracle.com/javase/8/docs/api/java/util/PriorityQueue.html" rel="nofollow">PriorityQueue</a> sorted by the simulation time to execute next. This way you efficient find the next task each time. Your task object might include a counter of how many times it has been started.</p>
|
JQuery how to find the closest element that is neither a parent nor a child of the current element? <p>Say I have HTML that looks like this:</p>
<pre><code><div>
<div>
<div class="calendar start">
</div>
</div>
<div>
<div class="calendar ... | <p>You can do it like below, But it is a costlier process.</p>
<pre><code> var parentWhichHasCalEnd =
$($(".calendar.start").parents()
.get().find(itm => $(itm).find(".calendar.end").length));
var calEnd = $(".calendar.end", parentWhichHasCalEnd);
</code></pre>
<h2><a href="https://js... |
How to align row flex elements in columns? <p>I use <code>flex</code> to align my elements. <code>#sentinels</code> is the outermost container and each line of <code>div</code> (green in the example below) has the class <code>line</code>.</p>
<pre><code>#sentinels {
display: flex;
flex-direction: column;
j... | <p>Look at this <a href="https://jsbin.com/jevaqovaga/edit?html,css,output" rel="nofollow">https://jsbin.com/jevaqovaga/edit?html,css,output</a>. Outer div with width 100% for each inner div could solve your problem.</p>
|
Right bar button does not appear <p>I try to add UINavigationBar programmatically and set bar button items.
I tried:</p>
<pre><code>self.artificialNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
self.artificialNavBar.backgroundColor = [UIColor whiteColor];
UIB... | <p>Declare </p>
<pre><code>@property (nonatomic, strong) UINavigationItem *navItem;
</code></pre>
<p>in the .h file of this class where you have written all these and then replace your code with below code.</p>
<pre><code>self.artificialNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame... |
How to bind 15 (desired no. of) rows from SQL Server on every next page index change? <p>How to bind 15 rows from SQL Server into a gridview with a condition and condition is that on every page index should be bind next 15 rows, means a query should be fired for retrieving next 15 rows (I don't want to retrieve all row... | <p>You need to use pagination with sql server</p>
<pre><code>Declare @From int=1
Declare @To int=15
WITH CTETable AS
(
SELECT ID, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
)
SELECT *
FROM CTETable
WHERE RowNum BETWEEN @From AND @To
</code></pre>
<p>You need to pass @From and @To vales as 1,15... |
php, how manage throw exception in multiple nested function? <p>I begin learn how use exceptions in php. In a subfunction in my code, I want use a throw statement for stop the main function if one error appears. </p>
<p>I have three functions : </p>
<pre><code>function main_buildt_html(){
...
check_if_paramet... | <p>Normally the exception will be throwin up until the highest level in the chain, or when you catch it in any level.</p>
<p>in your case, if you want to catch the exception in <strong>check_if_parameters_are_ok()</strong> and <strong>main_buildt_html()</strong> functions, you need to throw the exception up in the <st... |
Calculating a negative number arithmetic expression through the stack <p>I need your help, to calculate negative numbers.
I could not consider negative numbers.
I'm unable to calculate only positive numbers.
I would be glad if you help me fix it.</p>
<p>I want to be sure - the complexity of the code is O(n)?</p>
<pre... | <p>So really you need to distinguish between a binary operator <code>a-b</code> and an unary operator <code>-c</code>. </p>
<p>In terms of a formal grammar, you can define an Expression something like with a Prefix being a number or - followed by a number</p>
<pre><code>Expression :
PrefixExpression
Expressio... |
ERROR: In file './docker-compose.yml', service 'volumes' must be a mapping not an array <p>My docker-compose.yml looks like the below and I am trying to follow the compose file from the docker registry documentation <a href="https://docs.docker.com/registry/deploying/" rel="nofollow">here</a>. When i run docker-compose... | <p>The thing is that you are not indenting the fields properly. Your docker-compose should look like the below:</p>
<pre><code>registry:
restart: always
image: sudarshan/registry
ports:
- 5000:5000
environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.ke... |
writing on new window - new lines are lost <pre><code><div class="cardtitle">WEB</div>
<textarea id="web">
abc
abc
abc
</textarea>
<div id="btnprint">PRINT</div>
</code></pre>
<p>JS</p>
<pre><code>tosend = '';
$('#btnprint').click(function(){
$('.cardtitle').each(function(){
... | <p>Wrap it in a <code><pre></code> tag so that the formatting won't be lost.</p>
<pre><code>$('#btnprint').click(function(){
var tosend = '<pre>';
$('.cardtitle').each(function(){
tosend = tosend +
$(this).text().toUpperCase() + '<br>' +
$(this).next().val() +
... |
Problems with Angular2 on macOS Sierra <p>I have upgraded to mac os sierra GM version and having issue with angular2 cli.
I had it installed before the upgrade and it was running fine. Iâm getting <code>command not found</code> on terminal when I try anything with <code>ng</code>.
I have tried to reinstall with comma... | <p>you forgot the command name: <code>npm</code>.</p>
<p>Try this:</p>
<pre><code>sudo npm install -g angular-cli
</code></pre>
<p>Also be sure you have installed Node 6.6.0 (that includes with npm 3.10.3).</p>
<p>Best,
Demetrio</p>
|
Store data in cookie with asp.net core identity <p>I'm using asp.net core identity with EF end I would like to store data related to the user in the authentication cookie.</p>
<p>This is how I used to do with ASP.NET 4.6 (appcontext is the data to store):</p>
<pre><code>public static void IdentitySignin(AppContext ap... | <p>Use <code>AddClaimsAsync</code> or <code>AddClaimAsync</code> of <code>UserManager<YourUserIdentity></code>. for exemple like this when you sign in your user:</p>
<pre><code>public class AccountController : Controller
{
public UserManager<YourUserIdentity> UserManager { get; private set; }
publ... |
Spring boot: InternalResourceViewResolver not working <p>I spent several hours trying to use <code>InternalResourceViewResolver</code> in order to append prefix and suffix to html views.</p>
<p>My views located under <code>static/pages/</code> and by Spring docs, folder <code>static</code> is considered to be one of d... | <p>Just need add your own custom configuration like this</p>
<pre><code>@Configuration
public class WebMvcConfig {
@Bean
public InternalResourceViewResolver defaultViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/jsp");
re... |
aikau - implement export search results functionality <p>I have recently started developing with <code>aikau</code> in alfresco share.
I want to achieve a functionality wherein I can export search results to a CSV file. </p>
<p>For that, I can change the back-end repository web script to return csv data.
Now, At alfr... | <p>This <a href="https://community.alfresco.com/community/ecm/blog/2016/09/16/customizing-search-queries" rel="nofollow">blog post</a> provides an example on how you can custom the search page in Share. Although it specifically addresses changing the search queries the basic extension approach is more or less that same... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.