input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Run time (number of steps) of loops with conditions <p>I'm not sure how to determine the run time in terms of input size N, particularly when it gets into loops with certain restrictions. This is what I've attempted. I'm guessing the constants are correct. How does it look?</p>
<pre><code>i = 1; ... | <p>This is known as burning the candle from both ends. <code>i</code> and <code>k</code> are going to meet in the middle somewhere, but each element in the array is visited exactly once. So the run time is <em>O(n)</em>.</p>
<p>The outer <code>while</code> loop is just waiting for the process to finish, so doesn't fac... |
Center a popup window with JavaScript <p>I am using the following JavaScript to open a popup window, which does work, however it is not centered, just wondered if someone can help?</p>
<pre><code>var win = Runner.displayPopup( {
url: "Wizard_ExternalFactors_add.php",
width: 1400,
height: 900,
header: '... | <p>Something like this should work:</p>
<pre><code>top:50%;
left:50%;
margin-top:-450px;
margin-left:-700px;
</code></pre>
|
ddd: logic that spans multiple models, where should it go? <p>I am working on an system and am trying to utilize ddd with node.js. Here is the an example for the system, from a high-level:</p>
<pre><code>database tables(mongoldb):
user
username: String
firstName: String
middleName: String
lastName... | <p>Where did you get the idea services should not call other services. Security usually is a separate service or whatever.</p>
|
Android error inflating calendar layout <p>I am getting an exception when trying inflate this layout with a calendar from <a href="https://github.com/npanigrahy/Custom-Calendar-View" rel="nofollow">https://github.com/npanigrahy/Custom-Calendar-View</a>.</p>
<p>The exception is:</p>
<pre><code> java.lang.RuntimeExcep... | <p>Make sure you have <strong>CustomCalendarView</strong> at this location <code>com.stacktips.view.CustomCalendarView</code>.</p>
<p>The error is possibly because you donot have the CustomCalendarView class at the location com.stacktips.view.CustomCalendarView. If you have it in a different location you should have t... |
Hide app vertical scrollbar <p>I would like to have the vertical browser scrollbar always visible.
In the styles.css I have the following:</p>
<pre><code> html,
body {
overflow-y: scroll;
}
</code></pre>
<p>But Angular will show another scrollbar (a disabled one) next to the browser scrollbar </p>
<p>Howeve... | <p>You have one scrollbar for the body and another for the html element. If you just want one scrollbar you can use:</p>
<pre><code> body {
overflow-y: scroll;
}
</code></pre>
<p>Or</p>
<pre><code> html {
overflow-y: scroll;
}
</code></pre>
|
Multi posts per pages with Hakyll <p>I'm making a website with <strong>Hakyll</strong> and I would like to gather some posts in the same page. I find somes example on websites such as <a href="https://github.com/dannysu/hakyll-blog/blob/master/site.hs" rel="nofollow">dannysu</a> or <a href="http://www.eanalytica.com/si... | <p>This basic compile rule must be run before pagination : </p>
<pre><code>tools = do
match "tools/*" $ do
route $ setExtension "html"
compile $ compiler
>>= loadAndApplyTemplate "templates/tools.html" postCtx
>>= relativizeUrls
</code></pre>
<p>And then, it Work!</p>
|
How to get data from text area and show it like news feed as messages <p>This is my form area where I am using text field or text area for status messages I want to get text from text area and want to print them.</p>
<pre><code><form class="form-horizontal" method="post" id="status-update-form">
<div clas... | <p>You can access array $_POST after sending the form, e.g. $_POST['status']</p>
<pre><code><?php
if($_POST)
{
print_r($_POST);
}
?>
<form class="form-horizontal" method="post" action="" id="status-update-form">
<div class="form-group">
<div class="col-sm-8">
<tex... |
Angular controller syntax <p>While reviewing angular interview <a href="http://www.codeproject.com/Articles/891718/AngularJS-Interview-Questions-and-Answers" rel="nofollow">question and answers</a>, I noticed that the author has written the controller's syntax as follows:</p>
<pre><code>function Customer($scope)
{
... | <p>John Papa who is the nationally recognized "guru" on Angular and he recommends creating controllers as in your first example. See <a href="https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#controllers" rel="nofollow">HERE</a> for usage.</p>
|
Full width div below list row visible on click <p>I'd like to have a series of rows of images (all the same size) that, when clicked, open a description below that fills the width of the screen (see image below). </p>
<p><a href="http://i.stack.imgur.com/oni3F.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/oni... | <p><a href="http://jsbin.com/reqibarica/4/edit?html,css,js,output" rel="nofollow">EXAPMPLE SOLUTION is here on jsbin</a></p>
<p>You can change your CSS </p>
<blockquote>
<p>.item { width: calc(19% - 10px); }</p>
</blockquote>
<p>or</p>
<blockquote>
<p>.item { width: calc(20% - 14px); }</p>
</blockquote>
|
How do I programmatically validate a cypher query in Neo4j? <p>Is there any way to use the Java API to validate a Neo4J Cypher query programmatically?</p>
| <p>Based upon this thread, the compilation of cypher is handled by scala:</p>
<p><a href="http://grokbase.com/t/gg/neo4j/14amay53ch/cypher-grammar-file" rel="nofollow">http://grokbase.com/t/gg/neo4j/14amay53ch/cypher-grammar-file</a></p>
<p>The link on that thread is out of date, so heres the latest on github:</p>
<... |
Call something based on UITableView rows selected, in an IBAction <p>I just saw a post about selecting multiple UITableView rows and based on which row/rows are selected, something will happen when you press a button linked to an IBAction.</p>
<p>It's an interesting question and I've played around with it, but now I'm... | <p>Here is what I will do,</p>
<p>1st, get the array of selected rows by using <a href="https://developer.apple.com/reference/uikit/uitableview/1614864-indexpathsforselectedrows" rel="nofollow">indexPathsForSelectedRows</a>, </p>
<p>2nd, iterate the array to check if if indexPath.row is 1 or 2.</p>
<p>3rd, if your i... |
Starting a Timer Intermittently Deadlocks at Application Startup <p>I have an application with two separate GUI threads, and the main Form is run on each thread. (This is to allow simultaneous independent users on different screens.)</p>
<p>Each of these windows has an InactivityTimer component, which is used to take ... | <p>I only just today lucked into figuring out what was going on, because the debugger suddenly stopped in a completely different place.</p>
<p>rory.ap was correct in the comments that only things like locks, etc. would cause such a deadlock. However when I was looking over my code, it just never clicked that <code>Inv... |
How to apply multiple validations on a single cell in Google Spreadsheets <p>I have first column <strong>Date</strong> in my spreadsheet. I need two validations here.</p>
<ol>
<li><p>No cell of this column (date) can be filled if the previous one is empty. For example, you cannot fill A3 if A2 is empty. For that, I wr... | <p>Try:</p>
<pre><code>=if(and(A2="", ISERROR(DATEVALUE(A2))),"true", "false")
</code></pre>
|
java.util.Optional to java.lang.Iterable? <p>Is there a better alternative to writing a custom function? Preferably in the stock JDK?</p>
<p>If not, is there a better implementation than the following:</p>
<pre><code>public static <T> Iterable<T> toIterable(Optional<T> o) {
if (o.isPresent()) {
... | <p>Using <code>Optional.isPresent()</code> is usually code smell - it is no different from <code>!= null</code>.</p>
<pre><code>public static <T> Iterable<T> toIterable(Optional<T> o) {
return o.map(Collections::singleton)
.orElseGet(Collections::emptySet);
}
</code></pre>
<p>Also, a... |
R: Splitting comma-separated values from one column into a new dataframe (or how to use strsplit results) <p>I have a list of test results from two different groups that I've brought into R, and I have very little experience with R. My current dataframe looks like this:</p>
<pre><code>Samples <- c("A","B","C","D",... | <p>I'd do the following in this case: I create the data and calculate <code>split2</code> like you do (except I used <code>stringsAsFactors=FALSE</code> when creating the data.frame.) and go on like this:</p>
<pre><code># get the maximal length of the vectors in split2
ncol_new <- max(sapply(split2, length))
# set ... |
Include Bootstrap glyphs in Laravel Collective link <p>I'm using Laravel Collective's <code>link_to_route()</code> method to create a link. I want to include a Bootstrap glyph with this link.</p>
<p>As it is now, it's printing the actual Html code.</p>
<p>Any tips on how to do this?</p>
<p>My current code:</p>
<pre... | <p>There are few packages you can use,</p>
<ul>
<li><a href="https://github.com/patricktalmadge/bootstrapper" rel="nofollow">https://github.com/patricktalmadge/bootstrapper</a>
<a href="https://github.com/bradcornford/Bootstrapper" rel="nofollow">https://github.com/bradcornford/Bootstrapper</a>
Using these you can ea... |
How to output mongoose/mongodb query with date fields that print strings with specific format? <p>I'm querying mongoDB via mongoose for some items that have fields of Date type.<br>
I'm passing the result of this query to express as a web response.
<br>Somewhere, this Date is being converted to a string. The output is ... | <p>For this you can you the aggregation operator <a href="https://docs.mongodb.com/manual/reference/operator/aggregation/dateToString/" rel="nofollow">$dateToString</a></p>
<p>do something like:</p>
<pre><code>db.table.aggregate(
[
{
$project: {
fullYear: { $dateToString: { format: "%Y", date... |
Compile to .dll with some undefined references with MinGW <p>I heard somewhere that all Windows .DLLs <em>must</em> contain definitions for every symbol it references, so a .DLL file like this would never compile since it doesn't implement <code>bar()</code>.</p>
<pre><code>void bar();
__declspec(dllexport)
void foo(... | <p>I figured out how to do it with MinGW.</p>
<p>Usually, when linking DLL files (e.g. <code>plugin.dll</code>), you export a list of symbols to <code>libplugin.a</code>, but in this case, I actually want to export the symbols from the host executable <code>host.exe</code> to <code>libhost.a</code>.</p>
<p><code>x86_... |
Using jq to append output generated from Ansible template <p>I am writing Ansible play, one of the tasks is to append entry to a JSON document. E.g.</p>
<p>JSON document <code>staff.json</code>:</p>
<pre><code>{
"staff":[
{
"john":[
{
"position":"techwriter"
},... | <p>You may use <code>template</code> lookup plugin:</p>
<pre><code> - shell: cat staff.json | jq '.staff |= . + [{{ item | to_json }}]' > staff.json
with_template: person.j2
vars:
staff_name: jane
staff_position: admin
staff_sex: female
</code></pre>
<p>Note that you need to ... |
Transform kinect v2 coordinate to another coordinate <p>I actually measured (x,y) joint position that related to a human skeleton in the sagittal plan using Kinect v2 camera. Now, I want to create the angle between Kinect v2 and skeleton direction of motion( like in this figure: <a href="http://www.mediafire.com/file/7... | <p>I have no kinect available right now, but here is the theory how I would tackle this:</p>
<p>First of you seem to already be able access the different joint coordinates, so you have sth like this:</p>
<pre><code>if (body.IsTracked)
{
Joint spineMid = body.Joints[JointType.SpineMid];
float x = spineMid.Posi... |
How to make a complete Iframe registration / login / userpanel <p>So far i have such code</p>
<pre><code><form action="register.php" target="login" type=post>
<label for="name">Account </label><br><br>
<input type=text id="name" name="account" size=20 maxlength=<?php Echo MaxNa... | <p>I don't understand why you are using an iframe for this but I can see that you use $_GET in your php when your form submits $_POST (type="post")</p>
<p>Try changing that in your PHP code and see if it works</p>
<p>Edit*
As stated in the comments this is not a $_GET index $_GET["account"]["password"]</p>
<p>Let's ... |
Split is not a function? <p>I have this code I was testing with:</p>
<pre><code>var test:String="Hello there; im zane"
var parts:Array=test.split(";");
trace(parts)
trace(parts[0])
var randomnum:Number=0;
stage.addEventListener(Event.ENTER_FRAME, code)
function code(c:Event):void{
if(parts[randomnum] != undefined... | <blockquote>
<p>I also tried <code>parts[0]=parts[0].split(" ")</code> out of the event and it worked fine.</p>
</blockquote>
<p>Even outside of the event, this line doesn't make much sense, because it assigns the return value of <code>split()</code> to the same variable that the method was invoked on. As the <code>... |
How to authenticate against Kubernetes clusters running on Google Container Engine using REST API? <p>I'm writing an application to monitor a kubernetes cluster running on Google Container Engine. On the host where my application deployed, there are no <code>kubectl</code> and <code>gcloud</code> CLI nor are they allow... | <p>Token can be retrieve from <a href="https://developers.google.com/oauthplayground/" rel="nofollow">Google OAuth Playground</a></p>
<p>Kubernetes can be reached by the following <code>curl</code> command via REST API</p>
<pre><code># curl --insecure -H "Authorization: Bearer $MyBearerToken" https://${Kubenetes_IP}/... |
Showing characters instead of integers in arcs in OpenFST(PyFST) <p>I'm using the method <code>linear_chain</code> to accept a <code>String</code>. When I convert it into a <code>fst binary</code> to then into a <code>DOT</code> format, I get integers instead of the characters. Also, I have a SymbolTable for each of th... | <p>To do this on the command line, make sure you provide both an input and output symbol table. The command should be something like</p>
<pre><code>fstdraw --isymbols=input_syms.txt --osymbols=output_syms.txt fst.bin
</code></pre>
<p>I haven't used "PyFST", but I would suggest you use the Python bindings that are in... |
Functioning wordpress site address moved on same domain and server per WP directions but not now showing up <p>Co-Hosting on GoDaddy, have had a fully functioning WordPress site setup under the primary domain in a sub-folder renamed from "/wordpress/" to "/opportunities/" as in => "http: //howtoliveoffthegridnow.com]/o... | <p>Insomuch as I could gather from your question, you are trying to move (migrate) the WordPress site from a sub-folder to a subdomain (and it is not working).</p>
<p>Here is how I would go about with this:</p>
<p>On your original/working (sub-folder based) site, install this plug-in:</p>
<p><a href="https://wordpre... |
Angular2 View Child Undefined Error <p>I'm trying a very simple example of calling <strong>childMethod</strong> inside the child component from the parent component via <strong>@ViewChild()</strong> decorator. Unfortunately, the ViewChild variable is always undefined.</p>
<p><strong>Child Component</strong></p>
<pre>... | <p>This is the culprit:</p>
<pre><code>*ngIf="selectedCharacter"
</code></pre>
<p>That <code>ngIf</code> will prevent the <code>ViewChild</code> from being instantiated before it's too late. You can move it to inside <code>MyCharacter</code>'s template to have the <code>ViewChild</code> reference in parent component ... |
php array unique type check <p>I am using <code>array_unique</code> to get rid of the duplicate values in an array. But, the problem is <code>array_unique</code> does not consider data types while checking for duplicates. For example:</p>
<pre><code>$a = [1, true, null, false];
$u = array_unique($a);
var_dump($u);
</c... | <p>I came up with this solution that seems to work:</p>
<pre><code><?php
function array_really_unique($array){
foreach ($array as $key => $item){
foreach ($array as $key2 => $item2)
if ($key2 != $key && $item2 === $item)
unset($array[$key]);
}
return $ar... |
Using Razor templating engine on mac <p>I've been asked to redo the HTML and CSS for a website built on .net and which uses the Razor templating engine. It would be easy enough to simply go through all the Views and cshtml files and swap out the old markup with my own and to also include my own CSS. But how would I be ... | <p>If those views are just simple .cshtml files without things like <code>@Html.RenderPartial</code> you should be able to treat them just like simple, static HTML files and do the development the way you always do. Maybe you would have to replace <code>@Script</code> and <code>@Styles</code> Razor tags with pure HTML ... |
FXML set percentWidth on target node directly <p>Is it possible to set the percentWidth in the target node directly? I tried but im getting many errors if I do so:</p>
<pre><code><GridPane>
<Button fx:id="node" id="node" text="fooBar"
GridPane.columnIndex="1" GridPane.hgrow="always" GridPane.percentWid... | <p>No. There is no static <code>setPercentWidth(Node, ...)</code> method in <code>GridPane</code> (see <a href="https://docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/GridPane.html" rel="nofollow">docs</a>). </p>
<p>It wouldn't really make sense to allow this anyway; it would enable you to set different perc... |
C# Generic Method to avoid code duplication <p>I am working with three different classes that have a common interface. However, the interface, does not include all of the methods and properties for all three. Therefore, I am stuck with a situation where I have code duplication, see below:</p>
<pre><code>if (party is E... | <p><a href="http://automapper.org/" rel="nofollow">Automapper</a> is designed for exactly this purpose. You can set up maps between different object types, and it can automatically map properties of the same name. Here is a <a href="http://stackoverflow.com/questions/20635534/simple-automapper-example">simple example... |
Recursively count string inside of a string java <p>I am supposed to recursively count how many "XX" are in a string, if there is a small x in front of a double X it should not be counted. I am not sure what I am doing wrong; I seem to be getting stuck at the very first return, I keep getting 0.</p>
<p>UPDATE: I have ... | <p>Since the end index in the call of <code>substring</code> is <em>exclusive</em>, the call of <code>substring(0, 1)</code> will never return a two-character string; only a string consisting of the first character will be returned.</p>
<p>To take two characters first check that the length is two or more, and then cal... |
Kendo notification widget hide and show multiple times <p>I'm working on a set of CRUD operations and the Kendo notification widget is called at requestEnd. The issue is that I need to set up either </p>
<p>autoHideAfter: 5000,
or hideOnClick: true</p>
<p>The issue is that if the user attempts multiple CRUD operatio... | <p>It is possible to remove the existing visible notification messages before showing a new one. Use the <code>getNotifications</code> method and remove them from the DOM:</p>
<p><a href="http://docs.telerik.com/kendo-ui/api/javascript/ui/notification#methods-getNotifications" rel="nofollow">http://docs.telerik.com/ke... |
For loop algorithm to print right triangle with characters <p>Trying to print to console a text isoscles triangle of arbitrary size like below:</p>
<p><img src="http://i.imgur.com/lSMnsUG.jpg" alt="Image"></p>
<p>I've done transformation algorithms like this before but the fact its drawing just the shape outline is t... | <p>If you describe in text what each line is, you'll see there are three patterns, and the middle pattern needs a loop:</p>
<pre><code>o 1 'o' character
oo 2 'o' characters, separated by 0 spaces
o o 2 'o' characters, separated by 1 space
o o 2 'o' characters, separated by 2 spaces
o o ... |
How does Java represent an image using a byte[] array? <p>I'm just curious how java manipulate images and image processing. In matlab, image is saved as a 3D array of RGB values. But in Java we use byte[] arrays to store an image. But that array is a 1D array.</p>
<p>I'm wondering how this array can represent RGB valu... | <p>It's not only java. Low level screen memory use byte[] (linux frame buffer for example)</p>
<p>Depending on bpp (bits per pixels) size.
For 32 bpp you have 4 bytes for r,g,b,a values.
A color value goes from 0 to 255.
Each image line following the precedent in a one byte array.
Then width x 3 give you the 3rd row f... |
PyQt - QDialogButtonBox signals and tool tip <p>I got a couple of questions regarding qDialogButtonBox. While my code still works, I believed that there are a few parts that can be better refined/ I am not finding much info online</p>
<pre><code>class testDialog(QtGui.QDialog):
def __init_(self, parent=None):
... | <ol>
<li><p>Yes, that is the correct way to write signal connections (the other syntax you found is indeed the old way of doing it). You can find all the signals in the pyqt documentation for <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qdialogbuttonbox.html" rel="nofollow"><code>QDialogButtonBox</code></a>. Diffe... |
View - but not intercept - all IPv4 traffic to Linux computer <p>Is there a way to view all the <strong>IPv4</strong> packets sent to a Linux computer?</p>
<p>I know I can capture the packets at the ethernet level using libpcap. This can work, but I don't really want to defragment the IPv4 packets. Does libpcap provi... | <p>Yes, you can see all the packets that arrive at your network interface. There are several options to access or view them. Here a small list of possible solutions, where the first one is the easiest and the last one the hardest to utilize:</p>
<h2>Wireshark</h2>
<p>I'd say this is pretty much the standard when it c... |
Is reading a CSV file from S3 into a Spark dataframe expected to be so slow? <p>I am building an application that needs to load data sets from S3. The functionality is working correctly, but the performance is surprisingly slow. </p>
<p>The datasets are in CSV format. There are approximately 7M records (lines) in e... | <p>After some more digging I discovered that using S3 native makes a huge difference. I just changed the URI prefix to s3n:// and the performance for the job in question went from 2.5 minutes down to 21s. So only a 3s penalty for accessing s3 vs hdfs, which is pretty reasonable. </p>
<p>When searching for this topic t... |
Generating IDs, based on what number is not in use as an ID of other comment <p>I'm making this algorithm that should generate new ID for newly created comment. ID should be unique, so I made several loops, that iterate over existing comment's IDs and check if a number is already in use as a ID on other comment. </p>
... | <p>solution using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce" rel="nofollow">Array.prototype.reduce()</a></p>
<pre><code>var nextId = comments.reduce(a,c){
return Math.max(a, c.id);
},0) +1;
</code></pre>
<p>just get highest current and add one</p>
|
How to hide implicit parameters in the middle on apply chain <p>Reduced example:</p>
<pre><code>class Factory(x : Int) {
def apply(y : Int)(z : Int) : Int = x + y + z
}
class Sample {
def get[B <% Int](x : B) = new Factory(x)
}
val s = new Sample
</code></pre>
<p>What I want: <code>s.get(2)(3)(4)</code> shou... | <pre><code>s.get(2)(implicitly)(3)(4)
</code></pre>
<p>(<code>implicitly</code> is just a method defined in <code>Predef</code>: <code>def implicitly[A](implicit x: A) = x</code>.)</p>
|
manually building installing python packages in linux so they are recognized <p>My system is SLES 11.4 having python 2.6.9.
I know little about python and have not found where to download rpm's that give me needed python packages.<br>
I acquired numpy 1.4 and 1.11 and I believe did a successful <code>python setup.py bu... | <p>If you're using linux, make sure your <code>$PYTHONPATH</code> environment variable is set properly.</p>
<p>To do this type the following in the terminal:</p>
<pre><code>echo $PYTHONPATH
</code></pre>
<p>If you can't find it you can manually set the variable with the locations of the modules you want to find in y... |
Create a new object in angular <p>I'm new to programming and I'm having an issue with a memory concept.<br>
I have a <em>users</em> page displaying the users in the database through an ng-repeat, and each user has an option to edit or delete.
I also have a button on that page to add a new user. My issue is that when I... | <p>Some fundamentals and simplifications.</p>
<blockquote>
<p>When you push an object to an array it does not make a copy of the
object..it is a reference to that object. This is a critical concept to understand in javascript and fundamental to a lot of working with angular</p>
</blockquote>
<p>Editing the same o... |
How do I convert underscore into human-readable names in Java? <p>I'd like to write a method that converts CamelCase into a human-readable name.
This is very similar to <a href="http://stackoverflow.com/questions/2559759/how-do-i-convert-camelcase-into-human-readable-names-in-java">this question</a> but now with unders... | <p>A naive way of accomplishing this would be to replace every <code>'_'</code> with a <code>' '</code>, and then trim the whitespaces off the final string: </p>
<pre><code>public static String splitUnderscore(String s) {
return s.replace("_", " ").trim();
}
</code></pre>
<p>While the above works for most cases, ... |
Error while using jquery validation engine <p>I am trying to debug an old application and I created a separate html to debug jquery validation engine behavior.</p>
<p>I am getting this error:</p>
<pre><code>jquery.validationEngine.js:28 Uncaught TypeError: $(...).on is not a function
</code></pre>
<p>This error poin... | <p>You're using jQuery 1.4.4 but the <code>.on()</code> function was added in version 1.7</p>
|
Function simpleNameGame is undefined <pre><code>//main\
<html>
<head>
<script language="javascript" type="text/javascript" src="functions.js"> </script>
</head>
<body>
<head>CODE CHALLENGE</head>
<p>Andrea</p>... | <p>You need to keep your script code in script tags.</p>
<p>Example Snippet:</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-html lang-html prettyprint-override"><code><html>
<head>
<script ... |
cant echo javascript alert from php <p>I've looked for an answer already, but I understand how to achieve an alert from php I just don't know what I am doing wrong on this particular piece of code.<br>
I had this working until I added the if statement.</p>
<pre><code>if ($errors) {
echo "<script type='text/... | <p>I think you are doing the opposite of what you want:
Your if case doesn't match the action performed inside.
Maybe you should do:</p>
<pre><code>if (!$errors) {
echo "<script type='text/javascript'>";
echo "alert('Records Were Uploaded');";
echo "window.location.href = 'EmployeePicker.... |
Binary - Two's Compliment Addition <p>I've been given the directions</p>
<p>Add the following binary 2's compliment representation values
in 16 bits, then write "overflow".</p>
<p>0001 0101 0111 1101
+ 0111 1111 1011 1111 </p>
<p>I've tried to understand 2's complement, and I do to an extent. But, I'm still not cle... | <p>Two's compliment is a representation for handling positive and negative values in a way that allows you to follow the mechanics for doing addition as if they were positive values, but end up with the correct result even if either or both values represent negative values.</p>
<p><em>Taking</em> the two's compliment ... |
Real time text box value replace while typing for translator <p>First I want to tell you i am a beginner of JQuery. I am trying to build a translator in real time replacement on text box for a example if I typed "A" on text box, that is want to replace to "B".</p>
<p>This is want to check up to 3 words. Which means,</... | <p>Try this fiddle: <a href="https://jsfiddle.net/L9fe0py3/2/" rel="nofollow">https://jsfiddle.net/L9fe0py3/2/</a></p>
<pre><code>$(document).ready(function() {
var dict = [{word:"A",replacement:"B"},{word:"AB",replacement:"C"},{word:"ABZ",replacement:"D"}];
$('#txt').blur(function(){
for(var i=0;i<dict.l... |
Ruby / Rails - NoMethodError in Pages#home - Partial View <p><strong>Error:</strong>
<em>NoMethodError in Pages#home (emphasized text undefined method `profile' for nil:NilClass</em>)</p>
<p><a href="http://i.stack.imgur.com/53TRi.png" rel="nofollow"><img src="http://i.stack.imgur.com/53TRi.png" alt="enter image descr... | <p>The problem is <code>@user</code> is <code>nil</code> and you can't call the <code>profile</code> method on a <code>nil</code> object.</p>
<p>If you look closely, your <code>before_filter</code></p>
<pre><code>before_action :authenticate_user!, except: [:landing, :home, :plan]
</code></pre>
<p>is not calling <co... |
add string to the beginning of a file and another string to the end of a file <p>this is my file </p>
<pre><code>$ cat testjson2
[alot of text]
</code></pre>
<p>I would like to end up with below: (<code>{ "aaData":</code> append at the start of the file <code>}</code> appended at the end of the file)</p>
<pre><code>... | <p>Try:</p>
<pre><code>$ sed '1s/^/{ "aaData": /; $ s/$/ }/' testjson2
{ "aaData": [alot of text] }
</code></pre>
<p>This uses two substitute commands:</p>
<ul>
<li><p><code>1 s/^/{ "aaData": /</code> adds text to the beginning of the first line.</p>
<p><code>1</code> matches on line 1. <code>^</code> matches on t... |
Teradata distance between two geo-coordinates using ST_SPHERICALDISTANCE <p>I have read that in Teradata Version 13 and onward you can use ST_SPHERICALDISTANCE for calculating geo-distance.
I written a simple test query in Teradata:</p>
<pre><code>Select
Cast('POINT(-35.0000, 150.0000)' As ST_GEOMETRY) As location1,
C... | <p>Simply remove the comma within the point definition :)</p>
<pre><code>Select
Cast('POINT(-35.0000 150.0000)' As ST_GEOMETRY) As location1,
Cast('POINT(-35.0000 149.0000)' As ST_GEOMETRY) As location2,
location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km
</code></pre>
<p>Btw, another way to create a point:<... |
What is more in the spirit of the Julia language and philosophy? <p>I recently started programming in Julia for research purposes. Going through it I started loving the syntax, I positively experienced the community here in SO and now I am thinking about porting some code from other programming languages. </p>
<p>Work... | <p>The most you'll find is that there is an "official" <a href="http://docs.julialang.org/en/release-0.5/manual/style-guide/">style-guide</a>. The rest of the "Julian" style is ill-defined, but there are some ways to heuristically define it.</p>
<p>First of all, it means designing the software around multiple dispatch... |
Android - How to properly show a fragment when a radio button is checked by default? <p>I'm trying to make an app using fragments, based on this docs: <a href="https://developer.android.com/guide/components/fragments.html" rel="nofollow">Fragments</a>.</p>
<p>As far as I can understand, I need:</p>
<ul>
<li>Host Acti... | <p>What is happening is that you are checking the radio by default, and only loading fragments if the radio is changed or pressed. I would suggest loading the default fragment at runtime to avoid having to hit the button to get it to show up.</p>
|
Creating a Doughnut chart using JSON and chart.js <p>this is the first time I am playing with chart.js for analytics purpose. I have been googling around for a full solution on how to pass JSON data from SQL Database using LINQ Lambda expression into chart.js on a .NET platform. However I could not find a good tutorial... | <p>I see various issues.</p>
<p>In the $.ajax call, in the data attribute you send "{}" string instead of a JSON: {}.</p>
<p>In the getPieChartData() WebMethod you return a list of object but it shouldn't return a JSON valid string?!.</p>
<p>Read the documentation of <a href="http://www.chartjs.org/docs/#doughnut-pi... |
How to get a list of stylesheets in the documents? <p>I want to first get the list of stylesheets in the documents and then list the classes used in the particular stylesheet. I will populate those list of classes in a drop down.</p>
<p>I used <code>document.styleSheets</code> to get the list of stylesheets, but I onl... | <p>You can call <code>getElementsByTagName</code></p>
<pre><code>var stylesheets = document.getElementsByTagName('style');
stylesheets = Array.prototype.slice.call(stylesheets);
stylesheets.forEach(function(value) {
// Do something will value.className, or value.id, etc
// value is HTMLStyleElement
var cl... |
How to place HTML objects inside a mobile container <p>I want to place an image of mobile inside my webpage and i want to show all contents inside that mobile.for practical demostration,please have a look on <a href="http://goratchet.com/components/" rel="nofollow">http://goratchet.com/components/</a>
and please tell m... | <p>Try this snippet: <a href="https://jsfiddle.net/nwmbm21f/" rel="nofollow">https://jsfiddle.net/nwmbm21f/</a></p>
<p>HTML:</p>
<pre><code><div class="device" style="" id="barsInDevice" style="background-color:Lime;"></div>
</code></pre>
<p>CSS:</p>
<pre><code>.device {
position: relative;
top:... |
How to show the actual data of [object Object] in kendo grid <p>I'm trying to implement kendo grid with dynamic columns and the data showing [object Object].</p>
<p>How to show the address[object,Object] data in my kendo grid and i would like the sample output to be like the table below:-</p>
<pre><code>Name | ... | <p>You can utilize the <code>columns.template</code> functionality to achieve the desired result. (<a href="http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.template" rel="nofollow" title="Documentation Reference">Reference</a>)</p>
<p>Depending on your data-structure you could use a templ... |
linked list input type problems <p>I have this code where the user is asked to input a number to let the program know how big my linked list will be then the next user inputs will be the data pushed into the links. I am having no problems with integers but for whatever reason once I start using decimal points, for exam... | <pre><code>scanf_s("%d", &x);
</code></pre>
<p>should be</p>
<pre><code>scanf_s("%lf", &x);
</code></pre>
<p><code>%d</code> is for reading in a decimal integer. <code>%lf</code> is for <a href="http://stackoverflow.com/a/28566203/1270789">reading in a long floating point number</a>, that is a <code>double<... |
Converting an If-Else statement into a Formula <p>I have code as follows:</p>
<pre><code>`if (a <= 10){
z = 5;
} else {
z = -1;
}`
</code></pre>
<p>I figured out that when <code>s(10 - a) = |10 - a| / (10 - a)</code> where it outputs a 1 or -1. It outputs <code>1</code> if <code>a < 10</code> and <cod... | <p>An if statement can be transformed into a formula by using the following trick: we need to find a formula that's 1 if the <code>if</code> statement is true and 0 otherwise. We can use the signum function for this:</p>
<pre><code> f(x, y) = (sign(y - x) + 1) / 2
</code></pre>
<p>f(x, y) is 1 if x < y and 0 if x ... |
How to plot a week interval in X axis using c3js? <p>I want to plot a graph with c3.js library that displays a week interval in x axis as the picture below:
<a href="http://i.stack.imgur.com/J0AXS.png" rel="nofollow"><img src="http://i.stack.imgur.com/J0AXS.png" alt="enter image description here"></a></p>
<p>I have a ... | <p>I would have made this is a comment, however I cannot, so my recommendation would be to create this line graph using d3.js not c3.js. Here is a really good tutorial <a href="http://www.d3noob.org/2012/12/setting-up-axes-in-d3js.html" rel="nofollow">Setting up axes in d3.js</a> that will generate the above chart and ... |
How to replace this string using regular expression in vim? <p>I want to replace X with Y in vim with the regular expression <code>^+.*X$</code>, which begin with <code>+</code> and end with <code>X</code>.</p>
| <p>Another variant, using <code>\zs</code> to indicate start of match</p>
<pre><code>%s/^+.*\zsX$/Y/
</code></pre>
<p>See <code>:h \zs</code> for more info</p>
|
C language help:How to store strings from a .txt file into a character array? This .txt file is read from a command line argument btw. <p>I need to create a program that will read in a .txt file using the command line arguments and then encrypt the message in that txt file.</p>
<p>I used pointer to open the txt file ... | <p>Your while loop uses fgets that is intended to read line by line. If you want an array of characters that represents the bytes of the file, use fread. First you'll need to know how big the file is; use stat or fstat for that. </p>
<pre><code> #include <stat.h>
struct stat statbuf;
int FS;
char* buffer
... |
Angular 2 Observables implementation <p>I am trying to wrap my logic using the reactive programming method.</p>
<p>I have two dependent data sets which may or may not be in localstorage. However i need to compute one first and then the second.</p>
<p>So something like this:</p>
<pre><code>let storageCategories = thi... | <p>I have made a <a href="http://plnkr.co/edit/mpzCnH0KuOWI49CYZGNF" rel="nofollow">plunkr here</a> from your explanation. See if it meets your standards and solves your problem. Here is the summary:</p>
<pre><code>private getCategories(): Observable<any>{
if(this.categoriesInLs){
return Observable.of("categor... |
Why use Consul with Kubernetes, Docker, Mesos? <p>Most container services have some sort of built in service discovery mechanism. So why is it that someone would still incorporate Consul into their setup? I know that Consul provides other benefits besides service discovery, such as K/V store, Consul templates, and serv... | <p>It's simple - it depends on your application. If it needs those features Consul have, and which other systems don't, then you can go for it.</p>
<p>Besides that, there are a lot of Hashicorp products tightly integrated with a Consul in part of HA. Vault, Nomad and Terraform. Consul can be used like a variant of Zoo... |
Unable to find optional library: org.apache.http.legacy <p>Tried everything from stackoverflow. I have listed below all that I tried to rectify this error : (I know there are lot of answers for this. It's still isn't working for me)</p>
<ol>
<li>Checked for the presence of the .json file (check)</li>
<li>Add the "useL... | <p>For me I use this and it work:</p>
<pre><code>android {
useLibrary 'org.apache.http.legacy' // put it in here
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
v... |
Nested views | Codeigniter 3 <p>I need to neste a view that's already nested...</p>
<p>i mean, i have the view <code>app</code> inside this i have 5 nested views, but i need inside one of these 5 views, anoter nested view</p>
<p>its something like</p>
<pre><code>--> App
----> view 1
----> view 2
----> vi... | <p>If <code>dashboard.php</code> contains the code you show under </p>
<blockquote>
<p>Blockquote</p>
</blockquote>
<p>and it is loaded with this line</p>
<pre><code>$data['dashboard'] = $this->load->view('app/dashboard/dashboard', $data, TRUE);
</code></pre>
<p>then the problem is that you do not pass your... |
How do you order stacked bar categories by size in ggplot? <p>I am trying to reorder categories in a ggplot bar chart by the size of the variables, with the biggest categories first, followed by increasingly minor ones. I've tried playing with the order in a few ways but only seem to be able to set the order manually w... | <p>You can first obtain a vector of the categories, ordered by your quantity of interest:</p>
<pre><code>fruit_levels <- names(sort(tapply(mydata$varieties, mydata$fruit, sum)))
</code></pre>
<p>Then, in your call to <code>ggplot</code>, map <code>fill</code> to a factor variable with the corresponding levels:</p>... |
How to execute transaction without create a procedure in MySQL <pre><code>SET autocommit=0;
DELIMITER$$
CREATE OR REPLACE PROCEDURE mytestproc()
BEGIN
DECLARE `_rollback` BOOL DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `_rollback` = 1;
START TRANSACTION;
INSERT INTO tbl_campo
... | <p>Please try this:</p>
<pre><code>DELIMITER $$
DROP PROCEDURE IF EXISTS `mytestproc`;
CREATE PROCEDURE `mytestproc`()
BEGIN
DECLARE `_rollback` BOOL DEFAULT 0;
Declare autocommit int default 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `_rollback` = 1;
START TRANSACTION;
INSERT INTO tbl_campo
... |
installing processing on sublime and build project <p>I am trying to build my processing project on sublmine. i installed processing through package control. when i press ctrl B i get the following error. i also created a new build system and set the build system to it but still getting error. how do i run the program ... | <p>I don't know anything about Sublime, but it looks like it can't find Java on your PATH variable. That makes sense, because it doesn't look like your PATH contains Java!</p>
<p>Do you have Java installed? Usually it's installed in a place like: <code>C:\Program Files\Java\jdk1.8.0_101</code></p>
<p>If you don't hav... |
Goto another view programatically in Swift 3 <p>I'm using the following code to goto another view programmatically in swift 3. There is no error while running. But don't know why it is not going to that view</p>
<p>Code I used:</p>
<pre><code>let images = self.storyboard?.instantiateViewController(withIdentifier:"Col... | <p>In order to navigate to between view controllers you use <strong>UINavigationController</strong>.</p>
<p>I will provide you a basic example of navigation, hopefully it will help you to make navigation work in your project.</p>
<hr>
<h1>Result</h1>
<p><strong>ViewController</strong> passes an image to <strong>Det... |
How can I apply a pull request from the main project branch to my fork using the github UI or via command line? <p>I wish to apply this pull request </p>
<p><a href="https://github.com/MonoGame/MonoGame/pull/5114" rel="nofollow">https://github.com/MonoGame/MonoGame/pull/5114</a></p>
<p>to <a href="https://github.com/... | <p>You must specify the repository and branch to perform the pull request on when you originally create said pull request. AFAIK, there isn't any way to edit an existing pull request to do this.</p>
<h3>From the GitHub web UI</h3>
<ol>
<li>Go to the repo you want to pull from (<a href="https://github.com/Jjagg/MonoGa... |
How can I listen to onclick event SpotLight Helper and attach the TransformControls to the light? <h1>The problem:</h1>
<p>When I click on the cube, TransformControls is attached on the cube. But when I click on the light helper, nothing happen. I want the TransformControls to be attached on the light when I click the... | <p>The problem is raycaster.
Add the second parameter of raycaster.intersectObjects() to true.</p>
<p>So the final code is
<code>var intersects = raycaster.intersectObjects(objects, true);</code> </p>
<p>Here is the working sample for attach the transformControls to the light:
<a href="http://codepen.io/anon/pen/PG... |
Generate Swagger specification from Python code without annotations <p>I am searching for a way to generate a Swagger specification (the JSON and Swagger-UI) from the definition of a Python service. I have found many options (normally Flask-based), but all of them use annotations, which I cannot properly handle from wi... | <p>I suggest looking into <a href="http://apispec.readthedocs.io/en/latest/quickstart.html" rel="nofollow">apispec</a>.</p>
<p>apispec is a pluggable API specification generator.</p>
<p>Currently supports the OpenAPI 2.0 specification (f.k.a. Swagger 2.0)</p>
<p><strong><em>apispec</em></strong></p>
<pre><code>from... |
how to Trigger the event in Angular when user change the windows height ? <p>I need to count the element's position each time the user change windows height.so I create a directive.</p>
<pre><code> 'use strict';
angular.module "myApp"
.directive 'uibPosition',['$position','$document','$timeout', ($position,$docum... | <p>You can add the watcher to the directive:</p>
<pre><code> var w = angular.element($window);
scope.getWindowDimensions = function () {
return {
"h": w.height(),
"w": w.width()
};
};
var watcherTimeout;
scope.$watch(scope.... |
How to use WatchConnectivity to get data from iOS app <p>I'm fairly new to Apple Watch apps and maybe I am just approaching it the wrong way, but I am stuck after trying to figure it out for several hours and I need some guidance.</p>
<p>Currently I have an iOS app that gets data from <code>Firebase</code> and display... | <p>WatchConnectivity provides a way to send message to the iOS app and accepts a reply in completion "replyHandler".</p>
<pre><code>public func sendMessage(message: [String : AnyObject], replyHandler: (([String : AnyObject]) -> Void)?, errorHandler: ((NSError) -> Void)?)
</code></pre>
<p>But if the iOS app is n... |
In NSURLSession HTTPBody must be NSData? <p>When I use <code>AFNetworking</code> to post parameters is <code>NSMutableDictionary</code>, this request is succeeded.</p>
<p>But when I used <code>NSURLSession</code>, the self.request!.HTTPBody must be NSData, so request failed.</p>
<p>How can I use NSURLSession to make ... | <pre><code>let params = ["jgId": "1000000000"]
let data = try? JSONSerialization.data(withJSONObject: params, options: [JSONSerialization.WritingOptions(rawValue: 0)])
var request = URLRequest(url: URL(string: "https://my-url.com")!, cachePolicy: .returnCacheDataElseLoad, timeoutInterval: 30)
request.httpMethod = "POS... |
create table with loop in Php <p>What I want is show the total clicks per <code>Category id</code> of the items only for 20 items order by the highest total clicks per day.</p>
<p>Now I am using hard code and the result have to looks like this</p>
<p><a href="http://i.stack.imgur.com/kV4rl.png" rel="nofollow"><img sr... | <p>you need to add <strong>td</strong> dynamically within a table for each day report ( data should be grouped by date). </p>
|
Why variable still exists after function call finished -python <p>I read from a book about some code like below, but it was not explained.
As you can see, before I call the function, no variable exists.
But after function call, var2 was popped form stack and removed from our namespace of func_a as what we expected. Bu... | <blockquote>
<p>How to explain this phenomenon? Is var1 a special kind of variable?</p>
</blockquote>
<p>Yes, <code>var1</code> is a special kind of variable. Or perhaps more precisely, it's not a variable at all. It's an attribute of an object (even though the object is a function). The object existed before the fu... |
How to install Jekyll on Mac 10.11.6 <p>Hello and thanks for your help in advance.
I'm having trouble installing Jekyll because I receive the following error:</p>
<pre><code>ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument
</code></pre>
<p>This is slightly different than the question already posted, ... | <p>I'm able to successfully install jekyll on my Mac but I'm not using system Ruby. I'd highly recommend using <a href="https://github.com/rbenv/rbenv" rel="nofollow">RBEnv</a> to manage your Ruby installation on OSX. You'll find it much easier to work with than trying to deal with the system version or the Brew versio... |
How to deploy a Realm Object Server <p>I'm looking into using the new Realm Mobile Platform for a project of mine. I've gone through the guides and was able to get it up and running locally no problem. My question is, what's the best way to deploy the Realm Object Server so it can be run remotely? I read through the gu... | <p>It's hard to tell you what the "best" way is. There are always drawbacks and benefits to any setup, and everyone has different goals and objectives, so I don't think there is an objective "best way to run it," as you say.</p>
<p>The Realm Object Server doesn't support Heroku for the time being (or at least, no easy... |
C function to MIPS <p>I've been stuck with this homework problem for quite a while now and would like some help.</p>
<p>So far I've come up with this:</p>
<pre><code> f:
lw $t0, a
lw $t1, b
lw $t2, c
lw $t3, d
addi $sp, $sp, -4
</code></pre>
<p>The part that is really confusing... | <p>This is obviously a homework question.</p>
<pre><code> .data
.text
f:
# load arguments IN into temporary registers
lw $t0, 0($sp)
lw $t1, 4($sp)
lw $t2, 8($sp)
lw $t3, 12($sp)
# $t4 <-- calling func(a, b)
# backup $ra register on the stack
addi $sp, $sp, -4
sw $ra, 0($sp)
# alloc... |
How to email contact forms? <p>I'm looking for a way I can set my drop-down list to send an email to that specific person after clicking on their name. Basically the php code emailto will change to the persons email address that was selected in the drop-down list.</p>
<p>I don't know how to do it, but this is for a pr... | <p>You can add a hidden input field to your form and add an event handler to the dropdown (I.e. Onclick/onchange). Example:</p>
<pre><code><input type="hidden" id="email_to" name="email_to">
...
<a href="javascript:void(0)" onclick="document.getElementById("email_to").value = "someone@somewhere.com">Some... |
Can anyone tell me a better and free alternative to sumblime text editor? <p>I am using sublime text editor for last few months...Recently I have decided to create a video tutorial...but the message that sublime shows (it is unregistered) is annoying...So can anyone tell me an alternative that works exactly like sublim... | <p>Depending on what kind of code you're working with, you can give <a href="https://netbeans.org/" rel="nofollow">Netbeans</a> or <a href="http://brackets.io/" rel="nofollow">Brackets</a> a try too</p>
|
Border Image with Linear Gradient <p>I not expert in Jquery, but I tried build <strong>underline color</strong> with <strong>random color</strong> for <code>each li</code> like example this is a rough structure : <a href="https://jsfiddle.net/bnhjw6ap/3/" rel="nofollow">Jsfiddle here</a></p>
<p>I use function random c... | <p>try this </p>
<pre><code> return 'radial-gradient(at bottom, '+c1.rgb+'25%,'+c2.rgb+'50%,'+c3.rgb+'100%)';
</code></pre>
<p>Here may help you : </p>
<p><a href="http://stackoverflow.com/questions/12878649/bottom-gradient-border">Bottom Gradient Border</a></p>
|
Placeholder auto wrap inside a input field <p>I need to put a long <code>placeholder</code> text inside a input field.</p>
<p>However, the <code>placeholder</code> will be cut due to its long text.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippe... | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>input{
height:50px;
}
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
white-space:pre-line;
position:rela... |
How to create a new R vector by filtering with grepl()? <p>This is a straightforward problem, but I'm missing something below. </p>
<p>I have a very large vector of filepaths (i.e. strings) in R</p>
<pre><code>vec = c("\dir\subdir\pathname1\file.txt", "\dir\subdir\pathname1\file.pdf",
... | <p>You can use the logical vector produced by grepl() to index vec.</p>
<pre><code>txt_paths <- vec[grepl(".txt$", vec)]
</code></pre>
|
is it possible to invert svg image using css? <p>I'm trying to invert an image file with <code>.svg</code> extension using <code>css</code>.i know .png and .jpg files can be inverted using <code>css</code> <code>webkit</code> properties. i'm new on <code>svg</code> images.is it possible to invert <code>.svg</code> ima... | <p><strong>You can try this</strong></p>
<pre><code> svg {
-webkit-filter: invert(100%);
filter: invert(100%);
}
</code></pre>
<p>But you can also put your svg on <code><img src=""></code> and style like other format</p>
|
WPF treeview and datagrid selection changed <p>I am working on this WPF project with a <code>Treeview</code> and <code>DataGrid</code>.</p>
<p>On the left side is a tree structure with some documents shown on the right side in the data grid.
If we change the selected item in the tree view, the datagrid display should... | <p>Since the default TreeView does not support a Binding on SelectedItem, you have to perform an ugly Workaround. Subclass the Treeview and make it bindable first:</p>
<pre><code> public class TreeViewA : TreeView {
public new static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("... |
Garbage collection can't keep up with Buffer creation and removal <p>I have a method that runs every 2 seconds to capture a video stream to canvas and write it to file:</p>
<pre><code> function capture(streamName, callback) {
var buffer,
dataURL,
dataSplit,
_ctx;
_ctx = _canvas[streamName].... | <p>Matt, I am not sure what was not working with the pre-allocated buffers, so I've posted an algorithm of how such pre-allocated buffers could be used. The key thing here is that buffers are allocated only once for that reason there should not be any memory leak.</p>
<pre><code>var buffers = [];
var bsize = 10000;
/... |
Where to write the save function in Django? <p>Where to write my save function in django whether in models.py in a class model or in forms.py in form ?</p>
<p>For example :
models.py </p>
<pre><code>class Customer(models.Model):
name = models.CharField(max_length=200)
created_by = models.ForeignKey(User)
... | <p>It really depends on what you are trying to achieve. Default realization of <code>ModelForm</code>'s save calls <code>Model</code>'s save. But it is usually better to override it on <code>form</code> because it also runs validation. So if you are already using form I would suggest overriding <code>ModelForm.save</co... |
What is the best approach for team sign in after user sign in to the application? <p>I have an user sign in option on my app for that i'm using token based approach for the session handling. But now i want to create teams for each users and identify which team his currently logged in into. So what is the best approach ... | <p>Assign each user with a team. For example, Technical team have 6 users. so when a user detects then you can get his team. </p>
|
Alert not appearing if i put the route under auth middleware group <p>I am not allowing the user to submit the form if not logged in. So, giving the alert to login.<br></p>
<p><strong>Jquery and Ajax</strong></p>
<pre><code> $(document).on('submit', '.bet', function (e)
{
e.preventDefault();
var ... | <p>that's because request is returned (401) from the middleware and controller action is never executed. also middleware is right place for this check why don't you return unauthorised response from auth middleware ? something like this</p>
<p><strong>App\Http\Middleware\Auth</strong></p>
<pre><code>public function h... |
How to change page header depending session on asp.net? <p>I'm working in a VisualStudio project but I need help.
I have a database with the user information which includes a value to obtain the role. Depending that value, I need to change the page header to show/hide links and options, but I don't know how to make it.... | <p>Easy way to implement what you want </p>
<pre><code>void privilege ()
{
if(Session["role"].ToString() !="Admin")
{
//do somethings
}
else
{
//do other things
}
}
</code></pre>
|
Why is pip install pyopenssl==0.13 failing? <p>I'm trying to install PyOpenSSL 0.13 on my Macbook Pro (OSX version 10.11, El-Capitan). But it keeps failing. These are the steps I took</p>
<ol>
<li>Download and install Command Line Tools (OSX 10.11) for Xcode 7.3.1 from <a href="https://developer.apple.com/download/mor... | <p>It appears you are missing the OpenSSL development headers, as mentioned by <a href="http://stackoverflow.com/users/3929826/klaus-d">@Klaus D.</a> This most likely happened because due to upgrading to El Capitan, these development headers were broken. It can usually be fixed by reinstalling your command line tools. ... |
How to invoke Inject environment variables to the build process plugin in jenkinsFIle jenkins 2.x with pipeline <p>i'm trying to migrate my project from jenkins 1 to jenkins 2.x using pipeline as code or jenkinsfile
But i dont see any option in snippet generator to generate environment injector pugin into a script in j... | <p>Wanted to just comment on your question, but my lack of reputation is hindering me. </p>
<p>The list of supported steps is here: <a href="https://jenkins.io/doc/pipeline/steps/" rel="nofollow">https://jenkins.io/doc/pipeline/steps/</a></p>
<p>In general, you can use other plugins by using their Java style invocat... |
Prints only one value from the record <p>Here, I want to print those value which are in table.
So, my query is like this:</p>
<pre><code>$get_role_query = "SELECT id FROM table WHERE id IN (333,1,2)";
$roleres = mysqli_query($conn,$get_role_query);
$r_id = mysqli_fetch_assoc($roleres);
</code></pre>
<p>Here, <code>3... | <blockquote>
<p>Use while in order to fetch multiple values from the table:</p>
</blockquote>
<pre><code>$get_role_query = "SELECT id FROM table WHERE id IN (333,1,2)";
$roleres = mysqli_query($conn,$get_role_query);
while($r_id = mysqli_fetch_assoc($roleres))
{
echo $r_id['id'];
}
</code></pre>
|
TextInput is displaying the value react native <p>Hi in my <code>componentWillMount</code> I set my states like this</p>
<pre><code>componentWillMount(){
this.timeSheetData().then((timeSheetResponse)=>{
this.setState({comments:timeSheetResponse.comments});
this.setState({spentHours:parseInt(time... | <p>Input values need to be strings so you either need to remove <code>parseInt</code> in your <code>componentWillMount</code> method:</p>
<p><code>this.setState({ spentHours: timeSheetResponse.hours });</code></p>
<p>or in your template you need to convert the input value to a string with <code>toString()</code>:</p>... |
How to use plt.text() function to type special symbols into a plot produced by python3? <p>I am trying to type a text (which includes some astrophysical symbols like solar mass and Hubble's Parameter) inside an empty figure in a python script:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
plt.figu... | <p>replace your <code>plt.text...</code> line with the following:</p>
<pre><code>plt.text(0.05, 0.05, '$R_{{200m}}$={:.0f} kpc physical \n\n $M_{{200m}}$={:.3e} $h^{{-1}} M_\u2609$ \n\n\n\n x={:.0f} \n\n $M_{{DM}}$={:.3e} $h^{{-1}} M_{{\odot}}$'.format(A, B, C, D), size=20)
</code></pre>
<p>I just:</p>
<ol>
<li>repl... |
Using glBufferSubData and glMultiDrawArrays in OpenGL ES Android <p>I am porting a C++ Point and Polygons drawing to Android.Initially it looked straight forward to port the code to java style.I could draw Points using below code.</p>
<pre><code>//POINT
public class MyPoint
{
public float x,y,z;
}
//Points in x,y,z... | <p>The <code>glBufferSubData</code> function still exists so that should still work exactly as before. The <code>glMultiDrawArrays</code> function doesn't exist in GLES, so you just need to make multiple separate calls to <code>glDrawArrays()</code>, one for each object you want to render.</p>
|
Why does the design of a web page change at run time? <p>I have created a <strong>website using asp.net</strong>. Everything worked fine until now. But the last page <strong>does not behave as i expected</strong>. In the UI there is a dropdownlist,gridview,link button and few labels within a collapse bar. Gridview get ... | <p><strong>Following change solved my problem.</strong> </p>
<pre><code> protected void pdfViewAdmin_Click(object sender, EventArgs e)
{
//Response.Write(string.Format("<script>window.open('{0}','_blank');</script>", "viewPDF.aspx"));
this.ClientScript.RegisterStartupScript(this.GetTyp... |
How to make an argument optional in getopts bash? <p>I would like to make one of the optional characters (<code>-t</code>) which should not accept any argument in getopts bash. This is where i got so far </p>
<pre><code>while getopts ":hb:q:o:v:t" opt; do
case $opt in
b)
Blasting_list=$OPTARG
;;
l)... | <p>probably the easiest way is to set <code>species_tree</code> to <code>true</code> iff there's the <code>-t</code> command line flag:</p>
<pre><code>species_tree=false # <-- addition here
while getopts ":hb:q:o:v:t" opt; do
case $opt in
...
t)
species_tree=true ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.