Daily Archives

Articles indexed Sunday October 21 2012

Page 6/14 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Properties of mbox message in mbox module in Python

    - by Rajasankar
    I trying my luck to manage my mailbox with python. My example code is for eachmail in mailbox.mbox(mboxfile): print eachmail['From'] I got following by printing entire content. Delivered-To Subject To Content-Type MIME-Version Message-Id Is there any full document showing what are all the properties I can get from the mbox message instance? Python docs doesn't specify any of these http://docs.python.org/library/mailbox.html#mailbox.mbox

    Read the article

  • Magento delete some scripts

    - by Patrik van Dendis
    Hi I use a magento for my e-commerce. I have custom design, but when I show my source code I can see some scripts and css styles after my footer. I want edit it but I dont know where. <!--{%FOOTER_LINK}--> </div> </div> <script type='text/javascript' src='//www.beetailer.com/javascripts/beetailer.js'></script> <style type="text/css"> div.share-buttons {margin-top: 5px; margin-bottom: 2px; height: 28px; vertical-align: middle; text-align: justify} div.share-buttons-fb-like {width: 260px;} div.share-custom-container {width: 260px;} .share-buttons-fb-like .share-custom-container span {width: 260px !important;} iframe.fb_ltr {width: 260px !important;} div.top-container {margin-bottom: 0px; text-align: justify} .header-container .top-container {margin-bottom: 0px; text-align: justify} .header-container {margin-bottom: 0px;} div.share-buttons-og { margin-right: 5px !important;} .og-want {margin-top: 2px !important;} .og-own {margin-top: 2px !important;} </style>

    Read the article

  • OpenCL Matrix Multiplication - Getting wrong answer

    - by Yash
    here's a simple OpenCL Matrix Multiplication kernel which is driving me crazy: __kernel void matrixMul( __global int* C, __global int* A, __global int* B, int wA, int wB){ int row = get_global_id(1); //2D Threas ID x int col = get_global_id(0); //2D Threas ID y //Perform dot-product accumulated into value int value; for ( int k = 0; k < wA; k++ ){ value += A[row*wA + k] * B[k*wB+col]; } C[row*wA+col] = value; //Write to the device memory } Where (inputs) A = [72 45 75 61] B = [26 53 46 76] Output I am getting: C = [3942 7236 3312 5472] But the output should be: C = [3943 7236 4756 8611] The problem I am facing here is that for any dimension array the elements of the first row of the resulting matrix is correct. The elements of all the other rows of the resulting matrix is wrong. By the way I am using pyopencl. I don't know what I mistake I am doing here. I have spent the entire day with no luck. Please help me with this

    Read the article

  • Program to convert image and rotate

    - by user1755692
    I've been trying to make this program in c++ with opencv that converts the image to greyscale and rotates the image afterwards, but the output I get is all kinds of messed up. I have been searching for solutions and looking for help everywhere, but I haven't been able to find out what the heck I have done wrong so if any of you could help me it'd be great Code: http://pastebin.com/FSJKyaeU Also, here's a picture of the output I get http://i.imgur.com/qpYm1.jpg

    Read the article

  • What is a good cms that is postgres compatible, open source and either php or python based?

    - by hackg
    Php or python Use and connect to our existing postgres databases open source / or very low license fees Common features of cms, with admin tools to help manage / moderate community have a large member base on very basic site where members provide us contact info and info about their professional characteristics. About to expand to build new community site (to migrate our member base to) where the users will be able to msg each other, post to forums, blog, share private group discussions, and members will be sent inivitations to earn compensation for their expertise. Profile pages, job postings, and video chat would be plus. Already have a team of admins savvy with web apps to help manage it but our developer resources are limited (3-4 programmers) and looking to save time in development as opposed to building our new site from scratch.

    Read the article

  • Deploy CakePHP to a subfolder

    - by mgroves
    I have created a CakePHP 2 app, and now I'm trying to deploy it to a production web server. My app uses the default folder structure (app/lib/plugins/vendors), default htaccess, default routing, nothing special. I've been developing locally as if the app were in the root folder of the site (e.g. http://mycakeapp.localhost/ takes me to the site). But I'm deploying to a site (shared hosting) where that will not be the case (e.g. http://www.somedomain.com/mycakeapp). It doesn't work (I didn't really expect it to), so I assumed I had to tweak one or more htaccess files. I tried modifying the root .htaccess as suggested in this post, but that only partially worked (the link to the CSS didn't work, for instance): <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^mycakeapp$ mycakeapp/app/webroot/ [L] RewriteRule ^mycakeapp/(.*)$ mycakeapp/app/webroot/$1 [L] </IfModule> So what should I do to all the htaccess files to make this CakePHP site work in a subfolder?

    Read the article

  • Reading a bmp file and inverting it in C

    - by user1763396
    I have an assignment that deals with reading a bmp file into memory, inverts the pixels, and then saves the inverted image to a new file. From this description it seems fairly easy, however I don't think my professor did a great job in explaining the necessary steps to go about doing so. He taught us about fread and fwrite but there is so much more. Can anyone explain the process in going about this problem (I'm no looking for a direct answer just an explanation). Here is the link to the problem's description: https://engineering.purdue.edu/OOSD/F2012/Exercises/ex5.html Thanks in advance for any sort of help. NOTE: I actually have looked into this problem but since I don't have a good standing on this info it's not quite "clicking".

    Read the article

  • D3 fisheye on width on bar chart

    - by Dexter Tan
    i have been trying to create a vertical bar chart with a d3 fisheye cartesian distortion with only the x-axis being distorted. I have succeeded in distorting the x position of the vertical bars on mouseover with the following code: var maxMag = d3.max(dataset, function(d) { return d.value[10]; }); var minDate = d3.min(dataset, function(d) { return new Date(d.value[1], d.value[2]-1, d.value[3]).getTime(); }); var maxDate = d3.max(dataset, function(d) { return new Date(d.value[1], d.value[2]-1, d.value[3]).getTime(); }); var yScale = d3.scale.linear().domain([0, maxMag]).range([0, h]); var xScale = d3.fisheye.scale(d3.scale.linear).domain([minDate, maxDate]).range([0, w]).focus(w/2); var bar = svg.append("g") .attr("class", "bars") .selectAll(".bar") .data(dataset) .enter().append("rect") .attr("class", "bar") .attr("y", function(d) { return h - yScale(d.value[10]); }) .attr("width", w/dataset.length) .attr("height", function(d) { return yScale(d.value[10]); }) .attr("fill", function(d) { return (d.value[10] <= 6? "yellow" : "orange" ); }) .call(position); // Positions the bars based on data. function position(bar) { bar.attr("x", function(d) { var date = null; if (d.date != null) { date = d.date; } else { date = new Date(d.value[1],0,1); if (d.value[2] != null) date.setMonth(d.value[2]-1); if (d.value[3] != null) date.setMonth(d.value[3]); d.date = date; } return xScale(date.getTime()); }); } svg.on("mousemove", function() { var mouse = d3.mouse(this); xScale.distortion(2.5).focus(mouse[0]); bar.call(position); }); However at this point, applying fisheye on the width remains a mystery to me. I have tried several methods like using a fisheye scale for width however it does not work as expected. What i wish to do is to have the width of a bar expand on mouseover, the same way a single vertical bar is singled out on mouseover with the cartesian distortion. Any clues or help will be much appreciated! edit: http://dexter.xumx.me to view the visualisation i am talking about for easier understanding!

    Read the article

  • String contains all the elements of a list

    - by CSSS
    I am shifting to Python, and am still relatively new to the pythonic approach. I want to write a function that takes a string and a list and returns true if all the elements in the list occur in the string. This seemed fairly simple. However, I am facing some difficulties with it. The code goes something like this: def myfun(str,list): for a in list: if not a in str: return False return True Example : myfun('tomato',['t','o','m','a']) should return true myfun('potato',['t','o','m','a']) should return false myfun('tomato',['t','o','m']) should return true Also, I was hoping if someone could suggest a possible regex approach here. I am trying out my hands on them too.

    Read the article

  • C#: An object reference is required for the non-static field, method, or Property

    - by Omin
    I feel bad for asking this when there are so many questions that are related but I was not able to find/understand the answer I am looking for. // 2. Develop a program to convert currency X to currency Y and visa versa. using System; class Problem2 { static void Main (string[] args) { while (true) { Console.WriteLine ("1. Currency Conversion from CAD to Won"); Console.WriteLine ("2. Currency Conversion from Won to Cad"); Console.Write ("Choose from the Following: (1 or 2)? "); int option = int.Parse( Console.ReadLine() ); //double x; if (option == 1) { Console.WriteLine ("Type in the amount you would like to Convert CAD to Won: "); //double y =double.Parse( Console.ReadLine()); //Console.WriteLine( cadToWon( y ) ); Console.WriteLine( cadToWon( double.Parse( Console.ReadLine() ) )); } if (option == 2) { Console.WriteLine ("Type in the amount you would like to Convert Won to CAD: "); Console.WriteLine( wonToCad (double.Parse( Console.ReadLine()))); } } } double cadToWon( double x ) { return x * 1113.26; } double wonToCad( double x) { return x / 1113.26; } } This give me the Error messgae "An object reference is required for the non-static field, method, or property 'Problem2..." I know that I'll be able to run the program if I add static infront of the methods but I'm wondering why I need it (I think it's because Main is static?) and what do I need to change in order to use these methods without adding static to them? Thank you

    Read the article

  • Getting User input with Scanner

    - by Giannis
    I am trying to have a scanner take input in a loop. Once the user wants to finish he can exit this loop. I have tried many different ways to do it but there is always some problem. This is the code: Scanner sc = new Scanner(System.in); System.out.println("Continue?[Y/N]"); while (sc.hasNext()&& (sc.next().equals("Y"))) { System.out.println("Enter first name"); String name = sc.nextLine(); System.out.println("Enter surname"); String surname = sc.nextLine(); . . . System.out.println("Continue?[Y/N]"); } } The problem with the code above, which also happens on different methods I tried, is that when the user types Y, the scanner will skip the first input for first name,and jump to the surname. If the user types N the loop stops correctly. Someone can explain the reason this happens, and how to overcome using scanner class? p.s: Doing something like while(sc.nextLine().equals("Y")), will cause the loop to terminate before getting input from user after first run of the loop.

    Read the article

  • Access to bytes array of a Bitmap

    - by Deulis
    1- In Windows CE, I have a Bitmap object in C#. 2- I have a C function in an extern dll that expects as parameters the pointer to a bytes array that represents an image in RGB565 format, width and height. This function will draw on this array of bytes. So I need to pass the byte array pointer of the Bitmap object, but I can find a practical way to get this pointer. One way is convert this Bitmap into a bytes array using a memory stream or something else, but it will create a new bytes array, so I will keep in memory both object, the Bitmap and the bytes array, but I don’t want it because the few available memory, that’s why I need to access to the bytes array of the bitmap object, not create a new bytes array. Anyone can help me?

    Read the article

  • using Python reduce over a list of pairs

    - by user248237
    I'm trying to pair together a bunch of elements in a list to create a final object, in a way that's analogous to making a sum of objects. I'm trying to use a simple variation on reduce where you consider a list of pairs rather than a flat list to do this. I want to do something along the lines of: nums = [1, 2, 3] reduce(lambda x, y: x + y, nums) except I'd like to add additional information to the sum that is specific to each element in the list of numbers nums. For example for each pair (a,b) in the list, run the sum as (a+b): nums = [(1, 0), (2, 5), (3, 10)] reduce(lambda x, y: (x[0]+x[1]) + (y[0]+y[1]), nums) This does not work: >>> reduce(lambda x, y: (x[0]+x[1]) + (y[0]+y[1]), nums) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 1, in <lambda> TypeError: 'int' object is unsubscriptable Why does it not work? I know I can encode nums as a flat list - that is not the point - I just want to be able to create a reduce operation that can iterate over a list of pairs, or over two lists of the same length simultaneously and pool information from both lists. thanks.

    Read the article

  • Robocopy Invalid Parameters

    - by Drue
    I'm using the batch command robocopy to copy my website source files from my flash drive to my dad's laptop for a backup. I've ran it as an administrator and I get an invalid parameter error message. Here's what I have so far: @echo off robocopy "G:\xampp-portable\htdocs" "W:\xcopytest" /e pause>nul I want to use %cd% instead of "G:\xampp-portable" Also, my .bat file is in G:\xampp-portable. UAC is set to normal and I'm using Windows 7. [EDIT] I tried a similar code in 'W:\' under a test folder and it worked fine. I think the problem is the drive to drive. [/EDIT]

    Read the article

  • Make joomla blog link to inner pages(or blog roll post actual)

    - by somdow
    So i was told to create a blog for client in Joomla and, i have minimal knowledge of Joomla inner workings. I made the blog as seen here http://www.assurancepower.com/about-us/blog.html But the problem is that, the headers/titles for each story in that blog roll cant be clicked. Im wondering is there a way i can make this happen? Essentially this page is a collection of the stories and i want to be able to click on a particular one (any of them) and be taken to its inner page/full version of the story. Not exactly sure what im supposed to do/search for. Im not sure if joomla has a wordpress like functions.php or for example, is there somewhere i can instert a....maybe something like how wordpress does it with permalinks like so: <?php permalink(); ?> //title link here to the actual story. or something like <?php bloginfo('url');?>// this relative link for WP. Etc, All i want is to be able to have these titles in this story be active links to their full counterpart. Not sure what to look for/how to go about fixing this. Thanks in advanced.

    Read the article

  • Create a unique ID by fuzzy matching of names (via agrep using R)

    - by tbrambor
    Using R, I am trying match on people's names in a dataset structured by year and city. Due to some spelling mistakes, exact matching is not possible, so I am trying to use agrep() to fuzzy match names. A sample chunk of the dataset is structured as follows: df <- data.frame(matrix( c("1200013","1200013","1200013","1200013","1200013","1200013","1200013","1200013", "1996","1996","1996","1996","2000","2000","2004","2004","AGUSTINHO FORTUNATO FILHO","ANTONIO PEREIRA NETO","FERNANDO JOSE DA COSTA","PAULO CEZAR FERREIRA DE ARAUJO","PAULO CESAR FERREIRA DE ARAUJO","SEBASTIAO BOCALOM RODRIGUES","JOAO DE ALMEIDA","PAULO CESAR FERREIRA DE ARAUJO"), ncol=3,dimnames=list(seq(1:8),c("citycode","year","candidate")) )) The neat version: citycode year candidate 1 1200013 1996 AGUSTINHO FORTUNATO FILHO 2 1200013 1996 ANTONIO PEREIRA NETO 3 1200013 1996 FERNANDO JOSE DA COSTA 4 1200013 1996 PAULO CEZAR FERREIRA DE ARAUJO 5 1200013 2000 PAULO CESAR FERREIRA DE ARAUJO 6 1200013 2000 SEBASTIAO BOCALOM RODRIGUES 7 1200013 2004 JOAO DE ALMEIDA 8 1200013 2004 PAULO CESAR FERREIRA DE ARAUJO I'd like to check in each city separately, whether there are candidates appearing in several years. E.g. in the example, PAULO CEZAR FERREIRA DE ARAUJO PAULO CESAR FERREIRA DE ARAUJO appears twice (with a spelling mistake). Each candidate across the entire data set should be assigned a unique numeric candidate ID. The dataset is fairly large (5500 cities, approx. 100K entries) so a somewhat efficient coding would be helpful. Any suggestions as to how to implement this?

    Read the article

  • How to programmatically answer "Yes" to WebBrowser control security alert

    - by ih8ie8
    I am using WebBrowser control to programmatically access a single website, but whenever I login, I receive this certificate security alert: Since I trust that website and since I need to programmatically automate the login as well, this dialog box gets in the way. I searched SO for a solution and found a question similar to mine, but the accepted answer does not work! I defined a static member in the form that contains the WebControl: public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } In my form's constructor I added: ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); But that didn't get rid of the certificate security alert. Is there any way to get rid of this warning? Is there an IE equivalent to Firefox's Add Security Exception??? Note: The owner's certificate works perfectly fine (without exhibiting this security alert) with standalone browsers (IE, FF, Chrome, Safari). It only exhibits the problem with the WebBroswer control.

    Read the article

  • css menu for cross browser...mobile and desktop

    - by user1763319
    I made a cross browser drop down menu, which works well with IE6. However, I have problems with other browsers such as IE9, Firefox, Chrome... etc. How can I modify my HTML and CSS to get the same effect that works in IE6? Link to JSFiddle Here is my CSS: <style> .bar ul,li{ z-index:999; margin:0; padding:0; } .bar { color: #FFFFFF; font-weight: bold; text-align: center; } .bar a { padding: 11px; } .bar a:visited { color: #FFFFFF; font-weight: bold; text-decoration:none } .bar a:link { color: #FFFFFF; font-weight: bold; text-decoration:none } .bar a:hover { color: #FFFFFF; font-weight: bold; text-decoration:underline } #nav0{ list-style:none; font-weight:bold; /* Clear floats */ float:left; width:100%; } #nav0 li{ float:left; margin-right:10px; position:relative; } #nav0 a{ display:block; padding:5px; color:#fff; background:#003399; text-decoration:none; } #nav0 a:hover{ color:#fff; background:#333; text-decoration:underline; } /*--- DROPDOWN ---*/ #nav0 ul{ background:#fff; background:rgba(255,255,255,0); list-style:none; position:absolute; left:-9999px; } #nav0 ul li{ padding-top:1px; float:none; } #nav0 ul a{ white-space:nowrap; } #nav0 li:hover ul{ left:0; } #nav0 li:hover a{ text-decoration:underline; } #nav0 li:hover ul a{ text-decoration:none; } #nav0 li:hover ul li a:hover{ background:#333; } #nav0 li ul li a{ text-align: left; } #nav0 li:hover ul li ul { display:block; background:#003399; float:left; position:relative; padding-left:20px; } #nav0 li ul li:hover ul { display:block; background:#003399; float:left; position:relative; padding-left:20px; } </style> Here is my HTML: <body bgcolor="#79A6A6"> <div id="page" align="center"> <table class="bar" border="0" width="960" cellspacing="0" cellpadding="0" id="table_bar" bgcolor="#003399"> <tr> <td> <ul id="nav0"> <li><a><strong>Home</strong> </a> <ul> <li><a href="#" title>Top Item 1</a><ul> <li><a href="#" title="-">Item 1</a></li> <li><a href="#" title="-">Item 2</a></li> </ul> </li> <li><a href="#" title>Top Item 2</a><ul> <li><a href="@" title>Item 3</a></li> <li><a href="@" title>Item 4</a></li> </ul> </li> </ul> </li> <li><a><strong>Home</strong> </a> <ul> <li><a href="#" title>Top Title</a><ul> <li><a href="#" title="-">title</a></li> <li><a href="#" title="-">title123456789</a></li> </ul> </li> <li><a href="#" title>Top Hello</a><ul> <li><a href="@" title>hello</a></li> <li><a href="@" title>hello123456789</a></li> </ul> </li> </ul> </li> </ul> </li> <ul> </ul> </td> <td width="50" style="text-align: left">&nbsp;</td> </tr> </table> </div> </body> In ie6 Home Top Item 1 Item 1 Item 2 Top Item 2 Item3 Item4 In ie9 Home Top Item 1 Top Item 2 Item 2 Item 3 Item 4

    Read the article

  • Structure within union and bit field

    - by java
    #include <stdio.h> union u { struct st { int i : 4; int j : 4; int k : 4; int l; } st; int i; } u; int main() { u.i = 100; printf("%d, %d, %d", u.i, u.st.i, u.st.l); } I'm trying to figure out the output of program. The first outputs u.i = 100 but I can't understand the output for u.st.i and u.st.l. Please also explain bit fields.

    Read the article

  • Python script shows different pythonpath

    - by Bird Jaguar IV
    Attempting to run runsnake gives ImportError: No module named wx Opening an ipython or python session seems to work fine: >>> import wx >>> import sys >>> print [p for p in sys.path if 'wx' in p] ['/usr/local/lib/wxPython-2.9.4.0/lib/python2.7/site-packages', '/usr/local/lib/wxPython-2.9.4.0/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa', '/usr/local/lib/wxPython-2.9.4.0/lib/python2.7/site-packages/wx-2.9.1-osx_cocoa/tools'] as does putting that code in a script and calling python script.py. But putting that code at the beginning of runsnake.py prints an empty list (printing the whole sys.path prints a path quite different from my $PYTHONPATH). Why would it be different, and how to I get it to recognize wxPython?

    Read the article

  • Substitute values (for specific dates) from a second data frame to the first data frame

    - by user1665355
    I have two time series data frames: The first one: head(df1) : GMT MSCI ACWI DJGlbl Russell 1000 Russell Dev S&P GSCI Industrial S&P GSCI Precious 1999-03-01 -0.7000000 0.2000000 -0.1000000 -1.5000000 -1.0000000 -0.4000000 1999-03-02 -0.5035247 0.0998004 -0.7007007 -0.2030457 0.4040404 -0.3012048 1999-03-03 -0.2024291 0.2991027 0.0000000 -0.6103764 0.1006036 -0.1007049 1999-03-04 0.7099391 0.2982107 1.5120968 -0.1023541 0.5025126 0.4032258 1999-03-05 2.4169184 0.8919722 2.1847071 2.7663934 -1.2000000 0.0000000 1999-03-08 0.3933137 0.3929273 0.5830904 -0.0997009 -0.2024291 1.1044177 tail(df1) : GMT MSCI ACWI DJGlbl Russell 1000 Russell Dev S&P GSCI Industrial S&P GSCI Precious 2011-12-23 0.68241470 0.84790673 0.9441385 0.6116208 0.5822862 -0.2345300 2011-12-26 -0.05213764 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 2011-12-27 0.20865936 0.05254861 0.3117693 0.2431611 0.0000000 -0.7233273 2011-12-28 -0.62467465 -1.20798319 -1.1655012 -0.9702850 -2.0414381 -2.4043716 2011-12-29 0.52383447 0.47846890 0.8647799 0.5511329 -0.0933126 -1.2504666 2011-12-30 0.26055237 1.03174603 -0.4676539 1.2180268 1.9613948 1.7388017 The second one: head(df2) : GMT MSCI.ACWI DJGlbl Russell.1000 Russell.Dev S.P.GSCI.Industrial S.P.GSCI.Precious 1999-06-01 0.00000000 0.24438520 0.0000000 0 -0.88465521 0.008522842 1999-07-01 0.12630441 0.06755621 0.0000000 0 0.29394697 0.000000000 1999-08-02 0.07441812 0.18922829 0.0000000 0 0.02697299 -0.107155063 1999-09-01 -0.36952701 0.08684107 0.1117509 0 0.24520976 0.000000000 1999-10-01 0.00000000 0.00000000 0.0000000 0 0.00000000 1.941266205 1999-11-01 0.41879925 0.00000000 0.0000000 0 0.00000000 -0.197897901 tail(df2) : GMT MSCI.ACWI DJGlbl Russell.1000 Russell.Dev S.P.GSCI.Industrial S.P.GSCI.Precious 2011-07-01 0.00000000 0.0000000 0.0000000 0.0000000 0.00000000 -0.1141162 2011-08-01 0.00000000 0.0000000 0.0000000 0.0000000 0.02627347 0.0000000 2011-09-01 -0.02470873 0.2977585 -0.0911891 0.6367605 0.00000000 0.2830977 2011-10-03 0.42495188 0.0000000 0.4200743 -0.4420027 -0.41012646 0.0000000 2011-11-01 0.00000000 0.0000000 0.0000000 -0.6597739 0.00000000 0.0000000 2011-12-01 0.50273034 0.0000000 0.0000000 0.6476393 0.00000000 0.0000000 The first df cointains daily observations. The second df contains only the "first day of each month" forecasted values. I would like to substitute the values from the second df into the first one. In other words, the "first day of each month" values in the first df will be substituted for the "first day of each month" values from the second df. I tried to write an lapply loop that substitutes the values and was only trying to use match function. But I failed. I could not find the similar question at StackOverflow either... Greatful for any suggestions!

    Read the article

  • Piping SoX in Python - subprocess alternative?

    - by Cochise Ruhulessin
    I use SoX in an application. The application uses it to apply various operations on audiofiles, such as trimming. This works fine: from subprocess import Popen, PIPE kwargs = {'stdin': PIPE, 'stdout': PIPE, 'stderr': PIPE} pipe = Popen(['sox','-t','mp3','-', 'test.mp3','trim','0','15'], **kwargs) output, errors = pipe.communicate(input=open('test.mp3','rb').read()) if errors: raise RuntimeError(errors) This will cause problems on large files hower, since read() loads the complete file to memory; which is slow and may cause the pipes' buffer to overflow. A workaround exists: from subprocess import Popen, PIPE import tempfile import uuid import shutil import os kwargs = {'stdin': PIPE, 'stdout': PIPE, 'stderr': PIPE} tmp = os.path.join(tempfile.gettempdir(), uuid.uuid1().hex + '.mp3') pipe = Popen(['sox','test.mp3', tmp,'trim','0','15'], **kwargs) output, errors = pipe.communicate() if errors: raise RuntimeError(errors) shutil.copy2(tmp, 'test.mp3') os.remove(tmp) So the question stands as follows: Are there any alternatives to this approach, aside from writing a Python extension to the Sox C API?

    Read the article

  • Images won't load if they are of high size

    - by Fahim Parkar
    I have created web-application using JSF 2.0 and mysql. I am storing images in DB using MEDIUMBLOB. When I try to load image, I am able to see those images. However if the image size is big (1 MB or more), I can see half or 3/4th image on the browser. Any idea how to overcome this issue? Do I need to set any variable in JSF or MySQL? I know I should have saved the images over disk instead of DB, however this was client requirement. Client wanted to backup data and provide it to someone else and client don't want to backup DB and images also. Edit 1 Do I need to set any variables on mysql like query_cache. Edit 2 When I download same image and put below code it works perfectly. <h:graphicImage value="images/myImage4.png" width="50%" /> Edit 3 code is as below. <h:graphicImage value="DisplayImage?mainID=drawing" /> DisplayImage.java String imgLen = rs1.getString(1); int len = imgLen.length(); byte[] rb = new byte[len]; InputStream readImg = rs1.getBinaryStream(1); InputStream inputStream = readImg; int index = readImg.read(rb, 0, len); response.reset(); response.setHeader("Content-Length", String.valueOf(len)); response.setHeader("Content-disposition", "inline;filename=/file.png"); response.setContentType("image/png"); response.getOutputStream().write(rb, 0, len); response.getOutputStream().flush(); When I print len I get value as len=1548432

    Read the article

  • IOS-Fixed content in UIScrollview

    - by heaven
    I have a problem with UIScrollView and UILabel. I'm adding UILabel using addSubview inside UIScrollView, one UILabel on the top set Width: 3000 - height: 20; other UILabel on the left: set height: 1000 - width: 50; In the middle UISCrollView is here I wanna When scroll horizontal the UILabel on the top move to left or right (doesn't move to up or down) When scroll vertical the UILabel on the left move to up or down (doesn't move right or left)

    Read the article

  • How to expose MEX when I need the service to have NTLM authentication

    - by Ram Amos
    I'm developing a WCF service that is RESTful and SOAP, now both of them needs to be with NTLM authentication. I also want to expose a MEX endpoint so that others can easily reference the service and work with it. Now when I set IIS to require windows authentication I can use the REST service and make calls to the service succesfully, but when I want to reference the service with SVCUTIL it throws an error that it requires to be anonymous. Here's my web.config: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> <bindings> <basicHttpBinding> <binding name="basicHttpBinding" maxReceivedMessageSize="214748563" maxBufferSize="214748563" maxBufferPoolSize="214748563"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Ntlm"> </transport> </security> </binding> </basicHttpBinding> <webHttpBinding> <binding name="webHttpBinding" maxReceivedMessageSize="214748563" maxBufferSize="214748563" maxBufferPoolSize="214748563"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Ntlm"> </transport> </security> </binding> </webHttpBinding> <mexHttpBinding> <binding name="mexHttpBinding"></binding> </mexHttpBinding> </bindings> <standardEndpoints> <webHttpEndpoint> <standardEndpoint name="" automaticFormatSelectionEnabled="true" helpEnabled="True"> </standardEndpoint> </webHttpEndpoint> </standardEndpoints> <services> <service name="Intel.ResourceScheduler.Service" behaviorConfiguration="Meta"> <clear /> <endpoint address="soap" name="SOAP" binding="basicHttpBinding" contract="Intel.ResourceScheduler.Service.IResourceSchedulerService" listenUriMode="Explicit" /> <endpoint address="" name="rest" binding="webHttpBinding" behaviorConfiguration="REST" contract="Intel.ResourceScheduler.Service.IResourceSchedulerService" /> <endpoint address="mex" name="mex" binding="mexHttpBinding" behaviorConfiguration="" contract="IMetadataExchange" /> </service> </services> <behaviors> <endpointBehaviors> <behavior name="REST"> <webHttp /> </behavior> <behavior name="WCFBehavior"> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="Meta"> <serviceMetadata httpGetEnabled="true"/> </behavior> <behavior name="REST"> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> <behavior name="WCFBehavior"> <serviceMetadata httpGetEnabled="true"/> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> <behavior name=""> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true" /> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> Any help will be appreciated.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >