Daily Archives

Articles indexed Thursday August 21 2014

Page 14/19 | < Previous Page | 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • "type" Command Not Working As Expected on Git Bash

    - by trysis
    The type command, in Linux, returns the location, on the filesystem, of the given file, if it is in the current folder or the $PATH. This functionality is also available through Windows with the Git Bash command line program. The command also returns a file's location given the file without its extension (.exe, .vbs, etc.) However, I have run into what seems like a strange corner case where the file exists on the $PATH but doesn't get returned using the command. I am thinking of buying a new computer soon, so I looked up the method of transferring the license key from one computer to another, in preparation for actually doing this. The method I found mentioned the files slmgr.vbs and slui.exe, both of which reside in the C:/Windows\System32 folder, which is in my $PATH, as usual for a Windows computer. However, these two files aren't showing up when I use the type command. Also, neither gets executed when I call the files as commands without their extensions in Git Bash, and only slmgr.vbs gets executed when I call them with the extensions. Finally, slmgr.vbs is shown when listing the folder's contents in Git Bash, as well, but slui.exe isn't. I thought this might have to do with permissions, and, indeed, both files have very restrictive permissions, as you can see in the pictures below, but they both have the same permissions, which wouldn't explain why one gets executed and the other doesn't when called directly, nor why one file is listed on command line but the other isn't. C:\Windows\System32 folder, proving the files exist: File permissions for the Users and Administrators groups for the two files (they are identical): And the folder: type command and its output in Git Bash for the 2 files, plus listing the files in the folder (using grep to filter as the folder is huge), as well as listing part of the $PATH (keep in mind, for all these, that Git Bash changes the paths as they are displayed): Sean@MYPC ~ $ type -a slmgr sh.exe": type: slmgr: not found Sean@MYPC ~ $ type -a slmgr.vbs sh.exe": type: slmgr.vbs: not found Sean@MYPC ~ $ type -a slui sh.exe": type: slui: not found Sean@MYPC ~ $ type -a slui.exe sh.exe": type: slui.exe: not found Sean@MYPC ~ $ slmgr sh.exe": slmgr: command not found Sean@MYPC ~ $ slmgr.vbs /c/WINDOWS/system32/slmgr.vbs: line 2: syntax error near unexpected token `(' /c/WINDOWS/system32/slmgr.vbs: line 2: `' Copyright (c) Microsoft Corporation. A ll rights reserved.' Sean@MYPC ~ $ slui sh.exe": slui: command not found Sean@MYPC ~ $ slui.exe sh.exe": slui.exe: command not found Sean@MYPC ~ $ ls /c/Windows/System32/slui.exe /c/Windows/System32/slmgr.vbs ls: /c/Windows/System32/slui.exe: No such file or directory /c/Windows/System32/slmgr.vbs Sean@MYPC ~ $ echo $PATH /c/Users/Sean/bin:.:/usr/local/bin:/mingw/bin:/bin:/cmd:/c/Python33/:/c/Program Files (x86)/Intel/iCLS Client/:/c/Program Files/Intel/iCLS Client/:/c/WINDOWS/sy stem32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell /v1.0/:/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/c/Progr am Files/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)/ Intel/Intel(R) Management Engine Components/DAL:/c/Program Files (x86)/Intel/Int el(R) Management Engine Components/IPT:/c/Program Files/Intel/WiFi/bin/:/c/Progr am Files/Common Files/Intel/WirelessCommon/:/c/strawberry/c/bin:/c/strawberry/pe rl/site/bin:/c/strawberry/perl/bin:/c/Program Files (x86)/Microsoft ASP.NET/ASP. NET Web Pages/v1.0/:/c/Program Files/Microsoft SQL Server/110/Tools/Binn/:/c/Pro gram Files (x86)/Microsoft SQL Server/90/Tools/binn/:/c/Program Files (x86)/Open AFS/Common:/c/HashiCorp/Vagrant/bin:/c/Program Files (x86)/Windows Kits/8.1/Wind ows Performance Toolkit/:/c/Program Files/nodejs/:/c/Program Files (x86)/Git/cmd :/c/Program Files (x86)/Git/bin:/c/Program Files/Microsoft/Web Platform Installe r/:/c/Ruby200-x64/bin:/c/Users/Sean/AppData/Local/Box/Box Edit/:/c/Program Files (x86)/SSH Communications Security/SSH Secure Shell:/c/Users/Sean/Documents/Lisp :/c/Program Files/GCL-2.6.1/lib/gcl-2.6.1/unixport:/c/Chocolatey/bin:/c/Users/Se an/AppData/Roaming/npm:/c/wamp/bin/mysql/mysql5.6.12/bin:/c/Program Files/Oracle /VirtualBox:/c/Program Files/Java/jdk1.7.0_51/bin:/c/Program Files/Node-Growl:/c /chocolatey/bin:/c/Program Files/eclipse:/c/MongoDB/bin:/c/Program Files/7-Zip:/ c/Program Files (x86)/Google/Chrome/Application:/c/Program Files (x86)/LibreOffi ce 4/program:/c/Program Files (x86)/OpenOffice 4/program What's happening? Why aren't these files listed with the type command? Is this issue because of weird Windows permissions, or something even weirder? If permissions, why do they seem to have the same permissions, yet both are not handled in the same way?

    Read the article

  • c++ float subtraction rounding error

    - by Volkan Ozyilmaz
    I have a float value between 0 and 1. I need to convert it with -120 to 80. To do this, first I multiply with 200 after 120 subtract. When subtract is made I had rounding error. Let's look my example. float val = 0.6050f; val *= 200.f; Now val is 121.0 as I expected. val -= 120.0f; Now val is 0.99999992 I thought maybe I can avoid this problem with multiplication and division. float val = 0.6050f; val *= 200.f; val *= 100.f; val -= 12000.0f; val /= 100.f; But it didn't help. I have still 0.99 on my hand. Is there a solution for it? Edit: After with detailed logging, I understand there is no problem with this part of code. Before my log shows me "0.605", after I had detailed log and I saw "0.60499995946884155273437500000000000000000000000000" the problem is in different place.

    Read the article

  • Hoe to convert a JSON array of paths to images stored on a server into a javaScript array to display them? Using AJAX

    - by MichaelF
    I need for html file/ ajax code to take the JSON message and store the PATHS as a javaScript array. Then my buildImage function can display the first image in the array. I'm new to AJAX and believe my misunderstanding lies within the converting of the JSON to Javascript. I'm confused also about if my code creates a JSON array or object or either. I might need also to download a library to my app to understand JSON? Below is a PHP file loading the paths of the images. I believe json ecode is converting the PHP Array in a Json message. <?php include("mysqlconnect.php"); $select_query = "SELECT `ImagesPath` FROM `offerstbl` ORDER by `ImagesId` DESC"; $sql = mysql_query($select_query) or die(mysql_error()); $data = array(); while($row = mysql_fetch_array($sql,MYSQL_BOTH)){ $data[] = $row['ImagesPath']; } echo $images = json_encode($data); ?> Below is the script in is going to be loaded on an Cordova app. <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="css/styles.css"> <link rel="stylesheet" href="css/cascading.css"> <script> function importJson(str) { // console.log(typeof xmlhttp.responseText); if (str=="") { document.getElementById("content").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { //var images = JSON.parse(xmlhttp.responseText); document.getElementById("content").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","http://server/content.php"); xmlhttp.send(); } function buildImage(src) { var img = document.createElement('img') img.src = src alert("1"); document.getElementById('content').appendChild(img); } for (var i = 0; i < images.length; i++) { buildImage(images[i]); } </script> </head> <body onload= "importJson();"> <div class="contents" id="content" ></div> <img src="img/logo.png" height="10px" width="10px" onload= "buildImage();"> </body>

    Read the article

  • How to perform a Depth First Search iteratively using async/parallel processing?

    - by Prabhu
    Here is a method that does a DFS search and returns a list of all items given a top level item id. How could I modify this to take advantage of parallel processing? Currently, the call to get the sub items is made one by one for each item in the stack. It would be nice if I could get the sub items for multiple items in the stack at the same time, and populate my return list faster. How could I do this (either using async/await or TPL, or anything else) in a thread safe manner? private async Task<IList<Item>> GetItemsAsync(string topItemId) { var items = new List<Item>(); var topItem = await GetItemAsync(topItemId); Stack<Item> stack = new Stack<Item>(); stack.Push(topItem); while (stack.Count > 0) { var item = stack.Pop(); items.Add(item); var subItems = await GetSubItemsAsync(item.SubId); foreach (var subItem in subItems) { stack.Push(subItem); } } return items; } EDIT: I was thinking of something along these lines, but it's not coming together: var tasks = stack.Select(async item => { items.Add(item); var subItems = await GetSubItemsAsync(item.SubId); foreach (var subItem in subItems) { stack.Push(subItem); } }).ToList(); if (tasks.Any()) await Task.WhenAll(tasks); UPDATE: If I wanted to chunk the tasks, would something like this work? foreach (var batch in items.BatchesOf(100)) { var tasks = batch.Select(async item => { await DoSomething(item); }).ToList(); if (tasks.Any()) { await Task.WhenAll(tasks); } } The language I'm using is C#.

    Read the article

  • placing the matched 2 different child elements xml values in a single line from xslt2.0

    - by Girikumar Mathivanan
    I have the below input xml, <GSKProductHierarchy> <GlobalBusinessIdentifier>ZGB001</GlobalBusinessIdentifier> <Hierarchy> <Material>335165140779</Material> <Level1>02</Level1> <Level2>02AQ</Level2> <Level3>02AQ006</Level3> <Level4>02AQ006309</Level4> <Level5>02AQ006309</Level5> <Level6>02AQ006309</Level6> <Level7>02AQ006309</Level7> <Level8>02AQ006309</Level8> </Hierarchy> <Hierarchy> <Material>335165140780</Material> <Level1>02</Level1> <Level2>02AQ</Level2> <Level3>02AQ006</Level3> <Level4>02AQ006309</Level4> <Level5>02AQ006309</Level5> <Level6>02AQ006309</Level6> <Level7>02AQ006309</Level7> <Level8>02AQ006310</Level8> </Hierarchy> <Texts> <ProductHierarchy>02AQ006310</ProductHierarchy> <Language>A</Language> <Description>CREAM</Description> </Texts> <Texts> <ProductHierarchy>02AQ006309</ProductHierarchy> <Language>B</Language> <Description>CREAM</Description> </Texts> as per the requirement, xsl should check the matched value of GSKProductHierarchy/Hierarchy/Level8 in the GSKProductHierarchy/Texts/ProductHierarchy elements...and its should result as below flat file. 335165140779|02|02AQ|02AQ006|02AQ006309|02AQ006309|02AQ006309|02AQ006309|02AQ006309|02AQ006309|A|CREAM| 335165140780|02|02AQ|02AQ006|02AQ006309|02AQ006309|02AQ006309|02AQ006309|02AQ006310|02AQ006310|B|CREAM| Right now I have the below xslt, <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:set="http://exslt.org/sets" xmlns:str="http://exslt.org/strings" xmlns:java="http://xml.apache.org/xslt/java" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="exsl set str java saxon"> <xsl:output method="text" indent="yes"/> <xsl:variable name="VarPipe" select="'|'"/> <xsl:variable name="VarBreak" select="'&#xa;'"/> <xsl:template match="/"> <xsl:for-each select="GSKProductHierarchy/Hierarchy"> <xsl:variable name="currentIndex" select="position()"/> <xsl:variable name="Level8" select="Level8"/> <xsl:variable name="ProductHierarchy" select="../Texts[$currentIndex]/ProductHierarchy"/> <xsl:if test="$Level8=$ProductHierarchy"> <xsl:value-of select="Material"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level1"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level2"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level3"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level4"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level5"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level6"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level7"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="Level8"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="../Texts[$currentIndex]/ProductHierarchy"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="../Texts[$currentIndex]/Language"/> <xsl:value-of select="$VarPipe"/> <xsl:value-of select="../Texts[$currentIndex]/Description"/> <xsl:value-of select="$VarPipe"/> <xsl:if test="not(position() = last())"> <xsl:value-of select="$VarBreak"/> </xsl:if> </xsl:if> </xsl:for-each> </xsl:template> can anyone please suggest what function should i need to use to get the desired result. Regards, Giri

    Read the article

  • Tablesorter - filter inside input fields and values

    - by Zeracoke
    I have a small quest to accomplish, and I reached a point when nothing works... So the problem is. I have a paged table with a lot of input fields inside the rows with values, and I would like to search inside these values. Let me Show this, I hope that somebody will got the idea what I should do... <script type="text/javascript"> // add parser through the tablesorter addParser method $.tablesorter.addParser({ id: 'inputs', is: function(s) { return false; }, format: function(s, table, cell, cellIndex) { var $c = $(cell); // return 1 for true, 2 for false, so true sorts before false if (!$c.hasClass('updateInput')) { $c .addClass('updateInput') .bind('keyup', function() { $(table).trigger('updateCell', [cell, false]); // false to prevent resort }); } return $c.find('input').val(); }, type: 'text' }); $(function() { $('table').tablesorter({ widgets: ['zebra', 'stickyHeaders', 'resizable', 'filter'], widgetOptions: { stickyHeaders : '', // number or jquery selector targeting the position:fixed element stickyHeaders_offset : 110, // added to table ID, if it exists stickyHeaders_cloneId : '-sticky', // trigger "resize" event on headers stickyHeaders_addResizeEvent : true, // if false and a caption exist, it won't be included in the sticky header stickyHeaders_includeCaption : true, // The zIndex of the stickyHeaders, allows the user to adjust this to their needs stickyHeaders_zIndex : 2, // jQuery selector or object to attach sticky header to stickyHeaders_attachTo : null, // scroll table top into view after filtering stickyHeaders_filteredToTop: true, resizable: true, filter_onlyAvail : 'filter-onlyAvail', filter_childRows : true, filter_startsWith : true, filter_useParsedData : true, filter_defaultAttrib : 'data-value' }, headers: { 1: {sorter: 'inputs', width: '50px'}, 2: {sorter: 'inputs'}, 3: {sorter: 'inputs'}, 4: {sorter: 'inputs'}, 5: {sorter: 'inputs'}, 6: {sorter: 'inputs'}, 7: {sorter: 'inputs', width: '100px'}, 8: {sorter: 'inputs', width: '140px'}, 9: {sorter: 'inputs'}, 10: {sorter: 'inputs'}, 11: {sorter: 'inputs'}, } }); $('table').tablesorterPager({container: $(".pager"), positionFixed: false, size: 50, pageDisplay : $(".pagedisplay"), pageSize : $(".pagesize"), }); $("#table1").tablesorter(options); /* make second table scroll within its wrapper */ options.widgetOptions.stickyHeaders_attachTo = '.wrapper'; // or $('.wrapper') $("#table2").tablesorter(options); }); </script> The structure of the tables: <tr class="odd" style="display: table-row;"> <form action="/self.php" method="POST"> </form><input type="hidden" name="f" value="data"> <td><input type="hidden" name="mod_id" value="741">741</td> <td class="updateInput"><input type="text" name="name" value="Test User Name"></td> <td class="updateInput"><input type="text" name="address" value="2548451 Random address"></td> <td class="updateInput"><input type="email" name="email" value=""></td> <td class="updateInput"><input type="text" name="entitlement" value="none"></td> <td class="updateInput"><input type="text" name="card_number" value="6846416548644352"></td> <td class="updateInput"><input type="checkbox" name="verify" value="1" checked=""></td> <td class="updateInput"><input type="checkbox" name="card_sended" value="1" checked=""></td> <td class="updateInput"><input type="text" name="create_date" value="2014-02-12 21:09:16"></td> <td class="updateInput"><a href="self.php?f=data&amp;del=741">X</a></td> <td class="updateInput"><input type="submit" value="SAVE"></td><td class="updateInput"></td></tr> So the thing is I don't know how to configure the filter to search these values... I already added some options, but none of them are working... Any help would be great!

    Read the article

  • search map based on key wildcard

    - by Hugo Koopmans
    I have the following map of maps: <map:map xmlns:map="http://marklogic.com/xdmp/map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <map:entry key="101201"> <map:value> "content" </map:value> </map:entry> ... more maps ... Now I would like to search/filter the map based on the key using a wildcard. Actually I want to filter based on the first 4 characters of the key="101201" so key="1012**". Question: Give me all maps that have a key that is matching '1012*' ... Can that be done efficiently? tx for your time hugo

    Read the article

  • node.js: looping, email each matching row from query but it it emails the same user by # number of matches?

    - by udonsoup16
    I have a node.js email server that works fine however I noticed a problem. If the query string found 4 rows, it would send four emails but only to the first result instead of to each found email address. var querystring1 = 'SELECT `date_created`,`first_name`,`last_name`,`email` FROM `users` WHERE TIMESTAMPDIFF(SECOND,date_created, NOW()) <=298 AND `email`!="" LIMIT 0,5'; connection.query(querystring1, function (err, row) { if (err) throw err; for (var i in row) { // Email content; change text to html to have html emails. row[i].column name will pull relevant database info var sendit = { to: row[i].email, from: '******@******', subject: 'Hi ' + row[i].first_name + ', Thanks for joining ******!', html: {path:__dirname + '/templates/welcome.html'} }; // Send emails transporter.sendMail(sendit,function(error,response){ if (error) { console.log(error); }else{ console.log("Message sent1: " + row[i].first_name);} transporter.close();} ) }}); .... How do I have it loop through each found row and send a custom email using row data individual row data?

    Read the article

  • Best practice: Define form field name in backend or the template

    - by AbcAeffchen
    If you designing a webpage you should separate the backend from the frontend. But if you use forms you have to name them. But where should you set this name? e.g. PHP: $fieldName = 'email'; $template->setVar('field_name', $fieldName) ... if(!empty($_POST)) validate($_POST[$fieldName]); Template: <input type="text" name="{$field_name}"> Or just PHP: if(!empty($_POST)) validate($_POST['email']); Template: <input type="text" name="email"> Or should I write a function that can be called from the template an converts an array of field data (name, type, value, id, class, ...) into html code? Is there a best practice where to define fieldnames (types,etc.)? Notice: I used php and smarty like pseudocode (and tags), but its a general question.

    Read the article

  • Instantiating custom PropertySourcesPlaceholderConfigurer from spring context

    - by mmona
    I want to define a custom PropertySourcesPlaceholderConfigurer in spring context xml. I want to use there multiple PropertySources, so that I can load part of the configuration from several property files and provide other part dynamically by my custom PropertySource implementation. The advantage is that it should be then easy to adjust the order of loading these property sources just by making modifications to the xml spring configuration. And here I run into a problem: how to define an arbitrary list of PropertySources and inject it into PropertySourcesPlaceholderConfigurer, so that it uses the sources defined by me? Seems to be a basic thing that should be provided by spring, but since yesterday I cannot find a way to do it. Using namespace would enable me to load several property files, but I also need to define the id of the PropertySourcesPlaceholderConfigurer (as other projects refer to it), and also I want to use my custom implementation. That is why I am defining the bean explicitly and not using the namespace. The most intuitive way would be to inject a list of PropertySources into PropertySourcesPlaceholderConfigurer like this: <bean id="applicationPropertyPlaceholderConfigurer" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="ignoreResourceNotFound" value="true" /> <property name="order" value="0"/> <property name="propertySources"> <list> <!-- my PropertySource objects --> </list> </property> </bean> but unfortunately propertySources is of type PropertySources and does not accept a list. The PropertySources interface has one and only implementor which is MutablePropertySources, which indeed stores list of PropertySource objects, but has no constructor nor setter through which I can inject this list. It only has add*(PropertySource) methods. The only workaround I see now is to implement my own PropertySources class, extending MutablePropertySources, which would accept list of PropertySource objects on creation and manually add it via using add*(PropertySource) method. But why so much workaround would be needed to provide something that I thought was supposed to be the main reason of introducing the PropertySources (having flexible configuration manageable from spring configuration level). Please clarify what am I getting wrong :)

    Read the article

  • Android - Looking for an AOP solution

    - by Serj Lotutovici
    I'm writing an application that on the bottom line uses it's internal API for some manipulations. The problem is that to call any method provided by that class first I (or anybody who uses the API) have to call #prepare() and after that #cleanup(). It all worked fine until the application and the API started to grow. And the risk of not calling one of the supplied methods before or after the API is now to big to be ignored (which makes it a bug risky application). Searching for a solution I found this question. I use Google Guice in my app for other purposes, but Android doesn't support AOP, that's why a use only guice-no_aop-x.jar. So I end-up with two questions: Is there an AOP solution for android to implement the same approach that is shown in the link above? Or may be someone has an idea that will be suitable for my case? Thanks in advice!

    Read the article

  • Angular ng-style not changing with property

    - by ganaraj
    For the life of me I cant seem to figure out why the style property is not getting updated. In my larger application it seems to work fine. http://jsfiddle.net/ganarajpr/C2hRa/4/ Here is a fiddle which shows the issue I am currently facing. You will notice that the width and height are getting updated in the div when you change the input. But the style itself doesnt seem to be updating. Anyone can tell me what I am doing wrong here? I have tried all the following scenarios using $scope.$apply.. - Throws an error stating $apply already in progress.. $rootScope.$apply - same as above. Setting another variable in a service which is $watched in the other controller. - no change seen. It would be really cool if someone can get me an answer to this. Also would be really happy if you can tell me why exactly it is not getting updated.

    Read the article

  • How can I round a QWidgets corners?

    - by chacham15
    I am trying to round the corners of the current widget, but it doesnt work, why? PopupWindow::PopupWindow() : QWidget(0) { setWindowFlags( Qt::Tool | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowStaysOnTopHint ); this-resize(300, 100); setStyleSheet(".PopupWindow {border-style: outset;border-width: 10px;border-radius:10px;}"); QPushButton *hello = new QPushButton("Hello world!"); hello-setFont(QFont("Times", 18, QFont::Bold)); hello-setGeometry(10, 40, 180, 40); hello-setStyleSheet(""); QVBoxLayout *layout = new QVBoxLayout; layout-addWidget(hello); setLayout(layout); }

    Read the article

  • Multiple levels of 'collection.defaultdict' in Python

    - by Morlock
    Thanks to some great folks on SO, I discovered the possibilities offered by collections.defaultdict, notably in readability and speed. I have put them to use with success. Now I would like to implement three levels of dictionaries, the two top ones being defaultdict and the lowest one being int. I don't find the appropriate way to do this. Here is my attempt: from collections import defaultdict d = defaultdict(defaultdict) a = [("key1", {"a1":22, "a2":33}), ("key2", {"a1":32, "a2":55}), ("key3", {"a1":43, "a2":44})] for i in a: d[i[0]] = i[1] Now this works, but the following, which is the desired behavior, doesn't: d["key4"]["a1"] + 1 I suspect that I should have declared somewhere that the second level defaultdict is of type int, but I didn't find where or how to do so. The reason I am using defaultdict in the first place is to avoid having to initialize the dictionary for each new key. Any more elegant suggestion? Thanks pythoneers!

    Read the article

  • Mock the window.setTimeout in a Jasmine test to avoid waiting

    - by Aligned
    Originally posted on: http://geekswithblogs.net/Aligned/archive/2014/08/21/mock-the-window.settimeout-in-a-jasmine-test-to-avoid-waiting.aspxJasmine has a clock mocking feature, but I was unable to make it work in a function that I’m calling and want to test. The example only shows using clock for a setTimeout in the spec tests and I couldn’t find a good example. Here is my current and slightly limited approach.   If we have a method we want to test: var test = function(){ var self = this; self.timeoutWasCalled = false; self.testWithTimeout = function(){ window.setTimeout(function(){ self.timeoutWasCalled = true; }, 6000); }; }; Here’s my testing code: var realWindowSetTimeout = window.setTimeout; describe('test a method that uses setTimeout', function(){ var testObject; beforeEach(function () { // force setTimeout to be called right away, no matter what time they specify jasmine.getGlobal().setTimeout = function (funcToCall, millis) { funcToCall(); }; testObject = new test(); }); afterEach(function() { jasmine.getGlobal().setTimeout = realWindowSetTimeout; }); it('should call the method right away', function(){ testObject.testWithTimeout(); expect(testObject.timeoutWasCalled).toBeTruthy(); }); }); I got a good pointer from Andreas in this StackOverflow question. This would also work for window.setInterval. Other possible approaches: create a wrapper module of setTimeout and setInterval methods that can be mocked. This can be mocked with RequireJS or passed into the constructor. pass the window.setTimeout function into the method (this could get messy)

    Read the article

  • Mailgun Is Not Detecting My New MX Records

    - by Tyler Crompton
    When I issue a DiG command to verify my MX records, I get the following output: $ dig example.com MX ; <<>> DiG 9.9.5-3-Ubuntu <<>> example.com MX ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47700 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 5, ADDITIONAL: 5 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN MX ;; ANSWER SECTION: example.com. 85468 IN MX 10 mxa.mailgun.org. example.com. 85468 IN MX 10 mxb.mailgun.org. ;; REMAINDER OF OUTPUT REMOVED FOR BREVITY However, when I click "Check DNS Records Now" on Mailgun, it verifies the changes to the TXT and CNAME records but says that my MX records have not been changed. Type | Priority | Enter This Value | Current Value -----+----------+------------------+-------------------- MX | 10 | mxa.mailgun.org | 10 mail.example.com MX | 10 | mxb.mailgun.org | 10 mail.example.com I updated these records three to fours ago. I know it said to wait up to twenty-four to forty-eight hours. But I feel that if it detected the other DNS changes, then it should detect the MX record changes. Am I being impatient or is this a legitimate concern? What do you suggest I do? Note: I'd create a Mailgun tag for this; I feel that it'd be appropriate, but I don't have enough reputation to do so.

    Read the article

  • How do I prevent spawning of zombie-like apache2 processes on Dreamhost VPS?

    - by Jonathan Hayward
    I have had a website for months or longer on a DreamHost VPS, and I have had vague memories on, in initial setup, having to turn off some customized Apache under /dh to get a standard Apache 2.x to work with. Things have been going along on an even keel, when I started making some changes lately and I found that when I tried to bounce Apache (/usr/sbin/apachectl restart), it couldn't bind to port 80, and my site had been converted from a big literature site to a small parking site. I tried to see what was listening on 80, and it was a DreamHost-customized Apache that had spawned. I killed all of them, restarted Apache, and changed the parent directory under /dh to mode 000. That was a day or two ago. I was bouncing Apache again in trying to get a new site to load under HTTPS, and I found that once again DreamHost's apache had spawned, from the directory I set to mode 000, and once again converted my site to a parking page. I renamed the directory, but I am very skeptical of whether I have permanently killed the DreamHost-customized Apache. Besides duct tape options like a crontab to kill and delete each minute, how can I permanently turn off the Apache processes that are spawning from a location under /dh and interfering with standard Apache? What should I be doing that I am not? Can DreamHost's technical support stop the interference? Thanks,

    Read the article

  • Advice for an EC2 Architecture and Deployment Strategy

    - by Mark
    My company is currently migrating several websites and PHP web applications (standard LAMP stack) from three in-house servers to Amazon EC2. Because we had only three servers, we clustered several low-traffic websites with perhaps one high-traffic web application, and served them from the same server. The server admin has pretty much copied the previous architecture wholesale onto the EC2 instances, simply upping the instance size to account for the highest traffic client that occupies that particular instance. This architecture might be okay if it wasn't for deployment. Any time one of these sites/apps changes, it means redeploying the entire instance, along with the 30 sites/apps it hosts, instead of just updating one. How can we architect our cloud in a more modular fashion? Should each app get its own appropriately-sized instance? What is the best strategy for deployment in this type of situation?

    Read the article

  • Optimizing Apache for large file serving

    - by D_Guy13
    I have a random problem with Apache that I can't quite figure out, here is my setup, Windows Server 2008 R2, 64 Bit, 5GB RAM, SSD with 200 MB(Read/write) and Dual Core CPU @ 2.1 GHz A dump from mod-staus, Server Version: Apache/2.4.7 (Win32) mod_limitipconn/0.24 mod_antiloris/0.5.2 PHP/5.5.9 Server MPM: WinNT Apache Lounge VC11 Server Built: Nov 21 2013 20:13:01 Current Time: Thursday, 21-Aug-2014 23:38:06 W. Europe Daylight Time Restart Time: Thursday, 21-Aug-2014 20:30:47 W. Europe Daylight Time Parent Server Config. Generation: 1 Parent Server MPM Generation: 1 Server uptime: 3 hours 7 minutes 18 seconds Server load: -1.00 -1.00 -1.00 Total accesses: 283025 - Total Traffic: 1172.2 GB 25.2 requests/sec - 106.8 MB/second - 4.2 MB/request 62 requests currently being processed, 388 idle workers Serving large .zip & iso files using mod_xsendfile. (File size range 500 MB - 1.5 GB) The setup works and is running fine. CPU usage is very unstable, jumps all the time between 10% - 90% and the servers goes down when it hits 100%. In that case I have to hard restart the server. Server it outputting traffic at 30 Mbps. Is there anything else I should think about to get a more stable CPU usage? Is that CPU usage normal? Can switching to Linux help me achieve better CPU usage?

    Read the article

  • Iptables and counters

    - by mehturt
    I'm trying to use iptables counters with munin to monitor traffic of hosts on my local subnet. For each host I set up a rule like this: iptables -I OUTPUT -d $ip This should count the packets going from firewall to $ip, correct? I found out that this does not seem to count all packets. I start tcpdump on my router (Linux) and I see packets to $ip that are not counted. For example I check number of packets for rule to my phone IP. I start tcpdump, refresh Gmail on my phoone, I see packets in tcpdump's output but iptables rule counters are not incremented. Then I open a web page on the same phone and the counters are incremented. What could be the reason?

    Read the article

  • WSUS Looping 2 updates on 2003 servers

    - by Ericrobert
    Good afternoon, Hopefully I can articulate this so that people understand my problem. We have WSUS on windows server 2008. We have 8 Windows 2003 servers. There is an update ready to install KB2982792. We install it then it says there is another update to install KB2728973. Then it says there is another update to install, again KB2982792. This goes on and on. Talked to microsoft support and they confirmed that the update was infact installed and applied to the computer (Checking untrusted certifactions confirmed that for these updates) and their suggestion was to just "Hide update". This is fine except on the WSUS server it still shows failed updates which is not okay with our policy. I'm here to ask for help figuring this out and what I can do to trouble shoot it. Thank you in advanced.

    Read the article

  • Server not resolving after restart

    - by DomainSoil
    I restarted our server today, and now cannot for the life of me get anything to resolve... I suspect it has something to do with our routes. I've tried numerous Google results to no avail. Here is as far as I've gotten: [root@www ~]# route -n Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.101 0.0.0.0 255.255.255.255 UH 0 0 0 eth1 0.0.0.0 192.168.1.101 0.0.0.0 UG 0 0 0 eth1 Things you need to know: Our server (CentOS 6.3) runs two virtual machines, one live, and one development. They mirror each other as much as possible, but I can't find where I've went wrong with the live server. The dev server works fine. [root@www ~]# ifconfig eth1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx inet6 addr: xxxx:xxx:xxxx:xxxx:xxxx/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:118206 errors:0 dropped:0 overruns:0 frame:0 TX packets:165 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7825749 (7.4 Mib) TX bytes:7146 (69.2 KiB) Interrupt:28 [root@www ~]# /etc/init.d/network status Configured devices: lo Auto eth0 Currently active devices: lo eth1 If there is any other information you need, please don't hesitate to ask!

    Read the article

  • Can't pipe echo to netcat?

    - by user1641300
    I have the following command: echo 'HTTP/1.1 200 OK\r\n' | nc -l -p 8000 -c and when I curl localhost:8000 I am not seeing HTTP/1.1 200 .. being printed. I am on mac os x with netcat 0.7.1 Any ideas? #!/bin/bash trap 'my_exit; exit' SIGINT SIGQUIT my_exit() { echo "you hit Ctrl-C/Ctrl-\, now exiting.." # cleanup commands here if any } if test $# -eq 0 ; then echo "Usage: $0 PORT" echo "" exit 1 fi while true do echo "HTTP/1.1 200 OK\r\n" | nc -l -p ${1} -c done and testing with: curl localhost:8000

    Read the article

  • Apache Rewrite Rules

    - by Philip
    I have moved my website from a Wiki to Wordpress and in the process, realised that I have broken links to some popular pages on my website. Is it possible to fix this with a rewrite rule? I need the rule to redirect anything beginning with "^/wiki/(.+)$" to "/$1" but also replacing the "_" character used in MediaWiki slugs to "-" used in Wordpress slugs. For example: http://example.com/wiki/An_Example_Page should be pointed to: http://example.com/an-example-page Is it possible to write such a rewrite rule? Edit: It appears that Wordpress doesn't even care if the "/wiki/" part is removed - provided the slug matches, and that seems to be case-insensitive too. So all I need to do is change the "_" characters to "-" in the slugs.

    Read the article

  • Can't find created directory on zfs

    - by maniat1k
    I'm using openSUSE 13.1. I created a new directory on a zpool zfs create zpgd0/iSCSI -o compression=lz4 -o atime=off but I'm not looking on that... So I do it again but I'm getting... zfs create zpgd0/iSCSI -o compression=lz4 -o atime=off cannot create 'zpgd0/iSCSI': dataset already exists adding some data zpool history History for 'zpgd0': 2014-08-11.13:38:21 zpool create -f zpgd0 raidz2 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0490461 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0603473 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0606817 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0670246 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0673599 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0715212 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0722699 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0731193 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0732862 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0806663 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0807385 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0816943 2014-08-11.14:13:09 zpool set autoexpand=on zpgd0 2014-08-11.14:14:32 zfs create zpgd0/espacio 2014-08-19.11:47:47 zfs create zpgd0/iSCSI -o compression=lz4 -o atime=off zpool status -v pool: zpgd0 state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM zpgd0 ONLINE 0 0 0 raidz2-0 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0490461 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0603473 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0606817 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0670246 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0673599 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0715212 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0722699 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0731193 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0732862 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0806663 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0807385 ONLINE 0 0 0 scsi-SATA_WDC_WD4001FAEX-0_WD-WMC1F0816943 ONLINE 0 0 0 errors: No known data errors I have no errors but the folder does not appear, so what Can I do? sorry add it zfs list NAME USED AVAIL REFER MOUNTPOINT zpgd0 933K 35,5T 54,7K /zpgd0 zpgd0/iSCSI 54,7K 35,5T 54,7K /zpgd0/iSCSI

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19  | Next Page >