input
stringlengths
51
42.3k
output
stringlengths
18
55k
jqGrid 4.12 border disappearing in all browsers <p><a href="https://staging.transporthub.co.uk/gridtest/jqgrid.htm" rel="nofollow">https://staging.transporthub.co.uk/gridtest/jqgrid.htm</a> </p> <p>When clicking in the cell to edit the value the border at the right and bottom is disappearing. Is there a css issue?</p>...
<p>First of all, please, don't use old versions of <a href="https://github.com/free-jqgrid/jqGrid" rel="nofollow">free jqGrid</a>. The current version of free jqGrid is 4.13.4. I recommend you to change the URLs to CDN (see <a href="https://github.com/free-jqgrid/jqGrid/wiki/Access-free-jqGrid-from-different-CDNs" rel=...
setOnAction within another setOnAction not working for arrays of buttons in Javafx <p>I'm actually not sure about the title because I don't know if that is the real problem. I'm making this application that the user clicks on a plus or minus button to get a number of people, then for each person there are two more plus...
<p>The error is exactly what it says: i must be final (or effectively final, meaning that compiler must be able to deduce that the variable will never change.</p> <p>In your case, <code>i</code> changes (between 0 and 10), so it's not "effectively final".</p> <p>What you want to do is add a variable to hold the curre...
Allow multiple controllers to users according to their role in cakephp <p>Suppose, there are two roles: one is <code>admin</code>, another is <code>restaurant_owner</code>.</p> <p>I want to give access to some of the pages to <code>restaurant_owner</code>.</p> <p>In <code>AppController</code>, I used <code>beforeFilt...
<p>The proper way of handling this is through <a href="http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#using-controllerauthorize" rel="nofollow"><code>ControllerAuthorize</code></a> and the <code>AuthComponent::isAuthorized()</code> callback.</p> <p>First, you have to enable this functiona...
How to add object in an array of objects using Javascript <p>I have the below JS object and I need to push another similar object with <code>request.rules[0]</code>.</p> <pre><code>request : [ rules: [ { pageFilters: [ { matchType: 'contains', type: 1, val...
<p>You do not have to push to a specific position e.g request.rules[1].pageFilters[0], but rather to the array itself like this</p> <pre><code>var anotherFilter = { matchType=contains, type=1, value=c }; request.rules[1].pageFilters.push(anotherFilter); </code></pre>
Validate URL in Swift 3 <p>I am trying to validate an URL in Swift 3 but I can't seem to find the Regex that suits my needs. Regex that I am after needs to accept following combinations:</p> <pre><code>http://google.com http://google.com/foo/bar:30/35 https://google.com https://google.com/foo/bar:30/35 www.google.com ...
<pre><code>func validateUrl (urlString: NSString) -&gt; Bool { let urlRegEx = "((?:http|https)://)?(?:www\\.)?[\\w\\d\\-_]+\\.\\w{2,3}(\\.\\w{2})?(/(?&lt;=/)(?:[\\w\\d\\-./_]+)?)?" return NSPredicate(format: "SELF MATCHES %@", urlRegEx).evaluateWithObject(urlString) } </code></pre> <p>This worked.</p>
How to call a non-activity method on Notification Click <p>I have a java class <code>MyClass</code> which contains a method called <code>callMethod</code>. I want to call this method when user clicks on the notification</p> <p>Below is the code i used to generate the notification</p> <pre><code>public class MainActiv...
<pre><code> @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); //notification callbacks here in activity //Call method here from non activity class. Classname.methodName(); } </code></pre>
sessionStorage doesnt work on safari on iphone 6 - non private mode <p>If i use the following code below, it works perfectly on firefox (private window or normal window). I tried to use it on my iphone 6 using safari and it doesnt seem to store my information in normal mode (non private mode)? Maybe the code is not rig...
<p>I dont exactly have the answer to the question but instead i decided to use cookies to complete this task and i am only storing a value which i can access with an if statement so no personal information is stored.</p>
F# Sort an Array with foldBack or fold. <p>I am trying to sort an Array by using fold or foldBack. </p> <p>I have tried achieving this like this: </p> <pre><code>let arraySort anArray = Array.fold (fun acc elem -&gt; if acc &gt;= elem then acc.append elem else elem.append acc) [||] anArray </code></pre> <p>this...
<h3>To answer the question</h3> <p>We can use <code>Array.fold</code> for a simple insertion sort-like algorithm:</p> <pre><code>let sort array = let insert array x = let lesser, greater = Array.partition (fun y -&gt; y &lt; x) array [| yield! lesser; yield x; yield! greater |] Array.fold inse...
How to add event to my CustomCell in Swift3 <p>I have a UITableView which has rows which include two UISwitch buttons. Until I upgraded to Xcode8 it worked with me adding a protocol to the view controller like this</p> <pre><code>protocol CustomCellDelegator { func callSegueFromCell() } </code></pre> <p>Then I ad...
<p>Make sure You assign your delegate in <code>cellForRowAtIndexPath</code> for the cell. Also, I would recommend to keep <code>weak</code> reference to the delegate.</p> <pre><code>protocol CustomCellDelegator: class { func callSegueFromCell() } </code></pre> <p>In your <code>CustomTableViewCell</code> replace <...
dynamically checking existing cd rom letter and change it to Z in powershell <pre><code>Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = 'd:'" ) -Arguments @{DriveLetter='Z:'} </code></pre> <p>This script will check for cd rom letter and change it to Z .. but only if cd rom lette...
<p>There is a <code>Win32_CDROMDrive</code> WmiObject which you can use to determine the existing CDROM drive letter:</p> <pre><code>$letter = Get-WmiObject -Class Win32_CDROMDrive | select -ExpandProperty Drive Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = '$letter'" ) -Argum...
Scala implicit macros: Filter type members (tpe.decls) by sub-type <p>Let's say I have a simple impicit macro that gives me back a <code>weakTypeSymbol</code>:</p> <pre><code>@macrocompat.bundle class ExampleMacro(val c: blackbox.Context) { def macroImpl[T : WeakTypeTag]: Tree = { val tpe = weakTypeOf[T] val...
<p>This is doable with an API similar to reflection:</p> <pre><code> class TestMacro(val c: blackbox.Context) { import c.universe._ def filterMembers[ T : WeakTypeTag, Filter : TypeTag ]: List[Symbol] = { val tpe = weakTypeOf[T].typeSymbol.typeSignature (for { ...
Verify private static method on final class gets called using PowerMockito <p>I have the following class</p> <pre><code>public final class Foo { private Foo() {} public static void bar() { if(baz("a", "b", new Object())) { } } private static boolean baz(Object... args) { return true; // slightly abbre...
<p>The problem with your code is that you <strong>mock</strong> <code>Foo</code> so your method implementations won't be called by default such that when you call <code>Foo.call()</code> it does nothing by default which means that it never avtually calls <code>baz</code> that is why you get this behavior. If you want ...
Oxyplot horizontal pan only between the leftmost and rightmost points <p>I'm using <code>Oxyplot</code> to show graphs. I added the horizontal Pan as following:</p> <pre><code>private void AddHorizonalPanToLinearModel(){ var b = false; GraphModel.MouseDown += (s, e) =&gt; { if (e.ChangedButton != OxyMous...
<p>As explained <a href="http://stackoverflow.com/questions/31430752/oxyplotcannot-setting-axis-values">here</a> the solution is to set <code>AbsoluteMinimum</code> and <code>AbsoluteMaximum</code> of the axis.</p>
How do I get the first element of a dynamic/generic type <p>Is there any way to pass in a generic entity object and get the first in its query.</p> <p>My intention is to call <code>FirstOrDefault()</code> on every table, and try catch for errors in the databases integrity.</p> <p>It would have been nicer to be able t...
<p>Why not use <code>Set&lt;T&gt;()</code>?</p> <pre><code>public T GetFirstObject&lt;T&gt;() where T : class { return context.Set&lt;T&gt;().FirstOrDefault(); } </code></pre> <p>You can also pass <em>filter expression</em>:</p> <pre><code>public T GetFirstObject&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt...
Regex in Node.js not showing all matches <p>To prepare a request-url for an API-call I am using RegEx to replace values from a String with values from an object. </p> <p>Example of a 'template-string':</p> <pre><code>'https://api.fitbit.com/1/user/:ownerId/:collectionType/date/:date.json' </code></pre> <p>where :own...
<p>The problem was here <code>url = String(url).replace(m[0], decoded[m[1]])</code></p> <p>You modify <code>url</code> during the <code>exec()</code>, so matche's index change ...</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre cla...
Wordpress PHP shortcode, get_the_content by id won't display custom post type content <p>Currently working on a project where I want to display employees' business cards by a shortcode, for instance <code>[person id="1"]</code> or [<code>person name="bob"]</code>. </p> <p>I've created a seperate post type for employee...
<p>Your code seems a bit faulty.</p> <pre><code>// this is your shortcode extract(shortcode_atts(array( 'posts_per_page' =&gt; '1', 'post_type' =&gt; 'person', 'post_id' =&gt; null, 'caller_get_posts' =&gt; 1) , $atts)); </code></pre> <p>It should look like this (based on the assumption, that $atts' e...
Is drag-and-drop to open a file possible in VSCode? <p>I am wondering if something is wrong with my computer (or myself), because I can't seem to drag &amp; drop a file into Visual Studio Code to open it in the editor. Closing an opened folder first doesn't make a difference. VSCode always shows me the 'stop sign', in ...
<p>Searching for a solution, I stumbled on <a href="https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/72f35f33-2df0-47e8-a16d-006f1190d81e/drag-and-drop-brokendisabled-when-running-as-an-administrator-?forum=windowsgeneraldevelopmentissues" rel="nofollow">this page</a>, where one commenter explains:</p> <b...
Unit test Angular 2 error: Bootstrap at least one component before injecting Router? <p>I am writing test for component in angular 2 and I see a problem as below:</p> <p><a href="https://i.stack.imgur.com/trinn.png" rel="nofollow"><img src="https://i.stack.imgur.com/trinn.png" alt="enter image description here"></a></...
<p>You need to use the <a href="https://angular.io/docs/ts/latest/api/router/testing/index/RouterTestingModule-class.html" rel="nofollow"><code>RouterTestingModule</code></a> instead of the <code>RouterModule</code> when testing. If you only need the directives, you can just import it as is</p> <pre><code>imports: [ R...
Laravel 5.3 - TokenMismatchException in VerifyCsrfToken.php line 68: <p>When I log in to my app, and immediately go back when I enter it, and then try to log out, I get the error from the title, how can I fix that?</p>
<p>From Laravel 5.3 docs </p> <blockquote> <p>The Auth::routes method now registers a POST route for /logout instead of a GET route. This prevents other web applications from logging your users out of your application. To upgrade, you should either convert your logout requests to use the POST verb or register your o...
Search values on multidimensional array then display the result <p>I'm trying to retrieve the values on multidimensional arrays using a search like function.</p> <pre><code>$rows = array( array( 'Name'=&gt;'City of God', 'Year'=&gt;'2002', 'Rating'=&gt;'10' ), array( 'Name'=...
<p>try this it is reffered from <a href="http://stackoverflow.com/questions/8881676/how-can-i-check-if-an-array-contains-a-specific-value-in-php">How can I check if an array contains a specific value in php?</a></p> <pre><code>$array = array('kitchen', 'bedroom', 'living_room', 'dining_room'); if (in_array('kitchen',...
How to override System.Web.HttpContext.Current.Session (MVC4) <p>I'm trying to override <code>System.Web.HttpContext.Current.Session["foo"]</code>.</p> <p>My problem is that the system is already using <code>System.Web.HttpContext.Current.Session</code> and I want to add a guid on every session name. (too many to repl...
<p>If you do not want to use an extension method and change all the already implemented code that calls the string indexer then you could roll your own provider and do it there. See <a href="https://msdn.microsoft.com/en-us/library/ms178587.aspx" rel="nofollow">Implementing a Session-State Store Provider</a>. You can t...
c# EF query explosion <p>Dealing with three tables - Company, Employee and User. </p> <p>Company has 0 or Many Employees. Employee has a nullable int FK to Company. In practice this alway has a value. Employee has a non nullable int FK to User. User has a bit field AccountIsDisabled. </p> <p>In my Data Model I have...
<p>You need to call <code>.ToList()</code> or <code>ToListAsync()</code> to get all the data at once otherwise it will get the data on the fly per record.</p> <p>This is the problem with deferred execution VS immediate execution. When you don't materialize the list with <code>.Where(foo).ToList()</code> it loads each ...
Bash: using function with pipe as argument for another function <p>I'm trying to make function-wrapper for another functions to distinguish its in terminal</p> <pre><code>red_line="$(tput setaf 1)## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## $(tput sgr 0)" function wrapper { echo $red_line; echo "$...
<p>Tnx @chepner for referring post about passing complex commands as argument. But the actual problem was with mess with double quotes in functions arguments in <code>echo</code> and <code>wrapper</code>.</p> <p>Correct code:</p> <pre><code>red_line="$(tput setaf 1)## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #...
C++ Tweetnacl hash a file without read whole file to memory <p>I'm using tweetnacl to generate sha512 hashes of strings and file. For strings it works quite well but i have no idea how to do it with files.</p> <p>The signature of the function ist</p> <pre><code>extern "C" int crypto_hash(u8 *out, const u8 *m, u64 n);...
<p>Probably the easiest way is to use a <a href="https://en.wikipedia.org/wiki/Memory-mapped_file" rel="nofollow">memory-mapped file</a>. This lets you open a file and map it into virtual memory, then you can treat the file on disk as if it is in memory, and the OS will load pages as required.</p> <p>So in your case, ...
need only link as an output <p>I have multiple html tag I want to extract only content of 1st href="..." for example this single line of data.</p> <pre><code>&lt;a class="product-link" data-styleid="1424359" href="/tops/biba/biba-beige--pink-women-floral-print-top/1424359/buy?src=search"&gt;&lt;img _src="http://assets...
<p>If you need a single "product link", just use <code>find()</code>:</p> <pre><code>soup2.find('a', attrs={'class': 'product-link'})["href"] </code></pre> <p>Note that you can use a <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors" rel="nofollow">CSS selector</a> location technique as we...
ALM add-in error while trying to map excel (2013) fields with ALM fields <p>I am trying to upload test cases excel sheet to HP ALM. Below are the steps i followed to upload the sheet - Login and Auhtentication done successfully . When I click on Mapping and --> Tests it throwing me below error.</p> <p>I have double ch...
<p>Check the ALM OTA Client version you're running by logging in with your browser and then click Help>About HP Application Lifecycle Management Software.</p> <p>You most likely have an older version of the OTA Client in your HPQC installation and from my experience version 12.53 of the MS Word ALM Add-in isn't compat...
Running the ceylon typechecker from ceylon, like in typechecker/src/main/Main.java <p>I'm running the ceylon typechecker from a ceylon project with a run.ceylon which is exactly a ceylon version of typechecker/src/main/Main.java. </p> <p>This project is supposed to typecheck itself.</p> <p>It compiles without errors,...
<p>So the issue here is that the typechecker we use in the test runner <code>typechecker/src/main/Main.java</code> is only able to understand things defined in Ceylon source code. It is <em>not</em> able to read a compiled Java <code>.jar</code> archive and typecheck your Ceylon source code against the classes in that ...
change function from onclick to onload <p>I have this progress bar which loads once clicked. How do i change it from onclick to load when the page loads ?</p> <pre><code>&lt;div id="myProgress"&gt; &lt;div id="myBar"&gt; &lt;div id="label"&gt;10%&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script&gt; function m...
<p>You can put it on the body, onload event..</p> <p>or</p> <p>If you want to keep things all javascript, you can also use <code>document.addEventListener('DOMContentLoaded', funciton())</code></p> <p>example using body.onload</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-bab...
How to know onSurfaceTextureAvailable is called for which TextureView <p>I am writing an application where I need to display two <code>TextureView</code>(s) on my activity. I am attaching videos to each of the <code>TextureView</code> instance using <code>MediaPlayer</code> objects using the following code inside <code...
<p>You can just set two instances of TextureView with different listener.</p> <pre><code>textureView1.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { @Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) { doSomething(textureView1, surfaceTex...
Changing month to different language in laravel with timesamps <p>I am trying to change/format <code>created_at</code> and <code>updated_at</code> fields created by laravel when timestamps are set to true in its model.</p> <p>suppose if the value is '2016-10-08' i want it to change as '2016-أكتوبر-08'</p> <p>Is...
<p>Try adding this Eloquent Mutator to your model to override the base model using your set locale value (<em><code>ar</code> as defined in your <code>app.php</code></em>):</p> <pre><code>protected function asDateTime($value) { return (parent::asDateTime($value))-&gt;setLocale(App::getLocale()); } </code></pre>
Rails first or initialize not working <p>I have a product.<br> I have an order.<br> I have a booking in between.</p> <p>Whenever I make a booking from the product to the order it saves a new <strong>unique</strong> booking. </p> <p>It should:</p> <ol> <li>Save a new booking when it's the first made from this product...
<p>You can try</p> <pre><code> @order.bookings.find_or_initialize_by(product_id: params[:product_id]).tap do |b| # your business logic here end </code></pre>
C++ uses twice the memory when moving elements from one dequeue to another <p>In my project, I use <a href="https://github.com/pybind/pybind11" rel="nofollow">pybind11</a> to bind C++ code to Python. Recently I have had to deal with very large data sets (70GB+) and encountered need to split data from one <code>std::deq...
<p>The problem turned out to be caused by Data being created in one thread and then deallocated in another one. It is so because of malloc arenas in glibc <a href="https://siddhesh.in/posts/malloc-per-thread-arenas-in-glibc.html" rel="nofollow">(for reference see this)</a>. It can be nicely demonstrated by doing:</p> ...
Vimrc not updating <p>I am trying to setup vim to wrap my git commits to 72 characters but I am having trouble doing so. When I edit ":e $myvimrc" and add the settings to wrap the text it doesn't seem to work. I tried to open the vimrc file directly form my program files to check that the changes I have made had indeed...
<p>usually you don't need do special setting for gitcommit Filetype. Because GITCOMMIT was pre-defined as <code>wrap &amp; textwidth=72</code> under your <code>$VIMRUNTIME/ftplugin/gitcommit.vim</code></p> <p>Check if you have <code>filetype on</code> in your vimrc, so that the filetype plugins are activated. </p>
Is it possible to extend Test Cases in Nightwatch? <p>Does anyone has experience with extending Test Cases in Nightwatch. I want to have some main Test Case and than the same Test Case to extend it with few more functions. For example I have one Test Case which works fine on Desktop, but in order to work on Mobile dev...
<p>I use page objects for this, where all "clicky" logic is abstracted into little functions about "user intent". That could be ideal for what you're talking about. I also use globals to inject my browser name into my test_settings in nightwatch.json so I can test on it, or include it in screenshot names. You could use...
Extracting href from Nodelist <pre><code>var downloadLinks = document.querySelectorAll('[href*="/Download"]'); </code></pre> <p>gives me the NodeList with all elements, but how do I extract just the <code>href</code> value from all the nodes as a single array?</p> <p>I tried <code>return Array.from(downloadLinks)</co...
<pre><code>var downloadLinks = document.querySelectorAll('[href*="/Download"]'); var arrHREF = []; // create an Array to save hrefs var i = 0; for(; i&lt;downloadLinks.length; i++) { arrHREF.push(downloadLinks[i].href); // push hrefs in array } </code></pre> <p>or you can write it in one line as (using the for loop ...
Fullcalendar wordpress submit booking <p>i need creat this <a href="https://i.stack.imgur.com/ACGYi.png" rel="nofollow">calendar</a> i use fullcalendar jquery but i have many problem for integrate on my php page. I need save data for update woo commerce booking or save with submit listing job (wp jobmanager). Thank you...
<p>Next update but don't work. I need save availability of fullcalendar custom in wp job manager user as a field and update to availabity woo commerce booking calendar product. If anyone has a good idea on how to do this better, </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-bab...
Creating a recursive function for calculating R = x - N * y, with conditions <p>I wish to create a function for calculating R = x - N * y, where x and y are floats and N is the largest positive integer, so that x > N * y.</p> <p>The function should only take the inputs of x and y.</p> <p>I have previously created the...
<p>Here's a recursive way of computing R:</p> <pre><code>def florec(x, y): if x &gt; y: return florec(x-y, y) return x </code></pre> <p>(Note it only works for positive floats.)</p> <p>I don't know if this addresses your recursion issues. Maybe this use case is not best suited to illustrate recursion...
Get parent url parameter <p>I have this routing</p> <pre><code>import { ModuleWithProviders} from '@angular/core'; import {Routes, RouterModule} from '@angular/router'; import { AppComponent } from './app.component'; import { ChildComponent } from './app.child-component'; import { Child2Component } from './child2-comp...
<p>I guess this is what you are looking for</p> <pre><code>translateThis() { // Subscribe to router params observable this.sub= this.route.parent.params.subscribe( param =&gt; { let lang = param['lang']; console.log(lang); // Call method or something this.translate.use(lang); }); } </...
How to display waiter while resolving data in Angular 2.0.0? <p>I've project based on Angular 2.0.0, and I want to display waiter (gif or text) while navigating routes, which must resolve data like this:</p> <pre><code> { path: 'profile', loadChildren: () =&gt; System.import('../profile/profile.module')...
<p>I'd say you can create a service which would keep eye on routing events and based on <code>NavigationStart</code> &amp; <code>NavigationEnd</code> event it will <code>show/hide</code> loading based on <code>isLoading</code> flag value with combination of <code>[hidden]</code>.</p> <p><strong>Code</strong></p> <pre...
Naming the clusters of leaflet by unigue names like A, B,C instead of numbers <p>I have been trying to name the clusters of leaflet by unique name, can any one give the solution for this ?</p> <p>Context: I have some location pointers, where it get clustered into 5, 3, 4, 3 at some zoom level, instead of showing the n...
<p>Starting from the <a href="http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-custom.html" rel="nofollow">custom cluster example</a>, you can think of something along those lines:</p> <pre><code>var alphabet = "abcdefghijklmnopqrstuvwxyz".split(""); var n = -1; var markers = L.markerClusterGro...
Avoiding primary key constraint violation when using timestamp as the primary key <p>I have a database table where the primary key is defined as a timestamp. The application inserts records to the database based on a certain event that is triggered and the timestamp used will be the one that created this instance. Sinc...
<p>Do not use timestamp as primary key field.</p> <p>Use Integer or BigInt for primary key auto increment fields</p>
apache Ivy authentication with artifactory <p>I have shared repository in artifactory which requires authentication in order to resolve/retrieve dependencies.</p> <p>For some reason Ivy is not able to authenticate.</p> <p>my ivysettings.xml:</p> <pre><code>&lt;ivysettings&gt; &lt;settings defaultResolver="main" /&...
<p>in my configuration realm="Artifactory Realm" was wrong. It should be: realm="Authenticate Artifactory"</p>
How to run a zeppelin notebook using REST api and return results in python? <p>I am running a zeppelin notebook using the following REST call from python:</p> <p><code>import requests requests.post('http://x.y.z.x:8080/api/notebook/job/2BZ3VJZ4G').json()</code></p> <p>The output is {u'status': u'OK'}</p> <p>But I wa...
<p>Zeppelin has introduced a synchronous API to run a paragraph in its latest yet to be releases 0.7.0 version. You can clone the latest code form their repo and build a snapshot yourself. URL for API is <a href="http://[zeppelin-server]:[zeppelin-port]/api/notebook/run/[notebookId]/[paragraphId]" rel="nofollow">http:/...
Laravel count # of results from whereHas <p>I have the below relationship. <code>User-&gt;hasMany(Posts)</code> and <code>User-&gt;belongsToMany(Following)</code>. Now i want to retrieve the following. Get all the following users of a user that have a specific type of <code>post</code>. I have come so far</p> <pre><co...
<p>i'm simply put a custom attribute in Eloquent</p> <pre><code> protected $appends = ['ArticleCount']; public function getArticleCountAttribute(){ return $this-&gt;posts-&gt;count(); } </code></pre> <p>don't forget the relationship too : </p> <pre><code>public function posts(){ return $this-&gt;hasMany(...
Does the echo command append any extra character when writing to text file? <p>I am trying to create a shortcut using batch file. I mimic the following manual steps to do that, but although the manually created file works properly as a shortcut, the shortcut created by batch files command line command does not work-</p...
<p>This works for me:</p> <pre><code>echo [InternetShortcut]&gt; E:\myshortcut.url echo URL=file:///D:\Logs&gt;&gt; E:\myshortcut.url </code></pre> <p>Note that you must <strong>not</strong> have a space before the redirection <code>&gt;</code> or <code>&gt;&gt;</code> because that <em>will</em> be echoed into the fi...
Randomizing without duplicating multiple times <p>I have the following task to perform. I get a string which I must write in reverse and also randomize the words in order to form 5 different strings. I have mananged to write the string in reverse and randomize the words, but I'm not able to do it 5 times. Here is the c...
<p>Loop it until you get all 5 random string. If string is not in array loop back.</p> <pre><code>var randomArray = []; While(randomArray.length != 5){ wordsReverse(wordsArray).toString().replace(/\,/g, ' '); var str = createRandomText(wordsArray).toString().replace(/\,/g, ' '); if(randomArray.indexOf(str) &...
how can I answer and reject phone call programmatically in android <p>I need to answer and reject phone call programmatically in android. How can I do it when my app is running in the background. I used following method but it isn't working when the app runs in background</p> <pre><code>public void answerCall() { ...
<p>Create a Broadcast Receiver class like below.</p> <pre><code>public class IncomingCallReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { final TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SER...
Chart js: hide some labels in the legend <p>Is it any way to hide some labels from the legend in <code>chart js</code>?</p> <p>I know, that I can hide all legend, using this option: <code> legend: { display: false } </code> but I need to hide just a part of labels in the legend.</p>
<p>I've found an answer. It is possible to generate new labels, using <code>generateLabels</code> function such like this:</p> <pre><code>legend: { labels: { generateLabels: function(chart) { return [ { text: 'text', fillStyle: 'red' ...
I want to compile the __init__.py file and install into other folder in yocto build system? <p>I want to compile the __init__.py file and install into other folder in yocto build system?</p> <p>Scenario:</p> <blockquote> <p>This basically in yocto build system. Third party library as zipped file is available in ...
<p>You can place empty file <strong>__init__.py</strong> along with recipe and add it to <strong>SRC_URI</strong> in this recipe:</p> <pre><code>SRC_URI = "http://www.aaa/bbb.tar.gz \ file://__init__.py" </code></pre> <p>unpacker will just copy it to WORKDIR where the archive is unpacked.</p>
ckeditor set custom skinpath <p>I have a problem with the CKEDITOR. I installed it with bower and changed the basepath. So CKEDITOR works. My problem now is to laod a custom skin, because i download it also with bower.</p> <p>This is the code:</p> <pre><code>&lt;textarea id="editor-&lt;?= $block_count ?&gt;" name="bl...
<p>Yes you can. <a href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-skin" rel="nofollow">Check the documentation</a>. Quoting docs:</p> <blockquote> <p>It is possible to install skins outside the default skin folder in the editor installation. In that case, the absolute URL path to that folder should be pro...
Working with RadioButtonList in UserControl in jQuery <p>The below is the code in jQuery. </p> <pre><code>$(document).ready(function(){ $("[id^='rdlAvailability_'][type='radio']").each(function () { $(this).change(function(){ var radioBtnId = this.id; var $this = $(this); radconfirm('Are yo...
<p>Try binding the click directly and not in each function</p> <pre><code>$("[id^='rdlAvailability_'][type='radio']").on("change", function() { // your code here }); </code></pre>
selenium.common.exceptions.WebDriverException: Message: Service <p>I had a trouble when i use selenium to control my Chrome. Here is my code:</p> <pre><code>from selenium import webdriver driver = webdriver.Chrome() </code></pre> <p>When i tried to operate it ,it runs successfully at first,the Chrome pop on the scree...
<p>You need to provide the path of chromedriver...download from <a href="http://chromedriver.storage.googleapis.com/index.html?path=2.24/...unzip" rel="nofollow">http://chromedriver.storage.googleapis.com/index.html?path=2.24/...unzip</a> it and provide path to it in... webdriver.chrome ("path to chromedriver")</p> <p...
Caliburn Micro ViewLocator with different namespace <p>I'm using Caliburn Micro for MVVM. Now I have the following situation. I have a UserControl with View and ViewModel in my first assembly <code>assembly1</code> in <code>namespace1</code>. If I use it in an second assembly <code>assembly2</code> that has the same n...
<p>In your <code>Configure</code>method you should use :</p> <pre><code>ViewLocator.AddSubNamespaceMapping("ViewModelsNamespace", "ViewsNamespace"); </code></pre> <p>and you have to override the following method :</p> <pre><code> protected override IEnumerable&lt;Assembly&gt; SelectAssemblies() { var...
How to create Transparent text in pdfBOX or add opacity to the text with the help of pdfBOX? <p>I am not getting how to add transparent text with the help of pdfBOX.</p>
<p>Here's something that shows alpha with 1.8 (you should use 2.*, that is a bit easier).</p> <pre><code> PDExtendedGraphicsState gs1 = new PDExtendedGraphicsState(); gs1.setNonStrokingAlphaConstant(1f); PDExtendedGraphicsState gs2 = new PDExtendedGraphicsState(); gs2.setNonStrokingAlphaConstant(0.2f); ...
How to create user module at run-time? <p>I have different set of math expressions that must be evaluated at run-time. Currently the task is done by replacing symbols with equivalent values and <code>eval</code> the result. (could be done by any existing symbolic packages)</p> <p>Now, refer to the definition of module...
<p>This works:</p> <pre><code>julia&gt; m=Module() anonymous julia&gt; eval(m, :(a=5)) 5 julia&gt; m.a 5 julia&gt; eval(m, :(a)) 5 julia&gt; eval(m, :(2a)) 10 </code></pre>
Exception while trying to read file usin PCLStorage from PCL project <p>I am trying to get file from <code>PCL</code> project using <code>PCLStorage</code> as below. I am using Xamarin in Visual Studio 2015 Professional.</p> <pre><code>IFile file = await FileSystem.Current.GetFileFromPathAsync("file\path"); </code></p...
<p>You need to add the PCLStorage NuGet to both your PCL and your platform specific project.</p> <p>So if you have the following solution:</p> <pre><code>PCL Android iOS </code></pre> <p>You would need to add it to all of them:</p> <pre><code>PCL PCLStorage Android PCLStorage iOS PCLStorage </code></pre...
setContentView in retrofit response success doesn't show all the information in scroll? <p>I'm using retrofit and coordinatorlayout. All seems that work fine but I'm getting a small problem. That I want to do is that the layout will display in the moment that the response is success. For this reason, I'm calling the se...
<p>Call <code>setContentView</code> in <code>oncreate</code> just try do show layout to user when response is successful. you can manage it using <code>alpha</code> property of a <code>widget</code></p> <blockquote> <p>android:alpha="0.0" to make view invisible </p> <p>android:alpha="1.0" to make view visible</...
CSS Image Hover surprisingly not working? <p>I'm trying to create a hover effect that will change the color of the image to blue, as the mouse hovers it. I've already created a class for the images and styled it in my css but its still not working. I've also tried changing z-indexes but to no avail. </p> <p><div class...
<p>If you don't want to affect other elements and change the background color of <code>div</code> element around your images, then create new class like <code>myHover</code> and add existing CSS to it, like:</p> <p><strong>HTML</strong>:</p> <pre><code>&lt;div class="border_section myHover"&gt; &lt;img class="guita...
Regular expression not working in pywinauto unless I give full text <p>Here is the code snippet that I am using:</p> <pre><code>browserWin = application.Application() browserWin.Start(&lt;FirefoxPath&gt;) # This starts the Firefox browser. browserWin.Window_(title_re="\.* Firefox \.*") </code></pre> <p>If I use the ...
<p>Escaped <code>.</code> with "\" means real dot symbol should be at the start of the text. Just remove "\".</p>
How join multiple table <p>I have five tables and i want to retrieve specific details from specifc table using join can you suggest me how to do that?</p> <p>tables:</p> <pre><code>tblPriscriptionDetail tblPriscription tblpatient tblinsuranceplan tblinsurance </code></pre> <p>from those table <code>tblPriscriptionDe...
<p><strong>Try:</strong></p> <p>Replace <code>*</code> with column names you want to select.</p> <pre><code>SELECT * FROM tblPriscriptionDetail tpd INNER JOIN tblPriscription tpn on tpd.tblPriscriptionId=tpn.tblPriscriptionId INNER JOIN tblpatient tp on tp.tblpatientId = tpn.tblpatientId INNER JOIN tblinsuranceplan t...
Get json array response and store in another array <p>I have cURL function which make calls to api based on ID which I provide and return data in array. So far everything works perfectly. What I want and can't figure out is this:</p> <p>I have foreach which display in table all orders lie</p> <pre><code>@foreach($ord...
<p>You can use laravel's <code>unique</code> method for collections to remove duplicate order id's before iterating them.</p> <pre><code>$collection = collect([ ['name' =&gt; 'iPhone 6', 'brand' =&gt; 'Apple', 'type' =&gt; 'phone'], ['name' =&gt; 'iPhone 5', 'brand' =&gt; 'Apple', 'type' =&gt; 'phone'], ['...
editing a model in more than one view <p>My target is, to modify a model in more than one view. Since sometimes my models have many properties I want to modify them in more than one view. Something like:</p> <p>first page edits 2 properties, second page edits 3 other properties,...</p> <p>the model looks like this:</...
<p>There's two pieces to this. First, the post itself, and getting that to validate. For that, each step should have its own view model, containing only the properties it's supposed to modify. This allows you to add all the validation you need without causing other steps to fail. In the end, you'll combine the data fro...
How to apply filter to get elements which have same value in JSONobjects inside JSON array using AngularJS <p>I have a JSON array with multiple(dynamic) JSON objects. I need to compare the objects and pick the keys which has the same value in all the objects. My JSON looks like,</p> <pre><code>[ { "CreateA...
<p>You can do this just with <code>Array.reduce()</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 json = [ { "CreateAccountName":"Joseph", ...
ZingChart get crosshair position on click <p>The ZingChart <code>click</code> event states that the callback will receive an object. The <code>x</code> attribute will contain </p> <blockquote> <p>The x position of the click relative to the chart position</p> </blockquote> <p>I assume this is the cursor position in ...
<p>Full disclosure, I'm a member of the ZingChart team. </p> <p>Yes the values are relative the chart position. What you can do is use our API methods to get the chart information you need based on the xy location of the click. You will use <a href="https://www.zingchart.com/docs/api/api-methods/#zingchart__exec__api_...
Quickly build large dict in elegant manner <p>I have a list with size about 30000: <code>['aa', 'bb', 'cc', 'dd', ...]</code>, from this list, I want to build a dict which maps element to index, so the result dict is <code>{'aa': 0, 'bb': 1, 'cc': 2, 'dd': 3, ...}</code>. Here comes my code:</p> <pre><code>cnt = 0 mp ...
<p>The shortest is to use <a href="https://docs.python.org/2/library/functions.html#enumerate"><code>enumerate</code></a> and a dict comprehension, I guess:</p> <pre><code>mp = {element: index for index, element in enumerate(name_list)} </code></pre>
Untar subfolders from a folder in linux <p>I have a directory, <code>/Landsat_Data/</code> which contains subdirectories (<code>Landsat_Data/Site1</code>, <code>Landsat_Data/Site2</code>, etc.). Each subdirectory contains <code>.tar.gz</code> files (e.g. <code>/Landsat_Data/Site2/LE70930862008092-SC20160107074735.tar.g...
<p>You might parse the filenames and cd into the directories before running <code>tar</code>. You could place a simple shell script into <code>/folder</code> like this one:</p> <pre><code>~/folder$ cat extract-in-dir.sh #!/bin/bash DIRECTORY="${1%/*}" TARFILE="${1##*/}" cd $DIRECTORY tar -xf $TARFILE </code></pre> ...
pandas table subsets giving invalid type comparison error <p>I am using pandas and want to select subsets of data and apply it to other columns. e.g.</p> <ul> <li>if there is data in column A; &amp; </li> <li>if there is NO data in column B;</li> <li>then, apply the data in column A to column D</li> </ul> <p>I have t...
<p>I think you need add parentheses <code>()</code> to conditions, also better is use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a> for selecting column with boolean mask which can be assigned to variable <code>mask</code>:</p> <pre><code>ma...
Excluding the first 3 characters of a string using regex <p>Given any string in <strong>bash</strong>, e.g flaccid, I want to match all characters in the string but the first 3 (in this case I want to exclude "fla" and match only "ccid"). The regex also needs to work in <strong>sed</strong>.</p> <p>I have tried positi...
<p>If you want to get <em>all characters but the first 3</em> from a string, you can use <code>cut</code>:</p> <pre><code>str="flaccid" cut -c 4- &lt;&lt;&lt; "$str" </code></pre> <p>or bash variable subsitution:</p> <pre><code>str="flaccid" echo "${str:3}" </code></pre> <p>That will strip the first 3 characters ou...
Relaunching PowerShell script as admin user <p>I have a quite a few computer systems which we need to deploy software. I've been using a simple method for detecting if a user is a local admin, then detecting if they have admin rights. If needed, the script relaunches with elevated privileges. If the user is not a local...
<p>Don't re-define <a href="https://technet.microsoft.com/en-us/library/hh847768.aspx" rel="nofollow">automatic variables</a>. Nothing good will come of it.</p> <p>Besides, why do you want to anyway? The only thing you use <code>$PSScriptRoot</code> for is to reconstruct the script path you already have. Just assign t...
unable to iterate through for loop in windows batch script <p>Goal: Given string "CAR080 CAR085 CAR087" I need to iterate through all three cars and perform copying of files from the carname folder.</p> <p>Need to copy files from individual car folders by looping through it. Code:</p> <pre><code> @echo off se...
<p>Just simplify. This is equivalent to your code but without variables being set inside the <code>for</code> block, so you don't need delayed expansion (read <a href="http://stackoverflow.com/a/30177832/2861476">here</a>) to retrieve the value from the changed variables</p> <pre class="lang-dos prettyprint-override">...
How to assign value to cell in excel VBA after clearing validation <p>So my vba function should assign different values to a cell based on a boolean input. True part works perfectly, however I'm getting stuck with the False statement. The True part assigns a drop down list to the cell, and the False part should erase i...
<p>I guess you have to pass some range before assigning any value. For eg:</p> <pre><code>Range("A1:A10") = "some text" </code></pre> <p>or maybe something like this:</p> <pre><code>Dim example As Range Set example = Range("A1:A10") example.Value = 8 </code></pre>
Read regexes from file and avoid or undo escaping <p>I want to read regular expressions from a file, where each line contains a regex:</p> <pre><code>lorem.* dolor\S* </code></pre> <p>The following code is supposed to read each and append it to a list of regex strings:</p> <pre><code>vocabulary=[] with open(path, "r...
<p>You are getting confused by <em>echoing the value</em>. The Python interpreter echoes values by printing the <code>repr()</code> function result, and this makes sure to escape any meta characters:</p> <pre><code>&gt;&gt;&gt; regex = r"dolor\S*" &gt;&gt;&gt; regex 'dolor\\S*' </code></pre> <p><code>regex</code> is ...
Save JSON Decode to MySQL , PHP <p>Good Day Please can you assist I'm trying to update a mysql table with a JSON POST. The JSON output into a textfile fine but when I try and save it to the MySQL table then supplies an error:</p> <blockquote> <p>Undefined index: ptp.create</p> </blockquote> <p>The JSON Outputs the ...
<p>Your <code>for</code> loop has already taken care of the <code>ptp.create</code> for you.</p> <pre><code>foreach ($data as $ptp){ echo $ptp; // Will be 629, then 630 } </code></pre> <p>When you actually insert into your database, use prepared/parameterized queries with PDO or similar.</p>
Multiple find and replace in MS Word from a list in MS Excel <p>Hi I really hope you can help me as I've been trying to do this for a while with not a lot of luck. </p> <p>I have a list in Excel, say, file 1 (say, A1 - B10, 2 columns of words - the words in column A are the ones to be replaced by the ones in column B)...
<p>If I understood you right, you want to replace Words in your Word Document with Words listed in your Excel File. If so, this macro should do the trick(Macro for MS Word):</p> <pre><code>Function findAndReplace() Dim xlApp As Object Dim xlWB As Object Dim xlWS As Object Dim i As Integer, j As Integer Dim lastRow As...
Matlab random sampling <p>I am trying to exercise myself in Matlab. I am trying to select randomly two lines from a file named data.dat. </p> <p>My data.dat file looks like this:</p> <pre><code>12 4 6.1 7 14 4 8.4 62 7 56.1 75 98 9.7 54 12 35 2 4 8 7.8 </code></pre> <p>To select 2 lines randomly from the data.da...
<p>I think you are making a mistaking when you generate the random numbers, as indicated by GameOfThrows.</p> <pre><code>i = randi(length(M),N); % gives you a matrix NxN of numbers i = randi(length(M),[N,1]); % gives you a column of N numbers </code></pre>
GIF from external resource in page is not animating in apache wicket web application <p>I am using external images in my webaplication, everything wass fine until I wanted to add animated gif there, the gif loads, but it doesn't animate.</p> <p>Java code:</p> <pre><code> File sourceimage = new File("loading_img.gi...
<p>The problem is that the content type is not automatically set. You will need to override org.apache.wicket.request.resource.AbstractResource#setResponseHeaders() and set with via <code>resourceResponse.setContentType(String)</code>.</p> <p>Maybe this should be done automatically by Wicket in org.apache.wicket.reque...
deleting from two tables in single script in sql <p>I have three tables <code>xx_1 , xx_2, xx_3</code> such that :</p> <p>xx_1 </p> <pre><code>id obj_version_num location 1 x ubudu 2 x bali 3 x india </code></pre> <p>xx_2 </p> <pre><code>id ...
<p>There is no way to delete from many tables with a single statement, but the better question is why do you need to delete from all tables at the same time? It sounds to me like you don't fully understand how transactions work in Oracle.</p> <p>Lets say you login and delete a row from table 1, but do not commit. As f...
t.time saving field as a string in ActiveRecord <p>I have a table with a field called <code>time_start</code>. Example: </p> <pre><code>t.time :time_start </code></pre> <p>When I try to save the attribute, it saves it as a Hash-String. Example: </p> <pre><code>params{ "time_start(1i)"=&gt;"2016", "time...
<p>Looking back through the commits, a Junior dev originally assigned the <code>time_start</code> field as a <code>string</code> data-type in table <code>B</code>. The solution was to grab the version number of the previous migration (table <code>A</code>), and run <code>rake db:migrate VERSION=213412341234</code>, the...
HTML - How do I insert a <span></span> tag into each line of a <pre></pre> block without hard coding? <p>I was just trying to add line numbers at the beginning of source code using CSS. I realized the effect I wanted, as follows:</p> <p><a href="https://i.stack.imgur.com/A0P12.png" rel="nofollow"><img src="https://i.s...
<p>This can be achieved by using CSS counters</p> <p>This does not require any JavaScript (or jQuery) which means no need for each libraries or scripts and was introduced way back in CSS 2.1 so has great browser support across the board.</p> <p>You can read up more in the <a class='doc-link' href="http://stackoverflo...
SML Operator and operand don't agree in foldr <p>I'm working on an assignment where I have to write a function to get the length of a list. This is a trivial task, but I've come across something that I don't understand.</p> <p>My simple code</p> <pre><code>val len = foldr (fn(_, y) =&gt; y + 1) 0 </code></pre> <p>pr...
<p>This is an instance of the <a href="http://mlton.org/ValueRestriction" rel="nofollow">value restriction</a> rule application:</p> <blockquote> <p>In short, the value restriction says that generalization can only occur if the right-hand side of an expression is syntactically a value. </p> </blockquote> <p>Syntact...
Echo option value with selected <p>Im tryin to fix when i press my search button. That the selected search from my option field remains selected. But at the moment it automaticly picks the first field of the options in my form.</p> <p>First one is hardcoded and it works.</p> <pre><code>&lt;option value="HS" &lt;?= ($...
<p>Aside from quoting errors indicated in the syntax highlighting...</p> <p>You're trying to execute PHP code inside of a string:</p> <pre><code>echo "&lt;option value='$pin'($nickval == '$pin' ? 'selected='selected'' : '')&gt;$fullname &lt;/option&gt;"; </code></pre> <p>Variable interpolation is one thing, but code...
Print filename only with Robocopy <p>I'm copying files with Robocopy but path+filename is too long and the output gets too crowded. I would like to display filename only (without path).</p> <p>My command is:</p> <pre><code>ROBOCOPY /NDL /NFL /NJH /NJS /nc /ns %path% %local% %filename% </code></pre> <p>and outputs:</...
<p>The indicated command does not return the indicated output. You are explicitly using <code>/nfl</code> that will remove the file list.</p> <p>But, without <code>/nfl</code> but keeping <code>/ndl</code> we get the indicated behaviour: If we don't include the directory list, file names will include the full path. </...
How to get cursor position in an image with Matlab <p>I need to get the cursor position after a click on the image to obtain the corresponding pixel coordinates. This is what I've done so far, which works as long as I click on the empty part of the figure (if I click on the image, the callback is not triggered).</p> <...
<p>I've had to solve a similar problem before.</p> <p>If you add an empty callback like the following the gui will track the cursor position</p> <pre><code>function figure1_WindowButtonMotionFcn(~, ~, ~) </code></pre> <p>Then the figure1 handle should have a property <code>currentPoint</code> that will describe the ...
Convert json to Object List <p>I have the following String: </p> <pre><code>String json = "[{\"id\": \"0\", \"ip\": \"123\", \"mac\": \"456\"}, {\"id\": \"1\", \"ip\": \"111\", \"mac\": \"222\"}]"; </code></pre> <p>And a SlaveEntity Entity that has:</p> <pre><code>public class SlaveEntity extends BaseEntity { ...
<p>You can convert the result to an object list, or you can pass in a type parameter rather than the <code>List</code> class.</p> <pre><code>String jsonString = "[{\"id\": \"0\", \"ip\": \"123\", \"mac\": \"456\"}, {\"id\": \"1\", \"ip\": \"111\", \"mac\": \"222\"}]"; </code></pre> <h3>With <code>Object</code></h3> ...
Changing all links on page with js <p>I want to remove "/index.php" in all links on page</p> <p>Example:</p> <pre class="lang-none prettyprint-override"><code>http://example.com/?hostname=sad2.cherobr.ru&amp;path=/index.php/o-nas </code></pre> <p>change to:</p> <pre class="lang-none prettyprint-override"><code>http...
<p>with plain js</p> <pre><code>var allAnchors = document.querySelectorAll("a"); Array.prototype.slice.call( allAnchors ).forEach( function( el ){ var href = el.getAttribute( "href" ); el.setAttribute( "href", href.replace( "/index.php", "" ) ); }); </code></pre>
Java. The same objects with different hashes <p>I have two objects from database (in database it is same object), but they have different hashes:</p> <pre><code>GroupType groupType = groupTypeDao.findById(3); GroupType groupType1 = groupTypeDao.findById(3); System.out.println(groupType); System.out.println(groupType1...
<p>What you've printed are object references. They are indeed different if you created each reference by calling new.</p> <p>You need to override equals, hashCode, and toString according to "Effective Java" to get the behavior you want.</p>
Create 4D upper diagonal array from 3D <p>Let's say that I have a <code>(x, y, z)</code> sized matrix. Now, I wish to create a new matrix of dimension <code>(x, y, i, i)</code>, where the <code>(i, i)</code> matrix is upper diagonal and constructed from the values on the <code>z</code>-dimension. Is there some easy way...
<p>Here's an approach using <code>boolean-indexing</code> -</p> <pre><code>n = 2 # This would depend on a.shape[-1] out = np.zeros(a.shape[:2] + (n,n,),dtype=a.dtype) out[:,:,np.arange(n)[:,None] &lt;= np.arange(n)] = a </code></pre> <p>Sample run -</p> <pre><code>In [247]: a Out[247]: array([[[0, 1, 3], [4...
Add on-premise nodes to GKE <p>How do I add my on-premise node to my managed cluster?</p> <p>I've tried doing "kubeadm join --token " with a default-token from the ui and the cluster endpoint as ip.</p>
<p>You can add an on-prem node to your GKE cluster if you manually configure the kubelet (basically what kubeadm makes nice and easy). </p> <p>Your cluster may not work as expected though unless you also create a VPN connection between the on-prem node and your cloud network where the rest of your nodes are running an...
can we call python script in node js and run node js to get call? <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>python.py from pymongo import MongoClient from flask import ...
<p><a href="http://www.zerorpc.io/" rel="nofollow">ZERORPC</a> is a really nifty library built on top of ZeroMQ. This is probably the easiest way to make call python code from Node.</p> <p>For a really simple approach and non-robust approach, you could use a tmp file to write the python commands from Node. With an eve...
Force WPF application to maximize on Windows startup <p>I have a WPF app that installed on Windows 10 Pro via ClickOnce and uses MahApps.Metro.</p> <p>It is set to launch on Windows boot with a non-admin account that has no password. Tablet mode is enabled.</p> <p>I want the application pop up full screen to create <...
<p>You can do this in the MainWindow.xaml.cs by adding a windowstate of maximized.</p> <pre><code>public MainWindow() { InitializeComponent(); this.WindowState = WindowState.Maximized; } </code></pre>
Save as zip instead tar <p>Is it possible to change it (archive as tar) to archive as zip? I am not good in php </p> <pre><code>if (ARCHIVE &amp;&amp; isset($_GET['archive'])) { $log -&gt; add_entry('Directory archived'); $outfile = Item::get_basename($subdir); if ($outfile == '' || $outfile == '.') { ...
<p>Yes, you can use the PHP <a href="http://php.net/manual/en/class.ziparchive.php" rel="nofollow">ZipArchive</a> object. </p> <p>i.e. (from source link) : </p> <pre><code>&lt;?php $files = array('image.jpeg','text.txt','music.wav'); $zipname = 'enter_any_name_for_the_zipped_file.zip'; $zip = new ZipArchive; $zip-&g...
TRIGGERS need help on sql <p>How Can I remove all the numeric character and special characters from this string value '2016-05-27T12:12:12.000Z' need this solution early please guide me on this in triggers</p>
<p>If we follow your need then below one can be fullfill in <code>Oracle</code>, bt as mentioned in commnents, "What use is that date if you remove all the numeric characters"..stands valid..</p> <pre><code>select '2016-05-27T12:12:12.000Z', regexp_replace (regexp_replace('2016-05-27T12:12:12.000Z','([][)(}{:.$*+?,|^\...
Searching a PHP states array for beginning values <p>So I'm sure my solution is an easy one, but it just seems to escape me. I have a basic webpage where a user needs to be able to type in a beginning string of a state, hit search, and the page will output all of the states that begin with that string.</p> <p>For exa...
<p>Use this</p> <pre><code>$arr = array(); $search_str = 'Co'; foreach($states as $key =&gt; $value){ $strlen = strlen($search_str); if(strtolower(substr($value, 0, $strlen)) == strtolower($search_str)){ $arr[] = $value; } } print_r($arr); </code></pre>
PHP SQL / multible select request / slow <p>I have 2 requests on a SQL database. It takes really long to load the whole script / page. Is there a better (faster) way? My code looks like this</p> <pre><code> $abfrage = "SELECT * FROM table_a WHERE state = '0' ORDER BY EDIT DESC"; $stmt = $pdo-&gt;query($abfr...
<p>First if tables have relation I suggest you to take the data in a single call with join.</p> <pre><code>SELECT * FROM table_a a LEFT JOIN tabl_b b ON a.user_name = b.user_name WHERE a.state = '0' </code></pre> <p>Second for speeding up the things you can put INDEX on the two fields that you are using in the WHERE ...
Create full VPC using salt stack and boto.vpc <p>I am able to create VPCs in AWS using salt states, using boto.vpc. But I also need to create create (in addition to the VPC itself) subnets, internet gateways, route tables based on the original VPC that I'm able to create.</p> <p>So if the VPC definition looks like th...
<p>In order to get the VPC id of an existing VPC you can use <a href="https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.boto_vpc.html#salt.modules.boto_vpc.get_id" rel="nofollow">boto_vpc execution module</a></p> <p>The first part of your state will create a VPC with the name <code>dlab-new</code> then...
Reduce length of bootstrap pagination buttons <p>I'm using bootstrap in the whole document, I'm using it for the pagination too.</p> <p>This link is awesome: <a href="http://stackoverflow.com/questions/2616697/php-mysql-pagination">PHP &amp; MySQL Pagination</a> and it helped me a lot coding the method for pagination ...
<p>am not sure about the quality/performance of code, but you can do it multiple ways, 2 of them here. I actually started using lazy load and auto loading of pages when scroll rather page numbers, so I don't have the code.</p> <p>1) JS/CSS:You can create a fix width div for page numbers and scroll to current page usi...
Python handle 'NoneType' object has no attribute 'find_all' error with if else statement <p>I am using beautifulsoup4 to grab stock data and send to a spreadsheet in python. The problem I am having is that I cannot get my loop to skip over attributes that return None. So what I am needing is the code to add null values...
<p>You have used the <code>data</code> variable for two different things. The second usage overwrote your dictionary. It is simpler to just use <code>html.text</code> in the call to <code>soup.find()</code>. Try the following:</p> <pre><code>import requests import bs4 # My dictionary for storing data data = { ...
Why can't I commit changes in a conflicted state? <p>As we all know, merging branches in subversion (or any other revision control system for that matter) every so often results in conflicts. Somtimes these conflicts can be very complicated to resolve. Yet you are required to do so before committing the changes to the ...
<p>Think about what it would <em>mean</em> for your repository to be in a conflicted state. What that means is that there is more than one possible correct latest version of the code, which means that you have forked the repository. Source control systems already have means by which a repository can be forked.</p> <p>...
Where are the ASP.NET core symbols hosted? <p>Have the .NET / ASP.NET core symbols been hosted anywhere yet? They would be helpful in debugging and learning.</p>
<p>To debug Asp.Net Core, I followed the article sbouaked is mentionning, got the source from Git, and it's working perfectly. Didn't find a way to get only the symbols.</p>
openpyxl read formula value without changing formula <p>I want to read the formula value in an xlsx file, write the value in another cell and store the xlsx file.</p> <p>I'm using the data_only mode</p> <pre><code>excelDoc = openpyxl.load_workbook(clientFile, data_only=True) </code></pre> <p>to read the formula valu...
<p>You can't. You can either have the values or the formulae.</p>