input
stringlengths
51
42.3k
output
stringlengths
18
55k
Django contrib admin default admin and password <p>This may be a silly question. I start a new Django project as Document says, which only included an admin page. I start the server and use a web browser accessing the page. What can I enter in the username and password? Is their any place for me to config the default a...
<p>You can config using following command line in shell</p> <pre><code>python manage.py createsuperuser </code></pre> <p>Basically you're creating superuser who can access the django admin panel.</p>
Single point not shown in nvd3 line chart <p>I am using following configurations for displaying my line chart with the help of angular nvd3. The issue is that while displaying the chart if there is only one point near the edge then it gets doesn't get displayed unless it is hovered upon.</p> <pre><code>$scope.options ...
<p>if the length of your data is 1 then delete forceY from $scope.options.chart.forceY like this:</p> <p>delete $scope.options.chart['forceY']</p> <p>The chart will get the properly rendered by d3. The problem is that when you use the 'forceY' option in d3 if single point is not rendered.You will have to find the poi...
Accessing ListView CheckBox in Android <p>I'm making a to-do list app in android. Everything is working well enough except I have checkboxes in a ListView that I cannot set programmatically. I'm using a SQLite database that stores my tasks and whether or not they have been marked as complete. When I check a checkbox, i...
<p>Since it's a ListView item that you're setting up the CheckBox, you've to set it up in the adapter of the ListView itself. And manipulate the data model to check or uncheck the CheckBox.</p> <p>Create new class by extending BaseAdapter for populating ListView. Do not use ArrayAdapter if you've custom layout with mo...
wso2am-2.0.0 - error on server console while saving a subscription tier by admin <p>I am getting following error when I try to create a new subscription tier using admin credentials in wso2am -2.0.0. And, there is no error on screen. When I use this tier while subscribing to an API, there is no API blocking happening o...
<p>I found a similar <a href="https://wso2.org/jira/browse/APIMANAGER-5269" rel="nofollow">reported issue</a>. I made the priority high. </p>
Need help in building MYSQL query to count two content from single row/table <p>I'm trying to get count of two set of data which is listed under same table name, with specific date range. </p> <p>Table 'Event'</p> <pre> u_id event Create 123 F_log 25-Sep-16 127 C_log 25-Sep-16 123 F_log 25-Sep-16 126 F_log 2...
<p><strong>Query</strong></p> <pre><code>SELECT t.`Create`, SUM(CASE WHEN t.`F_log` &gt; 0 THEN 1 ELSE 0 END) as `F_log`, SUM(CASE WHEN t.`C_log` &gt; 0 THEN 1 ELSE 0 END) as `C_log` FROM( select `u_id`, `Create`, SUM(CASE WHEN `event` = 'F_log' THEN 1 ELSE 0 END) AS `F_log`, SUM(CASE WHEN `event` = 'C_lo...
How to Synchronize SQL Server 2008 and SQLITE Database <p>I have a Website and a Mobile Application on which people register them. The problem here is that Website using SQL server 2008 and my android application is using SQ-Lite. Is there any way that both my website and android application use the same database.</p>...
<p>Do not put all data into your SQLite DB. Just save data that are necessary for your app to work. For SQLite manipulation here is the doc: <a href="https://developer.android.com/training/basics/data-storage/databases.html" rel="nofollow">https://developer.android.com/training/basics/data-storage/databases.html</a></p...
How to convert file from windows utf-16 or windows utf-8 to unix utf-16 with C++ <p>Now, we use C++ on windows deal with some data. We have to convert some files to unix uft-16's xmls, the xml files are stored on a Unix server.</p> <p>So I want to kown how to convert file from windows utf-16 or windows utf-8 to unix u...
<p>std::codecvt_utf8_utf16 which requires codecvt header can be used to convert UTF-8 to UTF-16. A Sample from <a href="http://www.cplusplus.com/reference/codecvt/codecvt_utf8_utf16/" rel="nofollow">this link</a>. A compiler which supports C++11 is required. </p> <pre><code>// codecvt_utf8_utf16 example #include &lt;i...
What is a back-reference in Java? <p>Especially in the context of <code>readUnshared()</code> method of <code>ObjectInputStream</code>, what does a "back-reference" mean?</p> <p>I came across the term in this </p> <blockquote> <p>If readUnshared is called to deserialize a <strong>back-reference</strong> (the stream...
<p>When you serialize objects using an <code>ObjectOutputStream</code>, the stream will 'remember' which objects it has already written. When it has to write the same object again, it will not write the whole object again, instead it will write an identifier that is called the 'back reference'.</p> <p>The receiving <c...
Java Swing Image Slide Show why a picture don't change <p>Hi I create a class <code>ImageSlide2</code> and I have thread and only one time a picture change why ? </p> <p>I don't know why only time a picture change. The slide show have to all time display a changed picture This is my code : </p> <pre><code>public clas...
<p>Try to change your method by using javax.swing.Timer. Something like this:</p> <pre><code>public ImageSlide2(int x, int y, int width, int height) { setBounds(x, y, width, height); //Call The Function SetImageSize SetImageSize(list.length - 1); final Timer t = new Timer(1000, new ActionListener() { ...
Parse XML data in Apache Spark <p>I need to know how to how to parse XML file in Spark. I am receiving streaming data from kafka and then need to parse that streamed data.</p> <p>Here is my Spark code to receive data:</p> <pre><code>directKafkaStream.foreachRDD(rdd -&gt;{ rdd.foreach(s -&gt;{ ...
<p>Thanks guys.. Problem Solved. Here is the solution.</p> <pre><code>String xml = "&lt;name&gt;xyz&lt;/name&gt;"; DOMParser parser = new DOMParser(); try { parser.parse(new InputSource(new java.io.StringReader(xml))); Document doc = parser.getDocument(); String message = doc.getDocumentElement().getTextCo...
Angular2 support with HATEOAS <p>I have a restful web service with the support of HATEOAS links. When I call "<a href="http://localhost:8080/v1/bookings/1225380?lock=true" rel="nofollow">http://localhost:8080/v1/bookings/1225380?lock=true</a>" link I got following resource URLs. I want to integrate these Hypermedia wi...
<p>You can create an Injectable for this and use this class instead of the angular http class. Here you filter the links and than call http with the right link.</p> <pre><code>@Injectable() export class Hypermedia { constructor(private http: Http) { } get(links: any[], rel: String, body?: any, options?: Reque...
Select the rows where variable x starts with 65 (teradata) <p>I have a table with a column named x that includes numbers for all my observations. I now want to select only the variables that start with 65. </p> <p>I've tried:</p> <pre><code>SELECT * FROM table WHERE x REGEXP '^[65]' </code></pre> <p>and different v...
<p>If this is actually a Teradata DBMS your inital query will result in an error message because there's no <code>REGEXP</code> (but there's a <code>REGEXP_SIMILAR</code>).</p> <p>You don't need a regular expression to compare the first two digits. If the datatype of <code>x</code> is numeric you must cast it to a str...
Using NPM module in Backbone with RequireJS <p>Hejsa, I'm writing a webapp, which consists of a Node backend (Express server), which serves a Backbone app to the clients. The Backbone app uses RequireJS to load the modules used. I would like to use Ag-grid clientside, which can be included as an NPM module. <a href="ht...
<p>You guessed it and using a relative path all the way to the <code>node_modules</code> directory is the way to go.</p> <pre><code>requirejs.config({ paths: { "ag-grid": "../../../node_modules/ag-grid/dist/ag-grid", "backbone": "../../../node_modules/backbone/backbone" } }); define(["backbone...
Flink : Build is failing when I add gauge <p>Cannot use gauge , the build is failing: </p> <pre><code> def open(configuration: Configuration) { getRuntimeContext() .getMetricGroup() .gauge("RecordConverter.latency", new Gauge[Int]() { @Override def getValue(): Int = { return latency; ...
<p>You have to explicitly set the types, like this:</p> <pre><code> .gauge[Int, Gauge[Int]]("RecordConverter.latency"... </code></pre>
Twilio outbound call to conference <p>I need help. I have an agent and client situation. If the Agent make an outbound call and the client answer it, There is a button on my system which should redirect the both of the agent and client to a conference. The below code is my function which dial the number that is input b...
<p>It is absolutely possible to do that . In the code you mentioned above Twilio.Device.connect(params) invokes the Voice URL associated with the <a href="https://www.twilio.com/docs/api/rest/applications" rel="nofollow">TwiML App</a> in your account . </p> <p>This Voice URL could do the function of dialing both the...
Using call in JavaScript vs Returning by simple function <p>These are the 2 methods to calculate total amount based on object data: </p> <p><strong>Snippet 1</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-...
<p>I'll try to address each of your questions.</p> <blockquote> <p>Why second snippet gives error instead of answer? </p> </blockquote> <p>Because, you are using an IIFE, yet you are return nothing. If you do not explicitly return something in javascript (in a function) it is implied to return undefined. Thus your ...
access other values in array in coffee script in a loop (framer.js) <p>Hi I'm fairly new to javascript and CoffeeScript, so I'm currently working on a prototype and learning the language simultaneously. </p> <p>The following block of code does almost what I want it to do except for one important thing. Any help would ...
<p>You have to loop over all the objects in <code>categ</code> to and then check if they are the same as the layer that has been clicked on, to switch them on or off. </p> <p>The same holds for setting the opacity for a layer in another array, but then you should use the index of the loop to look the layer up:</p> <p...
how to find the a particular value from the available python dictionary and print the name of the dictionary in which that value is present <p>I am beginner in python.I have a particular value let say 30 and i have 5 python dictionary having keys and values.i want a function which iterates through every dictionary and ...
<p>The way I would do it would be to add all your dictionaries to a master dictionary, like below, - (Ive only used 3 for a minimal example):</p> <pre><code>master = {'one':{'a':10, 'b':20, 'c':30}, 'two':{'d':40, 'e':50, 'f':60}, 'three':{'g':70, 'h':80, 'i':90}} </code></pre> <p>The keys within your master are the ...
How to call external method with struct parameter that contains union <p>The C++ code is:</p> <pre><code>DLL_API DWORD WINAPI ExecuteCommand( LPCSTR, CONST COMMAND, CONST DWORD, LPREPLY); typedef struct { REPLY_TYPE replyType; union { POSITIVE_REPLY positiveReply; NEGATIVE_REPLY ne...
<p>You cannot replicate C union in C#. You should do something like this (change type names and constants according to your real code):</p> <p><code>public struct Reply { public int rt; public object o; public int? pr { get { return rt == 1 ? (int?)o : null; } } ...
Determine whether App is visible when clicking on a notification <p>I have a foreground service, which can be stopped by clicking on a "X" in the notification. </p> <p>When the foreground service is stopped an other activity should be shown.</p> <p>The problem is, I don't know whether the app is visible or in the bac...
<p>There is no 100% guaranty solution for your problem.</p> <p>One of the most simple is to track visible activity at global variable :</p> <pre><code>public void onResume(){ super.onResume(); App.visibleActivity = this; } public void onPause(){ super.onPause(); App.visibleActivity = null; } </code></...
Alternative to SimplyScroll with some features <p>I'm looking for an alternative to SimplyScroll (it's deprecated) with some features. I'd like a continuous, automatic carousel of boxes/images that stops when you pass over the mouse pointer (SimplyScroll can do it), and can move it when clicking and move your pointer (...
<p>I do not know about an exact alternative for SimplyScroll. As their website has mentioned these type of carousels are rare now a days. There are much better and responsive (touch enabled) carousel plugins.</p> <p>Here are some good examples of auto scrolling carousels: <br>1. <a href="https://css-tricks.com/infinit...
how to provide username and password in tnsnames.ora <p>I have connected oracle server database in excel with the help of oracle instant client software and i am getting table and data but whenever i am restarting excel to connect with oracle database it is asking username and password so i want to save the username a...
<p>It isn't possible to save username and password in tnsnames.ora file. you should fix it in excel.</p>
Understanding issues with double pointers and passing them to functions <p>I'm a c++ beginner and have an understanding issue with the following code. </p> <pre><code>#include &lt;iostream&gt; using namespace std; struct student { string name; int age; float marks; }; struct student *initiateStudent...
<p>Because the <code>stud</code> variable in <code>main</code> is an array of <code>student</code> pointers. When you pass an array by argument you need a pointer to the first element, whatever the elements are. Since the array is an array of pointers, you have a pointer to a pointer.</p>
How to make coloured buttons in bootstrap navbar? <p>I want to have a big red "Donate" button with white text in the navber, and my solution was <code>&lt;a href="#" class="btn btn-danger"&gt;Donate Now&lt;/a&gt;</code>. However, the button seems to turn transparent on hover.</p> <p>I've also tried <code>&lt;span clas...
<p>Try this code on your custom style sheet</p> <pre><code>.navbar-default .navbar-nav&gt;li&gt;a:focus, .navbar-default .navbar-nav&gt;li&gt;a:hover { color: #333; background-color: red!important; border: 1px solid red!important; } </code></pre>
How to Draw Correct Sign using PaperJs? <p><a href="http://i.stack.imgur.com/8MnYY.png" rel="nofollow">Correct Sign</a></p> <p>I want to draw something like above using PaperJs on image converted to Canvas, can someone point me to right direction?</p>
<p>You can follow the <a href="http://paperjs.org/tutorials/" rel="nofollow">nice tutorials</a>, especially the <a href="http://paperjs.org/tutorials/paths/working-with-path-items/" rel="nofollow">ones about paths</a>.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">...
Previous window without refreshing the page using JavaScript <p>I want to go to the previous window when I click the back button in chat_user window without refreshing the whole page. Below is my code:</p> <pre><code>&lt;a href="" onclick="window.history.go(-1); return false;"&gt;back&lt;/a&gt; </code></pre>
<p>You need to get the previous website (also known as the page referrer) first and then open a new window with the URL:</p> <pre><code>&lt;a href="#" onclick="window.open(document.referrer); return false;"&gt;back&lt;/a&gt; </code></pre> <p>After understanding what the OP actually wants, this should be the solution:...
Convert Textbox value to int and also check for is it Empty or Not <p>I am trying to update record of a person in a gridview when i am input into textbox(tAge) it shows me an exception <strong>Input string was not in a correct format.</strong> i had tried a lot of codes but won't work please help me out.And <strong>th...
<p>I would suggest to check the <code>Text</code> property first before assigning it to the appropriate values. For the conversion there exist a nice method <code>TryParse</code> it returns a <code>bool</code> and will only parse if the format is correct.</p> <pre><code>try { // ask whether it is blank or full of ...
cookie and modal error <p>I use javascript to make a popup window (modal) that warns people we use cookies on our website. There is a accept button wich on click should create a cookie that last 60 days and prevent the modal from displaying. but when i click the button i get a error saying i cant modify header because ...
<p>I have solved the problem by adding another page where i set the cookie. so the <code>&lt;form&gt;</code> from cookie.php will be <code>&lt;form actio="/etc/set_cookie.php" method="post"&gt;</code> and in <code>set_cookie.php</code> I use the same php script as before.</p> <p>I posted this answer to let people know...
How to vertically align div on page with flexbox <p>The following is not vertically aligning the div with text in browser tab (it is horizontally aligning correctly):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-co...
<p>The problem is with the height you given to the parent container. The <code>height :100%</code> does not take whole height. change that to <code>100vh</code> or like that</p> <p>Here is the updated <strong><a href="https://jsfiddle.net/6q4bsfu6/1/" rel="nofollow">Demo</a></strong></p> <p><div class="snippet" data-...
Getting SSRS report Data in your asp.net application <p>I'm new to SSRS, I would like to know if it is possible to get the SSRS report data in an asp.net application in ordrer to get the value of a specific field (example: sum of assets, ...) ?</p> <p>Is there any possibility to get the report data in json (webservice...
<p>SSRS reports bind from a datatable. Find the datatable you created for the SSRS report and do what you want with the data before or after your RefreshReport() call. </p>
How do I check for an empty nested list in Python? <p>Say I have a list like </p> <pre><code>cata = [["Shelf", 12, "furniture", [1,1]], ["Carpet", 50, "furnishing", []]] </code></pre> <p>and I want to find out in each nested list if it's empty or not.</p> <p>I am aware of using for loops to iterate through ...
<p>You're <code>return</code>ing from the function, that essentially means that you don't evaluate every element.</p> <p>Apart from that <code>for inner_2 in inner[3]:</code> will not do what you want because it won't execute for empty lists (<em>it doesn't have elements to iterate though!</em>). What you could do is ...
Which Excel's formula can do this without VBA UDF? <p>I'm bad in describe idea in English sothat I can't find the solution for this task, then I write a custom UDF for excel</p> <pre><code>Public Function ArrCompare(Rng1 As Range, Rng2 As Range) As Variant Dim vR1, strC As String Dim i As Long, Ui As Long vR1 = Rng1.V...
<p>The formula which will do the same as your UDF would be:</p> <pre><code>=SUMPRODUCT(--ISNUMBER(SEARCH(A1:A5,B1))) </code></pre> <p>But I would exclude empty cells in the range, so that the range can be bigger to be prepared for additional values:</p> <pre><code>=SUMPRODUCT(ISNUMBER(SEARCH($A$1:$A$100,B1))*($A$1:$...
How to plot inside while-loop in MATLAB? <p>Inside a while loop, I have some function that creates all the neccesary y-values for the plot I want to make. After all the y-values are done I want my program to plot the dat(while still inside the loop), but the plot can't be made because the data won't come out until the ...
<ul> <li>for Continuous line plot you can use <code>drawnow</code> and <a href="https://es.mathworks.com/matlabcentral/newsreader/view_thread/338583?requestedDomain=www.mathworks.com" rel="nofollow">here</a> it is explained how to do this (remember to use <code>pause(.)</code> if you want to visualize the changes "real...
How to start lighting up at 45 degree in aurduino flex sensor? <p>I want to make the led strips gradually lights up as the flex sensor bends. But I want the led strips start to light up when the flex sensor is 45 degree. And I want the led strips to be off before 45 degree. Here is my code which is in Arduino.</p> <pr...
<p>One problem is that you are setting your sensor to zero when the map function is expecting a value in the range of 460 and 850. It may help to change your default sensor value when below 45 degrees to the lowest value in the expected range (460.) </p> <p>You could also remove your if condition and shift it later in...
Remove image from MediaRouteControllerDialog <p>I want to remove the imageView from the MediaRouteControllerDialog since I don't have any image to display.</p>
<p>Unless you specify an image for the media (or a default one), the dialog will not show any image; there is no default image in the library to use when you don't specify one. Are you using any particular framework? The right approach to populate the metadata (including image) for a <code>MediaRouteControllerDialog</c...
BackboneJS Radio channel triggers events more than once <p>I am building a backbone js application, I use BackboneJS Radio for messaging.</p> <p>First I created a channel:</p> <pre><code>App.actionsChannel = Backbone.Radio.channel('actions'); </code></pre> <p>And when I click an action button, lets say 'next' action...
<p>It's because the registering <code>on</code> is done multiple times, somewhere not shown in your question, and it should only be done once.</p> <h1>✘ Don't do this</h1> <pre><code>var view = Backbone.View.extend({ events: { "click": "onClick" }, onClick: function(e) { App.actionsChan...
Multiple snapshots in GoogleMaps <p>How to make multiple snapshots in GoogleMaps each fully loaded? Experimented with this, but <strong>of course</strong> it doesn't work properly:</p> <pre><code>button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ...
<p>I did it. If anybody cares:</p> <pre><code>public void uploadScreenshots() { if (getRootActivity() != null) { iterator = 0; map =... sortedKeys =... //move to the first marker CameraPosition cameraPosition = new CameraPosition.Builder() .target(new La...
MS Access - running 12-month total <p>I am trying to calculate a 12-month running total in MS Access. In Oracle SQL I would achieve this using a window function like</p> <pre><code>SELECT date, SUM(salesvol) OVER (ORDER BY date ROWS 11 PRECEDING) AS running_tot FROM table1 </code></pre> <p>but apparently MS Access do...
<p>Convert the varchar date to DATE format. You can use dates as the 1st day of the month. Refer the <a href="http://stackoverflow.com/questions/12359395/how-to-convert-a-text-field-to-a-date-time-field-in-access-2010">link</a> for conversion.</p> <p>Then you can refer for the <a href="http://stackoverflow.com/questio...
Deleting App should not delete Document Directory <p>Is there any way not to Delete document Directory If iOS App is get unnistaled or any alternate way</p> <p>or</p> <p>Is there any way we can save data on different place so that after deleting app we can use it?</p>
<p>No there is <strong>no way to prevent system from deleting the documents folder</strong> once you <strong>uninstall the app</strong>. </p> <p>And if an <strong>iCloud</strong> is enabled in the device, it will backup the contents of the Documents directory. iCloud way is the most efficient as it handles documents f...
SDL: Calling SDL_CreateRenderer Segfaults <p>When I use Software Rendering in my SDL2 project, everything works as expected. e.g when the code for creating a SDL_Renderer looks like this:</p> <pre><code>this-&gt;renderer = SDL_CreateRenderer(this-&gt;window, -1, SDL_RENDERER_SOFTWARE); </code></pre> <p>When I use Har...
<p><a href="https://wiki.libsdl.org/SDL_GetWindowSurface" rel="nofollow">SDL_GetWindowSurace</a> documentation says <strong>You may not combine this with 3D or the rendering API on this window.</strong>. Either generate surface and update window surface yourself (and forget about hardware acceleration) or use SDL_Rende...
Check box not checked according to the stored array of id <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 data; var gridColumns; var grid; var showlist; var viewModel; ...
<p>The new TreeView instances that are created in <code>filterinfo</code>, do not have a <code>change</code> handler attached to their dataSources. This is currently done only once for the first TreeView instance, that's why the checked IDs are displayed only for this instance.</p>
how to retrieve stored post array from database using php <p>I am storing form post data in MySQL data base in array format but when i fetch value its not array it is become string.</p> <p>There are my fetch value:</p> <pre><code>Array ( [First_Name] =&gt; Rahul [Last_Name] =&gt; Singh [Street] =&gt; 210 Adhichini [C...
<p>I think you post data into database using serialize function and retrive data using unserialize function. this is best</p> <pre><code>$serialized_data = serialize(array('Math', 'Language', 'Science')); echo $serialized_data . '&lt;br&gt;'; </code></pre>
How to change model name from singular to plural in working app? <p>In my application I created two models <code>Stat</code>, <code>Setting</code> with <code>belongs_to</code> association to <code>User</code> model. Each <code>User</code> has association <code>has_one</code> to <code>Stat</code> and <code>Setting</code...
<p>No, it is idiomatic to use singular for the name of the class.</p> <p>You will have a happier coding experience if you stick to the conventions.</p> <p><a href="https://gist.github.com/iangreenleaf/b206d09c587e8fc6399e" rel="nofollow">https://gist.github.com/iangreenleaf/b206d09c587e8fc6399e</a></p>
Does `adb shell top` show the average cpu usage over the update time? <p>When calling <code>adb shell top</code> with Android to measure cpu usage, is the cpu usage percentage that is shown the average over the update time, or a snapshot of the usage over a shorter time, specifically, if I increase the update time usin...
<p>I compared the top -d to the CPU usage reported by the default system monitor.I tried both "top -d 1" and "top -d 10." Just to cover a short as well as large period. In both the cases top -d was not giving the instantaneous CPU usage. So I'm guessing the it is the <b>average CPU usage over that period.</b></p> <p>...
c# ASP.net Indirect download to client from file server <p>Sorry, I'm doing this first time with file server so there may be a few stupid questions.</p> <p>So I need to connect to file server and let user download some file, but user shouldn't be able to access file server directly. </p> <p>Is there some way to make ...
<p>You can use an <a href="https://msdn.microsoft.com/en-us/library/ms227675(v=vs.100).aspx" rel="nofollow">HttpHandler</a> to mediate between the browser and your filesystem, applying whatever restrictions you need programmatically. <a href="http://www.codeproject.com/Articles/544289/Restricting-files-download-using-...
Python - "Undo" text-wrap <p>I need to take a text and remove the \n character, which I believe I've done. The next task is to remove the hyphen from words where it should not appear but to leave the hyphen in compound words where it should appear. For example, 'encyclo-\npedia to 'encyclopedia' and 'long-\nterm' to 'l...
<p>A first pass would be to keep a set of valid words around and de-hyphenate if your de-hyphenated word is in the set of valid words. Ubuntu has a list of valid words at /usr/share/dict/american-english. An overly simple version might look like:</p> <pre><code>valid_words = set(line.strip() for line in open(valid_wor...
Hackerrank string reduction <p>I am working on the following problem <a href="https://www.hackerrank.com/challenges/reduced-string" rel="nofollow">https://www.hackerrank.com/challenges/reduced-string</a> . </p> <p>I want to solve the above problem recursively . My code is as follows .</p> <pre><code>import java.io.*;...
<p><code>str.charAt(0)+reduce(str.substring(1));</code></p> <p>What if <code>charAt(0)</code> becomes equal with the first char of <code>str.substring(1)</code>? You finish with an unreduced pair.</p>
SQLite module for Electron <p>I have a trouble with a sqlite3 module for electron. I had been looking about this problem before ask, but any answer has solved my problem.</p> <p>I have installed this module in electron in a some computers, in first place the module don't works and appears the next error:</p> <blockqu...
<p>You have to give a try for <a href="https://github.com/electron/electron-rebuild" rel="nofollow">electron-rebuild</a> package and rebuild the sqlite package for using with electron against electron headers (electron uses patched version of nodejs)</p> <p>Look at <a href="https://github.com/electron/electron/blob/ma...
How to run JavaScript Code when an issue is displayed in JIRA <p>I am currently developing a JIRA 7 server add-on, I am stuck and I'd be grateful for any help I can get. I am new to both JIRA and JavaScript, so forgive me if I fail to see the obvious solution :-)</p> <p>My Add-On includes a web panel which needs some ...
<p>If you are building the button &amp; the dialog2 HTML yourself, then you can control the HTML and JavaScript yourself.</p> <p>Use a button which has a <code>data-controls</code> attribute to tell it which dialog2 to trigger:</p> <pre><code>&lt;button class="aui-button your-button-class" data-controls="#your-dialog...
Accessing all function argmuments <p>I have a function with 4 arguments and want to check those 4 arguments for something. Currently I do it like this:</p> <pre><code>def function1(arg1, arg2, arg3, arg4): arg1 = function2(arg1) arg2 = function2(arg2) arg3 = function2(arg3) arg4 = function2(arg4) def ...
<p>Since you have a <em>set</em> number of arguments <em>just create an iterable out of them</em>, for example, wrap the argument names in a tuple literal:</p> <pre><code>for arg in (arg1, arg2, arg3, arg4): # do stuff </code></pre> <p>If you don't mind your function being capable of being called with more args j...
Remove an item from view inside an adapter <p>I am trying to remove an item from view when its flag become 4. I tried mObjects.remove(position) and then notifyDataSetChanged(). but it didn't worked.we tried all the following </p> <pre><code> if (getItem(position).getFlag().trim().equalsIgnoreCase("4")) { ...
<p>Please try following </p> <p><strong>Your code</strong></p> <pre><code>if (getItem(position).getFlag().trim().equalsIgnoreCase("4")) { mObjects.remove(position); adapter.notifyDataSetChanged(); matcheslistview.setAdapter(adapter); } </code></pre> <p><strong>TO</strong> do no...
mongo in() clause sort by most matches <p>Problem shows as follows:</p> <p>my query:</p> <pre><code>db.goods.find({tags:{$in:["white","black","gray"]}}).pretty(); </code></pre> <p>and data returned:</p> <pre><code>{ "id":1, "tags": [ "black", "blue" ] } { "id":2, "tags": [ ...
<p>You can use the following aggregation query to get the desired results.</p> <pre><code>db.goods.aggregate([ {$match: {tags: {$in: ["white","gray","black"]}}}, {$project: {"tags":1, "tagsCopy":"$tags"}}, {$unwind: "$tagsCopy"}, {$match: {tagsCopy: {$in: ["white","gray","black"]}}}, {$group: { ...
python 3.x what is -> annotation <p>In the following snippet what is <code>-&gt;</code> operator ,does it indicate the return type of the function also is it mandatory to use it in python 3.x ? Please point me to few docs for the same</p> <pre><code> def g() -&gt; str : ... return 'hello world' </code></pre>
<p><code>-&gt;</code> is an <a href="https://www.python.org/dev/peps/pep-3107/" rel="nofollow"><em>annotation</em></a>, attached to the function <em>return value</em>. Annotations are optional, but you can use the syntax to attach arbitrary objects to a function. You can attach more annotations by using <code>name : an...
could ConcurrentLinkedDeque clear be implemented as resetting head tail pointer? <pre><code>/** * Removes all of the elements from this deque. */ public void clear() { while (pollFirst() != null) ; } </code></pre> <p>current implementation is just pop the elements in the queue one by one, but could that ...
<p>The <code>pollFirst()</code> method does a lot more than just pop items from the queue. It does it in a thread-safe manner. </p> <pre><code>public E pollFirst() { for (Node&lt;E&gt; p = first(); p != null; p = succ(p)) { E item = p.item; if (item != null &amp;&amp; p.casItem(item, null)) { ...
How to get deployment slot in runtime for node.js in azure web app <p>I need to get the deployment slot in runtime. For example I think of something like :</p> <pre><code>process.env.ENVIRONMENT </code></pre> <p>Is there a way to get that? Thanks</p>
<p>You can set the <code>NODE_ENV</code> to <code>development</code> variable under the Website App settings configuration on the portal.<br> <a href="http://i.stack.imgur.com/Brj6T.png" rel="nofollow"><img src="http://i.stack.imgur.com/Brj6T.png" alt="enter image description here"></a></p> <p>Additionally, if you are...
While goback to previous page getting slow to loading in windows phone 8.1 winRT <p>I have firstPage and secondPage in my project, to navigate from first page. I use the following code</p> <pre><code>Frame.Navigate(typeof(secondPage)); </code></pre> <p>and to go back from the secondPage, i used the NavigationHelper c...
<p>What if you add this in the firstPage.xaml file?</p> <pre><code>NavigationCacheMode="Enabled" </code></pre>
MySQL Query with properties and inner joins <p>I have 3 tables and testdata, see below. </p> <p>How can i get this output doing a query?</p> <pre><code>Itemname Name Address ======================================== Test Item 1 test name 1 test address 1 Test Item 2 test name 2 test address 2 </code></pre...
<p>You will need to join the Itemproperties table twice, once for the name and once for the address:</p> <p><pre><code>SELECT i.name Itemname, ip1.value Name, ip2.value Address FROM Item i JOIN Itemproperties ip1 ON i.id = ip1.item_id AND ip1.property_id = 1 JOIN Itemproperties ip2 ON i.id = ip2.item_id AN...
Pipe Symbol in qsub Job name <p>Is a pipe symbol allowed in SunGridEngine job name? I found a few reference stating not to use special characters in the name but I'm not sure if pipe symbol is part of the list.</p>
<p>I just tried with OGS (descendant of SGE) and it works fine so I'm pretty sure it works in SGE as well. Make sure to enclose the job name into single quotes if you are trying this from the shell.</p> <pre><code>%&gt; qsub -N 'co|co' -b y test.sh Your job 438421 ("co|co") has been submitted </code></pre>
Render Menu Bar from a single class and highlight the menu dynamically in Yii2 <p>I have my top menu bar in my Yii2 project in a separate. I render them in my index file and use them.</p> <p><strong>js file to use active class dynamically.</strong></p> <pre><code>$(document).ready(function () { var url = window.l...
<p>I found out the solution for my question:</p> <p>As of now I haven't used yii2 Navbar instead have used html. When I use yii2 Navbar I don't have to call any javascript.</p> <p><strong>This my view page for the menu bar: views/topmenu/chemicalinventory.php</strong></p> <pre><code>&lt;?php echo yii\bootstrap\Nav::...
how to activate a current tab in angularjs bootstrap javascript <p>I am trying the below code to activate the current tab selected but it is not working.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('a[data-toggle="tab"]').on('show.bs.tab', function(e) { localStorage...
<p>You need to stringify your object that you want to store in localstorage. You cannot store objects in localstorage directly. A workaround can be to stringify your object before storing it, and later parse it when you retrieve it:</p> <pre><code>$(document).ready(function(){ $('a[data-toggle="tab"]').on('show.bs...
F#: How to Call a function with Argument Byref Int <p>I have this code:</p> <pre><code>let sumfunc(n: int byref) = let mutable s = 0 while n &gt;= 1 do s &lt;- n + (n-1) n &lt;- n-1 printfn "%i" s sumfunc 6 </code></pre> <p>I get the error: </p> <pre><code>(8,10): error FS0001: This expression was ex...
<p>Good for you for being upfront about this being a school assignment, and for doing the work yourself instead of just asking a question that boils down to "Please do my homework for me". Because you were honest about it, I'm going to give you a more detailed answer than I would have otherwise.</p> <p>First, that see...
Array reduce function is returning NAN <p>I have code similar to follows:</p> <pre><code>var temp=[{"name":"Agency","y":32,"drilldown":{"name":"Agency","categories":["APPS &amp; SI","ERS"],"data":[24,8]}},{"name":"ER","y":60,"drilldown":{"name":"ER","categories":["APPS &amp; SI","ERS"],"data":[7,53]}},{"name":"Direct"...
<p>You could use a start value and the add only one value from the array.</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 temp=[{"name":"Agency","y":32,"drilldown":{"nam...
How to call multiple functions on ng-change in angularJS? <p><code>ng-change = "ControllerName.functionName()"</code></p> <p>here I want to add one more function to that. How can I do that ?</p> <p>Thanks in advance.</p>
<p>Why not rather group the functions in the controller inside another function?</p> <pre><code>function onChangeGroup(){ doStuff(); doMoreStuff(); } &lt;input ng-change="ControllerName.onChangeGroup()"/&gt; </code></pre> <p>Regards</p>
Spring Boot 1.4.1 runnable jar javax.persistence.PersistenceException: Unable to resolve persistence unit root URL <p>We have a Spring Boot 1.4.1 application and when we create runnable jar and try to run it, we get following stack trace:</p> <pre><code>org.springframework.beans.factory.BeanCreationException: Error cr...
<p>You're probably affected by <a href="https://github.com/spring-projects/spring-boot/issues/6983" rel="nofollow">this regression</a>. There's a workaround provided in the issue. Please give that a try and wait for <code>1.4.2.RELEASE</code>. Sorry :(</p>
Why two arrays of objects are not equal in angularjs? <p>I can't understand why it's always shows NOT equal in code :</p> <pre><code> if(JSON.stringify(data.content.items) != JSON.stringify(updatedItems)) { console.log('update'); updatedItems = data.content.items; // updatedItems -global vari...
<p>Use <code>angular.fromJson(json)</code> instead. It will strip the <code>$$hashKey</code>, that's making it not equal</p>
When is the QBPrivateChat instance created locally? <p>I am new with quickblox. I have read all the examples and could create a simple chat with notifications, but there is something I do not understand. </p> <p>Following the quickblox guide, it says to add the QBPrivateChatManagerListener which callback methods has 2...
<p>There is a method that creates the chat manually and locally: </p> <pre><code>privateChatManager.createChat(opponentId, privateChatMessageListener); </code></pre>
Convert EXE file to something like os <p>Hi is it possible to convert a program written in C# to Operating System or just run it and use it like Windows. I mean boot C# program like Windows. I need something like Windows but Windows size is 3 Gigabyte I need Windows with 200 megabyte to run on a small mother board that...
<p>Yes, if you googled ".net Operating System" you would find the COSMOS project which allows you to write an operating system in .net.</p> <p><a href="https://github.com/CosmosOS/Cosmos/wiki/Develop-Your-Own-Operating-System-in-C%23-or-VB.NET" rel="nofollow">https://github.com/CosmosOS/Cosmos/wiki/Develop-Your-Own-Op...
Using the correct path with namespaces for parsing XML (in VBA) <p>I'm struggling to wrap my head around namespaces &amp; paths wrt parsing XML using VBA. Here I have some very simple XML...</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;GetOrdersResponse xmlns="urn:ebay:apis:eBLBaseComponents"&gt; &lt;Timestamp&gt;20...
<p>You are close enough! If you want to get number of elements:OrderID, I would prefer using <strong>integer/long</strong> variable for that (use <em>'Set'</em> when referring to an object reference only). Something like this:</p> <pre><code>Ordercount = objxmldoc.selectNodes("//OrderID").Count Debug.Print "Total Numb...
Number at risk table using survplot with cph() object <p>This is pretty specific to the rms package. When using survplot with a cph object, the number at risk table is not stratified according to the covariate. using npsurv() does this correctly.</p> <pre><code>library(survival);library(rms) data(lung) fit &lt;- cph(S...
<p>So I should have used</p> <pre><code>strat(sex) </code></pre> <p>as the term.</p>
Stuck with PHP redirection to URL based on input <p>I'm building a referral-based site and only want it to be accessed by people who enter a valid referral code. The landing page will just be a simple input box and a go button. Once they type in a correct code, they will then be redirected to a certain URL depending on...
<p>Why not use php's <code>header()</code> function for redirect? It's mutch saver too. Beside this, your error message only show whenever <code>$_POST['suche']</code> is set. You can move it just after the <code>if</code>, because <code>header</code> will redirect otherwise.</p> <pre><code>if (isset($_POST['suche']))...
Parallel.ForEach slows down towards end of the iteration <p>I have the following issue :</p> <p>I am using a parallel.foreach iteration for a pretty CPU intensive workload (applying a method on a number of items) &amp; it works fine for about the first 80% of the items - using all cpu cores very nice.</p> <p>As the i...
<p>This is an unavoidable consequence of the fact the parallelism is <em>per computation</em>. It is clear that the whole parallel batch cannot run any quicker than the time taken by the slowest single item in the work-set.</p> <hr> <p>Imagine a batch of 100 items, 8 of which are slow (say 1000s to run) and the rest...
Write test case for android listview click <p>I have Listview which contain multiples items. I like to click on 1st item of listview by using android test cases. How can achieve this?</p> <p>Please help me.</p> <p><strong>Listview hierarchy :-</strong> </p> <blockquote> <p>MainActivity -> ListFragment -> Listview<...
<p>Try this:</p> <pre><code>onData(hasToString(startsWith("item_name"))) .inAdapterView(withId(R.id.view_id)).atPosition(0) .perform(click()); </code></pre> <p>or </p> <pre><code>onData(hasToString(startsWith("item_name"))) .inAdapterView(withId(R.id.view_id)) .perform(click()); </code></pre> <p>You...
Jquery expand and collapse menu is not working <p>I am working on a sidebar menu navigation which expands and collapses when user clicks on the menu. On top of that, I want the menu to stay expanded if the link on the sub menu is active when the page loads.</p> <p>This is the code sample that I am working on right now...
<p>Please add jquery cookies library in your head just after jquery</p> <pre><code>&lt;script src="path/to/Scripts/jquery_cookie.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>check this for more info <a href="http://stackoverflow.com/questions/18024539/jquery-cookie-is-not-a-function">stack-cookie-is...
How to show disabled options in the combobox of Kendo UI? <p>Is it possible to enable the visiblility of disabled options in the Kendo UI combobox? </p> <p>The result should be like this: <a href="http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_disabled" rel="nofollow">http://www.w3schools.com/tags/try...
<p>In <code>li</code> template add class to disabled items and apply CSS:</p> <pre><code>.disabled { pointer-events: none; color: gray; } </code></pre>
MDX Month To Date Year To Date Query <p>I'm trying to build a query which will retrieve values from a cube and build a month to date and year to date SSRS report based on the current date. I'm basically trying to build a report that should look something like this...</p> <pre><code>Type Customer Product Group Quantity...
<p>Currently you don't have any dates <code>in context</code> which mean <code>currentmember</code> won't be finding much - to have a date <code>in context</code> you need to add an actual date member to your <code>WHERE</code> or <code>SELECT</code> clause - and not a <code>SELECT</code> clause of a <code>subselect</c...
Extracting multiple strings from a sentence that has been passed through the Stanford NER tagger <p>I wrote code to extract multiple patterns from my string which has passed through a Stanford NER parser and gives output like:</p> <pre><code>Input Sentence - Goldman profit at risk under Volcker rule Output Sentence -...
<p>Never mind that. I had not initialized my list hence was getting the null pointer exception. This is what I had to do:</p> <pre><code>List&lt;String&gt; list = new ArrayList&lt;String&gt;(); </code></pre> <p>Instead of:</p> <pre><code> List&lt;String&gt; list = null; </code></pre>
How can I update shown dialog imageview with selected image? <p>I am using Alert dialog for getting Image for User team pic and then I want to show image preview on dialog which is already open.</p> <p>I am passing image file to that fragment where my dialog is shown but how I can update that <code>ImageView</code> wh...
<p>In the <a href="https://developer.android.com/training/camera/photobasics.html#TaskPhotoView" rel="nofollow">Android Developer Page</a> under the Point Get the Thumbnail is a Example which shows how to add a Photo in a existing ImageView of the Activity after Capturing it with an Intent. I hope it is what you are lo...
How to configure emberjs routes in SpringMVC? <p>We have an Ember frontend and Spring Boot backend. When Ember runs standalone on port 4200 and the Spring Boot backend on 8080, then everything works. But this scenario is somewhat unusual for production environments, not only because of CORS problem. The URL of the back...
<p>after tests with different solutions I came up with a really simple one. Provide a normal, non-REST controller with request mappings for every route defined by the ember app. Every such request have to be answered with the view name of the ember app start page (index.html in most cases). The browser loads that html...
copying data to data structure using memcpy <p>I'm trying to read data from EEPROM, and I have three structs. </p> <pre><code>typedef struct { fract32 MechCoilPhiBase; // Mech Angle Table fract32 MechCoilPhi3rd; // Mech Angle Table fract32 PhiSaltwater; // Saltwater Table UINT16 d; UIN...
<p>No idea what your comment about powers of two means, if that's a requirement you have to make it clearer.</p> <p>Also, most casts to/from <code>void *</code> in C are not necessary, you shouldn't do them "just to be safe". It's hard to understand from your posted code why the casts are needed.</p> <p>Finally, reme...
How to resolve "_tkinter.TclError: unknown option"? <p>I am learning python tkinter but I have an error whenever I tried to compile it:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/python2.7/dist-packages/spyderlib/ widgets/externalshell/sitecustomiz...
<p>You have an issue with your code a little bit. Instead of <code>menu.config</code>, use <code>root.config</code>, you will not get any such errors. </p> <p>For more information and detailed tutorial, kindly visit <a href="http://effbot.org/tkinterbook/menu.htm" rel="nofollow">Tkinter Menu Widget</a>.</p>
Not able to query records from Hive , when data stored as AVRO format , returns "error_error..." exception <p>We have followed the below steps ,</p> <ol> <li><p>imported a table from MySQL to HDFS location <code>user/hive/warehouse/orders/</code>, the table schema as </p> <pre><code>mysql&gt; describe orders; +------...
<p>I think the reference to avro schema file in TBLPROPERTIES should be checked.</p> <p>does following resolve?</p> <p>hdfs dfs -cat hdfs://host_name//tmp/sqoop-cloudera/compile/bb8e849c53ab9ceb0ddec7441115125d/orders.avsc</p> <p>I was able to create exact scenario and select from hive table.</p> <pre><code>hive&gt...
The fixing imacros interruption with Javacript <p>I am currently downloading some files from the website. Due to the large amount of data that requires millions of clicks, I choose to use iMacros to accomplished the clicks. But the website is unstable and interrupt the automatic click from time to time. I had it fix so...
<p>Try to modify the <code>myLoop</code> variable in the following way:</p> <pre><code>SET myLoop EVAL("if ('{{myLoop}}' == '__undefined__') {try {ml = (confirm('CONTINUE FROM THE LOOP #' + ml + ' ?') ? ml : 1)} catch(e) {ml = 1;}} else if ('{{!EXTRACT}}' == '' || '{{!EXTRACT}}' == '#EANF#') ml = ml; else ml = ++ml; m...
Why does the getConnection method needs to be synchronized in ConnectionPool class? <p>I am writing a ObjectPool class for pooling of an Object instance. While looking at the existing codes on internet I saw that the getConnection method is synchronized. I am confused.Why do we require the getConnection method to be sy...
<pre><code> if (freeConnections.size() &gt; 0) { // A // Pick the first Connection in the Vector // to get round-robin usage con = (Connection) freeConnections.firstElement(); // B freeConnections.removeElementAt(0); // C </code></pre> <p>Imagine i...
How to convert language code to locale name in Django? <p>How to convert language code to locale name in Django?</p> <p>For example:</p> <ul> <li><code>zh-cn</code> to <code>zh_CN</code></li> <li><code>zh-Hans</code> to <code>zh_Hans</code></li> </ul>
<pre class="lang-py prettyprint-override"><code>from django.utils.translation import to_locale from django.conf import settings print to_locale(settings.LANGUAGE_CODE) </code></pre>
Making ios app with simular icon <p>I published one my app to store. </p> <p>Now I want to create a little bit different version of that app and publish it as separate app. (For the common account)</p> <p>I will extend the app's features Can I use simular icon? or which staff I need to replace? </p>
<p>In my case I use a different icon, bundle id, and different app description. Everything else were the same. If you're not sure if there's anything more to change just submit the app for review and apple will reply if there's anything more to change.</p>
How to remove items that exist in the array from object? <p><strong>This is how my array looks like:</strong></p> <pre><code>array(3) { [0]=&gt; string(3) "600" [1]=&gt; string(3) "601" [2]=&gt; string(3) "603" } </code></pre> <p><strong>This is how my object looks like:</strong></p> <pre><code>array(7) ...
<p>I created my own set of examples to simulate what you want to happen on your array:</p> <pre><code>$x = array('600','601', '603'); $y = array( array("id" =&gt; "600", "name" =&gt; "test", "avatar" =&gt; "image" ), array("id" =&gt; "601", "name" =&gt; "test1", ...
symfony2 formbuilder choice multiple throws no array <p>Issue: Multiple dropdown just hands over a string not an array.</p> <p>I tried to use a multiple dropdown in the formbuilder:</p> <pre><code>-&gt;add('options', 'choice', array( 'choices' =&gt; $printerOptionsDropdown, 'em...
<p>You must have <code>multiple</code> option defined as true. You have it in <code>attr</code>. change it as below :</p> <pre><code>-&gt;add('options', 'choice', array( 'choices' =&gt; $printerOptionsDropdown, 'empty_value' =&gt; 'Optionen wählen', 'label' =&gt; 'Optionen', 'attr' =&gt; array( ...
Angular2 - Class property is undefined even though it is being set <p>I'm having the following, very simple angular2 Service:</p> <pre><code>@Injectable() export class DrawingService { private _draw:Draw; constructor(private mapSvc:MapService) {} initialize(geometry: GeometryType):void { this._dr...
<p>If you pass a method reference like</p> <pre><code> this._draw.on("draw-end", this.addGraphic); </code></pre> <p>the reference to <code>this</code> points to the caller function.</p> <p>If you use instead</p> <pre><code> this._draw.on("draw-end", this.addGraphic.bind(this)); </code></pre> <p>it should work ...
Java: How can i scan a Map? <p>This is my controller:</p> <pre><code>public class AccessLogController extends ControllerServlet { private static final long serialVersionUID = 1L; public void buildAccessLogPaginationView() { HttpServletRequest req = getThreadLocalRequest(); AccessLogRepository accessLogRepo ...
<p>What you can use is <a href="https://docs.oracle.com/javase/8/docs/api/java/util/NavigableMap.html#subMap-K-K-" rel="nofollow"><code>NavigableMap#subMap(K fromKey, K toKey)</code></a> (that is already available from your <code>TreeMap</code> as it is already a <code>NavigableMap</code>) as your key is the index of t...
How to scroll down a sub-section in Selenium (C#)? <p>I am UI-testing a web page with a grid on it, using Selenium Webdriver in C#.</p> <p>The grid has its own scroll bar and I would like to scroll down to the bottom of the grid to check a certain result has appeared when I add it through a modal form (the UI test is ...
<p>First set focus to any object of grid by using any event</p> <pre><code>driver.FindElement(By.XPath("/html/body/div[2]//table/tbody/tr[1]/td[1]")).Click(); </code></pre> <p>Then add below two lines:</p> <pre><code>Actions actions = new Actions(driver); actions.SendKeys(OpenQA.Selenium.Keys.End).Build().Perform();...
Swift3 changes to UnsafeMutablePointer <p>I am porting one of my iOS Apps to Swift3 / Xcode8. I have embedded a C library, which expects a function parameter of type: </p> <pre><code>char *** </code></pre> <p>In Swift2.3 this was translated into a:</p> <pre><code>UnsafeMutablePointer&lt;UnsafeMutablePointer&lt;Unsa...
<p>Try</p> <pre><code>let myPointer = UnsafeMutablePointer&lt; UnsafeMutablePointer&lt; UnsafeMutablePointer&lt;Int8&gt;?&gt;?&gt;.allocate(capacity: 1) </code></pre> <p>Alternatively you could also use the <code>_Nonnull</code> annotation to keep the pointer as non-optional. Suppose the C function is <code>...
Implementation of compare() method in custom created Comparators <pre><code>class IntegerComparator implements Comparator&lt;Integer&gt; { @Override public int compare(Integer o1, Integer o2) { if(o1 &lt; o2) return 1; else if(o1 &gt; o2) return -1; else return 0; } } </code></pre> <...
<p>When te first argument is bigger than the other, result has to be a positive number. When the first argument is smaller - result is negative number. Your implementation gives descending order, because you are doing the opposite of what I just wrote. You can just multiply that by <code>-1</code> if you want ascending...
Excel cell values filled with 0 <p>The part of code shown below </p> <pre><code>import collections import csv import sys with open("321.csv","r") as f: cr = csv.reader(f,delimiter=",") d=collections.defaultdict(lambda : list()) header=next(cr) # read title. Retrieve the next item from the iterator by...
<p>I have not tested but perhaps this?</p> <pre><code>import collections import csv import sys max_len = 0 with open("321.csv","r") as f: cr = csv.reader(f,delimiter=",") d=collections.defaultdict(lambda : list()) header=next(cr) # read title. Retrieve the next item from the iterator by calling its __ne...
Call plugs from within a plug <p>I have a few plugs that I call every time. I would like to create a single plug that calls all of them for me. How would I go about doing that?</p> <p>This is what I've currently tried to do:</p> <pre><code>defmodule MyApp.SpecialPlug do import Plug.Conn def init(default), do: de...
<p>You can simply use <a href="https://hexdocs.pm/plug/Plug.Builder.html" rel="nofollow"><code>Plug.Builder</code></a> for this:</p> <pre><code>defmodule MyApp.SpecialPlug do use Plug.Builder plug SimplePlug1 plug SimplePlug2, args: :something end </code></pre> <p>This will define <code>init</code> and <code>c...
Best way to migrate increment ID and convert to Guid <p>I have two questions relating to migrating SQL data:</p> <p><strong>1. Migrate increment ID from <code>db1.table</code> to <code>db2.table</code> (different database)</strong></p> <p>Example: </p> <p><a href="http://i.stack.imgur.com/znT4t.png" rel="nofollow"><...
<p>You could add an extra column to the target database as an int ExternalID (or similar) and copy the original int identifier into that column. Your migration process then needs to refer to that column.</p>
For Loops in Python (Output Smallest Input) <p>Okay so I am practicing for loops in Python and I was wondering how could I make a user input 10 intergers then it would output the smallest one. I would know how to do this with a while loop for example: </p> <pre><code>Smallest = 0 count = 0 while count &lt; 10: Nu...
<p>Initialize your Smallest variable and all will works!</p> <pre><code>Smallest = int(input("Enter a Number &gt;&gt; ")) for i in range(9): Number = int(input("Enter a Number &gt;&gt; ")) if Number &lt; Smallest: Smallest = Number print("{0} is the smallest value you have entered.".format(Smallest)) ...
Node.js / Express Passing Data Between Pages Without Messing Up RESTful Routing <p>I have an Express app, where the landing page invites people to enter their email address and then click on "Sign Up" or "Log In", depending on whether they have an account yet or not.</p> <p>The user is then taken to "/signup" or "/log...
<p>You can use /signup and /login GET request for rendering UI. And /signup and /login POST requests for processing</p>
From VBA to Delphi conversion (Optional arguments issue) <p>At the moment I'm converting a project written in VBA to Delphi and have stumbled upon a problem with converting some Subs with <code>Optional</code> arguments. Say, there is a Sub declaration (just an example, actual Subs have up to 10 optional parameters):</...
<blockquote> <p>Is there any way to convert the VBA subroutines to Delphi procedures, still keeping the same flexibility in parameters?</p> </blockquote> <p>There is no way to achieve that – that flexibility to omit parameters, other than at the end of the list, simply does not exist. </p> <p>For methods of autom...
IIS Redirect with a fall back? <p>On a website I help support, they have country based websites (en-de, en-au) which they want to shut off a redirect to the main two which are en-gb and en-us.</p> <p>The website runs on a Microsoft server and tbh I am more Apache/PHP based. I have set up a redirect currently which red...
<p>Add another url rewrite to handle the 404's, below will direct all 404's back to your homepage.</p> <pre><code>&lt;rewrite&gt; &lt;rules&gt; &lt;rule name="Redirect404" stopProcessing="true"&gt; &lt;match url=".*" /&gt; &lt;conditions&gt; &lt;a...
how to work with mouse and arrow keys on select option? <p>I want to use arrow keys in this code if i change option using keys then class should be add into the div and background color should be change as user change the option!</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-bab...
<p>Try this, first: the code will work <code>onchange</code> second you had a unused <code>4</code> digit in 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>$(document...