input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to switch to normal wifi mode to access-point mode ESP8266 <p>I am using ESP8266-12 wifi module for accessing my home wifi network to control lights. For uploading new firmware(OTA: Over the Air) update, I want to use ESP8266's hotspot AccessPoint because after changing the password of my wifi network, I will not a... | <p>Put these lines to the top of the function called <strong>connectToWifi()</strong> :</p>
<pre><code> WiFi.softAPdisconnect();
WiFi.disconnect();
WiFi.mode(WIFI_STA);
delay(100);
</code></pre>
<p>ESP's WiFi module stores its own config on chip and he expects to overwrite it clearly. Do not make him to try so... |
PHP array curly brackets instead of square brackets <p>I'm attempting to output curly brackets from my array like this:</p>
<pre><code>"data":{facebook":{"message"}},
</code></pre>
<p>but I keep getting square brackets:</p>
<pre><code>"data":{"facebook":["message"]}
</code></pre>
<p>Here is my code: </p>
<pre><cod... | <p>As Paul Crovella said, your stated goal is invalid JSON.</p>
<p>Your valid options are for the <code>facebook</code> property to directly contain the message string:</p>
<pre><code>{
"data":{"facebook":"message"},
}
</code></pre>
<p><em>(note I've added the outer <code>{</code> and <code>}</code> missing from... |
Update expiry date of UIWebView Cookie <p>I am showing a web login page in my app. I don't want user to login again once they have logged in. But login cookies are getting expired after 8hours i guess. Can i update the expiry of this cookies? Below is the code though which i got the cookies - </p>
<pre><code>if let co... | <p>If you can't set cookie expiration in the source code of the website, you can do it manually. To retrieve and set cookies with updated expiration interval, you may follow this approach. <strong>Swift 3.0</strong> offers even shorter code:</p>
<pre><code>let storage = HTTPCookieStorage.shared
for cookie in s... |
Where is the implementation of IEnumerable of Collection<T> <p>Suppose I have a <code>Collection<string></code> and I'm using <code>GetEnumerator()</code> that returns <code>IEnumerator<string></code>, where can I find the implementation of <code>IEnumerator</code> for this collection? </p>
<p>On MS <a hre... | <p>Looking into the <a href="http://referencesource.microsoft.com/#mscorlib/system/collections/objectmodel/collection.cs,281923b8611114ec">source</a> we can see that <code>GetEnumerator</code> returns the GetEnumerator of its' <code>items</code> field which concrete type is <code>List<T></code> (inside the ctor)<... |
Making a button to be visible even while scrolling <p>Im using the following code to put up scrollview with button at the bottom. </p>
<pre><code><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
... | <p>Use the floating point button instead of the button.
Here is code snapshot:</p>
<pre><code><android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_plus_circ... |
Pathfinding On a huge Map <p>I am in need of some type of pathfinding, so I searched the Internet and found some algorithms.</p>
<p>It seems like they all need some type of map also.
This map can be represented by:</p>
<ul>
<li>Grid</li>
<li>Nodes</li>
</ul>
<p>As my map is currently quite huge (20.000 x 20.000 px),... | <p>This calls for some optimization, and reduce the amount of nodes you have. </p>
<p>Almost any pathfinding algorithm can take a node list that is not a grid. You will need to adjust for distance between nodes, though.</p>
<p>You could also increase your grid size so that it does not have as many squares. You will n... |
Gradle build failed when trying to deploy app <p>I have absolutely no idea what is going on. I have tried every single solution posted in SO but the problem persists.</p>
<p>When synching Gradle files, everything goes smooth:</p>
<pre><code>Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSou... | <p>In cmd type gradlew. It should download 2.14 version.</p>
|
Ruby reverse histogram <p>So I'm new to ruby and while I was reading about histograms I had a thought. Is there was a way to have a histogram convert a number into a line of symbols? For example, 12 would be converted into ############.</p>
| <p>You can multiply a string by an integer in Ruby. </p>
<pre><code>value = 12
result = '#' * value
=> "############"
</code></pre>
<p>So for [1, 3, 5, 4] you could do</p>
<pre><code>[1, 3, 5, 4].map{|value| '#' * value}
=> ["#", "###", "#####", "####"]
</code></pre>
|
NancyFx incompatibility with .Net Core <p>I've tried to get NancyFx running with .Net Core under Ubuntu and Windows but I get the message that NancyFx it not comatible with .NetCoreApp.
I'm new to the whole .Net Core thing, so any help is welcome.</p>
<p>My project.json</p>
<pre><code>{
"version": "1.0.0-*",
"bui... | <p>I've found the answer. The problem was the missing type in the Microsoft.NETCore.App dependency. </p>
<pre><code>{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
... |
How to take input from stdin, display something using curses and output to stdout? <p>I'm trying to make a python script that takes input from stdin, displays GUI in terminal using curses and then when user finishes interaction outputs the result to the stdout. Good example of this behaviour is <a href="https://github.... | <p>It doesn't work because the <code>print</code> statement is writing to the same standard output as <a href="https://docs.python.org/2/library/curses.html#curses.wrapper" rel="nofollow"><code>curses.wrapper</code></a>. You can either defer that <code>print</code> until after you have restored <code>sys.stdout</code>... |
Is there a rails or rack gem that blocks hacked URL requests? <p>My Rails application frequently receives bogus traffic from hackers scanning for vulnerabilities, hitting URLs like <code>/vb/showthread.php%3C/a</code>. These show up as noise in our logs and I would like to filter them out or handle these in some way (s... | <p>I'm not sure if this really answer your question by I think a custom filter will be better instead of a general gem.</p>
<p>I've added a before filter on my applicaton_controller to handle weird request, then you can alert and do what you want.</p>
<pre><code>class ApplicationController < ....
before_action :... |
Why use/develop Guice, when You have Spring and Dagger? <p>To my knowledge, Dagger does generate code, while Guice and Spring rely on runtime processing, thus Dagger works faster, but requires more work on programmer side. Because of performance edge it's good for mobile (Android) development.</p>
<p>However, when we ... | <p>It's important to realize that Dagger was created after Guice, by one of Guice's creators (<a href="http://blog.crazybob.org/" rel="nofollow">"Crazy Bob" Lee</a>) after his move to Square:</p>
<ul>
<li>Spring was originally released in <a href="https://en.wikipedia.org/wiki/Spring_Framework#Version_history" rel="no... |
How to assign logical/math operator to an Object's function? <p>So I'm making an expression parser in JavaScript and wanted to know: is there any way to assign an object's function to a logical/mathematical operator so that it gets called everytime the operator is used on that object?</p>
<p>I know that, for instance,... | <p>You can create a <code>.valueOf()</code> function to return a numeric value. The runtime will call that in cases analogous to when it decides to call <code>.toString()</code> — that is, when it wants to coerce the object to a numeric value.</p>
<p>You cannot, however, force the runtime to treat an assignment ... |
Parse XML file in Unity C# <p>I have a little problem with parsing XML file to object in C#. Whole project is in Unity3D. So I have this XML file: </p>
<pre><code><Questions>
<Question>
<questionText>What is this?</questionText>
<answer>blablabla</answer>
<... | <p>The XML file schema (<em>config2.xml</em>) and the XML serialization attributes in the corresponding class doesn't match. Your XML document's root element (<code>Questions</code>) and the questions list element are conflicting.</p>
<p>Change your <code>XmlRoot</code>'s <code>ElementName</code> (which is now <em>Que... |
How do I get Spring Boot Security and JBoss 7.1 to play nicely with each other? <p>Versions:</p>
<p>JBoss: 7.1
Spring Boot: 1.4.1.RELEASE</p>
<p>Starting a project from scratch and following the directions for securing a spring-boot app from here: <a href="https://spring.io/guides/gs/securing-web/" rel="nofollow">htt... | <p>Seems like you are using JDK 1.8 for your SpringBoot app.</p>
<p>JBoss AS 7 doesn't work on JDK8. </p>
<p>See <a href="http://stackoverflow.com/questions/31194474/unable-to-start-jboss-as-7-1-1-final-on-windows-8-1-command-prompt">Unable to start jboss-as-7.1.1.Final on Windows 8.1 command prompt</a></p>
|
Tell progress of quicksort <p>I am currently working on sorting files. At the moment I use heapsort for that because it is fairly easy to tell the progress of it. I mean there are two loops after one another and with some slight adjustments to how much weight you give one round of each of the two loops you have a very ... | <p>There are three steps:</p>
<ul>
<li><p>Separate elements into two lists</p></li>
<li><p>Sort left list</p></li>
<li><p>Sort right list</p></li>
</ul>
<p>You can give each step a part of the progress that it has to fill during execution. Let's say there are 100% in total. Step 1 gets 20%, step 2 40% and step 3 also... |
Spark scheduling / architecture confusion <p>I'm attempting to setup a Spark cluster, using the standalone / internal Spark cluster (not Yarn or Mesos). I'm trying to understand how things need to be architected.</p>
<p>Here's my understanding:</p>
<ul>
<li>One node needs to be setup as the Master</li>
<li>One or mor... | <ol>
<li><p>You can run your application from non-worker node - it's called client mode. If you run your application inside some worker node, it's called cluster mode. Both of them are possible.</p></li>
<li><p>Please take a look at Spark Streaming, it seems that it will fits your requirements. You can specify that eve... |
HTML modal popup animation not working second time <p>I have created the following code to display a popup, and it works fine with the animation I added afterwards to have a pop-out effect. However, if I close it and attempt to reopen it, the animation does not show? the modal just instantly appears.
How do I fix it?</... | <p>Look at this please</p>
<pre><code><div id="overlay">
<div>
<p>Content you want the user to see goes here.</p>
Click here to [<a href='#' onclick='overlay()'>close</a>]
</div>
</div>
<style>
#overlay {
visibility: hidden;
position: absolut... |
use angular.js to get data from a web endpoint <p>I need to use angular in order to get data from a web endpoint to fill this table. I have a list created with random names, but I need it to filled with data from a link instead. I still need to create the social media links as well.
Either way, can someone show me how ... | <p>I'm not sure if I did get this right, but:
You want to get the students from a web endpoint as json?</p>
<p>Then you would write something like this in angular:</p>
<pre><code>app.controller('myCtrl', function ($scope, $http) {
...
$scope.students = [];
$scope.totalItems = 0;
$http.get('https:... |
SQL Azure paging optimization <p>Had trouble with best fit for this question</p>
<p>With Azure Table Storage you just have fixed key of partition, rownum. They charge based on size and number of operations. </p>
<p>Have a LAN document manage application with a WPF client and a SQL database </p>
<p>Taking it to A... | <p>One of the benefits of using Azure is that you have multiple choices for storing data. From Azure tables, Document DB, all the way to SQL DB and SQL DW. Each service has great documentation that describes how they are different at what they are best at.</p>
<p>Because you have choices, you'll probably want to cho... |
(php) can't get id from table <p>I have two tables and I want to add data to the first table and get <code>id</code> of the newly inserted data from <code>first table</code> and use it to add the data to <code>second table</code></p>
<pre><code>$statement = $dbh->prepare("INSERT INTO sis_university (name,site,tel,e... | <p>You can use insert-id for get the id of last inserted row</p>
|
Adding new related entities in a single action <p>Every riddle has one or more questions, how can add both a Riddle and a Question to that riddle by submitting a single form?</p>
<p>This is RiddlesController Create action code:</p>
<pre><code>public ActionResult Create(RiddleViewModel model)
{
if ... | <p>You can try as shown below.</p>
<pre><code>_db.Questions.Add(new Models.Question
{
Body = model.FirstQuestionBody,
Answer = model.FirstQuestionAnswer,
CreationDate = DateTime.Now,
Riddle = new Models.... |
Check part of SVG image to fill them with color with fabric.js <p>I used to fabric.js and freedrawing. Most of the code is included here <a href="http://fabricjs.com/freedrawing" rel="nofollow">http://fabricjs.com/freedrawing</a>. I want to rewrite it to and add some new options. One of then is coloring book. I think i... | <p>After some time fiddling with your code at the <code>/11</code> update, I've come to an almost working fiddle:</p>
<p><a href="http://fiddle.jshell.net/2bc4y95L/" rel="nofollow">http://fiddle.jshell.net/2bc4y95L/</a></p>
<p>The problem with the fiddle is the algorithm to choose a single container to paint. I've tr... |
How to fill ListView with Loader? <p>I'm testing the Listview example in the <a href="https://developer.android.com/guide/topics/ui/layout/listview.html" rel="nofollow">Developer site</a>, which is an example for filling ListView with Loader and Adapter. The app fails because of some unknown bugs. I'm not sure but sus... | <p>The SecurityException and the permission denial gives the likely cause - have you given your app access to read (and possibly write) your contacts? </p>
<p>The permission you need are:</p>
<pre><code>Read access to one or more tables
<uses-permission android:name="android.permission.READ_CONTACTS">.
Write ac... |
Anaconda install Matlab Engine on Linux <p>I'm trying to install <code>Matlab Engine for Python</code> on CentOS 7 for Matlab R2016a using anaconda python 3.4.</p>
<p>I executed the following commands:</p>
<pre><code>source activate py34 # Default is python 3.5
python setup.py install
</code></pre>
<p>The output is:... | <p>After so many tortures I finally solved this in a simple way. Instead of configure system to use anaconda's python by modifying .bash_profile, you can add an alternative to python command:</p>
<pre><code> sudo update-alternatives --install /usr/bin/python python ~/anaconda3/envs/py34/bin/python 2
update-alternat... |
loop within a loop for JSON files in R <p>I am trying to aggregate a bunch of JSON files in to a single one for three sources and three years. While so far I have only been able to do it through the tedious way, I am sure I could do it in a smarter and more elegant manner. </p>
<pre><code>json1 <- lapply(readLines(... | <p>Here you go:</p>
<pre><code>require(jsonlite)
filelist <- c("NYT_1989.json","NYT_1990.json","NYT_1991.json",
"WP_1989.json", "WP_1990.json","WP_1991.json",
"USAT_1989.json","USAT_1990.json","USAT_1991.json")
newJSON <- sapply(filelist, function(x) fromJSON(readLines(x)))
</code><... |
Check table row based on value of input search SAPUI5 <p>I have a table (multiselect mode) with a search field. Is there a way that when I search, the value of the search result will automatically check the corresponding row in the table. Initially I though I could just search and then if the result length is 1, do a g... | <p>This gets much easier if you bind the <a href="https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ListItemBase.html#getSelected" rel="nofollow">selected property</a> of the <code>ColumnListItem</code> to your model.
You can then perform the filtering and selection on your model data:</p>
<pre class="lang-js p... |
Split one column by rows to multiple columns in Excel <p>I am working in Excel 2013, and I have data like the following:</p>
<p>A1</p>
<p>A2</p>
<p>A3</p>
<p>B1</p>
<p>B2</p>
<p>B3</p>
<p>(The As go to A13, Bs go to B13, Cs go to C13, and so on until you get to row 2495.)</p>
<p>How do I divide this long column... | <p>If you want to parse the data into three separate columns then in <strong>B1</strong> enter:</p>
<pre><code>=A1
</code></pre>
<p>In <strong>C1</strong> enter:</p>
<pre><code>=A14
</code></pre>
<p>In <strong>D1</strong> enter:</p>
<pre><code>=A27
</code></pre>
<p>Then copy these three cells downwards:</p>
<p>... |
Debug high iis worker process <p>I have a high iis worker process attached to a site, cpu hits 99% and stops the site. Ive been looking at the official guide at <a href="http://www.iis.net/learn/troubleshoot/performance-issues/troubleshooting-high-cpu-in-an-iis-7x-application-pool" rel="nofollow">http://www.iis.net/lea... | <p>If you're using Visual Studio 2015 the tools you're looking for are built into the IDE. </p>
<p><a href="https://msdn.microsoft.com/en-us/library/mt210448.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/mt210448.aspx</a></p>
<p>If you're not using that another way will be to use Debug Diag. </p>
<p>... |
From perl to python <p>I've got some code that I've translated from perl into python, but I am having a time trying to figure out this last part. </p>
<pre><code>my $bashcode=<<'__bash__';
. /opt/qip/etc/qiprc;
. /opt/sybase/sybase.sh
perl -mdata::dumper -e 'print dumper \%env';
__bash__
my $var1;
eval qx(bash -... | <p>Your program is generating a script and running it.</p>
<p>A first python approximation is:</p>
<pre><code>import os
script=""". /opt/qip/etc/qiprc;
. /opt/sybase/sybase.sh
perl -mdata::dumper -e 'print dumper \%env';
"""
os.system(script)
</code></pre>
<p>As you can see, perl is still being u... |
Data storage for IoT devices <p>How data is stored for Internet of Things devices? Are they stored in traditional relational database format (tables, rows , columns ) or some other format? Is there some software or algorithm applied to raw sensor data to organize them ?
Any reference to research paper is appreciated.</... | <p>IoT data will be stored in various different formats depending on a few factors, but not the least including:</p>
<ol>
<li>Format of the server ingested data files</li>
</ol>
<p>The data could be coming directly from a sensor or being relayed from an internet connected device (think cell phone). If it's coming di... |
WARN: Establishing SSL connection without server's identity verification is not recommended <p>Hello I am trying to connect to a mysql database via a java servlet using eclipse and tomcat, but I take the following error: "WARN: Establishing SSL connection without server's identity verification is not recommended".I add... | <p>First, you have to ensure you put <strong>username</strong> and <strong>password</strong> correctly.</p>
<p>The error you get comes from servlet code, when you try to connect with DriverManager:</p>
<pre><code>Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysys?autoReconnect=true&us... |
Angular 2 app - Google PageSpeed Insight tell me to "enable compress" <p>I'm using angular 2 CLI to build my project and it seem compressed, but when I test my webpage with <a href="https://developers.google.com/speed/pagespeed/insights" rel="nofollow">https://developers.google.com/speed/pagespeed/insights</a> I get sc... | <p>It's just a thought but i think it would work. break your css in to parts
1.) One contains minimal css required to render the loader/first render.
2.) Keep all other css here.
<strong>now you can generate it dynamically</strong> </p>
<pre><code> ngOnInit(){
let link = document.createElement('link'),
he... |
How to add number to textView on button click <p>I am trying to build a simple calculator.<br>
I need a method to put or display a number in a <code>textView</code> or <code>EditText</code>.</p>
<p>Something like:</p>
<pre><code>Public void putNumbertoView(){
//puts the number to a textView
}
</code></pre>
| <p>You need to import <code>java.util*;</code><br>
You have to use conversion.</p>
<p>i.e.:</p>
<pre><code>public static void main(String args[]) {
int x =Integer.parseInt("9");
double c = Double.parseDouble("5");
int b = Integer.parseInt("444",16);
System.out.println(x);
System.out.pri... |
Jquery, Javascript fadeIn, fadeOut not working <p><code>time_60_mod</code> in the code below counts from <code>0</code> infinity. I tried to add a <code>fadeIn</code>, <code>fadeOut</code> to it and it doesnt seem to work.</p>
<pre><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js... | <p>fadeIn and fadeOut functions must be used on elements of the DOM, here you are trying to fadeIn or fadeOut a local variable (a number, not an element).
Try to put the seconds in a tag ("span" for example) in your HTML and then apply the functions on this tag, referencing it the same way you referenced "h1".
Of cours... |
Wordpress Pagination on static homepage <p>I am trying to get Pagination working on my static homepage which I have integrated with wordpress. The problem I am having is when I click the "Older Entries" button on the page it goes to the ?paged=2 page but displays the first 10 posts still. Just like on the first page. <... | <p>This line should be "paged" instead of "page"</p>
<pre><code>$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
</code></pre>
|
JavaScript not working when in the top of PHP page <p>When I put the <code>This Code</code> section in the top, the JavaScript for calling the functions <code>UserExist</code> and <code>Success</code> is not working. On the other hand when I put it in the bottom, the JavaScript is working, but the <code>header("Locatio... | <p>Do sth like:</p>
<pre><code><?php
//do all the redirecting stuff etc
$code="";
if($sth){
$code="<script>alert(':)');</script>";
}
?>
<html>
<head>
<?php echo $code;?>
</head>
<body>
if $sth is true, you will see a :)
</body>
</code></pre>
<p></p>
|
Implement ASN1 structure properly using pyasn1 <p>I am new to ASN1 and want to implement this structure using pyasn1</p>
<pre><code> ECPrivateKey ::= SEQUENCE {
version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
privateKey OCTET STRING,
parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
... | <p>I guess in the ASN.1 module you are working with, EXPLICIT tagging mode is the default. So in your pyasn1 code you should use explicit tagging as well. </p>
<p>Here's slightly fixed code that should work as you want:</p>
<pre><code>from pyasn1.type import univ, namedtype, tag
from pyasn1.codec.der.encoder import e... |
How to create scenario in Yii2 with no validation rules active? <p>I have <strong>MyEntity.php</strong> model. As a part of the model script, there are some rules and some scenarios defined:</p>
<pre><code>public function rules()
{
return [
[['myentity_id', 'myentity_title', 'myentity_content', 'myentity_d... | <p>To be able to do this, you need to do a few things (including the ones you almost did yourself):</p>
<ul>
<li><p>In your controller, write <code>$modelMyEntity->scenario = 'scenario_three';</code></p></li>
<li><p>In model, add an additional scenario array 'scenario_three' in <code>scenarios()</code> method:</p><... |
Python Tkinter While Thread <p>Well i am a bit of newb at python, and i am getting hard to make a thread in Tkinter , as you all know using while in Tkinter makes it Not Responding and the script still running.</p>
<pre><code> def scheduler():
def wait():
schedule.run_pending()
time.sleep(1)
... | <h3>When to use the after method; faking while without threading</h3>
<p>As mentioned in a comment, In far most cases, you do not need threading to run a "fake" while loop. You can use the <code>after()</code> method to schedule your actions, using <code>tkinter</code>'s <code>mainloop</code> as a "coat rack" to sche... |
Updating a Element with PHP/Javascript <p>I've been trying to get this script to work. I made a PHP random number generator and I'm trying to get it to feed to my main php page and update a div with the number generated whenever I push a button.</p>
<p>It works, kind of. It generates the number one time and no matte... | <p>I do not know if it crucial that it is a separate page for generating the number, if not you can use JS for creating a random number, like so:</p>
<pre><code><script>
function roll() {
var bunnies = document.getElementById('bunnies')
bunnies.innerHTML = Math.floor((Math.random() * 10) + 1);
}
</scr... |
Bracket matcing plugin in generated by xtext <p>How do you match brackets in the eclipse plug-in generated in a xtext project?</p>
<p>When the cursor is over the open or close bracket the matching bracket is highlighted.</p>
| <p>The eclipse editor support the matching functionality, just enable the option under the preference menu.</p>
|
Criteria api Restriction of foreign key <p>i'm using Hibernate criteria api in my java ee app. I have two Agenda interface in witch i use jsf/primefaces schedule. the first one get data with the method findall() but the second one get data with the method findByCriteria(cri). in the cri variable i have to compare a for... | <p>You should use Restrictions#isNull. That one is used for comparing of NULL values.</p>
<pre><code>Criterion cri = Restrictions.isNull("demande");
</code></pre>
|
Is memory barrier related to some specific memory location? <p>I'm trying to learn the basics about low-level concurrency.</p>
<p>From Linux documentation:</p>
<pre><code> A write memory barrier gives a guarantee that all the STORE operations
specified before the barrier will appear to happen before all the STORE
o... | <p>Memory barriers are not related to any specific memory locations.</p>
<p>It's not about "write to memory address x should happen before write to address y", it's about execution order of instructions, e.g. for program</p>
<pre><code>x = 2
y = 1
</code></pre>
<p>processor may decide: "I don't want to wait until 2 ... |
Why does scanf accept more characters than there is room for in the buffer? <p>See the following code:</p>
<pre><code>int main()
{
char test[3];
scanf("%s", test);
__fpurge(stdin);
printf("%s", test);
}
</code></pre>
<p>The program should record only 3 characters, but when I type, for example, 8 characters, ... | <p>When you pass <code>test</code> to <code>scanf()</code>, you are passing nothing but a pointer to the first character of your buffer, so <code>scanf()</code> has no idea how large your buffer is. It will happily accept as many characters as you type, and it will store them all in there. So, when you type more than ... |
obtaining quantiles from complete gaussian fit of data in R <p>I have been struggling with how R calculates quantiles and the normal fitting of data.
I have data (NDVI values) that follows a truncated normal distribution (see figure)<a href="http://i.stack.imgur.com/P3Gx5.png" rel="nofollow"><img src="http://i.stack.im... | <p>R is using the empirical ordering of the data when determining quantiles, rather than assuming any particular distribution. </p>
<p>The 10th percentile for your truncated data and a normal distribution fit to your data happen to be pretty close, although the 1st percentile is quite a bit different. For example:</p>... |
Google search bar is redirecting me to www.google.com without launching the research <p>I'm trying to add a Google search bar on my personnal website (not for searching only on my website but for searching on the internet).</p>
<pre><code><form method="get" action="https://google.com/search" target="_blank">
... | <p>In the input tag, put an attribute called name. For example: </p>
<pre><code><input type="text" placeholder="Google" class="search" name='q'>
</code></pre>
<p>That should fix your problem.</p>
|
BootStrap Glyphicons don't show while using HTTPS protocol <p>I'm using BootStrap in the Grails application , but i'm facing weird thing , when use <code>HTTP</code> in my page ex:<code>http://www.mypage.com</code> Glyphicons are working fine , but when i use <code>HTTPS</code> they disappear ex:<code>https://www.mypa... | <p>Try using:</p>
<pre><code><link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
</code></pre>
<p>Some http resources may be blocked when using https protocol.</p>
|
min css these two classes & ids <p>What is the minimalist syntax for these two classes?</p>
<pre><code>.sortable1Wrapper { width:190px; height:200px; border: 1px solid #eee; float:left; margin: 0px 5px 0px 0px }
.sortable2Wrapper { width:190px; height:200px; border: 1px solid #eee; float:left; }
</code></pre>
<p>What... | <p>the minimalist sintax for your two class is </p>
<pre><code>.sortable1Wrapper, .sortable2Wrapper { width:190px; height:200px; border: 1px solid #eee; float:left; }
.sortable1Wrapper { margin: 0px 5px 0px 0px }
</code></pre>
|
Microsoft Sql Server multiple aggreate functions using Pivot <p>I have the data like this </p>
<pre><code>select * from age;
Payor Description ID Amount
---------------------------------
Medical S1 101 200
Medical s1 102 100
Medical S2 201 400
Medical S2 202 4... | <p>Try with UNION:</p>
<pre><code>Select payor, S1, S2, S3
FROM
(
Select payor, Description, count(ID) CountVal, 1 AS Orderby from table
group by payor, Description) z
PIVOT
(
MAX(CountVal) FOR Description IN ([S1], [S2], [S3])
) x
UNION
Select payor, S1, S2, S3
FROM
(
Select payor, Description, SUM(Amount) SumVal, ... |
Calling template method through a pointer to it <p>I have the next error :</p>
<blockquote>
<p>C2064 term does not evaluate to a function taking 1 arguments LINE 33</p>
</blockquote>
<p>It fails on calling the function "param.c1(x)". But why? It seems like it can not deduce the function "c1_1_order_()" taking 1 ar... | <pre><code>param.c1(x);
</code></pre>
<p><code>c1</code> is a class method pointer. A class method pointer is not a function pointer, it cannot be invoked by itself. A class method pointer must be invoked using either the <code>.*</code> or the <code>->*</code> operator, on an instance/pointer to the class in quest... |
Image wrapping with incomplete first row instead of last <p>I am trying to solve a problem which seems to be beyond my capacities.</p>
<p>The thing is apparently easy. There is a collection of <img> images, to be located in a <div> box and dynamically added to it. The images are to be arranged in rows, wit... | <p>You could implement a Javascript handler to scan the number of images in the "row"(Your class for each row), if <code>!=</code> to <code>4</code> append <code><img></code> element to "row". Then you would be able to class and re-class using javascript/jquery also, based off of your classes. For instance "row" ... |
link 2 different types of highcharts data <p>is it possible to link/sync 2 chart data in 2 different type of charts to show tooltips at once?</p>
<p>for an example, i have a pie chart and a area chart.</p>
<p>The pie chart represents the percentage of a particular browser and the area chart shows the downloads per ye... | <p>I am not sure what would you like to show in a tooltip when you hover on your pie. You have one point so its hard to show tooltip for whole series on another chart. </p>
<p>You can use mouseOver and mouseOut events callback functions for highlighting series (so they will look like on hover): </p>
<pre><code>point:... |
How to check database with one field in Android <p>I want create application, in this application users can insert data.<br>
Users can insert this data : <strong>Name</strong> - <strong>fName</strong> - <strong>Email</strong> - <strong>Address</strong> . <br>
This application is <strong>offline</strong> and i use <code... | <p>As much as I understood your question, you can put make a <code>unique</code> constraint on the table schema depending on whether you want one field to be unique or a combination of field to be unique like below. </p>
<p>For one unique value of Email column put <code>UNIQUE('Email')</code> before closing create tab... |
PHP openssl AES in Python <p>I am working on a project where PHP is used for decrypt AES-256-CBC messages</p>
<pre><code><?php
class CryptService{
private static $encryptMethod = 'AES-256-CBC';
private $key;
private $iv;
public function __construct(){
$this->key = hash('sha256', 'c7b358... | <p><a href="http://php.net/manual/en/function.hash.php" rel="nofollow">PHP's <code>hash</code></a> outputs a Hex-encoded string by default, but Python's <code>.digest()</code> returns <code>bytes</code>. You probably wanted to use <code>.hexdigest()</code>:</p>
<pre><code>def __init__(self, key, iv):
self.key = ha... |
VHDL frequency divider code <p>I have this code:</p>
<pre><code>architecture Behavioral of BlockName is
signal t: std_logic;
signal c : std_logic_vector (1 downto 0);
begin
process (reset, clk) begin
if (reset = '1') then
t <= '0';
c <= (others=>'0');
elsif clk'event and clk='l' then... | <ol>
<li><code>c <= (others=>'0');</code> is equivalent to <code>c <= "00";</code></li>
<li><code>t <= not(t);</code> assigns to <code>t</code> the opposite of the current value in <code>t</code>.</li>
<li><code>=</code> is an equality comparison in VHDL.</li>
<li><code><=</code> is signal assignment in ... |
How do I escape an ampersand in a Socrata SODA 2 API call? <p>I am working with the <a href="https://data.cityofnewyork.us/Public-Safety/NYPD-7-Major-Felony-Incidents/hyij-8hr7" rel="nofollow">NYC crime dataset</a> and I notice that the <code>offense</code> type for homicides is <code>MURDER & NON-NEGL. MANSLAUGHTE... | <p>You're correct, <code>hyij-8hr7</code> is the SODA 2.0 endpoint for that dataset. However, a 2.1 endpoint also exists: <a href="https://dev.socrata.com/foundry/data.cityofnewyork.us/e4qk-cpnv" rel="nofollow">https://dev.socrata.com/foundry/data.cityofnewyork.us/e4qk-cpnv</a></p>
<p>Using the 2.1 endpoint, you can e... |
overlaying boxes with the same factor <p>In the following plot, for every factor (week) there is three boxes, <a href="http://i.stack.imgur.com/6JIw5.png" rel="nofollow"><img src="http://i.stack.imgur.com/6JIw5.png" alt="enter image description here"></a>. However, I rather boxes from each week to be on top of each oth... | <p>We need <code>position = "identity"</code> with <code>alpha</code>, still looks less than ideal:</p>
<pre><code>ggplot(dat, aes(x = week_number, y = value, fill = condition)) +
geom_boxplot(position = "identity", alpha = 0.3) +
</code></pre>
<p><a href="http://i.stack.imgur.com/K18OS.jpg" rel="nofollow"><img sr... |
Playable Game Area in Swift 3.0 <p>I'm creating a mario clone for mac to help me learn swift programming. An issue I have come across is setting a playable game area. As of now, the 2 backgrounds I have ("background" and "level") will move when the left or right keys are pressed but grey areas at the sides will become ... | <p>I'm sure there is a much better, more clever solution, but off the top of my head you could add: </p>
<pre><code>let LEFTBOUND: Int = //Insert the left limit here.
let RIGHTBOUND: Int = //Insert the right limit here.
</code></pre>
<p>Inside <code>func keyDown()</code>, in the moving right/left if-statements, nest ... |
Extracting multiple links within a specific class <pre><code><div class="customer"><a href='view.php?customer=1234' class=''></div>
<div class="customer"><a href='view.php?customer=1235' class=''></div>
<div class="customer"><a href='view.php?customer=1236' class=''></... | <p>Unless there is a better way, I think this works...</p>
<pre><code> Elements links = doc.select("div.customer a[href]");
String absHref;
for (Element link : links) {
absHref = link.attr("abs:href");
System.out.println(absHref);
}
</code></pre>
|
i am not getting proper output in java using cmd .prompt <p>for large number of input the out put of the the last input is not displyed.
when i used to input 15 or more different input the output i get is one less than the given number of output . the output that is not displayed is the last output one. </p>
<pre><cod... | <p>Well I think, that second line of your code should explain the missing number from the input. You read first number from input and then do nothing with it:</p>
<pre><code>int t=sc.nextInt();
</code></pre>
<p>But there are more problems with your code.
Judging from casting to (long) you do in these lines:</p>
<pre... |
Undefined variable Laravel Foreach <p>I want to foreach some data but it says it doesn't know the variable:</p>
<p>The error I get:</p>
<pre><code> ErrorException in dbda158712a631f22ffd888cd244c74e60f3a433.php line 51:
Undefined variable: albums (View: /var/www/clients/client2/web2/web/resources/views/albu... | <p>You are passing album variable with view Album.blade.php, which is single object, not array of object so you can't iterate in a loop. </p>
<p>I think you are doing a mistake.</p>
<p>You want to do foreach in index.blade.php, because here you are passing the albums variable.</p>
<p>or </p>
<p>you need to return v... |
Connecting to MySQL DB in Java <p>I am running a database through 000WebHosting.com. When I try to connect to my database, I get the following error:</p>
<pre><code>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds a... | <p>Try to initilize your db connection like this (put your db name in the URL): </p>
<pre><code>final static String HOSTNAME = "yourdomain.com";
final static String PORT = "3306";
final static String USER = "youruser";
final static String PWD = "yourpassword";
final static String DBNAME = "dbname";
public java.sql... |
How to save field from ManyToMany relationship? Symfony2 <p>I have 2 entities, InProveedorProducto which has a id_producto field and InOrdenCompraDetalle which has a detail of a purchase order, including id_producto field too. InProveedorProducto in a table which has id_producto but also id_proveedor, that means that t... | <p>I think it's because you forgot to do this in your <code>__constructor()</code></p>
<pre><code>class InProveedorProducto {
public function __construct(){
$this->producto = new \Doctrine\Common\Collections\ArrayCollection();
}
}
class InOrdenCompraDetalle {
public function __construct(){
$t... |
GitPython "blame" does not give me all changed lines <p>I am using GitPython. Below I print the total number of lines changed in a specific commit: <code>f092795fe94ba727f7368b63d8eb1ecd39749fc4</code>:</p>
<pre><code>from git import Repo
repo = Repo("C:/Users/shiro/Desktop/lucene-solr/")
sum_lines = 0
for blame_com... | <p><code>git blame</code> tells you which commit last changed each line in a given file.</p>
<p>You're not counting the number of lines changed in that commit, but rather the number of lines in the file at your current HEAD that were last modified by that specific commit.</p>
<p>Changing <code>HEAD</code> to <code>f0... |
POST data from Chrome PostMan plug-in is empty in Eclipse PDT <p>I am trying to debug HTTP POST data sent to some AJAX PHP in Eclipse PDT and it is new to me, so I am probably making some very basic mistake.</p>
<p>I found what seems to be an excellent Chrome browser plugin: <a href="http://%20https://chrome.google.co... | <p>You are embedding your data in the <code>Header</code> section of PostMan. These are for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" rel="nofollow">HTTP Headers</a> and not what you want. When using angular's post method, the parameters are in fact embedded into the Body section of a POST req... |
Faster/shorter way to get an attribute's value in XElement with specified attribute in C# <p>Say I have something like:</p>
<pre><code><my-element>
<property name="the property name" value="the value"/>
<property name="some other property name" value="other value"/>
</my-element>
</code... | <p>I am not sure about this <em>subjective better way</em>, but you can also use <strong>Xpath</strong></p>
<pre><code>var xDoc = XDocument.Parse(xmlstring);
var val = (string)xDoc.XPathSelectElement("//property[@name='the property name']")
.Attribute("value");
</code></pre>
|
strtok() overwrites its source string <p>I'm writing a toy bash shell. My goal right now is to cycle through the environment looking for the path a specific command can be found at. Right now I am delimiting the PATH (e.g. "/home/user/bin:home/user/.local/bin:/usr/local/sbin" etc) by ":", and for each path that gives m... | <p>BLUEPIXY is right: the <code>tempEnv</code> isn't big enough for your string. Try:</p>
<pre><code>char *tempEnv;
tempEnv = malloc(strlen(path_var)+1);
strcpy(tempEnv, path_var);
</code></pre>
<p>and at the end</p>
<pre><code>free(tempEnv);
</code></pre>
<p><strong>With the proviso that</strong> this is full of ... |
Get UTC format from String Datetime <p>I have datetime in string format. What I need is to get the UTC format for the same datetime string so that I could send it on backend server. But also i need to send the correct UTC time means according to the time zone.</p>
<p>Example: I have a datetime string as "30-09-2016 22... | <p>When a <code>DateTime</code> is created in an app, usually it is <code>DateTimeKind.Local</code>, so you can just use the <code>ToUniversalTime()</code>method before you send it to your server.</p>
<p>If you have a string, just use <code>DateTime.Parse</code>, it would create a <code>Local</code> date time, which y... |
search for a word in file in bash and execute something if the word is present <p>I have written the following line as a bash:</p>
<pre><code>nmcli nm status id "My VPN id"> /home/Desktop/1.txt
</code></pre>
<p>So I want to check the id status and save it in the <code>1.txt</code> file.</p>
<p>Now I want to searc... | <p>To execute a command only if <code>connected</code> is not in <code>1.txt</code>:</p>
<pre><code>grep -q connected /home/Desktop/1.txt || nmcli con up id "My VPN id"
</code></pre>
<p><code>grep string file</code> will return exit code 0 (success) if the regex <code>string</code> is found in <code>file</code>. To ... |
Subset multiple dataframes in a loop in R <p>I am trying to drop columns from over 20 data frames that I have imported. However, I'm getting errors when I try to iterate through all of these files. I'm able to drop when I hard code the individual file name, but as soon as I try to loop through all of the files, I have ... | <p>As @zx8754 mentions, consider <code>lapply()</code> maintaining all dataframes in one compiled list instead of multiple objects in your environment (but below also includes how to output individual dfs from list):</p>
<pre><code>path <- "C://Home/Data/"
files <- list.files(path=path, pattern="^.file*\\.csv$")... |
Intel Pin with C++14 <h2>The Questions</h2>
<p>I have a few questions surrounding usage of Intel Pin with C++14 or other C++ verions.</p>
<ul>
<li>There are rarely any problems compiling code from older C++ with newer versions, but since Intel Pin is manipulates instruction level, is there any undesirable side effect... | <p>From the compiler options used to compile the pin tool, I presume you are using the latest version of Pin, namely 3.0. According to <a href="https://groups.yahoo.com/neo/groups/pinheads/conversations/messages/12185" rel="nofollow">Intel</a>, the CRT that ships with the framework doesn't support C++11 and later versi... |
String index out of range and Totals using input data <p>I need some help with the code below. I am trying to loop the program until the user selects 'N' and then I want to display the totals for lemonade sold in oz and total cookies and shirts of each kind.</p>
<p>I put in a while loop to loop the program but I get a... | <p>To get a single character from Standard Input (a/k/a STDIN a/k/a a keyboard), you can take one of two approaches:</p>
<pre><code>char tshirt = (char) System.in.read(); //Takes one character, casts to "char"
</code></pre>
<p>Or you can use a method from Scanner like so:</p>
<pre><code>char thsirt = scanner.next(".... |
Golang google sheets API V4 - Write/Update example? <p>Trying to write a simple three column table (<code>[][]string</code>) with Go, but can't.
The <a href="https://developers.google.com/sheets/quickstart/go" rel="nofollow">quick start</a> guide is very nice, I now can read sheets, but there no any example of how to ... | <p>Well after some tryouts, there is an answer. Everything is same as in <a href="https://developers.google.com/sheets/quickstart/go" rel="nofollow">https://developers.google.com/sheets/quickstart/go</a> Just changes in the main function </p>
<pre><code>func write() {
ctx := context.Background()
b, err := iout... |
Converting between timezones without affecting the actual time? <p>I am trying to store and retreive a date object that is supposed to remain consistant on saving regardless of whatever timezone the browser is set to. </p>
<p>For example. I have a 7PM IST which when converted with an offset should return to 7 PM of a ... | <p>convert the date into UTC format before you save to db</p>
<pre><code>moment.utc()
</code></pre>
<p>Whenever you retrive convert from UTC to local time.</p>
<pre><code>moment.utc(utcDateTime, utcDateTimeFormat).local().format(specifiedFormat)
</code></pre>
|
Accessing Undefined Value in Javascript <p>I'm having some problems in tackling this. </p>
<p>A user can upload an image to a variable called photo_id in my form. I take the first file object in photo_id and send it to the database to create a file object.</p>
<pre><code> if (photo_id) {
var file=photo_id[0]
... | <p>You are checking the length of the first element, but there is no first element. Use:</p>
<pre><code>if (photo_id && photo_id.length > 0) {...}
</code></pre>
|
Passing Quotation Mark Character (") as C# Console Application Argument <p>I have a project to demonstrate a program similar to the "echo" command in the MS-DOS Command Line. Here is the code in C#:</p>
<pre><code>using System;
namespace arguments
{
class Program
{
static void Main(string[] args)
... | <p>To be able to get the single quote, you'll need to bypass the default parsing performed by the CLR when populating the args array. You can do this by examining <code>Environment.CommandLine</code>, which in the case you describe above will return something along the lines of:</p>
<p><code>ConsoleApplication1.exe \... |
Why am I getting type specifier error in C programming? <p>I'm writing a program that shows the daily flights from one city to another:</p>
<pre><code> Departure time: Arrival Time
8:00 10:16 am
9:43 am 11:52 am
11:19 am ... | <p>First, your compiler should tell you what line each error is on. Look at those lines, and you should be able to figure out how each error should be fixed.</p>
<p>For example, compiling your code with gcc I get an error message:</p>
<pre><code>main.c:16:5: error invalid initializer
</code></pre>
<p>The <code>16</c... |
Get all files in array order by name c# <p>string mypath = txtPath.Text;</p>
<pre><code>DirectoryInfo d = new DirectoryInfo(mypath);
foreach (FileInfo fi in d.EnumerateFiles("*.jpg").OrderBy(x => x.Name))
txtStatus.Text = txtStatus.Text + fi.Name + Environment.NewLine;
</code></pre>
<p>the result of t... | <p>You are getting them in order. The problem is that they are strings, so you are getting them in string order.</p>
<p>The most straightforward solution is to rename your files so that they have the same number of digits, e.g. <code>banner-noche-estrellas-zacatecas2015_2.jpg</code> -> <code>banner-noche-estrellas-zac... |
Can I do checked arithmetic with Vector<T> <p>I've been experimenting with <a href="https://msdn.microsoft.com/en-us/library/dn858385(v=vs.111).aspx" rel="nofollow">Vector</a> to use HW to parallelise integer arithmetic. Is there any way to enable overflow checking with vector operations? </p>
<p>One example is to add... | <p>Using some trickery borrowed from Hacker's Delight (chapter 2, section Overflow Detection), here are some overflow predicates (not tested):</p>
<p>Signed addition:</p>
<pre><code>var sum = a + b;
var ovf = (sum ^ a) & (sum ^ b);
</code></pre>
<p>The result is in the signs, not full masks. Maybe that's enough,... |
Javascript Issue changing a form input <p>Thanks in advance.</p>
<p>I want to change the value of input text "total" in a form depending the value of the select "opciones". I tried with <code>onchange()</code>, with <code>document.getElementById("")</code>.value but it doesn't works.</p>
<p>I dont know what is failin... | <p>I think you should try to work with </p>
<pre><code>let e = document.getElementById("opciones");
let total = document.getElementById("total");
switch(e.selectedIndex) {
case 0:
total.value = 1000;
break;
case 1:
total.value = 1250;
break;
case 2:
total.value = 1500;
break;
default:
tota... |
Checking for user authentication error codes with Swift 3 <p>In older versions of Swift, the following code could be used to check for user auth errors: </p>
<pre><code> if (error != nil) {
// an error occurred while attempting login
if let errorCode = FAuthenticationError(rawValue: error.code) {
switc... | <p>Use <code>FIRAuthErrorCode</code> - it is an int enum </p>
<blockquote>
<p>enum FIRAuthErrorCode { FIRAuthErrorCodeInvalidCustomToken =
17000, FIRAuthErrorCodeCustomTokenMismatch = 17002,
FIRAuthErrorCodeInvalidCredential = 17004,
FIRAuthErrorCodeUserDisabled = 17005,</p>
</blockquote>
<p>From here... |
Scaling graphic assets vs calculating graphic assets size for different screen resolutions <p>Is it a best practice to calculate EXACT graphic assets' size for different screen resolution to increase performance? Or is it good enough to just calculate approximate final size of those assets and then scale them so they w... | <p>It's difficult to answer with all the different things you've tagged. </p>
<p>On a modern mobile platform, the compositing is probably GPU-side. The image will cover the same number of pixels regardless of the texture size, which means it'll run the pixel shader the same number of times. You may see moderate variat... |
Deserialize Json with object references <p>Is there a way to deserialize a JSON that includes references to objects that already exist inside it using typescript?</p>
<p>For example we have a grand parent "Papa" that is associated with two parents "Dad" and "Mom" that they have together two children, the json looks li... | <blockquote>
<p>So we face problem in front-end deserialisation </p>
</blockquote>
<p>you need to write most of the code yourself (or generate it using more code from your Java code). </p>
<p>That said, there are a few <em>hydration</em> helpers. I recommend : <a href="https://github.com/mobxjs/serializr" rel="nofo... |
How can I override Array Constructor in Ruby? <p>I have the following class:</p>
<pre><code>class Library < Array
attr_accessor :authors
end
</code></pre>
<p>And I would like to initilize the authors attribute inside the constructor of the class, and still use the Array#new behaviour. I tried this:</p>
<pre><co... | <p>So the <code>#initialize</code> override is failing because you're using object splat (<code>**</code>) instead of array splat (<code>*</code>). </p>
<p>But you shouldn't do this. Subclassing Ruby's core classes will lead to all sorts of counter-intuitive behavior because they have many methods that create new inst... |
Itertools Chain on Nested List <p>I have two lists combined sequentially to create a nested list with python's map and zip funcionality; however, I wish to recreate this with itertools. </p>
<p>Furthermore, I am trying to understand why itertools.chain is returning a flattened list when I insert two lists, but when I ... | <p>I'll try to answer your questions as best I can.</p>
<p>First off, <code>itertools.chain</code> doesn't work the way you think it does. <code>chain</code> takes <code>x</code> number of iterables and iterates over them in sequence. When you call <code>chain</code>, it essentially (internally) packs the objects into... |
Finding Mean of a text file seperated by spaces in R Language <p>I have some files with names Reg.stt in 30 different directories containing numerical data of integer and float type. I want to average out the data in another file. I don't know codding in R language. But according to my findings this is an easy job to w... | <p>Here is one way of doing it. I have made comments inside the code.</p>
<pre><code># Create a sub-folder into which we create files.
dir.create("temp_dir")
setwd("temp_dir")
# Create some files in temp_dir.
sapply(1:10, FUN = function(i) {
xy <- data.frame(a = rnorm(10), b = rnorm(10), c = rnorm(10))
write.t... |
load json file in nodejs/express app into d3 <p>I have an express app and I want to load json-data from the folder <code>public</code> into d3 (version 4).</p>
<p>My folder structure looks like this:</p>
<pre><code>public
|-myData.json
view
|-index.jade
app.js
</code></pre>
<p>The json data I want to load with d3:</... | <p>Make sure you point to the <code>public</code> folder in the first argument of <code>d3.json</code> <em>in respect</em> to where express is statically hosting the files.</p>
<pre><code>...
d3.json("../myData.json", function(data) {
console.log("d ", data);
});
});
</code></pre>
<p>Update: Edited ... |
Iterating to figure out combinations of variable number of elements <p>I'm making a program that uses dynamic programming to decide how to distribute some files (Movies) among DVDs so that it uses the least number of DVDs.</p>
<p>After much thought I decided that a good way to do it is to look at every possible combin... | <p>You should really stick to <a href="https://en.wikipedia.org/wiki/Bin_packing_problem" rel="nofollow">common bin-packing heuristics</a>. The wikipedia article gives a good overview of approaches including links to problem-tailored exact approaches. But always keep in mind: <strong>it's an np-complete problem!</stron... |
ruby on rails how to order by selection box <p>View:</p>
<pre><code><div>
<%= select_tag(:sorttitle, options_for_select(["title","publish_year"])) %>
<%= select_tag(:sortway, options_for_select(["Order By Asc","Order By Desc"])) %>
<%= submit_tag"Sort Books", class:"btn btn-info" %>
</div&g... | <p><code>@books = @books.order(params[:sorttitle] => :desc)</code></p>
|
If Cell Matches Cell in Either Column Return Adjacent Cell Text <p>So I have an excel spreadsheet that is supposed to keep track of grades, but I can't seem to get conversion from letter grades to numerical grades right. I'm trying to match cells from I21:I48 against reference letter grades in G10:G15 and I10:I15, and ... | <p><code>=IFERROR(IFERROR(VLOOKUP(I21,$G$10:$H$15,2,FALSE),VLOOKUP(I21,$I$10:$J$15,2,FALSE)),"???")</code></p>
<p>Pasting that in G21 and filling it down should do the trick.</p>
<p>This would have been a bit easier and required less nesting if your table was fully sequential, instead of having it split across four c... |
Remove "-" in all cell datas in Excel? <blockquote>
<p>I have 700 datas on one column in Excel and this datas has
"0956-989-52" format. How I can convert these datas to new format
"095698252", I means whitout "-" notation?</p>
</blockquote>
| <p>Select the column and set its format to text. This will prevent the converted data from being interpreted as numbers and lose leading zeros,</p>
<p>Use Find and Replace (<kbd>Ctrl</kbd>-<kbd>H</kbd>). In "Find what" enter a - sign. Leave "Replace with" blank and hit <kbd>Replace All</kbd></p>
|
python2.7 create array in loop <p>I would like to create a new variable in a loop with an index in which I write a 2d matrix of data. Something like this:</p>
<pre><code>import numpy
DARK = []
a = []
for i in range(0,3):
# create 3d numpy array
d = numpy.array([[1, 2], [3, 4]])
a.append(d)
stack = nump... | <p>After 4 days of trying I found the answer myself. Thanks for the great help guys...</p>
<pre><code>import numpy
DARK = []
a = []
stack = []
for i in range(0,3):
# create 3d numpy array
d = numpy.array([[1, 2], [3, 4]])
a.append(d)
stack.append(numpy.array(a))
# write it into the actual variable
... |
Different results from MySQL when run directly/run via bash <p>I run the code</p>
<pre><code>user@host:~$ mysql -h mysql-server -uuser -ppassword scans -N -B -e
'SELECT scan_id, count(*) FROM scan_info NATURAL JOIN found_results
WHERE fp_id = "1669" AND timestamp >= "2016-08-31"
ORDER BY scan_id LIMIT 1'
</co... | <p>There are three levels of quoting if the above command. This will cause a problem with the inner double quotes. Here's the command that bash will actual execute:</p>
<pre><code>mysql -h mysql-server -uuser -ppassword scans -N -B -e 'SELECT scan_id, count(*) FROM scan_info NATURAL JOIN found_results WHERE fp_id =... |
Using 'as' is giving two compile errors <p>I am not sure what is wrong (if anything, because it compiles fine, but when it does compile I get the following errors:</p>
<blockquote>
<p>src/Net/Route.ts(35,77): error TS1005: ',' expected.<br>
src/Net/Route.ts(35,80): error TS1005: '=' expected.</p>
</blockquote>
<p... | <blockquote>
<p>Then again I am using a new version of TypeScript (2.0.3).</p>
</blockquote>
<p>Actually you are probably using an <em>old</em> version of the compiler. This one works fine : <a href="http://www.typescriptlang.org/play/#src=let%20target%3A%20HTMLElement%20%3D%20document.querySelector(%22asdf%22)%20as... |
Angular2 ngModel binding in the third property level gets undefined <p>A weird thing is happening on my form or maybe i am not doing it right, let me explain to you by presenting my code.</p>
<p>i have defined a form object inside my component</p>
<pre><code>form = {};
</code></pre>
<p>There is a button on each row ... | <p>I am not sure if it helps your case, but I was in a very similar situation.</p>
<p>What helped me out was using the "safe-navigation-operator".</p>
<p>I assume that what you need to do is just add the <strong>?</strong> after <em>form</em>:</p>
<pre><code><input type="text" class="form-control" [(ngModel)]="fo... |
Basic Algorithm for Types of Triangles <p>Hi there I need to write algorithm which reads the largest angle of a triangle and the three sides from left, right then bottom. Then based on those results it outputs the specific angle/side triangle. </p>
<p>The specific triangles are acute scalene, right scalene, obtuse sca... | <p>You should be able to use the law of sines and then do a case by case analysis to figure out which kind of triangle your given triangle is. </p>
|
Got "is not a recognized Objective-C method" when bridging Swift to React-Native <p>I'm trying to bridge my React-Native 0.33 code to a super simple Swift method, following <a href="https://facebook.github.io/react-native/docs/native-modules-ios.html" rel="nofollow">this guide</a> but all I'm getting is <code>show:(NSS... | <p>I just tried this with Swift 3 and RN 0.33.0 without any issue by using: </p>
<pre><code>import Foundation
@objc(SwitchManager)
class SwitchManager: NSObject {
@objc func show(_ name: String) {
NSLog("%@", name);
}
}
</code></pre>
<p>This relates to Swift 3's <a href="https://github.com/apple/swift-evol... |
cast cx_vec element to double complex armadillo c++ <p>I've got a vector <code>cx_vec A(2);</code>. I'd like to pick the first element and get its argument. I have found no function in armadillo to do this so I am trying to do <code>arg( A.row(0) )</code> however <code>arg</code> expects a <code>double complex</code>. ... | <p>This should do the trick:</p>
<pre><code>arma::cx_vec A(2);
// ... fill A with stuff ...
double x = std::arg( A(0) );
</code></pre>
|
A more high-level explanation of Forth <h2>Preamble</h2>
<p>Forth, through the few manuals I've read, is often defined in extremely low-level terms, typically in assembly. Defining Forth in this way is extremely counter-intuitive for understanding implementations, and truly only shines for writing assembly-based or ot... | <p>Any Forth implementation can be logically divided into the following layers (or mechanisms):</p>
<ol>
<li><p>Forth processor. It includes access to the data stack, return stack, memory, call and return from subroutine, logical and arithmetic operations.</p></li>
<li><p>Code generator. It is responsible for access t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.