instruction stringlengths 71 71.9k |
|---|
I've written a function that takes a number and returns a value depending on where that number lies on a pre-defined scale. That's probably a little confusing so I've put the code below and added a JSFiddle (although you might be better off in the dev console).
var getSize = function(number){
var sizes = {
... |
I'm writing a program and I have a server that needs to be able to handle multiple client connections at once doing many different things.
I'm using the Qt library, so I handle new connections like this:
In the server constructor:
Server::Server(QObject* parent): QObject(parent)
{
connect(&server, SIGNAL(newConnectio... |
How can the following program execution time improved? I have used dynamic programming in both "recursive" as well as "prime" function, but I'm not getting the efficient execution time.
There is a wall of size 4xN in the victim's house where. The victim
also has an infinite supply of bricks of size 4x1 and 1x4 in h... |
I'm saving string values in an array one at a time so I cannot initialize the array with the values all at once. After I'm done with the array I need to pass it to another class that is expected a String array.
Normally I would use a List but the end result is expecting an Array so I stuck with the Array. I'm having se... |
I've been working on development for an Android game, and this is the game loop I have so far:
private static final int MAX_UPDATES_PER_DRAW = 10;
private long timeAccumulator = 0;
private long lastTime = System.nanoTime();
@Override
public void onDrawFrame(GL10 unused)
{
// Use this structure to set constant ... |
I wrote a program that reads a pcap file and parses the HTTP traffic in the pcap to generate a dictionary that contains HTTP headers for each request and response in this pcap.
My code does the following:
Uses tcpflow to reassemble the tcp segments
Read the files generated by tcpflow and check if it related to HTTP
If... |
Problem details from Codility:
A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.
Count the minimal number of jumps that the small frog must perform to reach i... |
Given such a structure the output should be
10->5->12->7->11->4->20->13->17->6->2->16->9->8->3->19->15.
Given a linked list where in addition to the next pointer, each node
has a child pointer, which may or may not point to a separate list.
These child lists may have one or more children of their own, and so
... |
Using jQuery I'm trying to find an efficient way to iterate through an array excludeMe and check if elements from another array needsExclusions are contained in the excludeMe array. Not sure if this is the most efficient, but it works. Fiddle here: http://jsfiddle.net/yef9q/3/
//Iterate through needsExclusions for an e... |
Designed for OpenCart, vQmod places or replaces bits of code based on XML files.
The following three versions of the code achieve the same goal, which is to replace nearly ALL of a specific page.
The offset parameter tells the vqmod how many lines of code to remove, including and following the search code.
It seems to ... |
In the following:
import Data.Bits (popCount, shiftL, (.|.))
import Data.Char (chr, ord)
import Data.Word (Word8)
import qualified Data.ByteString as B
data MByteSequence = MByteSequence [Word8] -- a sequence of map bytes (len 0-15)
data Atom = TerminationAtom |
NonOffsetAtom { nonOffsetGapLength :: Integ... |
I need to build a little UI to allow easy maintenance of some data stored in a MySQL database, and the end user wants to do that in Excel (I know, I know).
The code I came up with comes pretty close to what I'd call Model-View-Presenter (MVP).
I can get my form shown like this:
set x = new CustomerGroupsPresenter
set x... |
There have been many FizzBuzz questions lately, and here is one more! Granted, it is pretty straightforward to do FizzBuzz with SQL using calculations.
So instead, I'm going to do a FizzBuzz which will not only be functional, but demonstrate some of the core functions of SQL in general and MySQL PostgreSQL in particula... |
I have this code to check a couple conditions before allowing a play button to become visible. Is there anything to do to consolidate this code?
var isNodeWebkit = (typeof process == "object"); // check if using node app
var downloadURL = 'https://www.microsoft.com/getsilverlight/get-started/install/'; // setup downloa... |
I am fairly new to Javascript. I have written a website that works as designed. However, I have a strong feeling that my code could be heavily refactored. Can anyone see anything, besides line spacing, that I could do to clean up my code?
var i1 = document.createElement("img");
var i2 = document.createElement("img");
v... |
Given a Binary Tree, find the deepest leaf node that is left child of its parent. This question is attributed to GeeksForGeeks. Looking for code-review, optimizations and best practices.
public class DeepestLeftLeaf<T> {
private TreeNode<T> root;
/**
* Constructs a binary tree in order of elements in a... |
Just wanted to see what you all thought about my program, I basically have two different classes that I designed to allow for automated wrapping of text in a circular pattern. This is my first bit of useful and reusable code. Let me know what can be improved or added.
Here are some screenshots I took of the program in ... |
I am trying to send SMS using Twilio with Scala 2.10 in Playframework 2.2, but this code is looking odd to me, maybe due to lots of conditions. I'm sure it needs some important reviews.
val invalidEX = List(21211, 21614, 21608, 30006, 30005, 21604, 21601, 14101)
val reachEX = List(21612, 30004)
def sendSms = Action {... |
This question is about my answer to this king-of-the-hill challenge on Code Golf. In short, the purpose of the challenge is to code a slime that, trough various possible moves gains control over an 8x8 play area against 3 other slimes. The slimes get their turn one after another.
My idea was to go trough all possible m... |
I have base abstract GenericDAO class that executes CRUD operations with different kind of objects. Customer and Employee POJO classes are used in specific DAO classes that extends GenericDAO class. From my previous related question I have some unresolved problems:
Questions:
How to realize immutable objects in Generi... |
I'm writing code for an embedded device - specifically, a camera. The idea is different camera manufacturers can implement the code so it properly works with their camera.
Here, I'm encapsulating the request/response library we're using, because it's complicated to deal with, and we want to use ease of implementation a... |
I have the following code to select an image using Selenium, only now I have added an errorRecovery. Is there is a better way to right the code in the catch?
public static void selectHeader() {
try {
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfE... |
Goals:
So the plan was simple: Provide a factory to instantiate implementations of a certain interface (ModelConverter<T>), depending on what model-class you want to convert.
The approach is relatively straightforward:
statically map model-classes to ModelConverter implementations
use that mapping to obtain the implem... |
I have been learning Python and was trying to make a chat system which can be run by commands. This is my first attempt to write the code. Does this make sense or is it wrong usage of classes?
There is a User class which will contain the user of the chat.
The Message class is used to send messages and count their lengt... |
This is my first C# console application. This program asks for an input of a number, and finds the highest prime factor of that number. Please review my code.
Have I used things right?
Is my code efficient?
Is there a better way to achieve this?
using System;
using System.Collections.Generic;
using System.Linq;
u... |
I've come across the following piece of code in a Razor view
<table class="key-left">
<tr>
<td>Company</td>
@foreach (Customer c in Model.SelectedInstallers)
{
<td>@c.Name</td>
}
</tr>
<tr class="even">
<td>Address</td>
@foreach (Customer c in Mode... |
I wrote a program to display data in memory as binary and it worked. (It gave me immense sense of satisfaction and joy to see this work. I guess this happens to newbies who are just testing the waters). I know this isn't some terribly smart code, and I'm sure there must be surely lots of better ways to do this. Any adv... |
I want to find the first and second highest number in an array. I could come up with one solution, but I want to know the optimum solution to do the same. Can someone help me with some alternative solution to this?
int main()
{
int arr[10] = {0,1,2,13,4,5,9,8,11,6};
int first = arr[0];
int second = arr[0]... |
I wrote an R code that basically performs 2 operations:
For each segment in file A, find all segments in file B that lie in that segment.
Find the percentage of overlap for each case in previous point.
The code that I have written works fine but given I have 74 files of type A and the rows in file B are about 200K, t... |
I have an API with the following code
class API::V1::ReceptionController < API::V1::APIController
before_filter :ensure_document_exists
def produto
jid = ProdutoWorker.perform_async params[:document]
render json: {jid: jid}, :status => 200
end
def cliente
jid = Clie... |
I got a PHP developer interview test to solve for a company. I didn't get the job but I would like to know where I was wrong. Did I understand the test completely?
/**
* Create an Animal Choir simulator
*
* The task constraints are:
*
* There must be 3 different choir member animals
* (i.e. dogs, cats, mice)
*
... |
For a project, I need to validate a VAT number against the correct algorithm. I found a library for this here (freeware, so I should be able to reuse it) that I'm grateful exists. However, I feel like it could be improved upon in a few ways, but I'm not sure which.
The piece of code is:
// Check the string against the ... |
I have a DiningHall class that has the 3 properties: openingTime, closingTime, and nextMealOpeningTime, and I need to set these NSDate properties from the data from this website.
Each DiningHall object corresponds to a particular meal. For example, there is a separate "De Neve" dining hall object for breakfast, lunch,... |
I wonder, what might be the best (most pythonic) way of implementing multiple observerables in Python. There are multiple objects, which should be able to register themselves at one or multiple observables.
Shall I simply submit the update methods, like this:
class MethodObservable():
def __init__(self, data_sourc... |
I've coded a calculator in C# with WPF as the UI.
I wish to know mainly about these points:
Ways of optimizing
Better techniques, tactics and ways of coding this
All flaws on the surface as well as deep
Simpler logic
MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Te... |
I have a purpose for an application to run a daemon in my web application.
The application is running with Struts1 on a tomcat7 server using Java7.
This is what it does:
Launch itself when the application is loaded
every minutes does a task (the sysout in the code)
when the application stops, it stops the timer and l... |
The purpose of the program is to add 2 sides of an array starting from the bottom and top of both ends and to find the lowest difference at equal decrements of iteration. The program functions but it's slow.
int solution(vector<int> &A) {
int n = A.size();
int i, j, rsum, lsum, difference;
int currentmindif... |
I am writing an application that either mirrors a file/directory into another location or creates a zip file "snap shot" of a file or directory and stores it in another location. The user is able to create "rules" where they define the source file/directory, the destination file/directory and if they are archiving how... |
I just want to know whether I've done transaction handling well. Also what about the other types of transactions available in .NET with regard to this code snippet?
Also are there any redundant things in this code?
public void InsertAttendance(BindingList<IAttendance> attendanceList)
{
string selectStat... |
I want recommendations on how to improve this code.
JSFiddle for you to play in (It's laggy, so it would be better if you download the images and try it in your own PC).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf8">
<title>Let's play Tic Tac Toe!</title>
<script type="text/javascript" src="j... |
I am rewriting an old VB.NET app in C#. I will not subject you to the old VB.NET code that I am writing (the original method that I have already refactored was over 700 lines long).
The following is what we call On Demand Reports. There is a stored procedure that these objects fill in for us. I don't have a 100% unders... |
I have the following method for opening a file:
void TankFile::OpenForReading(const std::string & filename)
{
assert(!filename.empty());
errno = 0;
file.exceptions(0); // Don't throw
file.open(filename, (std::fstream::in | std::fstream::binary));
if (!file.is_open() || !file.good())
{
... |
I am creating a Blackjack simulator in Java in order to better understand the language. I have written the basic strategy section for a player and it is terribly long.
Is there a better way to do this other than if/else statements? I know a switch might work but that wouldn't make it much shorter. The reality is tha... |
I found a connected components algorithm posted here on SO and modified it for my own purposes. It runs well for small input sets, but doesn't scale as well as I would like.
The largest set I've been able to handle with it has just under 10,000 nodes and took 109 seconds to process. I threw in the towel when testing a... |
I'm working on this Objective C programming assignment I found online. I'm not sure if I have met all the requirements, especially part C. Any help or suggestion will be appreciated.
Part 6
a) Implement class A with properties a1, a2, and a3 (int,
string, int).
b) New objects are automatically initialized to 1, "he... |
Aim
In C#, the following method will cause a StackOverFlowException if called with parameter 0:
int Recurse(int i)
{
return i<100000 ? Recurse(i+1) : i;
}
However, this method actually uses tail-call recursion, meaning that if it ever performs a recursive call, that is always the last operation it performs. For th... |
The function below takes a datestring in the form d-mmm-yyyy and converts it to ISO date format (yyyy-mm-dd). Delimiters may be hyphen, space or /, and Dutch or English month abbreviations may be used.
Now, I know there is dateutil, but it returns unknown string format if you try to parse something with a non-Englis... |
I wrote a function that inserts or updates a Map key value depending on whether the key is already in the map. If it is, then the value gets added to the already existing map's value.
import Data.Map as Map
updateMap :: (Ord k, Num v) => k -> v -> Map k v -> Map k v
updateMap k v map = if member k map then Map.adjust ... |
Today I decided to learn some basic Haskell, and for starters I made a program for calculating the checksum of a Swedish personal identification number. It uses the Luhn-algorithm, aka. IBM MOD-10.
Explanation of this code can be found on Swedish Wikipedia and English Wikipedia
Here's a description of how the algorithm... |
Somewhere in this code seems to be a memory leak. A couple of users were exceeding 512Mb and I'm not sure how.
Adapted the following SO code to try and test memory usage of each function on the (OpenCart extension) page:
public function mem_test($func_name){
declare(ticks=1);
$handle = fopen("/Users/mikekilmer... |
A recent question inspired me to write a script for this task:
Shorten URLs in specified text files using googleapis.com
Handle multiple URLs, whether on the same line or multiple lines
The original question tried to do this in Bash, but it gets quite tricky when it comes to handling multiple URLs, so I decided to re... |
To try out the concepts and tools I've been learning, I decided to write a Blackjack game. I wrote it entirely with functions, so it hasn't helped me at all with the concept I really lack understanding in: classes. Could someone point me in the right direction as to how I could rewrite this program utilizing classes?... |
I basically have 3 processes which I loop through.
The first process is encoding Video. It's actually 2 processes but they are connected, so I don't need to worry about how it handles the other one.
The second and third are connected by me, however. One reads and the other writes, so I have to manually feed the stdin/... |
I have a pretty big file (3 million lines) with each line being a person-to-event relationship. Ultimate, I want to project this bipartite network onto a single-mode, weighted, network, and write it to a CSV file. I'm using NetworkX, and I've tested my code on smaller sample datasets, and it works as it should. However... |
I am trying to learn PHP in depth by creating this personal CMS. I try to utilize OOP concepts and do best I can...
The way I am trying to design this CMS is to keep including 'modules' within a page to minimize code. I am using extensively POST and GET variables to decide which module will be reached. The Index page w... |
Consider:
let mutable m' = m
while m' % i = 0L do
m' <- m' / i
I've refactored it into:
let m' =
let rec exhaust m =
if m % i = 0L then exhaust (m/i)
else m
exhaust m
but it's pretty obvious to me that the original code was wa... |
This fiddle has an ADD button when you click it a Chat window is added. When there are more than 1 windows the message from one window is reflected across all the windows.
Say you have templates (in above case "Chat Window") which will repeat in DOM (i.e. append and removal will happen dynamically):
var html="<h1>Chat... |
Below is my code that was written for the following task (based on an SO question):
Given a Java Collection (of N elements) create an ArrayList, containing N
collections of the same type with just one element in each.
Here's my code for such method:
public static <E> ArrayList<Collection<E>> SplitCollection (Collec... |
How can I optimize this code?
for(var i = 0; i<people_to_save_parse.length;i++)
{
if($(".ID-"+people[i].tdid).is(':checked')==true)
{
people_to_save_parse[i].id = $(".ID-text-"+people[i].tdid).text();
}else{
people_to_save_parse[i].... |
Here is a short and simple Ajax method that returns "True" or "False" if an entity exists in a database via a stored procedure that returns just "Y" or "N" (the details of this entity and database are not relevant to my question though).
This is the first time I've used the C# using() statement, and was wondering if ... |
This is my firstish (heavily rewritten) go at the completed project that I've been working on with CodeReview assistance, so further advice is appreciated! See here, here and here for the past history of the project.
I strongly suspect there's a much more functional way to manage my loops, so assistance with that area... |
I'm quite new to Laravel, and I'm not sure what am I doing is the best practice.
I'd like to return JSON if the request is Ajax, or return a view otherwise. This is the way I made it, and it works fine, but I'm not sure if this is the best way(it seems long winded). I'd really like to hear your suggestions.
public func... |
I'm currently working on a tool that needs to decode, modify data, then re-encode that data using the Yaz0 format. Everything has been in a working state, but after running some code analysis on my program it turns out it is spending an obscene amount of time on the encoding portion (Over 95%). However, I cannot think ... |
Following-up on this post, I wanted to be able to put a copy of that Excel workbook on a USB key and take it home to keep working on the code a bit (there's more than just one or two tables to maintain, so I'll have about a dozen forms when I'm done)... but to be able to test every functionality of my CRUD app without ... |
I tested the play framework the last days and had mixed feelings about it. In the end, I don't use play for my new REST project. I use http://www.sparkjava.com as minimal server setup.
But I really like the server session less idea from play and want them in spark for the option to scale the performance with more serve... |
I have two functions that are similar. The only differences is that they're using two different models. How can I change them into one function?
ITagRepository tagRepo = new TagRepository();
ICategoryRepository catRepo = new CategoryRepository();
public void AddTagsDontExist(string tags)
{
var allTags = ... |
I have a library for simple Word Sense Disambiguation (WSD).
I have a function for WSD based on the sum of maximum similarity score for every word. But it's slow because it iterates through all words in the input sentence and then finds the max similarity score between the every sense of each word.
How could I speed up... |
I want to create an XML format in which I will define data objects for a game I am currently working on.
The base idea is that I will have Elements which can be combined in other Elements, Items or Spells.
A primal element is an element which is directly available.
If an element is not primal then in order to create ... |
Is there a way to make a threading/async post with a web reference not slow down the whole website just because the web reference takes a long time to return a response?
I have a send email function that gets posted async with a threading system that basically looks like this. This whole .cs file is called Mail.cs (th... |
I finally set up my logging infrastructure to work as desired, however I feel like I had to do quite a lot things just to fulfill a few requirements. Now I'm worried if my approach has major drawbacks, e.g. in performance or stability, so I need your help!
Requirements
Logging to multiple output sources, depending on ... |
I'm doing some exercises in Python and this one is about using the Luhn-algorithm to calculate the checksum digit in Swedish personal identification numbers.
The description is the same as this question:
Given a string of 9 digits, abcdefghi compute:
array = [a*2, b, c*2, d, e*2, f, g*2, h, i*2]
Then you compute the ... |
The problem:
Treat an array as if it is circular; out-of-bounds indices "wrap around" the array to become in-bounds.
Current solution:
// roudedArray.cpp
#include <iostream>
template <typename T, int N>
int wrapAroundArray(int i, T(&ThisArray)[N])
{
// "wrap" i around ThisArray, landing on a valid index
while (i <... |
I recently wanted to write a regression testing script that produces a report that looks like this:
Testing 'nmap -n -Pn -sT localhost'
0.0670049190521 => Trunk time
0.098452091217 => nsock time
The results are consistent.
Testing 'nmap -n -Pn -sT scanme.nmap.org'
9.35733294487 => Trunk time
7.95617294312 => n... |
This code simply sends a HttpRequest message and, if it comes back Unauthorized, gets a new login and tries again.
This code is meant to deal with the moment a JSON Web Token goes out of date. In this system the client is notified of this by having its request become Unauthorized, it then picks up a new Token by loggin... |
I have a string like str = " 4+ 6 * 30";. I have to perform an arithmetic operation on this using C#; My solution to this problem is as follows.
string temp = " 4 + 6 * 5";
int firstNaum = 0;
int secondNum = 0;
int ThirdNum = 0;
int finalResults = 0;
//Spliting strings
string[] withoutO... |
I am rewriting a VB.NET application in C#. This code was originally done in 50 lines and I am trying to clean it up. As you can see I have gotten it down to 10 but I still feel its ugly. I want to convert the call and assignments into one Linq statement or method chain. See Comments:
public void Update(IEnumerable<MyOb... |
In my publications with meteor.js, I find myself repeating the same style of code and would like a cleaner approach. For example:
I have a users collection that has the distinguishing field school, an identifier that tells me by which school, I should filter what information on the server so that I don't send the wrong... |
I'm writing a tool to create shortcut menus for an application that I maintain built on the Access runtime. I compile this app into an *.accde file, so much to my chagrin, all right click menus are disabled.
After some research, I've been able to develop this tool to add the menus to the database. This code is called ... |
I have written the below code to get the unique factors. Please offer suggestions for better results.
#Python program to print out all ways to multiply smaller integers
#that equal the original number, without repeating sets of factors
def print_factors_list(dividend, factorstring, predivisor):
"""This function tak... |
I've been learning about language theory and parsing, and decided to write my first parser: a LL(1) recursive descent parser. But actually, it does a little more than just expressions; it can also parse variable definitions with the "define" keyword. It parses into an AST and then the other portion of the program evalu... |
I'm working on solving a problem involving finding the largest of a series of numbers being XORed.
This is the actual problem:
Xorq has invented an encryption algorithm which uses bitwise XOR
operations extensively. This encryption algorithm uses a sequence of
non-negative integers \$x_1, x_2, ... x_n\$ as key. To... |
Inspired by the XML format for game data question, I was interested to see how my system works for storing game data. My system works a lot like Halo, where there are a variety of gametypes and configurations vary between them, but some basic items are always configurable.
For example, every game has a time limit, but ... |
This PHP (5.3) code is intended to take an array and a key as inputs, and return an array of the values paired with that key‡
function valuelist($array, $array_column) {
$return = array();
foreach($array AS $row){
$return[]=$row[$array_column];
};
return $return;
};
Can this be improved in term... |
There's this website I'm working on that needs to swap images every few seconds, like a slideshow or image fade swap in a way, except that you need to target 5 IMG tag elements. I was able to make a weak version of that function. But i'm sure this could be done even better, considering that I still have a few bugs that... |
When I was about 13 or 14 years old, I was a little interested in cryptography (which is, after all, an interesting field). I learnt quite a lot since that time (it has been about 8 years since then), but I'm still very far away from considering myself an expert in cryptography.
Whatever, when I was at that age, I wrot... |
I have a type representing an immutable order which contains immutable order lines that belong to it. I want to use path-dependent types for this. Obviously you cannot instantiate a path-dependent type without having the value it depends on, so I decided to take a function from the constructor. Since (order: Order) => ... |
I created a k-ary tree in C to be used as an easy and efficient way to organize "UML-like" data in embedded devices. The left node is at the lower logical level (a child) while the right node is at the same logical level but represent a different data or option (sibling).
Since it is to be used in embedded devices with... |
Here is a Bitcoin address validator I am looking to have reviewed in C. Normally I would have the enum and function prototypes declared in a header file, but I decided for the purpose of this question to integrate them into one for easy copying and compilation.
/**
* @file bitcoin.c
* @brief Bitcoin address validati... |
I'm using VS 2013/EF 6/WEB API 2.
This application of mine which is working on will eventually grow to be big project and I'm in the very beginning stage and need your expertise to make it simple as possible without over-complication.
My goal is to make it KISS solution and I'm trying my best. After spending a lot of ... |
Use Case
_.pick creates a shallow clone of an object given a predicate that identifies which keys to keep. pickDeep would perform a deep clone of the object and would "pick" up all nested objects containing the given keys. All containers containing the nested objects would remain and would not be removed.
Requirements
... |
I'm rewriting a simple app using HTML/CSS/JavaScript that creates animations with images using intervals, and there's a bunch of buttons that controls these animations.
It's scaling and becoming really messed up, with logic mixed with DOM manipulations via jQuery all through one JavaScript script file.
I've decided to ... |
Expression trees are the bread and butter of functional programming but when it comes to adding additional information to an established tree it can be difficult to incorporate such changes without breaking the existing interface. I have attempted to solve the problem with this example which demonstrates two different ... |
The code is generic, trying to support both STL iterators and normal C pointer arithmetic.
#include <cstdio>
#include <vector>
template<typename I>
void quick_sort_step(const I left, const I right)
{
auto pivot = *(left + (right - left) / 2);
auto l = left;
auto r = right;
while (l <= r) {
whi... |
I just started development on a new bignum library that can operate on numbers of any arbitrary base (up to 232). I want to get a good idea of where I can improve before taking things any further. Right now, the library supports basic addition and subtraction, comparisons, and absolute values. I will be adding division... |
I found myself in the need of a function to pairwise an array 2D so I created one:
public static IEnumerable<TOut> Pairwise<TIn, TOut>(this TIn[,] source ,Func<TIn, TIn, TOut> selector)
{
Point[] deltas =
{
new Point(-1, -1), new Point(0, -1), new Point(1, -1),
new Point(-1, 0), ... |
I'm fairly new to Clojure and I struggled a bit coming up with a nice Clojure-y solution for implementing an algorithm for one of my applications. The real issue I'm trying to solve would require a large writeup in order to understand what it's about, so I've come up with a contrived problem statement that's much easie... |
I'm trying to save a webpage as text file, using the following function:
def html_to_txt():
import urllib.request
url = str(input('Enter URL: '))
page = urllib.request.urlopen(url)
with open(str(input('Enter filename: ')), "w") as f:
for x in page:
f.write(str(x).replace('\\n',... |
I have a pretty large model library I'm working on and it's turning out quite complex, or so I believe at least and I could use a second opinion.
The basic idea is that the user should only have to create an instance of a big base class and then build on that with the other object types.
These are some of the propertie... |
I have such part in my script, how can I optimize such parts? I don't want to use many local variables.
size_variants = []
for size in sizes_list:
size_variants.append({'size': size})
Also here:
variants_tmp = list()
all_color_list = list(get_all_colors())
[variants_tmp.extend(var) for var in all_color_list]
|
I have the following codes, which I created as extension for datatable in my project.
It actually worked. Just wonder if there is any optimization can be made through. Thanks. =)
<Extension()>
Public Function HasNull(ByVal dataTable As DataTable) As Boolean
For Each column As DataColumn In dataTable.Columns
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.