Search Results

Search found 20 results on 1 pages for 'shahzad mian'.

Page 1/1 | 1 

  • [Python] Tips for making a fraction calculator code more optimized (faster and using less memory)

    - by Logic Named Joe
    Hello Everyone, Basicly, what I need for the program to do is to act a as simple fraction calculator (for addition, subtraction, multiplication and division) for the a single line of input, for example: -input: 1/7 + 3/5 -output: 26/35 My initial code: import sys def euclid(numA, numB): while numB != 0: numRem = numA % numB numA = numB numB = numRem return numA for wejscie in sys.stdin: wyjscie = wejscie.split(' ') a, b = [int(x) for x in wyjscie[0].split("/")] c, d = [int(x) for x in wyjscie[2].split("/")] if wyjscie[1] == '+': licz = a * d + b * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) elif wyjscie[1] == '-': licz= a * d - b * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) elif wyjscie[1] == '*': licz= a * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) else: licz= a * d mian= b * c nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) Which I reduced to: import sys def euclid(numA, numB): while numB != 0: numRem = numA % numB numA = numB numB = numRem return numA for wejscie in sys.stdin: wyjscie = wejscie.split(' ') a, b = [int(x) for x in wyjscie[0].split("/")] c, d = [int(x) for x in wyjscie[2].split("/")] if wyjscie[1] == '+': print("/".join([str((a * d + b * c)/euclid(a * d + b * c, b * d)),str((b * d)/euclid(a * d + b * c, b * d))])) elif wyjscie[1] == '-': print("/".join([str((a * d - b * c)/euclid(a * d - b * c, b * d)),str((b * d)/euclid(a * d - b * c, b * d))])) elif wyjscie[1] == '*': print("/".join([str((a * c)/euclid(a * c, b * d)),str((b * d)/euclid(a * c, b * d))])) else: print("/".join([str((a * d)/euclid(a * d, b * c)),str((b * c)/euclid(a * d, b * c))])) Any advice on how to improve this futher is welcome. Edit: one more thing that I forgot to mention - the code can not make use of any libraries apart from sys.

    Read the article

  • cli commands not working asterisk on ubuntu

    - by Mian Khurram Ijaz
    hi guys today my first day on asterisk on ubuntu. I installed vmware and then ubuntu and then on ubuntu i am running asterisk. i started the asterisk server successfully by following a tutorial. After making few changes into the sip.conf i want to reload the sip.conf i issue the command sip reload and nothing happens neither the commands to restart the asterisk server work actually the commands do not exists can some please throw light or point to right direction. thanks

    Read the article

  • How to use join in EntityQuery,.. using RIA and Entities

    - by mian
    Hi i use the following patterh for fetching data using RIA objTestAppContext is an instance of LinqToEntitiesDomainService class EntityQuery query = from tmpTable in objTestAppContext.GteOrdrs() where tmpTable.orderID == d select tmpTable; Now scenerio is ,, that I also have a OrderDetail entity in EDMS which is attached to he Order as orderID in OrderDetails which is managed by the association set named as FK_orderdetals_orders. Please tell how can i use join in the "query"

    Read the article

  • Scala passing type parameters to object

    - by Shahzad Mian
    In Scala v 2.7.7 I have a file with class Something[T] extends Other { } object Something extends OtherConstructor[Something] { } This throws the error: class Something takes type parameters object Something extends OtherConstructor[Something] { However, I can't do this object Something[T] extends OtherConstructor[Something[T]] { } It throws an error: error: ';' expected but '[' found. Is it possible to send type parameters to object? Or should I change and simply use Otherconstructor

    Read the article

  • php regex replace slashes and spaces and hyphens

    - by Muhammad Shahzad
    I have fews combinations of strings that I need to bring in to one pattern, that is multiple spaces should be removed, double hyphens should be replaced with single hypen, and single space should be replaced with single hyphen. I have already tried this expression. $output = preg_replace( "/[^[:space:]a-z0-9]/e", "", $output ); $output = trim( $output ); $output = preg_replace( '/\s+/', '-', $output ); But this fails in few combinations. I need help in making all of these combinations to work perfectly: steel-black steel- black steel black I should also remove any of these as well "\r\n\t".

    Read the article

  • stop android emulator call

    - by Shahzad Younis
    I am working on an Android application, having functionality like voicemail. I am using BroadcastReceiver to get dialing events. I have to get the event "WHEN CALL IS UNANSWERED (not picked after few rings) FROM RECEIVER". I will do some actions on caller end against this event. I am using AVD emulator, and I do call from one instance to another instance and it calls perfectly, but the problem is: It continuously calls until I reject or accept the call. This way I cannot detect that "CALL IS UNANSWERED AFTER A NUMBER OF RINGS". So I want the Caller emulator to drop the call after a number of rings (if unanswered) like a normal phone. I can do it (drop the call after some time) by writing some code, but I need the natural functionality of phone in the emulator. Can anyone please guide me? Is there any settings in the emulator? Or something else? The code is shown below in case it helps: public class MyPhoneReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { String state = "my call state = " + extras.getString(TelephonyManager.EXTRA_STATE); Log.w("DEBUG", state); } }

    Read the article

  • High level programming logic, design, pattern

    - by Muhammad Shahzad
    I have been doing programming from last 7 years, getting better and better, but still i think that am lacking something. I have been doing work in JOOMLA, MAGENTO, WP, Custom PHP, Opencart, laravel, codeignitor. Sometimes i need to design logic for a huge database application, in the applications we need nesting loops and queries, although i follow OOPS standards, ORM etc, still i feel i need more robust coding designs. I need to know how can i improve these things, so that code remain neat, efficient and faster. Also how big webapps like facebook twitter tests there code speed? How high level programmers choose design patterns. If you can help me find something useful with examples?

    Read the article

  • Forming a SOAP request message through WSDL

    - by Shahzad
    I'm very new to webservices. I'm trying to figure out how I can formulate a request message (and determine what the response message) would be based on the wsdl description that I have. This is from a third party web service. The WSDL description that I have access to gives me a bunch of information like <types> <message> <operation> etc. But in the examples that I've seen online, it's showing the request mesage within the "soap:envelope" tag. What am I missing? Eventually I'd like to be able to call this webservice using JQuery. But I can't even figure out how to formulate the request message let alone make an ajax call to it. any help would be appreciated.

    Read the article

  • different behavior when using re.finditer and re.match.

    - by Shahzad
    Hi, I'm working on a regex to to collect some values from a page through some script. I'm using re.match in condition but it returns false but if i use finditer it returns true and body of condition is executed. i tested that regex in my own built tester and it's working there but not in script. here is sample script. result = [] RE_Add0 = re.compile("\d{5}(?:(?:-| |)\d{4})?", re.IGNORECASE) each = ''Expiration Date:\n05/31/1996\nBusiness Address: 23901 CALABASAS ROAD #2000 CALABASAS, CA 91302\n' if RE_Add0.match(each): result0 = RE_Add0.match(each).group(0) print result0 if len(result0) < 100: result.append(result0) else: print 'Address ignore' else: None

    Read the article

  • Determining if you&rsquo;re running on the build server with MSBuild &ndash; Easy way

    - by ParadigmShift
    When you're customizing MSBuild in building a visual studio project, it often becomes important to determine if the build is running on the build server or your development environment. This information can change the way you set up path variables and other Conditional tasks.I've found many different answers online. It seems like they all only worked under certain conditions, so none of them were guaranteed to be consistent.So here's the simplest way I've found that has not failed me yet. <PropertyGroup> <!-- Determine if the current build is running on the build server --> <IsBuildServer>false</IsBuildServer> <IsBuildServer Condition="'$(BuildUri)' != ''">true</IsBuildServer> </PropertyGroup>   Shahzad Qureshi is a Software Engineer and Consultant in Salt Lake City, Utah, USAHis certifications include:Microsoft Certified System Engineer 3CX Certified Partner Global Information Assurance Certification – Secure Software Programmer – .NETHe is the owner of Utah VoIP Store at www.UtahVoIPStore.com and SWS Development at www.swsdev.com and publishes windows apps under the name Blue Voice.

    Read the article

  • C# beginner help

    - by ThickBook
    Can you help in this example? I am a beginner. Thanks using System; class Program { public static void Mian(string[] args) { Console.Write("Your Name?: "); string name = Console.Read(); Console.WriteLine("Welcome {0}", name); } }

    Read the article

  • How to handle JSON response using SBJSON iPhone?

    - by Jay Mehta
    I am receiving the below response from my web service? Can any one has idea how to handle it using SBJSON? { "match_details" : { "score" : 86-1 "over" : 1.1 "runrate" : 73.71 "team_name" : England "short_name" : ENG "extra_run" : 50 } "players" : { "key_0" : { "is_out" : 2 "runs" : 4 "balls" : 2 "four" : 1 "six" : 0 "batsman_name" : Ajmal Shahzad * "wicket_info" : not out } "key_1" : { "is_out" : 1 "runs" : 12 "balls" : 6 "four" : 2 "six" : 0 "batsman_name" : Andrew Strauss "wicket_info" : c. Kevin b.Kevin } "key_2" : { "is_out" : 2 "runs" : 20 "balls" : 7 "four" : 4 "six" : 0 "batsman_name" : Chris Tremlett * "wicket_info" : not out } } "fow" : { "0" : 40-1 } } I have done something like this:

    Read the article

  • Tab Sweep: FacesMessage enhancements, Look up thread pool resources, JQuery/JSF integration, Galleria, ...

    - by arungupta
    Recent Tips and News on Java, Java EE 6, GlassFish & more : • Fixing remote GlassFish server errors on NetBeans (Igor Cardoso) • FacesMessage Enhancements (PrimeFaces) • How to create and look up thread pool resource in GlassFish (javahowto) • Jersey 1.12 is released (Jakub Podlesak) • VisualVM problem connecting to monitor Glassfish (Raymond Reid) • JSF 2.0 JQuery-JSF Integration (John Yeary) • JDBC-ODBC Bridge Example (John Yeary) • The Java EE 6 Example - Gracefully dealing with Errors in Galleria - Part 6 (Markus Eisele) • Logout functionality in Java web applications (JavaOnly) • LDAP PASSWORD POLICIES AND JAVAEE (Ricky's Hodgepodge) • Java User Groups Promote Java Education (java.net Editor's Daily Blog) • JavaEE Revisits Design Patterns: Aspects (Interceptor) (Developer Chronicles) • Java EE 6 Hand-on Workshop @ IIUI (Shahzad Badar) • javaee6-crud-example (Arjan Tims) • Sample CRUD application with JSF and RichFaces (Mark van der Tol) • 5 useful methods JSF developers should know (Java Code Geeks) Here are some tweets from this week ... Almost 9000 Parleys views at the #JavaEE6 #Devoxx talk I did with @BertErtman. Not even made available for free yet! #JavaEE6 is hot :-) Sent three proposals for Øredev, about #JavaEE6, #OSGi and a case study about Leren-op-Maat (OSGi in the cloud) together with @m4rr5 [blog] The Java EE 6 #Example - Gracefully dealing with #Errors in #Galleria - Part 6 http://t.co/Drg1EQvf #javaee6 Tomorrow, there is a session about Java EE6 #javaee6 at islamia university #bahawalpur under #pakijug.about 150 students going to attend it.

    Read the article

  • Creating a Yes/No MessageBox in a NuGet install/uninstall script

    - by ParadigmShift
    Sometimes getting a little feedback during the install/uninstall process of a NuGet package could be really useful. Instead of accounting for all possible ways to install your NuGet package for every user, you can simplify the installation by clarifying with the user what they want. This example shows how to generate a windows yes/no message box to get input from the user in the PowerShell install or uninstall script. We’ll use the prompt on the uninstall to confirm if the user wants to delete a custom setting that the initial install placed in their configuration.  Obviously you could use the prompt in any way you want. The objects of the message box are generated similar to the controls in the code behind of a WinForm. At the beginning of your script enter this: param($installPath, $toolsPath, $package, $project)   # Set up path variables $solutionDir = Get-SolutionDir $projectName = (Get-Project).ProjectName $projectPath = Join-Path $solutionDir $projectName   ################################################################################################ # WinForm generation for prompt ################################################################################################ function Ask-Delete-Custom-Settings { [void][reflection.assembly]::loadwithpartialname("System.Windows.Forms") [Void][reflection.assembly]::loadwithpartialname("System.Drawing")   $title = "Package Uninstall" $message = "Delete the customized settings?" #Create form and controls $form1 = New-Object System.Windows.Forms.Form $label1 = New-Object System.Windows.Forms.Label $btnYes = New-Object System.Windows.Forms.Button $btnNo = New-Object System.Windows.Forms.Button   #Set properties of controls and form ############ # label1 # ############ $label1.Location = New-Object System.Drawing.Point(12,9) $label1.Name = "label1" $label1.Size = New-Object System.Drawing.Size(254,17) $label1.TabIndex = 0 $label1.Text = $message   ############# # btnYes # ############# $btnYes.Location = New-Object System.Drawing.Point(156,45) $btnYes.Name = "btnYes" $btnYes.Size = New-Object System.Drawing.Size(48,25) $btnYes.TabIndex = 1 $btnYes.Text = "Yes"   ########### # btnNo # ########### $btnNo.Location = New-Object System.Drawing.Point(210,45) $btnNo.Name = "btnNo" $btnNo.Size = New-Object System.Drawing.Size(48,25) $btnNo.TabIndex = 2 $btnNo.Text = "No"   ########### # form1 # ########### $form1.ClientSize = New-Object System.Drawing.Size(281,86) $form1.Controls.Add($label1) $form1.Controls.Add($btnYes) $form1.Controls.Add($btnNo) $form1.Name = "Form1" $form1.Text = $title #Event Handler $btnYes.add_Click({btnYes_Click}) $btnNo.add_Click({btnNo_Click}) return $form1.ShowDialog() } function btnYes_Click { #6 = Yes $form1.DialogResult = 6 } function btnNo_Click { #7 = No $form1.DialogResult = 7 } ################################################################################################ This has also wired up the click events to the form.  This is all it takes to create the message box. Now we have to actually use the message box and get the user’s response or this is all pointless.  We’ll then delete the section of the application/web configuration called <Custom.Settings> [xml] $configXmlContent = Get-Content $configFile   Write-Host "Please respond to the question in the Dialog Box." $dialogResult = Ask-Delete-Custom-Settings #6 = Yes #7 = No Write-Host "dialogResult = $dialogResult" if ($dialogResult.ToString() -eq "Yes") { Write-Host "Deleting customized settings" $customSettingsNode = $configXmlContent.configuration.Item("Custom.Settings") $configXmlContent.configuration.RemoveChild($customSettingsNode) $configXmlContent.Save($configFile) } if ($dialogResult.ToString() -eq "No") { Write-Host "Do not delete customized settings" } The part where I check if ($dialog.Result.ToString() –eq “Yes”) could just as easily check the value for either 6 or 7 (Yes or No).  I just personally decided I liked this way better.   Shahzad Qureshi is a Software Engineer and Consultant in Salt Lake City, Utah, USA His certifications include: Microsoft Certified System Engineer 3CX Certified Partner Global Information Assurance Certification – Secure Software Programmer – .NET He is the owner of Utah VoIP Store at http://www.utahvoipstore.com/ and SWS Development at http://www.swsdev.com/ and publishes windows apps under the name Blue Voice.

    Read the article

  • how to find by date from timestamp column in JPA criteria

    - by Kre Toni
    I want to find a record by date. In entity and database table datatype is timestamp. I used Oracle database. @Entity public class Request implements Serializable { @Id private String id; @Version private long version; @Temporal(TemporalType.TIMESTAMP) @Column(name = "CREATION_DATE") private Date creationDate; public Request() { } public Request(String id, Date creationDate) { setId(id); setCreationDate(creationDate); } public String getId() { return id; } public void setId(String id) { this.id = id; } public long getVersion() { return version; } public void setVersion(long version) { this.version = version; } public Date getCreationDate() { return creationDate; } public void setCreationDate(Date creationDate) { this.creationDate = creationDate; } } in mian method public static void main(String[] args) { RequestTestCase requestTestCase = new RequestTestCase(); EntityManager em = Persistence.createEntityManagerFactory("Criteria").createEntityManager(); em.getTransaction().begin(); em.persist(new Request("005",new Date())); em.getTransaction().commit(); Query q = em.createQuery("SELECT r FROM Request r WHERE r.creationDate = :creationDate",Request.class); q.setParameter("creationDate",new GregorianCalendar(2012,12,5).getTime()); Request r = (Request)q.getSingleResult(); System.out.println(r.getCreationDate()); } in oracle database record is ID CREATION_DATE VERSION 006 05-DEC-12 05.34.39.200000 PM 1 Exception is Exception in thread "main" javax.persistence.NoResultException: getSingleResult() did not retrieve any entities. at org.eclipse.persistence.internal.jpa.EJBQueryImpl.throwNoResultException(EJBQueryImpl.java:1246) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:750) at com.ktrsn.RequestTestCase.main(RequestTestCase.java:29)

    Read the article

1