input
stringlengths
51
42.3k
output
stringlengths
18
55k
Getting an SQL Exception 'NaN' is not a valid numeric or approximate numeric value <p>I'm having an SQL exception while i'm trying to parse a JSON object. Here's my code snippet. </p> <pre><code>public JSONArray paymentMode(String stringObjects) throws SQLException { JSONObject jsonObject = JSONFactoryUtil.create...
<p>You're getting a <code>javascript</code> <code>[NaN][1]</code> in <code>jsonObject.getDouble("amount")</code>. So you need to deal with it somehow. E.g. you can replace it with <code>0</code> or <code>Double.NaN</code>:</p> <pre><code>String amt = jsonObject.getString("amount"); Double amount = "NaN".equals(amt) ? ...
Saving images with pixels in django <p>I want to save images with specific pixels, when someone uploads image on django models it will be resized and then save according to id. I want them to be saved in path product/medium/id. I have tried defining path in it which saves image but not on the path I want. </p> <p><str...
<pre><code>from PIL import Image import StringIO import os from django.core.files.uploadedfile import InMemoryUploadedFile class Product(models.Model): pass # your model description def save(self, *args, **kwargs): """Override model save.""" if self.product_medium: img = Image.op...
filter data in Kendo grid by connect to a method asp.net MVC <p>I am making a code using ASP.NET MVC with kendo grid. I want to bring the data from database to Kendo grid which equal to specific date or by default "today". </p> <p>I want to make a datepicker and a button at the toolbar and everytime I click the butto...
<p>You have to pass data from client to server using <code>getFilterDate</code> function specified in you Kendo Grid Read <code>Data</code> method. Implement a function like this. The return type must be an object with fields with the same name you defined in your MVC Action, in this case <code>date</code>. Kendo will ...
Visual Studio won't detect my device <p>Yes, yet again another question about connecting a device to Visual Studio... I know there are plenty of answers, but I couldn't make it work, hence this new topic.</p> <hr> <p>So I got a Visual Studio Community 2015. I created a new Cordova Project, using Cordova 6.1.1 When I...
<p>Install a driver for your phone :) currently i am using pdaNet to connect my phone for android dev. check it here -> <a href="http://pdanet.co/a/" rel="nofollow">http://pdanet.co/a/</a></p> <p>just for you to know how to check if you have driver for your phone <a href="http://www.junefabrics.com/android/driver.ph...
How to loop inside custom field group in WordPress <p>I want to emulate the following layout on WordPress pages. </p> <p><a href="https://i.stack.imgur.com/fio4u.png" rel="nofollow"><img src="https://i.stack.imgur.com/fio4u.png" alt="enter image description here"></a></p> <p>but how do I make the encircled city dyna...
<p>Well, it would have been of great help if you had shared the table structure. Assuming that there are three separate records for:</p> <ol> <li>Cupertino</li> <li>Infinite Loop</li> <li>Cupertino, CA</li> </ol> <p>We can do this:</p> <pre><code>select group_concat(x separator ' ') address from (select 'Cupertino 1...
Kentico - Different transformations for hero banners <p>I've set up a custom page type for my hero banners (all are inside /hero/ folder on the content tree) and used a repeater to display the banners in form of a carousel. The current transformation I have centering all elements (text/buttons) inside all banners. Howe...
<p>Probably the easiest way would be to add an extra field (or a couple of fiedls) to a page type, where editor could specify the position of elements or simply type in a class. E.g. drop down with otions right, left and center; each option value could be a class that you just include into your transformation. The rest...
SDWebImage blocking tableview title label <p>I need some help, I'm using SDWebImage to display my images in my Xcode app but I'm also trying to show text using the tableView's testLabel. But what is happening is the image is pushing the textLabel to the right, next to the image instead of being on top of the image. I'm...
<p>In default TableView cell image is always in centre and textLabel is right to imageView. So for this you have to design a custom TableView cell.</p>
Progress Bar in C# <p>My problem is I have a method which loading some datas. It took about 10-15 second until the website is loaded. I wanna add a progress bar to the site for the user to show him how long it takes to complete loading the website.</p> <p>I made a progress bar with pace.js and added it to the .html. T...
<p>The progress bar initializes after the load happened. In fact, the load happens on the server before aything is sent to the browser. I would solve the problem as follows:</p> <ol> <li><p>I would modify my code to make sure that the slow part of the code does not execute on the server before it responds to the brows...
React typescript typings not working <p>After installing via typings I get the below error in terminal</p> <p><strong>Terminal error</strong></p> <pre><code>error TS2320: Interface 'Element' cannot simultaneously extend types 'ReactElement&lt;any&gt;' and 'ReactElement&lt;any&gt;'. Named property 'type' of types 'R...
<p>I figured out the issue finally. </p> <p>I went on to install types once via <strong>tsd</strong> and then <strong>typings</strong> that led to duplicate typings. </p> <p>Deleted the <strong>@types</strong> folder to resolve my issue.</p>
Cannot read property 'blur' of null at nightmarejs <p>I have been making simple code lately. however It's doesn't work. why do that? I don't understand. I guess it didn't have error syntax.</p> <p>but It occurred "Cannot read property 'blur' of null"</p> <p>could you please help me?</p> <pre><code>var Nightmare = re...
<p>There is a known issue where DOM elements that are changed or removed during typing events can cause a similar problem. It will be fixed in the next release of Nightmare. See <a href="https://github.com/segmentio/nightmare/pull/820" rel="nofollow">#820</a> for details. Quoting from the fix PR:</p> <blockquote> ...
How to get the logout message in custom login page <p>I have to create a login module for my project using Spring Security where I have overridden the <code>configure(HttpSecurity http)</code> method of <code>WebSecurityConfigurerAdapter</code> and created a custom login page.</p> <p><code>customLogin.jsp</code>:</p> ...
<p>See <a href="http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc-form" rel="nofollow">Spring Security Reference</a>:</p> <blockquote> <p>An example log in page implemented with JSPs for our current configuration can be seen below:</p> <p>[..]</p> <pre><code>&lt;c:url value="...
str_replace php a string <p>I have a string</p> <blockquote> <p>X_HD003_0</p> </blockquote> <p>I have a function PHP</p> <pre><code>str_replace() </code></pre> <p>Ugh......</p> <p>My result that i want:</p> <blockquote> <p>HD003</p> </blockquote> <p>^^, some funny from PPAP song, but some string is: X_HD01_1...
<pre><code>$parts=explode('_','X_HD003_0'); echo $parts[1]; //HD003 </code></pre> <p>Or in newer versions</p> <pre><code>echo explode('_','X_HD003_0')[1]; </code></pre> <p>That should work just fine for all the use cases you mentioned</p>
How to access OpenXML content by page number? <p>Using OpenXML, can I read the document content by page number?</p> <p><code>wordDocument.MainDocumentPart.Document.Body</code> gives content of full document.</p> <pre><code> public void OpenWordprocessingDocumentReadonly() { string filepath = @"C:...
<p><strong>You cannot reference OOXML content via page numbering</strong> at the OOXML data level alone.</p> <ul> <li><strong><em>Hard page breaks</em></strong> are not the problem; hard page breaks can be counted.</li> <li><strong><em>Soft page breaks</em></strong> are the problem. These are calculated according to ...
Large Icon Bitmap appears as white square in notification? <p>I am having this problem where I generate a <code>Bitmap</code> from a URL that I use in my notification. However, on my phone, the <code>Bitmap</code> shows up like a small white square. I looked into it and found many posts like so talking about it: <a hre...
<p>I think you have been downloading the image from an URL right?. So, please place an Asynctask to download the image from the url and then use the notification builder to show the notification as like this SO post: <a href="http://stackoverflow.com/a/24866080/6452886">http://stackoverflow.com/a/24866080/6452886</a></...
How to sort content based on values in custom part? <p>I created a PersonPart and attached it to my Employee type. It contains a first name and a last name and implements <code>ITitleAspect</code> so that when I create a bunch of Employees, they don't all show up as "Employee" in the content list. Now I want to create ...
<p>To add new bindings in Orchard to use in custom queries, you have to add these bindings as following:</p> <ol> <li>You should go to <code>Bindings</code> page as following:</li> </ol> <p><a href="https://i.stack.imgur.com/uht1W.png" rel="nofollow"><img src="https://i.stack.imgur.com/uht1W.png" alt="Bindings"></a><...
AngularAdal restrict AD users <p>I'm using AngularJS Adal plugin to handle login on my page, with Azure AD. I got everything working and it's great, one problem I have is, I would like to restrict who in Azure AD can use the login, is this possible? <br><br> Thanks, <br> Feeloor</p>
<p>To restrict the users for the apps which protected by the Azure AD, we can config the app to enable the ‘User assignment required to access app’ on the portal like figure below: <a href="https://i.stack.imgur.com/svwVz.png" rel="nofollow"><img src="https://i.stack.imgur.com/svwVz.png" alt="enter image descriptio...
How do I delete already merged local Git branches with TortoiseGit? <p>I would like to find solution for problem very well described <a href="http://stackoverflow.com/questions/7726949/remove-local-branches-no-longer-on-remote">here</a> - in short, this problem can be solved with <code>git branch -d $(git branch --merg...
<p>As of version 2.3 TortoiseGit only helps you for automatically cleaning up remote tracking branches.</p> <p>You can do this automatically when you use the Pull/Fetch-dialog an check "Prune". Then all remote-tracking references which are not there on the remote are automatically removed. On Sync dialog select "Clea...
How can I default my spring boot application to application/xml without killing /health? <p>I'm working on a spring-boot (1.4.0-RELEASE) MVC Groovy app which will present an XML api. By default Spring seems to wire up Jackson which marshalls my response objects to JSON, however I want it to default to responding in XML...
<p>You need to add <code>jackson-dataformat-xml</code> dependency:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;com.fasterxml.jackson.dataformat&lt;/groupId&gt; &lt;artifactId&gt;jackson-dataformat-xml&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>Then, make its <code>XmlMapper</code> available:...
Mysqli connection using object <p>I just started switching my project form the mysql to mysqli. So what i did is i just create a class db and function connect.how can i create objects and re use it</p> <p>This is my code:</p> <p><strong>class db:</strong></p> <pre><code>class db { //global var session priva...
<p>You can create a basic function like strategy to handle this type of Scenario. Hence if you include the function file alone your DB will be connected on the fly and you can use this using the variable that you connect to the DB.</p> <p>You can have two files and then you can perform the scenario like this.</p> <p>...
Subtracting UTC and non-UTC DateTime in C# <p>I assumed that when subtracting 2 datetimes the framework will check their timezone and make the appropriate conversions.</p> <p>I tested it with this code:</p> <pre><code>Console.WriteLine(DateTime.Now.ToUniversalTime() - DateTime.UtcNow.ToUniversalTime()); Console.Write...
<p>The type <code>System.DateTime</code> does not hold time zone information, only a <code>.Kind</code> property that specifies whether it is Local or UTC. But before .NET 2.0, there was not even a <code>.Kind</code> property.</p> <p>When you subtract (or do other arithmetic, like <code>==</code> or <code>&gt;</code>,...
What is the TcpListener.BeginAcceptTcpClient I/O Model in DotnetCore 1.0.x <p>I already know the BeginXXX(AMP) or XXXAsync(TAP) use IOCP in .NetFramework , then now I want to construct httpServer build on dotnetcore . so I need to know the inner mechanism.</p> <p>My pervious version in .NetworkFramework like the follo...
<p>I have just resolved. </p> <p><strong>In windows:</strong></p> <p>AcceptAsync use the AcceptEx+SocketAsyncEventArgs(IOCP)<br> BeginAccept use the AcceptEx+SafeNativeOverlapped(IOCP)</p> <p>Reference from: <a href="https://github.com/dotnet/corefx/blob/release/1.0.0/src/System.Net.Sockets/src/System/Net/Sockets/So...
I wonder how does a computer inrernally shut down when we click on shut down option? Is there also something with binary system? <p>For example how a printer prints a page? CPU transfers binary 8 bit codes to printer than...... so like this what happens with the computer internally when we start or shut down it?</p>
<p>The original <a href="https://en.wikipedia.org/wiki/IBM_Personal_Computer/AT" rel="nofollow">AT computers</a> used the <a href="https://en.wikipedia.org/wiki/Power_supply_unit_(computer)#Original_IBM_PC.2C_XT_and_AT_standard" rel="nofollow">AT PSU</a> which had <em>only</em> a mechanical switch to turn the power on ...
php -f executes script from page but accessing web page does not? <p>My problem is that i don't have any proper explanation for this happening. </p> <p>When i run the php file with the script in it using run command <code>php -f "file"</code> it executes properly.</p> <p>When i run it via webpage, it does not, i have...
<p>stupid me, on server i had root privileges for file i was editing via script, on webpage i did not, gave the right permissions, all works )) </p>
vim creates swap file every exit, complains each future edit <p>I'm using vim 7.4 within cygwin on a Windows 10 OS. Every single time I edit a file with vim, it seems to leave a .swp file in the directory. The next edit of that file complains about an existing swap file. This is very annoying.</p> <p>I know I can d...
<p>You may find that you have another instance of VIM open with the file and it is the owner of the swap file. This can happen if you accidentally pressed "Ctrl+Z" which is fairly easy if you're a windows user (undo shortcut).</p> <p>Run "ps -a" to see if there is another instance of vim running.</p>
Receive POST data from login on page, but form action goes to other page <p>Currently I have a login script with a form that goes login.php, on this page the user can login, and the server checks his/her email &amp; password combination. </p> <p>Now I have another page were users can enter a other form, called employe...
<p>you have to grab the email from the database first and save it as a session variable. e.g</p> <pre><code>&lt;?php require_once 'inc/config.php'; if(isset($_POST['login'])) { //if the login button was clicked $username = mysql_real_escape_string($_POST['username']); // $password = mysql_real_escap...
Can't load Django static files in view <p>I'm a new player in Django and Python. I want to load the static files from the project level static folder. The problem is I can't but I still can load the static of an app. This is the structure of my project:</p> <pre><code>Yaas __init__.py settings.py urls.py ...
<p>I made this work by adding the following:</p> <pre><code>STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] </code></pre> <p>From the <a href="https://docs.djangoproject.com/en/1.10/howto/static-files/#configuring-static-files" rel="nofollow">docs</a> (after point 4):</p> <blockquote> <p>Your project will pr...
PowershellScript ObjectNotFoundException CommandNotFoundException Path <p>I sign my Dlls with SNK-Files. This is done without problems through the visual studio build.</p> <p>Now i want to validate the DLLs that I really gave them a strong name. I found <a href="http://practicethis.com/script-validate-assemblys-snk-us...
<p>instead of </p> <pre><code>$expression = $snPath + ' -vf "' + $item.FullName +'"' $verify = Invoke-Expression $expression </code></pre> <p>you could do it like that: </p> <p><code>$verify = &amp; $snPath -vf $item.FullName</code></p>
Why does pandas dataframe indexing change axis depending on index type? <p>when you index into a pandas dataframe using a list of ints, it returns columns.</p> <p>e.g. <code>df[[0, 1, 2]]</code> returns the first three columns.</p> <p>why does indexing with a boolean vector return a list of rows?</p> <p>e.g. <code>...
<p>Because if use:</p> <pre><code>df[[True, False, True]] </code></pre> <p>it is called <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow"><code>boolean indexing</code></a> by mask:</p> <pre><code>[True, False, True] </code></pre> <p>Sample:</p> <pre><code>df = pd.D...
How can I delay a change to my model until I finish typing? <p>I have this field:</p> <pre><code> &lt;input ng-model="phs.englishRange" style="width:6rem;" type="text" /&gt; </code></pre> <p>The word is used in a filter so when I make any changes to it the filter changes while th...
<p><strong>For your use-case</strong>, to trigger model update 1s after last character typed (model update timer will be reset each time): </p> <pre><code>ng-model-options="{ updateOn: 'default', debounce: {'default': 1000} }" </code></pre> <p><strong>More options - update on blur:</strong></p> <pre><code>ng-model-...
Bootstrap dropdown hover transition <p>I'm trying to get a fade in transition on my Bootstrap dropdown menu on hover. So far I have tried the following with no luck.</p> <p><strong>My attempt</strong></p> <pre><code>.dropdown-menu { display: block; opacity: 0; -moz-transition: all 1000ms ease; -web...
<p>You seem to have just left off telling what to transition.</p> <pre><code>.dropdown-menu { -webkit-transition: opacity 1000ms ease; -moz-transition: opacity 1000ms ease; -o-transition: opacity 1000ms ease; transition: opacity 1000ms ease; opacity: 0; } .sidebar-nav li:hover .dropdown-menu { opacity: 1; ...
How @Tested internally creates object for singleton class? <p>@Tested internally instantiates the class object. But in case of singleton class how @Tested internally creates instance because for singleton private constructor is there.</p>
<p>Private constructors (or fields, methods, etc.) can always be executed/accessed through Reflection.</p> <p>When <code>@Tested</code> is used, an instance gets created regardless of the constructor's accessibility. This is described in the <a href="http://jmockit.org/api1x/mockit/Tested.html" rel="nofollow">API docu...
How to insert {{$index}} into an ng-class directive? <p>I have a directive that loops through a list and adds class upon <code>div</code> elements like this :</p> <p><code>&lt;div ng-class="{'has-error' : error.degreeYear_{{$index}}} /&gt;</code></p> <p>When I inspect the element, the source code shows the index bein...
<p>Like this:</p> <pre><code>&lt;div ng-class="{'has-error' : error.degreeYear_ + $index} /&gt; </code></pre> <p>Since <code>ng-class</code> is already an expression there is no need for the double brackets. </p>
Add variable amount of trailing zeros based on input integer <p>There are a lot of questions regarding rounding decimal to 2 decimals points after the comma, or adding leading zeros. I'm unable however, to find one which adds trailing zeros with a variable amount of zeros.</p> <p><strong>What I want to achieve:</stron...
<p>Try the following:</p> <pre><code>String.format("%." + n + "f", (1.0/n)); </code></pre>
Push notification codelab Uncaught SyntaxError: Unexpected identifier in curl request <p>I am following this tutorial <a href="https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/#send_a_request_from_the_command_line_for_fcm_to_push_a_message" rel="nofollow">https://developers.goo...
<p><code>curl --header etc etc</code> is a shell command. The tutorial you link to says <em>From your terminal, run the cURL command below</em></p> <p><em>Uncaught SyntaxError: Unexpected identifier</em> is a JavaScript error message. You appear to be trying to enter that code in a JavaScript program (possibly by past...
How to find exact value using xpath in selenium webdriver? <p>I am using <code>XPath</code> to find exact value:</p> <p><code>//h5[@class='familyName productFamilyName'][contains(text(),'Dozers ')]</code></p> <p>but it was failing because in my application there are 2 elements with text values <code>"Dozers "</code> ...
<p>If you want to match element with exact <code>innerHTML</code> value just use </p> <pre><code>//h5[@class='familyName productFamilyName'][text()='Dozers')] </code></pre> <p>or </p> <pre><code>//h5[@class='familyName productFamilyName'][text()='Dozers wheel')] </code></pre> <p>Depending on <code>HTML</code> struc...
Twitter Fabric TWTTweet image shrinks <p>I am using fabric for showing the <code>tweetView</code> everything is fine but sometimes some tweets has images with a wrong size</p> <pre><code> self.tableView.register(TWTRTweetTableViewCell.self, forCellReuseIdentifier: "tweetCell") TwitterOAuth.getTimelineTweets(String(s...
<p>Mike from Fabric here. This was a bug in version 2.4.0, version 2.5.0 has the fix. From the release notes <a href="https://docs.fabric.io/apple/changelog.html#id38" rel="nofollow">here</a>: </p> <p>"Fixed bug where Retweets with photos did not layout correctly".</p> <p>If you update to the latest version, the issu...
Get a default-initialized (NOT value/zero-initialized) POD as an rvalue <pre><code>#include &lt;iostream&gt; struct A { int x; }; void foo(A a) { std::cout &lt;&lt; a.x &lt;&lt; std::endl; } int main() { A a; foo(a); // -7159156; a was default-initialized foo(A()); // 0; a was value-initialized...
<p>If i understand the question correctly you need a replacement for <code>foo(A());</code> or similar cases where <code>A()</code> is called so that you don't have default initialization of members.</p> <p>In that case one here is what i came up with:</p> <ul> <li><p>First i tried to add <code>A() = default</code> (...
C# tabbed MDI forms: Always last tab is closed <p>I was following the tabbed MDI forms example from <a href="http://www.codeproject.com/Articles/17640/Tabbed-MDI-Child-Forms" rel="nofollow">HERE</a>. I just copied the code into a test application.</p> <p>The problem is, that if I press the "X" button to close a form, ...
<pre><code> private void tabForms_SelectedIndexChanged(object sender, EventArgs e) </code></pre> <p>you may missed this code of , forgot the event binding with this </p>
how to get correct hight when we have some content on UIWebView in swift iOS? <p>I have disqusView(link) in UIWebView, I want to scroll webView as the size of disqusView, I don't want default scroll of webView</p> <p>here is my code,in these I'm getting more height then actual height of webView content size.</p> <pre...
<p>Seems you want the <code>contentSize</code> of the <code>webView</code>? If that is the case, then this other StackOverflow question should point you in the right direction <a href="http://stackoverflow.com/questions/3936041/how-to-determine-the-content-size-of-a-uiwebview">link</a></p> <p>Essentially you'd do <cod...
Sometimes "Content Download" takes too long in Chrome and other major browsers <p>When I refresh my website (Ctrl+F5), loading of <br/> <code>/bundles/Script?v=kHj78R8CVSwiLFaq5EOrj6UALoxbJmoUCasHhdgb9EQ1</code> <br/> <em>(this is the script bundle that contains few js files, 2kb, 2kb, 70kb and the biggest one is the "...
<blockquote> <p>What could be a problème?</p> </blockquote> <hr> <blockquote> <p>that weighs 2mb</p> </blockquote> <p>You can utilize <code>localStorage</code> or <code>requestFileSystem</code> to download files once, at each subsequent load of page retrieve files from <code>storage</code> or <code>LocalFileSys...
Symfony2 host matched route matches other routes too <p>Here is my routing.yml file</p> <pre><code>admin: path: / host: "admin.devhostname.com" defaults: _controller: AdminBundle:Default:index app: resource: "@AppBundle/Controller/" type: annotation prefix: / </code></pre> <...
<p>Here is what solution I figured out. So far is the best way. </p> <p>I moved all site related routes in another file routing_site.yml and then included that routing with <code>host</code>.</p> <pre><code>admin: path: / host: "admin.%domain%" defaults: _controller: AdminBundle:Default:index ...
umbraco cms I'm confused <p>I need information. My company gave me to edit a site created with CMS Umbraco. I opened it with Visual Studio and it works correctly, but if I want to change the code is different from normal just because it has been used Umbraco.</p> <p>They told me I have to open it directly in the CMS U...
<p>You need to be a bit clearer.</p> <p>Umbraco is a content management system, if you want to edit content then you will need to be running an instance of Umbraco, you will need to be logged in as an administrator and you will need to publish any changes.</p> <p>The login URL should be <a href="http://yourdomain.com...
python preserving output csv file column order <p>The issue is common, when I import a csv file and process it and finally output it, the order of column in the output csv file may be different from the original one,for instance:</p> <pre><code>dct={} dct['a']=[1,2,3,4] dct['b']=[5,6,7,8] dct['c']=[9,10,11,12] header...
<p>Instead of <code>dct={}</code> just do this:</p> <pre><code>from collections import OrderedDict dct = OrderedDict() </code></pre> <p>The keys will be ordered in the same order you define them.</p> <p>Comparative test:</p> <pre><code>from collections import OrderedDict dct = OrderedDict() dct['a']=[1,2,3,4] dct['...
What's the best way to separate each stone in an image with many stones (some above the others) <p>I need to make a study of the floor of a lake, and have to calculate the number and average size of the stones on the floor.</p> <p>I have been studying morphological procedures to solve it in OpenCV but still need to fi...
<p>Wathershed is probably what will give you an approximation to the solution.</p> <p>Other thing that you may do is try labelling images with the number of flakes and particles you can count and feed it to a deep neural net and let it findout how to count the flakes, if you have enough training cases you may endup wi...
How can I know how many elements does req.body holds? <p>I've been learning <em>express.js</em> and <em>node js</em> recently, and I'm developing a questionnaire form which posts the relevant parameters to the server. I'd like to know if my clients complete all questions. How can I check how many elements are in <code>...
<p>You need to parse req.body for that. I recomend to use some kind of bodyparser middleware. Once you get it parsed, it should give an object, and there you can count the keys of that object. ie</p> <pre><code>var count = Object.keys(myParsedBodyObject).length </code></pre>
Math, something a bit complicated for me <p>so I have a math question, i need to use it in my code. say this:</p> <hr> <pre><code>630 ---&gt; 10000 125 ---&gt; 1000 230 ---&gt; ?? can anyone help me solve this? with an explanation maybe... </code></pre> <hr>
<p>It looks like multiplication by 5 on the left translates to multiplication by 10 on the right, as 125*5=625. I'd guess that you do not want a linear but an exponential connection, something like</p> <pre><code>y=10^log5(x) = pow( 10, log(x)/log(5) ) = x*pow( 2, log(x)/log(5) ) = x*pow(x, l...
How to include __build_class__ when creating a module in the python C API <p>I am trying to use the <a href="https://docs.python.org/3/c-api/" rel="nofollow">Python 3.5 C API</a> to execute some code that includes constructing a class. Specifically this:</p> <pre><code>class MyClass: def test(self): print...
<p>Their are (at least) two ways to solve this it seems...</p> <h2>Way 1</h2> <p>Instead of:</p> <pre><code>pGlobal = PyDict_New(); </code></pre> <p>You can import the <code>__main__</code> module and get it's globals dictionary like this:</p> <pre><code>pGlobal = PyModule_GetDict(PyImport_AddModule("__main__")); ...
Nested for loop in unix shell scripting <p>I have two variables named A and B for files subject and Scores like below </p> <pre><code>A=contents of file 'subject' which contains "English Hindi Telugu" B=contents of file 'Scores' which contains "60 60 10" </code></pre> <p>i want to tag the subject with marks in respe...
<p>This would be somewhat easier if the words in the files appeared on separate lines, such as</p> <pre><code>$ cat subject English Hindi Telugu $ cat Scores 60 60 10 </code></pre> <p>Then use some nifty Unix philosophy:</p> <pre><code>$ paste subject Scores | sed 's/\t/ ==&gt; /' English ==&gt; 60 Hindi ==&gt; 60 T...
Pandas: using groupby if values in columns are dictionaries <p>I have dataframe</p> <pre><code>category dictionary moto {'motocycle':10, 'buy":8, 'motocompetition':7} shopping {'buy':200, 'order':20, 'sale':30} IT {'iphone':214, 'phone':1053, 'computer':809} shopping {'zara':23, 'sale':18, 'sell':20} IT {'le...
<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html" rel="nofollow"><code>groupby</code></a> with custom function with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.nlargest.html" rel="nofollow"><code>nlargest</code></a> and <a href=...
Joda Time: Invalid format. Data is malformed <p>Trying to process this string with date and time:</p> <pre><code>2015-10-23T00:00:00+03:00 </code></pre> <p>By using this code: </p> <pre><code>String transactionDateValue = getNodeValue(nodeList, i, "transactionDate"); DateTimeFormatter dateTimeFormatter = DateTimeFor...
<p>Your Format must be:</p> <pre><code>DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ"); </code></pre> <p>It must be exactly like the date string, with the fixed values escaped by single quotes and without additional blanks. Also you have to use <code>HH</code>for 24 hours Format. hh is 12 hours Format and it star...
Dynamically loading stickers for iMessage <p>As we can create simple iMessage stickers by just dragging images in the new template(Sticker Pack Application) provided by XCode. Is there a way that rather than having images in XCode, we can have images on a server and the pack gets whatever is there on the server as user...
<p>To do so, you will need a proper iMessage extension, not a simple sticker pack. This way you'll be able to handle all the logic to load the collection of stickers. But it's completely possible, just a bit more complicated as Apple don't handle that part. You could also put your stickers into an in-app purchase and k...
Rails 4 Heroku Multi-tenancy app redirecting to heroku homepage <p>Ok so im really lost and not even too sure what to post here for information. </p> <p>I am Brand new to multi tenancy, i have followed a tutorial on using the apartment gem. Everything is working perfectly on lvh.me:3000, however when I push the app to...
<p>This error might occur when you don't have the tenant in your database. Try after creating it.</p> <p>Similar <a href="https://github.com/influitive/apartment/issues/196" rel="nofollow">issue</a> in Github</p>
Overwrite width only in CSS with an {if} rule <p>I'm working on adjusting a slider right now, when going from 2-3 images it changes class. Now i want 4 images, and it works alright, however the slider bullets (that changes between the slider images) isn't in center of the page anymore, it's aligned slightly right.</p> ...
<p>I tested your code and to me it seems fine unless i am not understanding what you are trying to achieve these are the results i got <a href="https://i.stack.imgur.com/qxQ7G.png" rel="nofollow">3 bullets</a> and <a href="https://i.stack.imgur.com/u6GW5.png" rel="nofollow">4 bullets</a> could you please explain better...
Combinations of array values using google appscript <p>Here is my JS code </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>var allArrays = new Array(['a', 'b'], ['c', 'z'], ...
<p>For a start console.log() doesn't work in GScript, replace it with Logger.log(). </p> <p>Putting it into a GScript it seems to work fine:</p> <pre><code>function test_getPermutation() { var allArrays = new Array(['a', 'b'], ['c', 'z'], ['d', 'e', 'f']); function getPermutation(array, prefix) { prefix ...
Html templates loaded asynch (JQuery/JavaScript asynch) <p>So I'm making a webpage with some code snippets loaded in from txt files. The information to paths and locations of the txt files are stored in a json file. First I'm loaing the json file looking like this </p> <pre><code>[ {"root":"name of package", "html":"h...
<p>To my knowledge, there is no golden method and i usually apply one of the following options:</p> <p>1) Preload the files separately e.g. create key "body" for each entry in your json and then set the value of it to the contents of the file.</p> <p>2) Do not display items until they are not fully loaded in the DOM ...
Ghostscript won't convert PDF to PDF/A. Annotation Issue <p>I'm trying to convert a PDF to PDF/A. At every pass I'm getting the error "<code>GPL Ghostscript 9.19: Annotation set to non-printing, not permitted in PDF/A, reverting to normal PDF output</code>". </p> <p>The PDF has previously been generated from HTML by <...
<p>I thought the error was quite specific; PDF/A does not permit annotations to be set to non-printing. You haven't included an actual example of the kind of file causing you a problem, so I can't possibly comment on the presence of any annotations, but I assure you that its not possible to get this message without hav...
How to test a java sql query that checks a values uniqueness <p>I have a number of Java methods that check for a values uniqueness against similar values in a database. Heres an example:</p> <pre><code>public static boolean isNameUnique(String name){ Statement stmt; try { stmt = dbConnection.createSta...
<p>Use the below query</p> <p>String sql = "SELECT name FROM model where name != ?";</p> <p>In Question mark, pass the value that you are getting by trimming that value.</p>
jQuery._data event handlers <p>I am trying to determine whether Twitter Bootstrap "tab.js" has been loaded. One way is to look at the events that it hooks.</p> <p>If I dump the event handlers to the console:</p> <pre><code>var ii; var docEvents = jQuery._data(document, "events"); var docClickEvents = docEvents.click;...
<p>It was a timing problem. I was loading 'tab.js', appending it to the body, and assuming this process would complete immediately:</p> <pre><code>ourScript = document.createElement("script"); ourScript.type = "text/javascript"; ourScript.src = sourceDir + "tab.js"; document.body.appendChild(ourScript); </code></pre>...
Using ion-list to display the sub-items of the selected item <p>I'm creating an app where there is a list of items displayed. when an item is selected it will be re-directed to another page where another set of items are listed with check box, so that the items can be check-boxed for further process. Im able to select ...
<p>This would correctly:</p> <p>Within your config of your application, should I set the state that v to receive the parameter as follows:</p> <pre><code>carService.config(function($stateProvider, $urlRouterProvider) { .state('html2', { templateUrl: 'overview', params: ['value'], cont...
iOs Safari and Google Chrome SVG animation doesn't show up <p>I have been struggling with this for quite a bit now.</p> <pre><code>.intro #intro-n, .intro #intro-o, .intro #intro-a2 { stroke-dasharray: 400; stroke-dashoffset: 400; } .intro #intro-n { /*-webkit-animation: intro-letters 0.9s linear;*/ -webkit-an...
<p>After spending a fair amount of time on this issue, I finally cracked it down, it seems that the issue was in this bit of code:</p> <pre><code>.intro svg { position: absolute; top: 50%; left: 50%; -webkit-transform: translateX(-50%); -webkit-transform: translateY(-50%); -moz-transform: trans...
Matrix Form Representation of Results <p>I have 7 csv files which has list of words. I have taken all the words from 7 csv and put in a new file called Total_Words_list. </p> <p>The issue is that I need an output in the following matrix:</p> <pre><code> APPLE BALL CAT DOG.... A 0 1 1 0 B 1 1 0 ...
<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html" rel="nofollow"><code>concat</code></a> for concating all <code>DataFrames</code> and then <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.stack.html" rel="nofollow"><code>stack</code></a> wi...
how to change all elements id in div child <p>How I can change and add something to all ids in div child elements that have something like <code>bi_</code> in his first. like this example:</p> <pre><code>&lt;script&gt; var opts = '1'; $('.mm &gt; #bi_name').attr('id', 'bi_name_'+opts); $('.mm &gt; #bi_emai...
<p>You can use target all the elements using <a href="https://api.jquery.com/attribute-starts-with-selector/" rel="nofollow">Attribute Starts With Selector [name^=”value”]</a> then use <a href="http://api.jquery.com/attr/#attr2" rel="nofollow"><code>.attr(attributeName, fn)</code></a> to set the <code>id</code></p...
Find similar items in mysql table when values are just a bit random <p>I have database of laboratory analysis results. Due to the nature of analysis, the results a just a bit random- it is normal in real world. All result are stored in database in integers (we keep results in ppm - part per million). The problem is, th...
<p>You really don't want to do this using SQL.</p> <p>Essentially what you're doing is calculating the <a href="https://en.wikipedia.org/wiki/Connected_component_(graph_theory)" rel="nofollow">connected components</a> of the graph defined by your database, where two rows have an edge connecting them if they are within...
Devise skip reconfirmation <p>I need to skip, not the confirmation email, but REconfirmation emails.</p> <p>Suppose I have a user with a confirmed email. I want to manually change its email for testing/support purposes</p> <pre><code>u.email # =&gt; email1@example.com u.email = 'email2@example.com' u.save u.email # =...
<p>That method only skips sending of mail, that does not confirm the new mail which is stored in <code>unconfirmed_mail</code>. maybe you could just confirm the user manually like <code>u.confirm</code>. <code>confirm</code> method works only after object is saved.</p> <p>To skip reconfirmation email notification use ...
Show first 4 items inside div with class active rest without <p>I got some projects that use a template layout/slider. The slider works by wrapping the first 4 projects in a div with class <code>active</code> and the rest inside divs without <code>active</code> but still grouped per 4.</p> <p>I tried the following:</p...
<p>try this Code . if u have questions about the code just post under it.</p> <pre><code>&lt;?php $tel = 1; $next_div = true; $foreach_ended = 0; // 2 New vars they are needed for the right output down foreach($projectcr1 as $projects1) { $projectimages = $projects1['images']; // Get image parameters of the artic...
Adding full .NET to .NET Core library <p>I am writting a .NET Core library I intend to publish on NuGet, full .NET compatible.</p> <p>To do so, I set the project.json as follow:</p> <pre><code>"frameworks": { "netstandard1.1": { "imports": "dnxcore50" } } </code></pre> <p>I want that library to use a full .N...
<p>Try to modify your project.json by changing "netstandard1.1" to "net45":</p> <pre><code>{ "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.6.0", "OtherLib": "X.Y.Z" }, "frameworks": { "net45": { "imports": "dnxcore50" } } } </code></pre>
SAPUi5 Usage Grid and GridData <p>I'm trying to hide some controls on different screen sizes using a Grid and GridData Layout.</p> <p>I want to use the properties visibleM, visibleS, visibleXL described in the documentation <a href="https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.layout.GridData.html" rel="n...
<p>In your JS Bin, please add quotes to false --> "false".</p> <pre><code>layoutData: new sap.ui.layout.GridData({ visibleM : "false", </code></pre>
Task scheduler PowerShell Start-Process is not running <p>I have this simple script on Windows 10, which works fine when just executing, but fails to start notepad when running from task scheduler. <strong>Stop-Process works perfectly, Start-Process does not run.</strong> When I run it on demand, it closes the notepad ...
<p>The application was ran in background. To make it run on foreground, had to check the box <strong>Run only when user is logged on</strong>.</p> <p><a href="https://i.stack.imgur.com/ahW9u.png" rel="nofollow"><img src="https://i.stack.imgur.com/ahW9u.png" alt="enter image description here"></a></p>
Windows: How to control the adaptive brightness? <p>I want to control(On/Off) the <strong>adaptive brightness</strong> like the Power Options</p> <p>Enable adaptive brightness:</p> <p><img src="https://i.stack.imgur.com/PvxUx.png" alt="Enable adaptive brightness"></p> <p>by API in Win 10. I guess the API is included...
<p>I found the solution by myself, and I share the way to everyone who needs!</p> <pre><code>GUID *guidScheme; bool bResult = false; byte enableFunction= 0x1; //Set 0x0 to disable bResult = PowerGetActiveScheme(NULL, &amp;guidScheme); if (bResult != ERROR_SUCCESS){ //error message } GUID guidSubVideo = { 0x7516b9...
How can I make a volatile struct behave exactly like a volatile int during assignment? <p>When one assigns to a <code>volatile int</code> from a non-volatile <code>int</code>, the compiler. When one assigns from a <code>volatile struct</code> from a non-volatile <code>struct</code> of the same type, the compiler appear...
<p>Your initial problem is because the implicit assignment operator has signature</p> <pre><code>Bar&amp; operator=(const Bar&amp; rhs); </code></pre> <p>... and that isn't callable for a <code>volatile</code> object. The warnings are because your updated function returns a volatile reference, but that reference is ...
View controller in a tabbar is getting black while pushing another view controller in the navigation stack <p>I am having an application in which 4 view controllers are added to the tabbar. </p> <p>The first view controller is landing page. The view controller is added in to the tab bar by following way.</p> <pre><c...
<p>So you don't want the navigation bar at the landing page at all?</p> <p>Put this to your landing Page:</p> <pre><code>override func viewWillAppear(animated: Bool) { self.navigationController?.setNavigationBarHidden(true, animated: animated) super.viewWillAppear(animated) } </code></pre> <p>and this to you...
How to use Anaconda Python to execute a .py file? <p>I just downloaded and installed Anaconda on my Windows computer. However, I am having trouble executing .py files using the command prompt. How can I get my computer to understand that the python.exe application is in the Anaconda folder so it can execute my .py file...
<p>Anaconda should add itself to the PATH variable so you can start any .py file with "python yourpythonfile.py" and it should work from any folder. </p> <p>Alternatively download pycharm community edition, open your python file there and run it. Make sure to have python.exe added as interpreter in the settings.</p>
Robot Framework - How to get text of an element that then use that text in another keyword <p>I have a test case where I register an account with a unique email address.</p> <p>What I want to do is sign out and sign back into the account using the newly created email address. I have a keyword that gets the text of the...
<p>Assign the value of <code>${email}</code> you get from <strong>Get Email Address</strong> to a variable (f.e. <code>${new_email}</code>) and use it as an argument for <strong>Enter Newly Registrered Email</strong>:</p> <pre><code>${new_email}= Get Email Adress Enter Newly Registrered Email ${new_email} </code>...
How to make a custom control in iOS using Objective C <p>Anyone who know the implementation shows how to make a custom control. Like this,</p> <p><a href="https://i.stack.imgur.com/AN6kv.png" rel="nofollow"><img src="https://i.stack.imgur.com/AN6kv.png" alt="enter image description here"></a></p> <p>Where you can set...
<p>Please check below link, You may get what you need</p> <p><a href="https://github.com/muZZkat/NMRangeSlider" rel="nofollow">https://github.com/muZZkat/NMRangeSlider</a></p>
Streaming more than one video at a time <p>I want to stream through Google Chrome and Google Cast more than one video at a time.</p> <p>For example, I selected 3 videos and send them to chromecast using Chrome Browser.</p> <p>Any Suggestion on How to do this?</p>
<p>As long as you are using Cast SDK, you can form a queue of media (video or audio, not images) and load the queue and have them be played one after the other. You can even manipulate the queue (reshuffle, go next/previous, etc). The APIs to create and manage a queue is available in all three sender platforms.</p>
What protocols are supported for VoIP on iOS? <p>My colleagues have developed a web-based (RTC) VoIP app and I am now going to develop the iOS counterpart. However, after researching the forums, I have found several limiting factors with the iOS:</p> <p>-No support for RTC </p> <p>-SIP must use Mac WiFi Solution DNS6...
<p>There is no limiting factor with iOS to develop VOIP based app.</p> <p>Well, about notifying user ( iOS User ) about incoming VOIP call in background / kill state, you need to handle with push kit ( Silent push notification ).</p> <p>About users are online / offline, it would be better to get flag from sockets, no...
Reading mobile data(strings and numbers) from file in C <p>I have a file with data in the following format:</p> <pre><code>/*Number Date Time Status Call_duration(in minutes) */ 9893575103 22-09-2016 12:32:01 incoming 2 9893575102 22-09-2016 12:44:05 outgoing 3 98935...
<p>This works. Not sure what you want to do with the data, but this prints to screen.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #define MAXLINE 1000 #define MAXARG 20 FILE *f1; int main(int argc, char *argv[]) { char FileName[MAXARG]; char line[MAXLINE]; if (argc &lt;= 1) { ...
How to interpret this scala syntax "Class[_ >: Float with Int with Double]" <p>When I read Mxnet source code, I was confused in following statements:</p> <pre><code>object NDArray { private val logger = LoggerFactory.getLogger(classOf[NDArray]) private[mxnet] val DTYPE_NATIVE_TO_MX: Map[Class[_ &gt;: Float with In...
<p>The <code>with</code> keyword is used for expressing <a href="https://en.wikipedia.org/wiki/Type_system#Intersection_types" rel="nofollow">intersection types</a>. </p> <p>The type <code>Float with Int with Double</code> is basically a subtype of <code>Float</code> and <code>Int</code> and <code>Double</code>. Of co...
Codeigniter only home page working on Live server <p>I am creating a website on localhost in xampp. It is working correctly with routes working as well. Path was 'localhost/mywebsite'.</p> <p>I uploaded that website to live server. Path is 'www.mywebsite.com/beta/'. The website is not working. Only index page is worki...
<pre><code>-Change your htaccess code and replace this code. &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] &lt;/IfModule&gt; </code></pre>
Interactive image AngularJs <p>I have created a Web site using <code>AngularJS</code> and HTML, I want to load a static image and to create interactive spots on this image.</p> <p>When I hover mouse on this spot, I want some popup notification with some information.</p> <p>Which library should I use? I checked OpenLa...
<p>You can use html image map. Here's an example:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="https://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Click on the sun or on one of the planets to watch it closer:&lt;/p&gt; &lt;img src="planet...
Create server using 'app' as request handler? <p>In simple NodeJS, we can create server using -</p> <pre><code>http.createServer(function(req,res) { /* header etc. */}); </code></pre> <p>but I started using express and server is created automatically. Then I proceeded to learning sockets, but socket.io required an ht...
<p>Yes. It actually returns a function that takes <code>(request, response, next)</code> which is one of the middleware prototypes. Essentially the express module exports a function called <code>createApplictaion</code> which returns a middleware handler. <a href="https://github.com/expressjs/express/blob/master/lib...
Date filter formatting Angularjs <p>I want to show <code>date</code> and <code>time</code> on my app in this format,</p> <pre><code>Date: 14 - 19 Sep Time: 16:30 to 18:30 </code></pre> <p>And I'm getting data from server in below format,</p> <pre><code>"EventDate":"2015-09-14T16:30:00Z", "EndDate":"2015-09-14T18:30:...
<p>For month. Try this.</p> <pre><code>{{Evdate.j[0].EventDate | date : 'd'}} - {{Evdate.j[0].EndDate | date : 'd MMM'}} </code></pre> <p>For time</p> <pre><code>{{Evdate.j[0].EventDate | date : 'HH:mm'}} - {{Evdate.j[0].EndDate | date : 'HH:mm'}} </code></pre> <p>Hope it helps. Notify me if it doesn't work.</p>
How to add the values of all the fields in a struct in matlab? <p>I have a struct lets say <code>ABC</code> with dimension "1*100" struct and it has a field called <code>EFG</code> which holds a value of <code>1.6</code> each.</p> <p>I need to get <code>1.6+1.6+1.6+.......+1.6</code> 100 times by using MATLAB.</p> <p...
<p>You need brackets:</p> <pre><code>for ii = 1:100 % Just creating the struct ABC(ii).EFG = 1.6; % 1x100 struct with the field EFG end sum([ABC(:).EFG]) ans = 160.0000 </code></pre> <p>Notice the brackets around <code>[ABC(:).EFG]</code>.</p> <p>The reason is because without it you get an output from...
How do I create a query with greater than one date and not between some other dates? <p>So I need to pull back data that is after 1st jan 2017 but NOT between Oct 2016 and 31st dec 2016</p> <p>This is my current code:</p> <pre><code>SELECT [SequenceID] ,[AppointmentDate] FROM dbo].[AmsAppointment] where Appointmen...
<p>You can do this a number of ways, but I think a <code>not between</code> would work best:</p> <pre><code>SELECT [SequenceID], [AppointmentDate] FROM [dbo].[AmsAppointment] where AppointmentDate &gt;= '2017-01-01' and AppointmentDate not between '2016-10-01' and '2017-12-31' </code></pre> <p>And maybe your exam...
Android Notifications cutom view and button press <p>I have notification with custom view that contains button. When user press the button in notification it should get some Toast mesage. However Toast never shows up because <code>onReceive</code> is never called. What I'm doing wrong? </p> <pre><code> int icon...
<p>You're using <code>PendingIntent.getService()</code> with an <code>Intent</code> that has a <code>BroadcastReceiver</code> target. You need to use <code>PendingIntent.getBroadcast()</code> instead. And make sure your Receiver is registered in the manifest.</p>
how to customize this stacked bar chart with d3 <p>I'm newbie with d3 library I found this stacked bar chart I want to customize it to use it </p> <p><a href="http://codepen.io/benlister/pen/bNeLQy" rel="nofollow">http://codepen.io/benlister/pen/bNeLQy</a> thats the two lines that I wanna customize</p> <pre><code> ...
<p>In</p> <pre><code>d.y0 /= y0;; d.y1 /= y0;; </code></pre> <p>You divide <code>d.y0</code> and <code>d.y1</code> with <code>y0</code> (which in this case is the sum of all rates and you get percentage instead. So step 1 is to remove this (delete these two rows).</p> <p>Step 2 is to remove the '%-format for the y-a...
C# auto fit to any screen resolution <p>I am working on a small project using MS Visual Studio C# 2010.</p> <p>In my MainFormDesigner.cs file I have the following code. All it does is load a web page from my server. I need the app to fill the display which is 1080 x 1920. But when I save and build the app some the the...
<p>If you are using WinForms you can set the WindowState to <a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.formwindowstate%28v=vs.110%29.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow">FormWindowState</a> Maximized like this.</p> <pre><code>this.WindowState = FormWindowState.Maximized; </c...
Getting all positions of bit 1 in javascript? <p>I have provided binary for example, <code>01001</code>, and would like to get positions of bit 1, so I expect it will return me <code>[0, 3]</code>.</p> <p>Is there any function provided by javascript to get all positions of bit 1?</p>
<p>If it's a number, convert it to a string before hand, if it is a string you can do:</p> <pre><code>positionArray = []; binary.split(''); for (i = 0; i &lt; binary.length; i++){ if (binary[i] == "1"){ positionArray.push(i); } } return positionArray; </code></pre> <p>What i'm essentially doing is convertin...
What to use as hover effect for an image? <p>I want to achieve the following hover effect on my portfolio elements - <a href="http://imgur.com/a/JGhLT" rel="nofollow">link with before and after</a>.</p> <p>I am using Bootstrap with Masonry so the HTML for the original image is looking like that:</p> <pre><code>&lt;di...
<p>Go with <code>:hover</code>. If anything can be done by CSS, don't turn to JavaScript. </p> <p>For example: </p> <pre><code>img { background: url("img.png"); } </code></pre> <p>Ideally, you <strong>should</strong> use CSS sprites for icons, flags and/or any "smaller images", by setting the <code>background-po...
Subscribed topics <p>In my forum I'm showing all topics. It looks like this:</p> <p><a href="https://i.stack.imgur.com/BjALF.png" rel="nofollow"><img src="https://i.stack.imgur.com/BjALF.png" alt="enter image description here"></a></p> <p>So a user can subscribe by clicking on the red hearth. </p> <p>I'm loading the...
<p>You can add an attribute (which is not present in the database) by creating an accessor.</p> <pre><code>public function getSubscriptionsAttribute() { return Topic::subscribedBy(Auth::user())-&gt;get(); } </code></pre> <p>and then adding it to the <code>$append</code> property.</p> <pre><code>protected $append...
Run RobotFramework tests with Sikuli Library with Jenkins on VM (RDC) <p>I have automation tests based on RobotFramework with SikuliLibrary, which are for Image Compare. I'm using Jenkins to run on external server (VM) the tests. If I open the VM - image compare script works. The screenshot is created.</p> <p>If I clo...
<p>Running Sikuli Test on VM is possible but need to keep session open. We cannot run Sikuli script on locked PC. When you close VM , it get locked and Test fail to run. Sikuli needs images for comparing and clicking, if session is locked there are no images so Test fail to run. So how we overcome this ? : <a href="ht...
translating sql to SSIS expression builder <p>How to do the below in SSIS expression?</p> <pre><code>select REVERSE(LEFT(REVERSE(filename),CHARINDEX('\', REVERSE(filename), 1) - 1)) </code></pre> <p>Just stuck getting the filename but would want to do it in a package from the source in SSIS expression</p>
<p>If we assume we have a whole path of the file <code>(eg. C\folder\filename...)</code> in a user variable <code>(eg. @[User::Variable])</code>, yuo can try with:</p> <pre><code>RIGHT( @[User::Variable], FINDSTRING(REVERSE( @[User::Variable] ) , "\\", 1) - 1) </code></pre> <p>I hope this help.</p>
xamarin forms How to pass enum value to XAML and use it in switch statement? <p>I declared enum with some values and I want to pass to my Formated parameter. Here is my C# code:</p> <pre><code> public MyControllerView() { ContentEntry.TextChanged += Entry_TextChanged; } ...
<p>Well, to solve this issue regarding <a href="http://forums.xamarin.com/discussion/46778/how-to-set-default-value-converter-for-a-custom-control" rel="nofollow">this</a> forum post helped for my to figure out everything. Here is my C# code:</p> <pre><code>public enum FomationType { NameValidation...
Rails combining RESTful methods in a new controller <p>I have a rails app where <code>users</code> create <code>projects</code>. Currently these are nested, and are completed as separate actions (A <code>user</code> registers, and then from the <code>project</code> dashboard creates a new <code>project</code>).</p> <p...
<p>In my opinion better way is create another controller. Then you have better atomization of code. Which is easier to refactor. You can inherit this controller, and use <code>super</code> for creating user.</p>
Realm - mix models from different projects <p>I have a model in my Main project:</p> <pre><code>public class A extends RealmObject{ private String var1; private B var2; //... more } </code></pre> <p>Also, I have my class <code>B</code> in my library (different android-studio module)</p> <pre><code>publ...
<p>You have to use RealmModule to expose your schema in library project. </p> <p>Check out the doc: <a href="https://realm.io/docs/java/latest/#sharing-schemas" rel="nofollow">https://realm.io/docs/java/latest/#sharing-schemas</a></p>
Expiry time for member in Redis <p>I'm using Jedis client to store geo coordinates in Redis.</p> <p>Is there any way to set expiry time for member in Redis? I know, I can set the expiry time for a key.</p> <p>For example, I added below three coordinates and now I want to expire "Bahn" member in 10 secs.</p> <pre><co...
<p>Behind the scene, GEOADD uses a ZSET to store its data.</p> <p>You can store the same data (without geolocation) in a second ZSET, with a unix timestamp as score this time, using a regular ZADD command.</p> <pre><code>ZADD expirationzset &lt;expiration date&gt; &lt;data&gt; </code></pre> <p>You can get the expir...
Java : Sort String formatted as XML using attributes <p>I have a String formatted as XML which I need to sort using attribute key. The result should also be a sorted xml format of String. I am not able to do so.</p> <p>The XML String format is:</p> <pre><code>&lt;Main&gt; &lt;Node&gt; &lt;name&gt;ABC&lt;/name&g...
<p>The JDOM API offers sorting in the Element class: <a href="http://www.jdom.org/docs/apidocs/org/jdom2/Element.html#sortChildren(java.util.Comparator)" rel="nofollow">http://www.jdom.org/docs/apidocs/org/jdom2/Element.html#sortChildren(java.util.Comparator)</a></p>
Two fullscreen menus - how to show one and hide the other - using toggleclass <p>I'm using <code>jquery</code> <code>toggleclass</code> to show and hide a fullscreen menu. The problem arises because there are two fullscreen menus. If one is open, how do I hide it if the user clicks on the other one?</p> <p>I'm guessin...
<p>Ensure that the class is removed from the other menu when one is selected.</p> <p>For example:</p> <pre><code>$(".menu_link").click(function(){ $(".projects_overlay").removeClass("show_projects"); $(".menu_overlay").toggleClass("show_menu"); }); </code></pre> <p><a href="https://jsfiddle.net/facnr6f9/1/" ...
Filter minions by memory size <p>Is it possible in Salt Stack to filter minions by memory size, but indicating value that the memory size must be greater or less than, rather than equal to? So instead of this:</p> <pre><code>salt -C 'G@mem_total:993' test.ping </code></pre> <p>I need somthing like this:</p> <pre><co...
<p>I'm afraid you actually can't by using the <a href="https://docs.saltstack.com/en/latest/topics/targeting/" rel="nofollow">targeting feature</a> as it is.</p> <p>First thing that comes in my mind is writing a <a href="https://docs.saltstack.com/en/latest/topics/grains/#writing-grains" rel="nofollow">custom grain</a...
AutoCAD Get Length from BlockReference. <p><strong>The Problem</strong></p> <p>im struggling to get the Length from a BlockReference in AutoCAD. I somehow being a math noob got the Widh &amp; Height but i cannot get the Length so far of a BlockReference. Is there a way of getting the Length of a BlockReference. Ive ...
<p>Is your block reference a 3D object? If so. I noticed that you currently get the bounds of the object along the X axis (Width) and Y Axis (Height) but you're missing utilizing the Z Axis. If the Block Reference is a 2D object, then going about the method you described won't work since that information simply isn't...