input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Finding first n primes efficiently <p>I have a brute-force algorithm that takes an input n, and displays the first n prime numbers. The code works, but I also have to answer this question:</p>
<blockquote>
<p>Give the number of test items that would be required to assure correctness.</p>
</blockquote>
<p>Is there ... | <p>If you have a number <em>n</em>, and need to check if it is a prime, there are more efficient ways than brute force.</p>
<p>One way would be to use the <a href="https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test" rel="nofollow">Miller-Rabin Primality Test</a>. The Miller-Rabin test either finds proof... |
Query with linq using a where clause <p>Okay so I've already asked this question but I've narrowed it down and am now able to word it better.</p>
<p>I have a sql database and an asp.net mvc project with entity frameworks. I already figured out how to query the database and display all contents. But now I need to query... | <pre><code>var context = new MyContext();
var query = context.Inventory.Where(p=> p.quantity <= p.statusLow); // write the statement to query
var result = query.ToList(); // obtaining the result, trigger the database
</code></pre>
|
Dynamic templateURL with Angular 2 version of the Angular UI Bootstrap library <p>I am creating a dynamic template URL using the following code <a href="http://stackoverflow.com/questions/39410355/how-to-use-variable-to-define-templateurl-in-angular2#answer-39411464">How to use variable to define templateUrl in Angula... | <p>I would leverage the following way to do it working :</p>
<pre><code>this.compiler.compileModuleAndAllComponentsAsync(DynamicHtmlModule)
.then(factory => {
const moduleRef = factory.ngModuleFactory.create(this.vcRef.parentInjector);
const compFactory = factory.componentFactories
.find(x =>... |
How to use one class in jquery to php/html foreach loop? <p>My title is quite confusing but my question is..</p>
<p>is have this script plugin wherein the plugin will create a bubble-like progress bar found <a href="http://www.jqueryscript.net/chart-graph/Customizable-Liquid-Bubble-Chart-With-jQuery-Canvas.html" rel="... | <p>I'm guessing it's an issue with the script. You might be better off trying to init each waterbubble with a unique ID.</p>
<pre><code><?php foreach($bins as $binArray): ?>
<div class="row">
<?php foreach ($binArray as $bin):?>
<div class="col-xs-8">
<canvas id="demo<... |
Remote command does not return python <p>I am rebooting a remote machine through Python, as it is a reboot, the current ssh session is killed. The request is not returned. I am not interested in the return though.</p>
<p>os.command('sshpass -p password ssh user@host reboot')</p>
<p>The code is performing the reboot, ... | <p>I'm surprised that the script doesn't return. The connection should be reset by the remote before it reboots. You can run the process asyc, the one problem is that subprocesses not cleaned up up by their parents become zombies (still take up space in the process table). You can add a Timer to give the script time to... |
Evernote Initial Sync Boost <p>I'm working on an application that requires completely syncing a users Evernote account, however on some larger account we run into rate limits. According to the API documentation there is a feature known as Initial Sync Boost, however I can not find any information on how to implement th... | <p>You don't have to implement anything on your side. When you activate your key on the production environment on <a href="https://dev.evernote.com/support/" rel="nofollow">this page</a>, you can request the initial sync boost so the support increase the limit for the initial sync for your key.</p>
|
Optimizing HTTP request and multiple Split on CSV file <p>I'm trying to read a CSV file from a website, then split the initial string by <code>\n</code>, then split again by <code>,</code>.
When I try to print out the content of one of the arrays, it was very slow, it takes almost one second between each <code>Console.... | <p>You should cache the results in a variable, either in the <code>Content</code> property or before the loop because currently your code downloads and split the string every time in the loop which is why it is taking 1 second</p>
<p>So, your code should look like this:</p>
<pre><code>var data = new ReadCSV();
var c... |
How do I printout multiple text in JText Field using if/else statement? <p><a href="https://i.stack.imgur.com/DhyT8.png" rel="nofollow"><img src="https://i.stack.imgur.com/DhyT8.png" alt=""></a></p>
<pre><code> private void resultActionPerformed(java.awt.event.ActionEvent evt) { ... | <p>Use a <code>StringBuilder</code> and build the message as you go along:</p>
<pre><code>private void resultActionPerformed(java.awt.event.ActionEvent evt) {
StringBuilder message = new StringBuilder();
// TODO add your handling code here:
if (pick1 > pick2) {
... |
code working good in chrome, firefox, mircrosoft edge but not working in safari <p>I am creating a website for my client. Website is working great in Chrome, Firefox, Microsoft Edge and Even Internet Explorer :P. But I don't know why this site is not working in Safari. This is my code:-
HTML </p>
<pre><code><html&... | <p>Finally I got it :). It takes some time but now I know why my code is not running correctly on Safari. </p>
<p>I have to test my css code one by one by commenting it. Offf.!
But when I comment </p>
<pre><code>width:100vw;
height:100vh;
</code></pre>
<p>I got some result. Then I changed it to </p>
<pre><code>wid... |
IOS: Move TextField Up When Keyboard Appears <p>I am using the following method to move the view upwards when the keyboard appears so the keyboard does not block a textfield. Basically, I embed the textfields in a scrollview and scroll upwards when the keyboard appears.</p>
<pre><code>// Called when the UIKeyboardDidS... | <p>If you are using autolayout, you should use constraints to manipulate the view instead of frames. You could try manipulating the bottom spacing of your textField or view to its superview as per your need and putting the <code>layoutIfNeeded</code> call inside an animation block. Also you can check if the value of yo... |
Images & Videos on Firebase Storage <p>I am trying to upload images and videos from the photos & videos storage on the phone to firebase storage and I have not been able to. And after being able to, I want to be able to post on a chat app to be seen like on twitter-- Android Studio. PLEASE HELP!!!</p>
| <p>Google for this youtube channel "TVAC Studio" and follow his firebase tutorials. It's insightful for beginners.</p>
<p>You won't be able to do a chat message app simply by follow his tutorial, but he doea a thorough run through for uploading and retrieving all the data you want (He teaches Audio files and images).<... |
Bootstrap - collapse one <ul> when another <ul> is expanded <p>assuming i have this</p>
<pre><code><li>
<a data-toggle="collapse">item 1</a>
</li>
<li>
<ul class="panel-collapse collapse">
<li>sub item 1</li>
<li>sub item 2</li>
</ul>
</li>
<li... | <p><strong>Here is the demo</strong></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><link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/b... |
Beginning a game <p>I started a game, but there is something wrong with it. It actually don't shows anything and neither give me an error. It just run it and do nothing else.</p>
<p>Here are my codes:</p>
<p>CLASS</p>
<pre><code> package Game;
import java.awt.Canvas;
import java.awt.Dimension;
impor... | <p>You write nothing on your main method,so the program do nothing.you should new a Game object and a Window object ,then call the window method in the main method.</p>
|
Bootstrap accordion with Django: How to only load the data for the open accordion section? <p>I'm trying to make a webpage that will display recipes in the format of a bootstrap accordion like so (<a href="https://i.stack.imgur.com/1QEbG.png" rel="nofollow">see here</a>).
This is how I'm doing it as of now:</p>
<pre><... | <p>Always better to do that logic before it gets to the template. What if you set the ordering on ingredients so then you won't have to order them in the template? Does that work and improve the performance?</p>
<pre><code>class Ingredient(models.Model):
...
class Meta:
ordering = ['ingredient_name']
<di... |
Consuming Asp.Net Core api locally <p>I don't know if my google skills are diminishing or what but I can't seem to figure out how to consume a local api. This may be best explained with sample code...</p>
<p>So I have a simple api</p>
<pre><code>public class FooApiController : Controller
{
public IActionResult Ge... | <p>You are doing it wrong.
If you want to reuse the code among multiple controllers, then it is better to move it from the GetFoo method and put it into a shared class and access it from everywhere else.</p>
<p>If you want to call it from a view through REST, then call it using $.ajax
ex: </p>
<pre><code>$.ajax('FooA... |
Can I use PyQt for both C++ and Python? <p>I'd like to learn Qt both on Python and C++. I am on Windows.</p>
<p>Is instaling PyQT5 with <code>pip3 install pyqt5</code> enough for C++ development or do I still have to install both Qt and PyQt?</p>
<p>How do I do the second option?</p>
| <p>For C++ development you're going to need a C++ compiler. On Windows Qt supports both the Mingw and Visual Studio toolchains. From there, I don't believe pyqt includes the header files you're going to need for C++ development and I cannot say for certain what toolchain it was compiled with. </p>
<p>Your best bet is ... |
SSL: Client Authentication, multiple certificate version in same store <p>Here is the situation:</p>
<ol>
<li><p>Our Application talks to multiple 3rd party applications and few of them need client authentication.</p></li>
<li><p>One particular third party app needs client auth and has appropriately provided certifica... | <p>You can have both certificates in the truststore. JSSE will select whichever one matches the trusted CAs the server advises when it requests the client certificate.</p>
<p>However the scenario you describe is radically insecure. If you are the client, you should be providing your own client certificate, not one tha... |
python receive image over socket <p>I'm trying to send an image over a socket - I'm capturing an image on my raspberry pi using pycam, sending to a remote machine for processing, and sending a response back.</p>
<p>On the server (the pi), I'm capturing the image, transforming to an array, rearranging to a 1D array and... | <h1>Decoding to the Proper Type</h1>
<p>When you call <code>tostring()</code>, datatype (and shape) information is lost. You must supply numpy with the datatype you expect.</p>
<p>Ex:</p>
<pre><code>import numpy as np
image = np.random.random((50, 50)).astype(np.uint8)
image_str = image.tostring()
# Works
image_de... |
Why is python trying to ASCII encode my unicode string for Mysqldb? <p>Yes, again a question about unicode and Python. I thought I've read it all and adopted good programming practice after you guys opened my mind about Unicode,but this error came back at me :</p>
<pre><code>'ascii' codec can't encode character u'\xc0... | <p>you can put following code if exception come.</p>
<pre><code>varName = ''.join([i if ord(i) < 128 else ' ' for i in strName])
</code></pre>
<p>here, strName is string which contains Non ascii value</p>
|
What aren't my checkboxes responding individually? <p>So the issue I am having is that my checkboxes in my JS game isn't responding to individual clicks. When I console.log, I get index 0 every time, no matter which box I click and a non responsive check box. However, the level functions are responding.</p>
<p><div cl... | <p>Dai has good advice, but your actual issue is here:</p>
<pre><code>... onclick="javascript:check(value)" ...
</code></pre>
<p>There no global <em>value</em> variable so you're passing <em>undefined</em>, which evaluates to 0. What you actually want to pass is the value of the checkbox:</p>
<pre><code>... onclick=... |
Which class get inherited when using nested class <pre><code>class Admin::ApplicationController < ApplicationController
def index
end
end
</code></pre>
<p>Which class get inherited when I using nested class?</p>
<pre><code>class Admin < ApplicationController
class ApplicationController
end
end
</code></... | <p>If the question is what is the equivalent of this line:</p>
<pre><code>class Admin::ApplicationController < ApplicationController
</code></pre>
<p>Then your second assumption is correct, it is equivalent to:</p>
<pre><code>class Admin
class ApplicationController < ApplicationController
end
end
</code><... |
Tomcat 8 - Database realm configuration <p>I have configured tomcat 7 server to use MD5 digest in database realm configuration.
It worked fine.
Now I need to upgrade my servers to tomcat 8.
But it generates a different hash for my my passwords in database.
How can I configure it to generate same old values?
I have alre... | <p>Finally <a href="http://%20http://stackoverflow.com/a/38937341/4595123" rel="nofollow">this</a> solved my question.</p>
<p>To answer the first point, here's a comparison of the from my context.xml before and after the switch to Tomcat 8:</p>
<p><strong>Before:</strong></p>
<pre><code><Realm className="org.apa... |
How do I print a variable within a class' if statement? <p>I'm trying to print a variable in Python using the following code:</p>
<pre><code>from time import sleep
import random
class Hero:
def __init__(self,name):
self.name = name
if name == "rock":
self.health = 50
self.... | <p><code>self</code> is just a parameter name used inside the methods. Don't use it outside the method.</p>
<p>To access the variables refer to them using the object name (<code>player</code>) like this</p>
<pre><code>player.health
</code></pre>
<p>The <code>name</code> variable you are printing "works" because it's... |
Nodejs delete folder on Amazon S3 with aws-sdk <p>I'm facing issue of deleting folder which contains photos inside on Amazon S3</p>
<p>1. Create folder</p>
<pre><code>var params = {Bucket: S3_BUCKET, Key: "test/", ACL:"public-read"};
s3.putObject(params, function(err, data) {
});
</code></pre>
<p>2. Upload pho... | <p>The problem here is a conceptual one, and starts at step 1. </p>
<p>This does not create a folder. It creates a placeholder object that the console will display as a folder. </p>
<blockquote>
<p>An object named with a trailing "/" displays as a folder in the Amazon S3 console. </p>
<p><a href="http://docs... |
Why don't we need to perform modulo operation on every operands in Fast Power algorithm? <p>Today I practiced with a puzzle "fast power", which used a formula:
<code>(a * b) % p = (a % p * b % p) % p</code> to calculate <code>(a^n)%p</code>, something like that: <code>2^31 % 3 = 2</code></p>
<p>However, I am so confu... | <blockquote>
<p>Should not it be <code>((temp * temp) % b * a % b) % b</code>?</p>
</blockquote>
<p>No. For <code>a</code>, if you know beforehand that <code>a</code> won't overflow(a is smaller than b), you don't have to mod it.</p>
<p>The idea is <a href="https://en.wikipedia.org/wiki/Modular_arithmetic" rel="nof... |
JAVA: Game of Craps making sure what printed is correct <p>I have an assignment for my programming course. I have only one issue which I cannot figure out.</p>
<p>My instructions are the following: Write a program that simulates how often a player would win if they rolled the dice 100 times. If the players rolls a 7, ... | <p>I think you dont need following if condition in your code.</p>
<pre><code>if (sumOfDies == point) { System.out.println(sumOfDies + " You Won! Congratulations! You Won! Congratulations!"); return true; }
</code></pre>
<p>infact all you need in your code is following condition.</p>
<pre><code>if (sumOfDies == 7 || ... |
swift how to make phone call iOS 10? <p>I want my app to be able to call a certain number when a button is clicked. I've tried to google it but there doesn't seem to have one for iOS 10 so far (where openURL is gone). Can someone put an example for me on how to do so? For instance like: </p>
<pre><code>@IBAction func ... | <p>You can call like this if you want a popup</p>
<pre><code>if let url = URL(string: "telprompt://\(number)") {
UIApplication.shared.openURL(url)
}
</code></pre>
<p>else if you want to call direct </p>
<pre><code> if let url = URL(string: "tel://\(number)") {
UIApplicatio... |
How to extract child of node in data snapshot <p>My firebase set up is as such:</p>
<pre><code>Parent_node:{
Type:{
1476663471800:{ //This is a timestamp = Int64(date.timeIntervalSince1970 * 1000.0)
uid: USERS_UID;
}
}
}
</code></pre>
<p>how would I access the users uid? I have tr... | <p>First of all use <code>snapshot.value?.allValues</code> to get values and than parse it...</p>
<pre><code> if snapshot.exists() {
for value in (snapshot.value?.allValues)!{
print(value) // you get [uid: USERS_UID] here
// ... parse it to get USERS_UID
print("user_id -- \(value["... |
Deserialize error with adding more serialized variables for saving/loading in Unity <p>I have been messing around with saving and loading in Unity in which I save a serialized class to a file. I have a Serializable class :</p>
<pre><code>[Serializable]
class Save
{
public List<int> ID = new List<int>(... | <p>This problem is known when using C# serializer. Convert the data to Json with <code>JsonUtility</code> then save it with the <code>PlayerPrefs</code>. When loading, load with the <code>PlayerPrefs</code> then convert the json back to class with <code>JsonUtility</code>.</p>
<p>Example class to Save:</p>
<pre><code... |
Concerned about JWT security <p>Recently, I implemented the JWT strategy using passport and node.js... however, I am beginning to worry about the concept in general. Isn't it true that once someone has access to the JWT, it can be used to retrieve protected data? And isn't gaining access to the JWT, as easy as using ch... | <blockquote>
<p>Isn't it true that once someone has access to the JWT, it can be used to retrieve protected data? And isn't gaining access to the JWT, as easy as using chrome dev tools?</p>
</blockquote>
<p>Generally speaking, it shouldn't be an issue if the user can access <em>their own</em> JWT -- because they're ... |
How to get the key value output from RDD in pyspark <p>Following is the RDD:</p>
<pre><code>[(8, [u'darkness']), (2, [u'in', u'of', u'of', u'of']),
(4, [u'book', u'form', u'void', u'upon', u'face', u'deep', u'upon', u'face'])]
</code></pre>
<p>How do i print the keys and the value length for the above.</p>
<p>The ou... | <p>You can use a <code>map</code> function to create a tuple of the key and number of words in the list:</p>
<pre><code>data = sc.parallelize([(8, [u'darkness']), (2, [u'in', u'of', u'of', u'of']), (4, [u'book', u'form', u'void', u'upon', u'face', u'deep', u'upon', u'face'])])
data.map(lambda x:tuple([x[0],len(x[1])]... |
Add custom Markers that will be shown in the Goto Symbol (Cmd+R) window <p>I've posted this exact same question in the ST forum plugin dev threads</p>
<p><a href="https://forum.sublimetext.com/t/add-custom-markers-that-will-be-shown-in-the-goto-symbol-cmd-r-window/23772" rel="nofollow">https://forum.sublimetext.com/t/... | <p>The contents of the symbol list is controlled by a preferences file that tells sublime what scopes should appear in the symbol list for any given language and, optionally, what transformations should be done for display purposes (e.g. to indent the methods in a class). </p>
<p>Such configuration files are <code>tmP... |
Finding median for given range of indices of an array <p>Given an array of integers, we have to answer certain queries where each query has 2 integers. These 2 integers are the 2 indices of the given array and we have to find the median of the numbers present between the 2 indices (inclusive of the given indices.)</p>
... | <p>Here's how to do this in Python:</p>
<p>import numpy as np</p>
<pre><code>def median(arr):
arr_sort = sorted(arr)
n = len(arr)
n_over_two = int(n/2)
if (n%2 == 0):
return (arr_sort[n_over_two-1]+arr_sort[n_over_two])/2.0
else:
return arr_sort[n_over_two]
tmp = [5,4,3,2,1]
prin... |
Maximum area of triangle having all vertices of different color <p>Points from (0,0) to (R,C) in the cartesian plane are colored r, g or b. Make a triangle using these points such that-</p>
<pre><code>a) All three vertices are of different colors.
b) At least one side of triangle is parallel to either of the axes.
c) ... | <p>The area of a triangle is <code>1/2 * base * height</code>. So if one side of the triangle is parallel to the<br>
x-axis, then the base of the triangle is formed by two colors on the same row (spread as far apart as possible), and the third color should be on the row that's farthest from the base. Hence, you can pre... |
Dropwizard client deal with self signed certificate <p>Quite new with Dropwizard.</p>
<p>I found a lot of solution to deal with Jersey and ssl self signed certificate.
Dropwizard version is 0.9.2</p>
<p>I have tried to set a SSLContext but I get</p>
<pre><code>The method sslContext(SSLContext) is undefined for the t... | <p>I think to create an insecure client in 0.9.2 you would use a Registry of ConnectionSocketFactory, something like... </p>
<pre><code> final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] { new X509TrustManager() {
@Override
public void... |
Excel IF function for three conditions (2 x number, 1 x text) and two outcomes <p>I have a column which has positive numbers, negative numbers and a text statement "No Responses.". If the number is positive I would like "yes" to be the outcome in a new column, if it is negative or the text 'No Responses." I would like ... | <p>You could use the following to avoid any string comparison issues</p>
<pre><code>=IF(ISNUMBER(E2), IF(E2>0, "yes", "no"), "no")
</code></pre>
<p>This way only positive numbers will give a "yes" anything else is "no"</p>
|
How to create a Text type field in db via Hibernate+Java <p>I do have a Java Web Applicaiton (struts2, hibernate, beans) + PostreSQL as DB. The task is to save the <code>base64</code> encoded text in the db for some specific table. That <code>base64</code> is generated from <code>pdf</code> file, which is then <code>ci... | <p>I think you should go with this annotation :</p>
<pre><code>@Lob(type = LobType.CLOB)
</code></pre>
|
Successor Arithmetic Prolog Mod function <p>How to write <strong>mod/3</strong> function for <strong>successor arithmetic</strong> (Peano's Numbers) in prolog?</p>
| <pre><code>s(0).
s(X):- X.
plus(0, Y, Y).
plus(s(X), Y, s(Z)):- plus(X , Y , Z).
minus(A, B, C) :- plus(C, B, A).
mod(_, 0, 0).
mod(0, _ , 0).
mod(X, s(0), 0).
mod(A, B, N) :- minus(A, B, R), (R @< B -> N = R ; mod(R, B, N)).
</code></pre>
|
Replace numbers in a file name in unix (BASH) <p>I have multiple files approximately 150 and there names do not match a requirement of a vendor. example file names are:</p>
<pre><code>company_red001.p12
company_red002.p12
.
.
.
.
company_red150.p12
</code></pre>
<p>I need to rename all files so that 24 is added to e... | <p>Do:</p>
<pre><code>for file in *.p12; do
name=${file#*_} ## Extracts the portion after `_` from filename, save as variable "name"
pre=${name%.*} ## Extracts the portion before extension, save as "pre"
num=${pre##*[[:alpha:]]} ## Extracts number from variable "pre"
pre=${pre%%[0-9]*} ## Extracts... |
Emoji not visible when copied from one table to another in Mysql <p>I have text with emojis in a sql table. Collation is set to utf8mb4_bin. The mobile app reads the emoji from table and displays correctly. It inserts the emojis properly.</p>
<p>Using dashboard, sometimes I copy this text to another table with same co... | <p>Question Marks (regular ones, not black diamonds) (Se?or for Señor):</p>
<ul>
<li>The bytes to be stored are not encoded as utf8/utf8mb4. Fix this.</li>
<li>The column in the database is CHARACTER SET utf8 (or utf8mb4). Fix this.</li>
<li>Also, check that the connection during reading is UTF-8.</li>
</ul>
<p>More... |
Get data in Async Task in Android <p>I want to receive data inside <code>AsyncTask</code> class, a <code>list</code> sent as parameter from other class. I am unable to receive list in he <code>Async</code> class. Thanks in advance.</p>
<pre><code> classforAsync classforAsyncO = new classforAsync();
button2.setOnClic... | <p>Try this. You must have a constructor in place to pass in your list. Update the <code>type</code> accordingly. </p>
<pre><code>public class classforAsync extends AsyncTask<String,Void,Void>{
private List<String> list;
public classforAsync(List<String> list) {
this.list = list;
}
@Override
... |
Xamarin: How to get current theme name in code? <p>In Xamarin Android, how do I get the current theme name programmatically? I need to get the name as a string such as "Theme.AppCompat.Light.Dialog".</p>
| <p>You may refer to the code bellow:</p>
<pre><code>PackageInfo packageInfo;
packageInfo = PackageManager.GetPackageInfo(PackageName,PackageInfoFlags.MetaData);
int themeResId = packageInfo.ApplicationInfo.Theme;
var name = Theme.Resources.GetResourceEntryName(themeResId);
</code></pre>
<p>And here is the <a href="h... |
Search Bar showing wrong/mixed cell results <p>I have a problem in my iOS project. I'm using a search bar to filter my array in my custom tableview to show the matching keywords of the search. </p>
<p>It shows no code errors but obviously there's a problem.</p>
<p>Normally there's over 20+ items in my tableview but w... | <p>Use NSPredicate for searching best option.</p>
<pre><code>searchArray=[[NSArray alloc]init];
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF.YOURSEARCHKEY contains[c] %@", YOURTEXTFIELD.text];
NSLog(@"%@",resultPredicate);
searchArray = [ORIGNALARRAY filteredArrayUsingPredicate:resultPredicat... |
AJAX calls inside a loop <p>So, I have a list of data that I am out putting onto my view, and each list item has an id. </p>
<p>Each of these list items is a bar and I have a document created for each bar that at least one user is going to. For those bars where no users are going, there is no document created. </p>
<... | <p>You should check out the npm library called async, it has an each method that you can do asynchronous calls within. If you use promises, the Promise.all method in Bluebird could be very useful for you.</p>
|
concatenating maptype values while doing groupby on dataframe <p>I have this dataframe which contains 3 columns -> userId, date, generation</p>
<pre><code>+-------+--------+----------------------------------------------------------------------------+
|userId | date |generation ... | <p>You can create a naive User Defined Aggregation Function (UDAF) that combines maps, and then use it as the aggregation function. Since you didn't define how to combine two <em>values</em> in the map for two <em>identical</em> keys, I will assume that keys are unique, i.e. for each <code>userId</code> and <code>date<... |
How to get last 90 days monday to sunday date? <p>How to get last 90 days monday to sunday date.</p>
<pre><code>S.no Start_dt End_dt week
1 18-Jul-16 24-Jul-16 Week1
2 25-Jul-16 31-Jul-16 Week2
3 1-Aug-16 7-Aug-16 Week3
4 8-Aug-16 14-Aug-16 Week4
5 15-Aug-16 21-Aug-16 Week5
6 ... | <pre><code>select trunc(sysdate-(13-rownum)*7, 'iw') start_dt, trunc(sysdate-(12-rownum)*7, 'iw')-1 end_dt, 'week'||rownum week
from dual
connect by rownum<=90/7+1
</code></pre>
|
Passing pipe | and caret ^ chars through batch CALL <p>I'm trying to pass through caret chars through batch.
Escaping them once would be easy, but I need to do it twice.
I have an executable that will back up tables based on a Regex expression (not my code).
I want to back up all tables with an exclusion list.
Using <c... | <p>In batch file 1 use:</p>
<pre><code>SET "ignoreTables=tableOne|tableTwo"
:: Call the backup script
CALL SecondBatch.bat "%ignoreTables%"
</code></pre>
<p>And in batch file 2 use:</p>
<pre><code>:: Passthrough ignoreTables
Executable.exe --ignoreTablesPattern="^(?!%~1).*$"
</code></pre>
<p>Run in a command prompt... |
Android, What is the difference between neenbedankt A.P and Support Annotation? <p>Recently I replaced <code>neenbedankt</code> annotation processing library with google <code>Support-Annotation</code> library, and change all <code>apt</code> methods in <code>build.gradle</code> with <code>annotationProcessor</code> an... | <p>There is no difference. <code>annotationProcessor</code> is the new feature of gradle plugin.</p>
<p>More info from the creator of <code>android-apt</code> <a href="http://www.littlerobots.nl/blog/Whats-next-for-android-apt/" rel="nofollow">here</a></p>
<p>The main conclusion from this article is that <code>annota... |
ng-repeat angularjs conflicting whit ng-model <p>i am creating a web app in which i am using angularjs for database conectivity</p>
<p>here is my code</p>
<pre><code><div ng-repeat="x in sonvinrpm">
<input type="Text" ng-model="venuemobile" value="{{x.venuemobile}}" ng-init="venuemobile='{{venuemobile}}'"
&l... | <p>You do not have to call a function to update a $scope variable, since angular uses two way data binding by default, the updated value will be bound to scope. Anyway your HTML should be</p>
<pre><code><input type="Text" ng-model="venuemobile" value="{{venuemobile}}" ng-init="venuemobile='{{venuemobile}}'"
</di... |
Mac Mini - Continuous Integration <p>Does anyone here leverage Mac Mini Server with continuous integration?</p>
<p>I am currently facing an issue where vendor is trying to use the company's mini server for continuous integration but both of them are having different Apple ID, of course none of the provisioning profile... | <p>The way I typically handle this is by giving each machine its own Apple ID. Then you can invite that Apple ID to any developer team you need and give it its own dev certificate/key. Make sure they have the appropriate provisioning profiles downloaded as well.</p>
|
How to declare collection name and model name in mongoose <p>I have 3 kind of records,</p>
<pre><code>1)Categories,
2)Topics and
3)Articles
</code></pre>
<p>In my mongodb, i have only 1 colection named 'categories' in which i stroe the above 3 types of documents.</p>
<p>For these 3 modules,i wrote 3 models(one eac... | <p>Try-</p>
<pre><code>mongoose.model('category', CategorySchema, 'categories');
mongoose.model('topics', TopicSchema, 'categories');
mongoose.model('articles', ArticlesSchema, 'categories');
</code></pre>
<p>As mentioned in docs: <a href="http://mongoosejs.com/docs/api.html#index_Mongoose-model" rel="nofollow">http:... |
up a telephone number in the directory with Android <p>I want a function that allows Clicking a button on my application, the directory is opened and when the user selects a contact, its number is copied in a EditText on my program. as with the buttons ("+") found on messaging applications.</p>
| <p>Your button clicklistener will look like</p>
<pre><code>BUTTON.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"));
... |
How do I pass in an argument to a list of lambdas? <p>Intent: I'm trying to return each dictionary that contains the passed in matching keywords and values within a list of dictionaries. For example, <code>a='woot', e='1', c='duh'</code> would return only</p>
<pre><code>{'a': 'woot', 'b': 'nope', 'c': 'duh', 'd': 'rou... | <p>You can do this (in Python 2.7):</p>
<pre><code>def get_matched_lines(input_dict, **param):
return [dic for dic in input_dict if all([key in dic and dic[key] == val for key, val in param.iteritems()])]
</code></pre>
<p>The same code in Python 3 is</p>
<pre><code>def get_matched_lines(input_dict, **param):
... |
How to take year 2016 onwards? <p>I have this code below working fine w/o the condition in the line <code>payrollEndDate = p.PayrollEndDate.Value.Year >= 2016</code> because it gives me an error <code>Invalid cast from 'Boolean' to 'DateTime'.</code> and the code that I added is return a boolean</p>
<pre><code>var ... | <p><code>select</code> is for projections, not filtering. It sounds like you want a <code>where</code> clause instead. I'd suggest not using query expressions here, given that you're only doing simple things:</p>
<pre><code>var query = db.Periods
.Where(p => p.PayrollEndDate != null &&
... |
How to search over whole cities in combobox <p>I inserted about 18 cities in government field and I can search over each city I want by ID, but now I want to search over all of the cities by ID when I do not select any thing in combobox. </p>
<pre><code>string c = "%";
c = comboBox1.Text;
int a;
a = Convert.ToInt32(te... | <p>You could change the statement in case of "nothing selected"</p>
<pre><code>if (ComboBox.Text == string.Empty)
{
cmd.CommandText = "select * from Person where ( PER_ID = '" + a + "')";
}
</code></pre>
<p>Remarks:</p>
<ul>
<li>use variable names like <code>string sCity = "%";</code> instead of <code>string... |
Regarding Docusign envelope API <p>I am getting the below response using <code>Docusign</code> envelope API</p>
<pre><code>{
""envelopeId"": ""0aac02c3-ccdc-4bfe-88af-eefa2438d696"",
""uri"": ""/envelopes/0aac02c3-ccdc-4bfe-88af-eefa2438d696"",
""statusDateTime"": ""2016-10-14T10:39:02.4900000Z"",
""status"... | <p>Created status means you will find it in your draft folder and that it has not been sent. If you want a <a href="https://www.docusign.com/p/RESTAPIGuide/Content/REST%20API%20References/Post%20Sender%20View.htm" rel="nofollow">POST sender view</a> then you will need to make the correct call and use the URL returned b... |
How to add an unspecified amount of variables together? <p>I'm trying to add in python 3.5.2 but I have an unspecified amount of variables. I have to use very basic functions; I can't use <code>list</code>. I can't figure out how I'm supposed to add each new variable together without a <code>list</code>. When I run the... | <p>Keep another variable around and sum than up, also, <code>count</code> isn't used for anything so no real reason to keep it around. </p>
<p>For example, initialize a <code>price</code> name to <code>0</code>:</p>
<pre><code>price = 0
</code></pre>
<p>then, check if the value is <code>-1</code> and, if not, simply... |
Run method in parallel in C# and collate results <p>I have a method that returns a object. In my parent function I have a list of IDs.</p>
<p>I would like to call the method for each ID I have and then have the objects added to a list. Right now I have written a loop that calls the method passing each ID and waits for... | <p>I think <strong>Task parallel libraries</strong> will help you</p>
<pre><code>Task[] tasks = new Task[2];
tasks[0] = Task.Factory.StartNew(() => YourFunction());
tasks[1] = Task.Factory.StartNew(() => YourFunction());
Task.WaitAll(tasks);// here it will wait untill all the functions get completed
</code></... |
Gantt chart in cakephp <p>I need Gantt chart in cakephp.I have tried Some Jquery Gantt charts .</p>
<p>But for my requirement i found 'dhtmlxGantt' is suitable.
But it works fine for only limited number of tasks.</p>
<p>Is there any solution for this.or any alternative charts ??Kindly suggest.</p>
| <p>Try RadiantQ jQuery Gantt - www.radiantq.com. Support unlimited number of tasks through virtualization.</p>
|
Kafka - mirror from one server to another server <p>I'm trying to mirror Kafka real-time data from one server to another server.</p>
<p>Found a tool called 'Mirror Maker' at Apache website.</p>
<p>[Apache Kafka Mirror Maker][1]
<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27846330#Kafkami... | <p>Apache's Mirror Maker is a relatively simple tool, this is why all the documentation you read doesn't seem incredible informative. There isn't much information to give. All it does is produce data from cluster A and consume to cluster B. Mirror Maker does provide real-time topic transfer but as far as stability goes... |
Working process of logical NOT operator in if(!(i%6)) <pre><code>#include<stdio.h>
int main(void)
{
int i;
char ch;
/*display all numbers that are multiples of 6*/
for(i=1; i<10000; i++){
if(!(i%6)){
printf("%d, more?(Y/N)", i);
ch= getche();
if(ch... | <p>Actually it is not quite clear what is your question / what exactly you dont understand. However, I will try to clarify:</p>
<pre><code>if(!(i%6)){
</code></pre>
<p>First <code>(i%6)</code> is evaluated, then you should consider that the not operator takes a <code>bool</code> as parameter:</p>
<pre><code>bool... |
If i<1000,this program can run successfully ,but i change it to i<10000, this program can't run ,Why this happened? <p>Something test about Java GC</p>
<pre><code>public class StringTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s1;
for(int i=0;i<10000;i++){... | <p>This is an issue of your console (assumed Eclipse). Your program is running, and the output is shown, but for whatever reason the console can not properly handle lines of that length. In practice, it is seldom required to print such long lines. You should consider using <code>System.err.println()</code> instead of <... |
How to find the Indices of a pixel label using a loop <p>I have this segmented image in which I need to find the indices of all pixels labelled â20â
I know I can easily do this with the code:</p>
<pre><code>img = [00 00 00 00 00 00 00 00;
00 20 00 00 00 20 00 00;
00 00 30 00 00 00 00 00;
10 10... | <p>Of course, it is not efficient to loop through an image with typically 10's of thousands to millions of elements. But if you insist, there is always a loop solution.</p>
<pre><code>for ii = 1:numel(img)
if img(ii) == 20
% do_the_thing
end
end
</code></pre>
<p>Nevertheless, even if I have to loop ov... |
JDBC Phoenix driver for HBASE, retries 36 and throws exception <p>I have a standalone HBase installed in a server(Remote).
I written a Java Client, which communicates using Phoenix, and saw it tries for 36 attempts and hence throws exception.<br></p>
<pre><code>HBase-Version : 1.1.5
Phoenix-core: 4.8.0-HBase-1.1
</cod... | <p>In my experience, this usually occurs when you're getting timeouts on the scanners. And in your case, that appears to be true, as well b/c in your error message it says:</p>
<blockquote>
<p>callTimeout=60000, callDuration=80992</p>
</blockquote>
<p>meaning you went on for 81 seconds when your timeout was a minut... |
javascript function is not working in cakephp <p>I have casecading in zone , state and city. I have added following code in my Controller and View. but my Javascript function <code>onchange</code> is not working in View form, please help </p>
<p>Code for controller:</p>
<pre><code><?php
class StatesCon... | <p>you seem to not call the same id as in your input, try changing your jQuery to this:</p>
<p><code>$("#zone_id").on('change', function () {
//your stuff
}</code></p>
|
react+redux how can son component get props? <p>this is my code:<br>
<strong>action:</strong><br>
<code>const increaseAction = { type: 'increase' }</code><br>
<strong>reducer:</strong> </p>
<pre><code> // Reducer
function counter(state = { count: 0 }, action) {
const count = state.count
switch (action.type... | <p>You can pass down peice of state (to children's) via MapStateToProps method ,similarly you can pass down actions to children's via mapDispatchToProps function like below : </p>
<pre><code>function mapDispatchToProps(dispatch) {
const {updateData} = importedActions;
return {
actions: bindActionCreators({upda... |
How to use promises in mongoose <p>By runnig the below code,i can see the values in my console,but the response i got is empty ,i thoink it may be because of promises....</p>
<p>My code,</p>
<pre><code>exports.getcatlist = function(req, res) {
var params = req.params,
item = {
'status': '1',
'type': 'categories'... | <p>Sorry but your code is pretty messy, here's solution and clean approach, i would strongly suggest to use <a href="http://caolan.github.io/async/" rel="nofollow"><code>async</code></a> library for things you tryin to accomplish.</p>
<pre><code>//npm install async --save
var async = require('async');
exports.getcatl... |
Using the '.localhost' TLD searches in browsers instead of showing the site associated with the address <p>According to <a href="https://tools.ietf.org/html/rfc2606" rel="nofollow">RFC 2606 (1999)</a> the TLD <em>.localhost</em> is reserved for use for testing locally.</p>
<p>The goal is to configure a preview site to... | <p><code>.localhost</code> is not an existing, delegated TLD, which is why your browser doesn't find it.</p>
<p>What RFC 2606 says is that <code>.localhost</code> (along with <code>.test</code>, <code>.invalid</code> and <code>.example</code>) will never be a delegated TLD, so you can safely use that name for your own... |
How to get height of UITableView when cells are dynamically sized? <p>I have a UITableView with cells that are dynamically sized. That means I have set:</p>
<pre><code>tableView.estimatedRowHeight = 50.0
tableView.rowHeight = UITableViewAutomaticDimension
</code></pre>
<p>Now I want to get the height of the whole tab... | <p>You should calculate the height of tableView in the following delegate method,</p>
<pre><code>func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
//Get the height required for the TableView to show all cells
if indexPath.row() == (tableV... |
Auto scroll with data updates <p>So I'm trying to make an info screen for a local company in my neighborhood. They want a page, that automatically scrolls to the bottom, then gets back to the top and reloads the data from some outlook calendars. I'm using ASP.net to do so, but I can't seem to figure out how to use java... | <p>You can use <strong>Jquery Ajax</strong> for this query.</p>
<p>Here is <a href="http://www.codeproject.com/Articles/239436/Load-Data-From-Server-While-Scrolling-Using-JQuery" rel="nofollow">link</a>. It wiil help you</p>
|
Return single record from multi join with LINQ in form of viewmodel in MVC <p>I'm trying to return a single record from multi join by LINQ in MVC, I use a model from my personnel database that have main table named personnel, some fields are only an id and dependent on other tables.
Therefore, I need a way to join thes... | <p>You have two options here. You can use the <code>Single()</code> method. This will check the entire collection for a single instance that meets the predicate that you can supply or you can uses the <code>SingleOrDefault()</code>. If the collection does not have a instance that meets the predicates requirements then ... |
Adobe Air - Mobile Width and Height <p>I have written my first mobile AIR app. On my iPad, the layout is a dismal failure. It looks perfect in the Flash Builder simulator. </p>
<p>I have the application set up to run in portrait mode with no auto-orientation. It starts at 160 DPI and scales up. When the applicatio... | <p>The problem is probably that the screenWidth and screenHeight are still returning the real width and height but since you are setting the DPI to a fixed value the actual visible area is smaller than that ?</p>
<p>You could use the Capabilities.screenDPI to recalculate the real size but the problem is that it is hig... |
I am New To the Development of Outlook Plugin Using C# I want to achieve the following design in my app <p><a href="https://i.stack.imgur.com/lWEe4.png" rel="nofollow"><img src="https://i.stack.imgur.com/lWEe4.png" alt="enter image description here"></a></p>
<p>I want to integrate the following specifications in my ou... | <p>You can create a Task Pane (<a href="https://msdn.microsoft.com/en-us/library/aa942864.aspx?f=255&MSPPError=-2147217396" rel="nofollow">https://msdn.microsoft.com/en-us/library/aa942864.aspx?f=255&MSPPError=-2147217396</a>) or a Form Region (<a href="https://msdn.microsoft.com/en-us/library/bb386301.aspx" re... |
How can i merge more arrays in javascript <p>I have 3 or more array :</p>
<pre><code> var array1 = [a,b,c];
var array2 = [c,d];
var array3 = [e,f];
</code></pre>
<p>Want to get 1 merged array with the result like this one:</p>
<pre><code>result = [ace, acf, ade, adf, bce, bdf, bde, bdf, cce, ccf, cde, cdf]
</code>... | <p>You could use an iterative and recursive approach with a combination algorithm.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function combine(array) {
function c(... |
sizeForItemAtIndexPath not work with custom flowLayout? <p>I've replaced default <code>UICollectionViewFlowLayout</code> with my custom <strong>subclass</strong> of <code>UICollectionViewFlowLayout</code>, and I found that <code>sizeForItemAtIndexPath</code> didn't work any longer.
Did I miss something, or I should set... | <p>In your subclass, use <code>itemSize</code> instead:</p>
<pre><code>- (CGSize)itemSize
{
return CGSizeMake(100,100);
}
</code></pre>
|
Need the default SSL certificate validation in iOS app <p>The iOS app needs the basic ssl validation to secure the client-server communication. I need a way to avoid SSL pinning which may have the client-server dependencies and need to update the app if the SSL cert changed. </p>
<p>Is there any way to allow all the v... | <p>If you are looking for a way to bypass the transport security layer imposed by apple, you can do this.</p>
<p>Put the below code in your plist file</p>
<pre><code><key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</code></pr... |
Automatic Db migration (MysQl) <p>I'm doing a project in angular.js and node.js, which have three different environments(development, test and product).Each of them have different database(Mysql).My question is related to database migration,</p>
<p><strong>At present</strong> Db migration (from development to test/pro... | <p>You could try <a href="http://www.red-gate.com/products/mysql/mysql-compare/" rel="nofollow">MySQL Compare</a>. This is a commercial tool developed at the company I work for, but is free for non-commercial use.</p>
<p>This <a href="https://www.simple-talk.com/sql/sql-tools/mysql-compare-the-manual-that-time-forgot-... |
Font-awesome Icon disappearing on change of font <p>I'm trying to incorporate <em>font-awesome</em> icons in my webpage, and it all works fine, until I change to my font of choice, <em>Exo 2</em>, and the icons show up as a bordered square. It works fine with other fonts, but for some reason this won't work.</p>
<p>I ... | <p>fontawesome is font icons and Exo 2 is font and not "font icons"</p>
<p>to work fontawesome u must apply</p>
<pre><code>font-family: FontAwesome;
</code></pre>
<p>and if u change it to something else here i think "Exo 2"</p>
<pre><code>font-family: Exo 2;
</code></pre>
<p>it wont work and will disply u square</... |
getRenditions() on org.apache.chemistry.opencmis.client.api.CmisObject returns null <p>I am using Apache Chemistry 0.14.0 to access documents in Alfresco 5.1. I am using AtomPub binding to access Alfresco.</p>
<p>When I invoke getRenditions() method on CmisDocument null is returned for all documents. Any ideas what co... | <p>By default, renditions are not requested. You have to use an OperationContext with a rendition filter.</p>
<p>See:</p>
<ul>
<li><a href="https://chemistry.apache.org/docs/cmis-samples/samples/content/index.html#working-with-renditions" rel="nofollow">https://chemistry.apache.org/docs/cmis-samples/samples/content/i... |
why spark can not recovery from checkpoint by using getOrCreate <p>Following offical doc, I'm trying to revovery StreamingContext:</p>
<pre><code>def get_or_create_ssc():
cfg = SparkConf().setAppName('MyApp').setMaster('local[10]')
sc = SparkContext(conf=cfg)
ssc = StreamingContext(sparkContext=sc, batchDu... | <p>Finally,I found the reason from Spark UI`s Environment page.</p>
<p>When I launch the code at first time, spark.master has been set to 'local[10]'ã</p>
<p>But after recover from checkpoint , spark.master change to 'local[*]' automatically </p>
<p>I have to edit conf/spark-defaults.conf with 'park.master local[1... |
Find max value of two tables, <p>Lets say we have 2 tables with number of cats and dogs respectively and name of cities. We want find in which city there are more cats than dog using a SQL statement.</p>
| <p>I think that the next query will do his work for you.</p>
<pre><code>SELECT cat.city_name
FROM (SELECT upper(city_name), count(*) quantity
from cats
group by upper(city_name)) cat
, (SELECT upper(city_name), count(*) quantity
from dogs
group by upper(city_name)) dog
where dog.city_name = ... |
align flex child at top-center and bottom-center, flexbox <p>I need a layout using flexbox, where 2 flex-items, item-1 should be aligned at top-center, while item-2 should be at bottom-center. I could not figure out how to do that.</p>
<p>See the below code:</p>
<p><div class="snippet" data-lang="js" data-hide="false... | <p>Do you mean something like this?
<a href="https://jsfiddle.net/da4jdff7/1/" rel="nofollow">https://jsfiddle.net/da4jdff7/1/</a></p>
<pre><code>.container{
display: flex;
min-height: 50vh;
align-items: center;
flex-direction: column;
}
.item-5 {
margin-top: auto
}
</code></pre>
|
Convert textarea model to array <p>I am new to angularjs. I have textarea as below.</p>
<pre><code><textarea class="form-control" maxlength="100" ng-model="EmailList"></textarea>
</code></pre>
<p>The user enters data in the text box as a list in the textarea (as below).</p>
<pre><code>Data1
Data2
Data3
<... | <p>Angular offers <a href="https://docs.angularjs.org/api/ng/directive/ngList" rel="nofollow">ngList</a> that does exactly that:</p>
<pre><code><textarea ng-model="list" ng-list="&#10;" ng-trim="false"></textarea>
</code></pre>
<p>Every line will end up as entry the the array <code>list</code>.</p>
|
FindBy in pageFactory (webdriver) doesn't work correctly <p>I want to write tests in selenium <code>WebDriver</code> with <code>PageFactory</code>, but if I add annotations in <code>PageFactory</code> form in class</p>
<pre><code>@FindBy(id="email")
public WebElement mailLink;
</code></pre>
<p>and usage:</p>
<pre><c... | <p>You did not initialize your elements before using. To initialize your page elements PageFactory method initElements. It's better if you call it in your constructor like this:</p>
<pre><code>public HomePage(WebDriver driver) {
super(driver);
PageFactory.initElements(driver, this);
}
</code></pre>
<p>Hope it... |
Non https web sites display the content of https sites <p>We have a cpanel server that hosts some web sites. we have 2 hosts that use SSL. When I open a non SSL website with http:// everything is ok but when I type https:// , it shows the contents of one of the SSL websites instead of displaying not found error!!
Usual... | <p>Your question is really confusing. It would be better if you can edit and elaborate your question. Still let me guess your question and answer it.</p>
<p>Your cPanel server has hosted more than one websites, out of them only two have SSL certificate. Let me guess those two sites as abc.com and xyz.com. Now if I hav... |
how to store data that is receieved to webserver from arduino <p>Since i didnt do any webserver code so far,my mind is full of questions.Lets say I have web server and I want to store data that comes from an arduino in database.How can I receive data ? Do I have to use php,write a script for webserver.Lets say I write ... | <p>I already did something like you want to do, and today I think the best choice is to do a <a href="http://stackoverflow.com/questions/671118/what-exactly-is-restful-programming">REST api</a> on an external webserver (you can do it with PHP). You can also install you API (or any other kind of program) on your arduino... |
How to play a single frequency tone on android device? <p>I'm new in android development. I'm now trying to play a single tone on a specific frequency on my cell phone. I didn't find any method that could play a specific tone. For example, only play a tone on 400Hz.
Does anyone help me to find some method? Thank you.</... | <p>There are a utility software under linux named 'sox' which can generate any single frequency you wanted.
for example:
sox -r 44100 -n 5.wav synth 60 sine 20<br>
this command can generate a file named 5.wav, which is 20Hz sine wave with sample rate 44.1k and lasting 60 seconds.
you can try android version:
<a href=... |
No key with alias found in keystore <p>Our android project consists of <strong>mobile and wear app</strong> ( wear app is under development) and we are trying to release the mobile app. When we try to generate signed apk we get this follow message : </p>
<pre><code>Error:Execution failed for task ':wear:packageRelea... | <p>In your build.gradle you have defined a signing config that it's pointing to a keystore that it's not in your code base.</p>
<p>Something similar to this.</p>
<pre><code>android {
...
buildTypes {
release {
signingConfig signingConfigs.staging
...
}
}
signing... |
Incrementing The Index getting error <p>I am using the <code>core data</code> in my Project. I have an option to add the car in my App and i am displaying that added cars inside the <code>tableView</code> fortunatly i have added 3 rows. When I open my App I am calling the Service in that I am getting totally 45 data. I... | <p>Please try :</p>
<pre><code>for ( Car * car in self.carSelectionManager){
[self.service getMakesForYear:car.year];
}
</code></pre>
<p>Or you can try this:</p>
<pre><code>if (carSelectionManager){
for ( int i = 0 ; i < [self.carSelectionManager count];i++){
Car *car = [self.carSelectionManager carAt... |
DirectoryInfo.GetFiles throws unhandled StackOverflowException <p>In my Downloading document Application I am getting the <code>Stackoverflow Exception as Unhandled</code> when I am iterating through the Directory to get the files details and renaming & moving the files to some folder my code is</p>
<pre><code>pub... | <p>Please try <code>directory.EnumerateFiles()</code> instead of <code>directory.GetFiles()</code>. Then also, instead of <code>.Count() > 0</code> use <code>.Any()</code>.</p>
<p>They differ as follows:</p>
<ul>
<li>When you use <code>EnumerateFiles</code>, you can start enumerating the collection of FileInfo obj... |
Separate system of coordinates for x and y <p>I am using matplotlib for plotting in my project. I have a time series on my chart and I would like to add a text annotation. However I would like it to be floating like this: x dimension of the text would be bound to data (e.g. certain date on x-axis like 2015-05-04) and y... | <p>It seems like I found the solution: one should use blended transformation:
<a href="http://matplotlib.org/users/transforms_tutorial.html#blended-transformations" rel="nofollow">http://matplotlib.org/users/transforms_tutorial.html#blended-transformations</a></p>
|
How to set PHPExcel_Cell_DataType::TYPE_STRING in krajee yii2-export <p>I meet a problem - when I export excel by Krajee yii2-export it will change long number to scientific notation in which lost last two bits.
For example 201210171530 will be 2.012E+12, when I click it, 2.012E+12 will display as 201210171500. The las... | <p>when your export successfull, you must open your excel
and then you block the number metric and then, right click the block
choose Format Data, and then click Number, and OK</p>
|
Javascript condition not working as expected <p>I have a JS code which works fine when </p>
<pre><code>checkQueryString != "M"
</code></pre>
<p>but When the value becomes <code>checkQueryString == "M"</code> it doesn't goes inside the loop </p>
<p>Here is my code.</p>
<pre><code>function GridExpInfo_ClientAdd(recor... | <p>Because </p>
<pre><code>if (checkQueryString == "M") {
alert('Value is M now');
} else {
alert('Kindly select the stage');
}
</code></pre>
<p>Has inside <code>if (checkQueryString == "M")</code></p>
<p>So try this</p>
<pre><code>function GridExpInfo_ClientAdd(record) {
var checkQueryString = '<%= ... |
Access elements inside a div outside of the current div <p>This is probably a very easy approach, however I haven't been able to figure it out.</p>
<p>My approach is to get all elements that have the "expanded-image" class that are within the "img-preview" of my current "entry".</p>
<p>This is my html:</p>
<pre><co... | <p>Firstly you don't need the <code>each()</code> at all as you can apply the <code>click()</code> event handler to all elements within a single selector.</p>
<p>To solve your issue you can use <code>closest()</code> to find the nearest parent <code>.entry</code> element to the clicked <code>.more-text</code>. From th... |
How to call a webservice with Parameters in Android? <p>I am new to android development. I know how to call webservice in iOS but when it comes to android I am blank. I have read many answer to it and they suggest different approaches. I have main activity and one Webservice class which extends AsynTask class. I want t... | <p>If you wan't use third party, you can follow this <a href="http://www.androidhive.info/2011/10/android-making-http-requests/" rel="nofollow">link</a>, hopefully can help you guys :)</p>
|
using function caller names in method chaining <p>I have the following <code>Pet</code> and <code>cat</code> inherits from <code>Pet</code>, as follows:</p>
<pre><code>function Pet(){};
Pet.prototype.run = function takeoff(cb, sec) {
setTimeout(function() {
cb();
console.log('Run');
}, sec);
};
Pet.prototype.... | <p>You can add a property in child classes and based on this value, you can return <code>this</code>.</p>
<h3>Sample</h3>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// Par... |
android studio:Unable to create media player <blockquote>
<p>Why do i get this error? Please help!</p>
<p>10-17 09:34:13.217 17220-20262/com.example.e19adm.onlineradioplayer
E/MediaPlayer: Unable to create media player</p>
</blockquote>
<p>public class MainActivity extends AppCompatActivity {</p>
<pre><code>... | <p>Consider adding the permission to access <code>INTERNET</code> to your <code>AndroidManifest.xml</code></p>
<pre><code><uses-permission android:name="android.permission.INTERNET"/>
</code></pre>
|
C# Save PictureBox Image to Remote Server <p>I have my own server with local IP is 172.23.1.66 with CentOS 7</p>
<p>So in my program, I can call image from my server with string imageLocation = "<a href="http://172.23.1.66/img/978979892782.jpg" rel="nofollow">http://172.23.1.66/img/978979892782.jpg</a>";</p>
<p>In ot... | <p>Use Server MapPath to make sure you can use your URL on your server:</p>
<pre><code>picImage.Image.Save(Server.MapPath("~/img/") + clsLibrary.throwCode + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
</code></pre>
|
Assume view state with Espresso test <p>JUnit library has an <code>Assume.*</code> instructions like <code>Assume.assumeTrue(boolean)</code> which works like assertions, but not cause test to fail and just to been ignored.</p>
<p>I want to perform such checking in <code>arrange</code> part of test for one of my views,... | <p>The only way i've founded at this moment is just finding assuming view manually with activity from test rule. And then assume via jUnit. </p>
<pre><code>CheckBox checkBox = (CheckBox) mActivityTestRule.getActivity().findViewById(R.id.cbCheckAll);
Assume.assumeTrue(checkBox.isChecked());
</code></pre>
<p>If you kno... |
Using protected $relations in User model? <p>I have two tables: <code>Users, Workers</code>.</p>
<p>The relationship is: <code>Users.id = Workers.user_id</code></p>
<p>In <code>User model</code> I set related model as:</p>
<pre><code>protected $relations = ['workers'];
</code></pre>
<p>And there is method <code>wor... | <p>You should use <code>workers()</code> relation to get this info:</p>
<pre><code>dd(Auth::user()->workers());
</code></pre>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.