instruction
stringlengths
71
95.1k
I was looking at this website: http://www.devshed.com/c/a/MySQL/Creating-User-Models-in-PHP-and-MySQL/1/ and http://www.devshed.com/c/a/MySQL/Creating-User-Models-in-PHP-and-MySQL/2/ In the first one they have methods such as: /** * Perform a SELECT statement */ public function select($table, $where = ''...
This might be a dumb question for you advanced developers. Below is a script on my own website that I want to modify, in order to avoid declaring same variables in each function. I want to avoid declaring variables in the main script structure. Below code works, still wanted to know if there is a more elegant way to do...
I have built a JavaScript PNG sequence engine that allows for playing, pausing and stopping and a time change event. I am asking for genuine opinions if the code is actually good. Its ONLY for the iDevice range (not for desktop browsers or anything) and here is the code and a link to the gist if you wanted to edit it f...
I wrote this downloadContent() function. Is there some other way to download the content faster? private string downloadContent() { try { WebRequest request = WebRequest.Create(testingUrl); request.Proxy = null; request.Method = "GET"; response = request.GetResponse(); S...
I am trying to use a map as a way to implement an object factory. In Python it is possible to store a class type in a map, and use it later to create objects from that type: class Foo: # ... class Bar: # ... factory_map = { 'foo' : Foo, 'bar' : Bar } foo_object = factory_map['foo']() I am not aware of a simi...
My application hangs up on IE and mobile browsers when these functions are fired. Is there anything that stands out as being obviously performance-killing? $this.find('input.bundle-check').live('change', function() { var $box = $(this), ntn = $box.data().ntn, price = $box.data().price, savings = $box.da...
I made the following class to wrap mysqli for PHP using prepared statements. It seems to work well, but I was hoping to get opinions (on overall structure, performance, usage, etc.). Thanks for the insight. <?php class database { private $conn, $stmt, $arr, $eof=true, $error; public function __construct($host,...
It's an interview question, I was asked to compare 2 strings, and the number in the string are evaluated to integers when comparing. I can use C/C++ and can not use stl or stdlib. Some test cases are showed in the code. I submitted the code below but failed. The interviewer said that the code is not clean enough. Can ...
I was selected for the third round of MS internships for third years. We were surprisingly asked a very easy question: “Make a program that counts the number of times the WORD "a" or "A" occurs”. I wrote the code below and was rejected from attending the final interview. What is wrong with my code? Please tell me how ...
At work I've recently been tasked with creating an XSLT to transform some XML as it is being generated on a scanner. The point being to disregard some pages that we are not interested in for further processing, and this is what I've come up with: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version...
I was asked to create a TODO manager using JavaScript and CSS. I did not get a good review on the code nor specific comments on how to improve it. Can someone here help by give me tips on what is bad with my implementation? <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js...
The way I am using this method assumes all data is byte-aligned, so I don't really care about the rest of the bits. This method is written in an extension of BinaryReader which provides more methods when I'm reading binary data from files. The BinaryReader provided does not appear to support reading bits. Is there a be...
I want to check if all items of a list meet a set of criteria: bool AreValid(list<string> vals) { bool allValid=true; foreach(string val in vals) { if(!condition1) ... allValid=false; else if(!condition2) ... allValid=false; } return allValid; } ...
This legendary C++ delegate article can be easily converted into C++11, without the need for fancy preprocessor magic in the original. I'd like to know if I got all the necessary C++11 nuances right. Suggestions? #pragma once #ifndef DELEGATE_HPP # define DELEGATE_HPP #include <cassert> #include <memory> #include <n...
What needs to be corrected, added, or subtracted here? class mutexLocker { private: /* Declaration of a Mutex variable `mutexA`. */ pthread_mutex_t &mutexA; /* `mutexStatus` holds the return value of the function`pthread_mutex_lock `. This value has to be returned to the callee so we need to prese...
I'm just learning the basics of animating with Javascript and HTML5. I'm trying to create this scrolling logos element for my site, and I'm pretty sure that my code is very inefficient. Can anyone give me any tips on how to do a better job of what I'm trying to do here? http://jsbin.com/anagug/1/edit Thanks! EDIT: Here...
I'm making requests to Parse.com to 3 different objects that are needed to render a View. I'd like to know what's the general/best approach in cases like these in which there are multiple requests before actually handling the data. Code: var Parse = require('parse-api').Parse; var parse = new Parse(); expo...
I have many <spans>s which need to group to change opacity after hover. All of them need to have unique IDs. Is there a way to combine all these hover functions to one function? jQuery //09 $('#c_09_241a, #c_09_241b, #c_09_241c, #c_09_241d').hover( function() { $('#c_09_241a, #c_09_241b, #...
function check_itv(key) { if (key.length){ if(key=="left"){ left_itv = setInterval(left,100); check_left= false; check_right=true; check_up=true; check_down=true; clearInterval(right_itv); clearInterval(down_itv); clearInterval(up_itv); } if...
This is one idea of implementation: Array.prototype.unique = function () { unique_array = []; for (var i = 0, l = this.length; i < l; i++) { if(unique_array.indexOf(this[i]) == -1){ unique_array.push(this[i]); } } return unique_array; } This version uses Object.keys which is a ECMAScript 5 only...
I have the following code, which acts like a turntable and plays Sgt. Pepper when you load the page. This works only in Safari (I suppose I can delete the FF parts then), so I'm wondering how I can make the code better. The reason for there being a first, last, and main class on most div's is because records start out ...
I have a central domain assembly which contains various rich domain models. Lots of business logic, etc. To keep this example simple, here's probably the simplest one: public class Location { private int _id; public int ID { get { return _id; } private set { if (value =...
This is a slightly specialised A* algorithm, basically it allows you to search to and from disabled nodes. It's for a game and we the entities spawn in houses and go into them. The rest of the search behaves normally, it doesn't traverse any disabled nodes in between the start and end points. NavData is a class which h...
I have created a class for reading data from an Excel sheet and holding on the variable. I am not sure if my code is optimized, meaning I will be reading heavily from Excel. Is there a room to further optimized this code? I will be using this class heaving in my code, and I wanted to get some opinions/feedback. I wil...
I'm working an example to list directory contents. When I process each directory the code works. Now I'd like to put both directories in an array and iterate the array. I get an error when I declare 'dir_c' because I've not given it a directory name which will change. def outfile = new File('Y:/TEMP/dirlist.txt') d...
I need to solve this problem in Python 3 (within 3 sec): A is a given (NxM) rectangle, filled with characters "a" to "z". Start from A[1][1] to A[N][M] collect all character which is only one in its row and column, print them as a string. Input: \$N\$, \$M\$ in first line (number of row and column \$1 \le N\$, \$M...
I have to display a menu where some buttons have dropdown submenus and show if the current button is active or not and put a CSS class to it for each of the two situations (or in both). <?php $menus_array = array( array('item1', false), array('item2', true), array('item3', false) ); $active_item = 'item2'...
I had previously asked this question on SO. The answer pointed me towards using the task parallel library for multiple parallel downloads. I'm not actually utilizing this exact code, but it got me to rethink my design. The one open issue that wasn't really addressed (and I didn't ask it), cancelling the a local WebCl...
I am trying to write a simple (trivial?) "compare" program for Eclipse preferences files. Eclipse preferences files take more of less this form: # optional comment line /a/sequence/of/path/elements=string /another/sequence/of/path/elements=42 # ... (possibly repeated) Let's call the path sequences "keys" and what fo...
This is a solution to the problem: "The Broken Pedometer" on the UVA online judge. (Note: I can not use anything beyond what is in g++ 4.6 which is what is used for the competition I'm training for.) Algorithmic approach (pretty simple, but fast enough, not needed to understand to comment on the code): possible_led_re...
I created a Matrix class. I tested it and it seems to work. Can someone tell me if this class is good? Can I improve it? Can I use more move semantics (where)? What do I have to modify? Are there some logic/programming errors? #ifndef MATRIX_H #define MATRIX_H #include <iostream> #include <initializer_list> #inclu...
I've created the below script and would appreciate any feedback. # svn directory ^/tags/release/ # 1/ # 2/ # 3/ # 4/ # usage: svnnextrelease fixes email formatting # generated line: svn cp ^/trunk ^/tags/release/# -m'fixes email formatting' function svnnextrelease(){ NextVersion=$(svn ls ^/tags/release | tail -n 1 |...
I am never to sure when it comes to ifstream and reading lines. I am often confused with the good(), bad(), eof() and so on. Could anyone tell me if I am doing it right? int parseLine(std::ifstream & _file) { while( std::getline( _file, line, '\n' ).good() && !_file.eof() ) { // some treatment } return...
I've noticed a tendency towards two styles of conditionally executing methods: Conditional before the call def foo(thing) puts thing end if thing foo(thing) end Conditional within the call def foo(thing) return unless thing puts thing end foo(thing) Pros of 1: Method is concise and easier to read Method ...
I'm having trouble thinking of a good name for the following extension method: public static IEnumerable<T> TrimOrExpand<T>(this T[] items, int desiredCount) { var ratio = (double)items.Length / desiredCount; for (int i = 0; i < desiredCount; i++) yield return items[Convert.ToInt32(i * ratio)]; } The t...
A prospective employer asked me for a code sample, but unfortunately this is the best project I've done, most of my other programs were very short (~100 lines). Should I send this in/try to refactor it? Or would it be best to send a shorter sample, or quickly write a new project? #!/usr/bin/python import curses impo...
I would really appreciate any feedback on the back-end of my mobile application. I tried to keep an MVC pattern, where I considered the app to be my view. Perhaps an REST framework would have been good to use, but for now I am not attempting cross domain requests. Controller The Group Controller, that receives JSON req...
This is a function that checks that when users register into the site, they only create one single account per email. The little twist is that all emails in the DB are hashed with unique salts (=Input2). Because hashing the new mail input with all unique salts (=STEP 2) will be horribly slow, I keep a "diggest" version...
This is part of the code from a spectral subtraction algorithm. I'm trying to optimize it for Android. Matlab code: function Seg=segment(signal,W,SP,Window) % SEGMENT chops a signal to overlapping windowed segments % A= SEGMENT(X,W,SP,WIN) returns a matrix which its columns are segmented % and windowed frames of the ...
I have the two functions that calculate whether or not a given coordinate (x, y) is a diagonal or anti-diagonal of another coordinate that is a power of 2. In other words if (x+/-k, y+/-k) == (cx, cy) where cx or cy is a power of 2, then the binary representation of (x+/-k, y+/-k) follows known patterns. In case of mi...
Fairly new to jquery, can i improve this code please? HTML <a href="#" class="dialog" id="login">login</a> Javascript function Dialog() { // Event handler for a dialog click. $('a.dialog').click(function () { var dialog = $("#" + this.id + "_dialog"); // Bind the hide functions here, as the ...
Here's the exercise: Given a string of X's and O's and a maximum number of swaps, determine the longest possible sequence of X's after swaps. Here's my solution using itertools. import itertools as iter def swaps_gen(s): '''This generator yields all the possible outcome of applying one swap to the input st...
I wrote a program to take a list of letters and from every permutation of them and check that against the dictionary and print out valid words. The constraints are that there is a control letter which means that letter must be in the word, and you can't repeat any letters. Everything works, but the running time is way...
I was looking for a PHP class to handle all database operations (MySQL) and came across the following class. Someone please help me telling if this uses Prepared Statements correctly to make my web app safe from SQL injection. class db extends PDO { private $error; private $sql; private $bind; private $errorCallbackFun...
I created script that generates maze or some kind of dungeons that looks like this: http://s13.postimage.org/4uify3jxj/blocks.jpg I have problem with optimize, because when I've tried to add blockade to not overwrite existing blocks, script is executing most of times more than 60s. So... any ideas how can I optimize th...
I have written an implementation of the observer pattern that allows messages to be passed to listeners in what would normally be the notify() method. For example a subscriber sub-class might look like the pseudo-code below, where Message is a simple class that can be subclassed and made to contain value objects or oth...
I was hoping I could get some of you to look over a program I wrote. I am just beginning to learn about Python (for the last month or so). Therefore, I may not be aware of techniques that would make this program better. Currently I'm studying Python 2.7. Any advice or suggestions you could provide would be appreciated....
This code works fine but is way to bulky for my liking. Is there a better way to go about filtering classes and adding a style to them? $('.leftNav li a').click(function() { $('.leftNav li a').removeClass('active'); $(this).addClass('active'); $('span.overlay').css('opac...
Base functionality: Reading a CSV file and inserting in database after replacing values with web macro. Reading values from CSV @ first header information NO,NAME next to that, then read one by one values from CSV and put into web macro context like below: context.put("1","RAJARAJAN") Web macro will replace $(NO) ==>...
It's based on the Hardy-Weinberg formula. I used the easygui module because I don't fully understand events in Tkinter yet. It's my first relatively useful script so any constructive criticism would be helpful. from __future__ import division import sys from easygui import * def calculate_frequency(recessive,total): ...
I'm trying to clean up this function to target individual #hdid. I'm also using $this, but with no success. <script> $(function() { $(".delete").click(function() { $('#load').fadeIn(); var commentContainer = $(this).parent(); // var id = $this.(".delet...
The goal is to solve an ODE numerically with forward Euler method. The programs works well (numerical solution really near analytical one). The problem I see is that the Euler scheme don't jump to eyes, probably because of push_back() functions. This approach is the only one I found to let the time of simulation (numbe...
I wrote the following code to test a score-keeping class. The idea was to keep score of a game such that the score was kept across multiple classes and methods. I'm looking for any input on being more efficient, more 'pythonic' and/or just better. import os class Foo(): def __init__(self): self.stored_en...
I have been trying to optimize the filtering process of a Collection<Alert> based on the DateTime GeneratedOn property of Alert class. Below is the code block which filters the List by taking in From Date and To Date. if (this.Alerts != null) { var fromDt = Convert.ToDateTime(this.FromDateAlert.ToSh...
I have written a parser function that returns a JQuery Promise. You can see from the code that this is the top level parser and it delegates out to two other more specific parsers. At the minute it feels a little scattered about with the promise being rejected and resolved all over the place. perhaps it would be bett...
I have two code examples that I wrote for best practices encrypting a string that I'm looking for feedback both in terms of best practices and security. They are both using authenticated encryption. One is using the bouncy castle API to do AES-GCMand the other is for the limitation of only using the built in .NET API ...
I want to search a DB table and display the records in a gridview below is my stored proc create procedure search @Firstname varchar (50), @Lastname varchar (50), @Gender varchar (10), @Maritalstatus varchar (20), @Height varchar (30), @Complexion varchar (10), @...
Let's say I want to parse audio track information into two variables like this: '2/15' -> track = 2, num_tracks = 15 '7' -> track = 7, num_tracks = None What's an elegant way to do this in Python? For example: track, num_tracks = track_info.split('/') This works for the first format, but not for the second, raising ...
I cannot quite see all the advantages of OOP PHP. I have already started translating some procedural functions into object oriented. How is the second code better than the first one? Is there anything I am missing? Could it be improved? It is surely a newbie question but I'm starting now with the Object Oriented aspect...
I'm working on a battery indicator feature in my app, and I was wondering if there is a better way than what I am doing to check what image should be displayed when. I am currently using if statements, but I was wondering if case statements would be a better option. - (void)observeValueForKeyPath:(NSString *)keyPath o...
What would be the best (performance, memory wise) to achieve a clean way to create a class or some way to properly structure the code, that shares 2 variables (req, res) which have a decent object size. And yes, for those who use Node.js it are the req and res variables, but it is irrelevant. This is what I tried so fa...
I have the following using statement, used specifically for the purpose of archiving content in SharePoint libraries. In this statement my objects are disposed in two places: finally { web.Dispose(); site.Dispose(); } and at the termination of my using statement. The full using statement is: using (var site = ...
Okay, So I have this method I made that searches a 2d array of user input column length and row length comprised of integers. The method is suppose to find 4 alike numbers in rows, columns, and both major and minor diagonals throughout the entire array. The array can be as large as the user would like. My method works,...
While preparing an automated process to manipulate files, I've made the following function to check for the base directory and sub-directories presence, as to allow or deny the remaining code to be executed: /* Check Directories * * Confirm that the necessary directories exist, and if not, * tries to create them. *...
I have been trying to get the problem Quadrant Queries correct for a while now. Although my approach is an optimal one, I am getting a TLE on 3 test cases. Please help me optimize my approach so that I can pass all test cases for the problem. #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm...
I was looking into removing multiple inputs and selects at once using jQuery, but I couldn't find a solution, so I ended up with the following code: $(function() { $('a.add').click(function(evt) { //clone lists //is there any way to simplify this part --begin-- $('#s0 option').clone().appendTo('#s'+obj);...
I have a little chain of JQuery promises. My problem is at each stage I want to notify my progress to the user, keep them in the loop (Perhaps using .notify somehow?) What I've eneded up with is this bizarre mess of callbacks and promises. It works but I'm quite certain there is a neater, more logical way to do this....
I have seven checkboxes on a data maintenance WinForm, which indicate the days of the week that are "valid" for a particular operation to be performed. These "map" to a list of DayOfWeek enum values on the backing domain object; if the value is present in the list, the box should be checked, otherwise not. Any combinat...
This is a pet project :) I have hundreds of playlist files .m3u whose many entries have a wrong path. I'd like to fix them programmatically. Suppose one of my .m3U contains the following entry: z:\wrong-folder\Michael Jackson - Thriller.mp3 The file is stored in: G:\my-collection-of-mp3\any-folder\Michael Jackson - Th...
So I had this idea; what if I could decorate my Enum values with an attribute that cross-references a "default" value of another Enum that should be used when a variable of the current Enum type has this value? The desired usage would look like: public enum MyEnum { Value1, Value2, Value3, } public enum Co...
I have a simple class inheritance in JS: var Class = function(){}; Class.extend = function(){ var Extended = function(constructor){ function extend_obj(destination, source) { for(var property in source){ if(typeof source[property] === "object" && source[property] !== null && d...
Below is the code for a compiler I created for a language called Jack. This compiler is one of the projects for the book "The Elements of Computing Systems" (http://www1.idc.ac.il/tecs/plan.html) where you build an entire computing system from the ground up. Anyway, what this compiler does is translate code from a high...
I created the following code to solve a simple ODE. It is clear enough? Is it efficient code? I really want to read opinions because I want to make all my exercise solutions the same way (same structure of the program), so I need to make sure that this code is really clear and efficient. #include <iostream> #include <f...
In the code below, does not clearing or setting the local variable completed to null create the potential for a memory leak? private Vector<Element> elements; private void update() { Vector<Element> completed = new Vector<Element>(); for( Element e : elements ) { if( e.isComplete() ) { ...
I have a helper method to clean up a string and remove pieces that I will be generating again. (defined by the "SpecialKey" Constants) but I've never been real happy with the code. Although I find it easy to read adding more keys doesn't always seem so clean. protected static System.String[] GetStringParts(System.S...
I've got a NumericUpDown control for each denomination of money and all of the events run the exact same code save for a single line so I'm trying to condense them into 1 event. I was originally going to use a switch but you can't switch on a non-value object so I just did an if tree. Is there a better way to do this? ...
I have two methods here that does the same thing: get the user input and validate them. If they enter a letter, the program will prompt them again to enter a number. |After that, if it's a number it will compare it to the bound given by the program or the user. It is working fine, but can anybody help me refactor this...
I am writing a script to count the number of rows in a textarea, and as it will be called on every keypress I want to make sure it runs as fast as possible. I'm not aiming for a general solution: we can assume that the textarea has a monospace font and enough horizontal space for exactly 80 characters. I've probably so...
I'm writing a simulator for Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life) in C++ and I'm trying to make the code as idiomatic as possible. The central object is a double array to represent the board: typedef vector<vector<bool> > Board; My main method has a Board b as a local variable, a...
This is my first implementation of MongoDB, much much more to come. This sheds light on some things like how I've structured my collection. I hope to gain feedback and insight from the community on best practices as well as do's and don'ts. Givens I have a website with multiple apps. Each user can at one point signup ...
SQL: CREATE FUNCTION dbo.fnRandomForeNames () RETURNS VARCHAR(50) AS BEGIN RETURN ( SELECT TOP 1 [FirstName] FROM [tmp_ForeNames] ORDER BY (SELECT new_id from GetNewID) ) END GO Similar functions for dbo.fnRandomSurNames() etc. UPDATE Table1 SET firstname = dbo.fnRandomFo...
I'm starting Rails and Ruby for a short time. But I try to make it the cleanest way I can. So, in an attempt to clean my view, I try to custom my FormBuilder: # /config/initializers/custom_form_builder.rb class ActionView::Helpers::FormBuilder # My test form function def test label return "Whatever I want ...
I am using the following code to compare 2 images: HTML (for example use only): <canvas id="gViewCanvas"></canvas> <img id="image1" src="image1.png" /> <img id="image2" src="image2.png" /> Javascript: var gOldImage = document.getElementById("image1"); var gScreenImage = document.getElementById("image2"); var gViewCan...
I have a List of a custom structure (myStruct) which has two ranges stored in it. I'm trying to write a function where I can figure out if a range is completely enclosed in any of the ranges. Is this optimal and if not how can I improve it in terms of speed and memory efficiency? class myStruct { private int start...
When git runs my post-receive hook, I'd like it to run all the scripts in the subdirectory post-receive.d. My script is as follows #!/bin/bash SOURCE="${BASH_SOURCE[0]}" DIR="$( dirname "$SOURCE" )" for SCRIPT in $DIR/post-receive.d/* do if [ -f "$SCRIPT" -a -x "$SCRIPT" ] then "$SCRIPT" fi done Source: ht...
The domain model of my application revolves around movies. Use case: We have a movie for which only one title (in one country) is known and we want to know titles of this movie in other countries. To get that information, we call external movie repositories. The Movie class has a map of titles in countries. It also has...
String fileId = "CPP420.A2_2012072416244467745"; String reg1 = "CPP350"; String reg2 = "CPP420.A1"; String reg3 = "CPP420.A2"; String country = ""; if(fileId.startsWith(reg1)) { country = "CA"; } else if(fileId.startsWith(reg2)) { country = "US"; ...
I have recently started a project of SIMD libraries development for C++ on FASM for x86-64 Linux. I would be glad to hear any opinion or feedback about the project, cleanness of the code and documentation. Here is the project's web site on SourceForge. This is just a fragment of code (addition of two vectors) and some...
I neglected java.nio package in the past and now I am wondering if this is the best way to copy everything from a Readable to an OutputStream: public static void copy(@Nonnull Readable src, @WillNotClose @Nonnull OutputStream dest, @Nullable Charset targetCharset) throws IOException { targetCharset = safeCharset(ta...
I'm looking for code correctness and improvements for the following code. It's my first step into class based programing. What the class does, is simply to read a directory (path is passed as constructor argument) and find all sub directories matched by the search pattern. Then it returns a random directory (strimg) ba...
I have the following code to split an address string in T-SQL. Excepting the unit number, which is already in its own field, it would affect too much of the application to split the address into different database fields. It's a bit of a long story, but it's also not possible to make it a parameterized query, or to wri...
I've seen few ways of processing forms with PHP. Whenever I am working with a form, I typically have two files: one for displaying the information (e.g. form.php) and the other for processing information (e.g. process_form.php). The latter uses sessions and simply redirects to the appropriate page depending on if the i...
As an exercise on GADTs I wrote a type-safe implementation of AA trees. I'm quite happy that the AANode data type correctly grasps the properties of the tree. Just from the type it can be concluded that the trees has the balancing property. But there I things I'd like to improve, but I didn't find a nice solution for ...
I have a jQuery script that checks for the strength of a password. The code looks like this (with more more of those "blocks"): if(passwordLC && lessThan12Password) { $('.passwordStrenght').animate({width:'75px',height:'5px'},200).show(); $('.passwordStrenght').css('background-color',red); $('#password').cs...
Can anyone review this? setInterval(function() { var days_array = [31,29,31,30,31,30,31,31,30,31,30,31]; var m = randNum(12); var m_limit = days_array[m-1]; var d = randNum(m_limit); $("code").html("day = "+d+"<br>month = "+m); },1000); function randNum(limit){var r=Math.floor(Math.random()*limit)+1;return r;} jsFiddl...
I know this code is pretty awful, but, by any chance, could someone point out all the flaws you can find and tell me them? It's Python 3.2.3, by the way. # Alien Assualt # A bullet hell alien invasion game. # Bobby Clarke #Imports import pygame, sys, os, random, math, easygui from pygame.locals import * pygame.init()...
I got a file with lots of ASCII characters. No extension, and has the Type Of file attribute 190000 File. I have many characters like L¿ö in the file however I required to remove lines from a word PYGR to another word MCG. It has several lines in between. I tried the following code. And got everything working. Indexes...
I'm writing a program in wxpython, and to make GUI parts that are built in different modules I made a module called runtime, where all the GUI parts get stored on runtime. This is how it looks: mainFrame = anotherGUIPart = InputDialog = SomethingElse = None For example, when I need to make a ListControl to update it...
Is this return style acceptable? Would the code be more readable if I assigned the MonthDay.parse() return value to a variable and returned that variable on the last line? Also, is it a bad idea to both log and rethrow inside a catch block? /** * Parses showing date from the header text. * * @throws PageStructureEx...
Here is my code; import socket def read_line(sock): "read a line from a socket" chars = [] while True: a = sock.recv(1) chars.append(a) if a == "\n" or a == "": return "".join(chars) def read_headers(sock): "read HTTP headers from an internet socket" lines =...