instruction stringlengths 71 71.9k |
|---|
An array is given with the element name and their respective pH values. Print the combination of 2 elements which make a neutral compound
Here is the solution that I came up with but uses a Hashmap hence O(N) space complexity. Any idea I can reduce space complexity but maintaining O(N) time complexity
public stati... |
I've implemented the basic logic of a stack data structure. How can I make this code more generic? Is there any better way to display the stack contents?
StackMethods.java
import java.util.Arrays;
public class StackMethods {
private int top;
int size;
int[] stack ;
public StackMethods(int arraySize){
... |
Below is the code of a development status project. I have designed a main window with 3 children. I am mainly interested in your comments on the design pattern used for drawing the child windows and the controls per child. The childwindows will be selected via the menu (show and hide). the logic of the control will be ... |
I have a legacy code parsing .obj 3D mesh files. However, it seems to me a bit ugly:
char Prefix[7];
float X, Y, Z;
int A1, A2, A3, B1, B2, B3, C1, C2, C3, D1, D2, D3;
while ( !IStream->Eof() )
{
Luint64 Pos = IStream->GetFilePos();
LString Line = IStream->ReadLine();
int NumRead = sscanf( Line.c_str(),... |
Is this code okay?
import java.util.Stack;
public class StackReverse {
public static void main(String[] args) {
final String inputString = "code review";
final String reversed = reverseString(inputString);
System.out.println("The reversed string is " + reversed);
}
public stati... |
This file manager has a code snippet that handles an argument of the "cd" console command. It converts the argument to a valid path, expands ~ and environment variables into the corresponding values:
std::vector<unicode_t> ConvertCDArgToPath( const unicode_t* p )
{
std::vector<unicode_t> Out;
std::vector<unico... |
As a beginner (Learn Python the Hard Way), I've set myself this exercise with classes and it works but looks very inelegant to me. I'm trying to write classes which could be re-used in other code. I've left long variable names and comments so you can see what I thought I was doing. What should I focus on in my study to... |
I need to move data from one database to another, and since I don't have SSIS I'm doing this ETL with T-SQL scripts.
One of the source tables contains invoice details, and features a column that contains the number of units invoiced per size (it's clothing); as I transfer the data over to my database, I'm normalizing t... |
We have currently rewritten an Excel calculation engine in F# and are looking to refactor the code to make it a lot more idiomatic and standardised.
One of the big problems with the code is that we have a massive function named companyModel that builds a CompanyModel type (a record type that holds some of the cached ne... |
Usually when I see tutorials about Observer Pattern I see an unique method called notify, but I'm wondering. What if I have different methods that can be called in different moments but needs to notify the others when this happen? Like events, am I doing this wrong? or still begin the observer pattern?
#include <iostre... |
My program takes as first input the number of test cases, n. For the following n inputs, I output the smallest positive integer that has to be added to the input to make the input a numeric palindrome. If the input is already a palindrome the output shall be zero.
I have a problem with the performance, the algorithm i... |
To celebrate an important event, I hastily cobbled together an HTML canvas-based animation.
A few concerns I have include:
Performance: Does it run reasonably smoothly on most modern machines? How can I make it more efficient?
Portability / Compatibility: Does it work correctly on all modern browsers (excluding old v... |
I am implementing finite element code using MPI. Obviously, when using MPI I will have to include communication between different nodes so that all processors have all relevant information. As this is my first time doing something like this, I have implemented a very naive algorithm to get updated volume information fo... |
I have the following girth-counting algorithm on a large 0-1 matrix and I need to optimize it for speed:
function CountG8()
M = 512
N = 1024
H = rand(0:1,M,N)
girth_8 = 0
for i=1:M-3
for j=1:N-1
if H[i,j]==1
for j1=j+1:N
if H[i,j1]==1
for i1=i+1:M
... |
A few days ago, I was looking for simple pagination example and I decided to write my own version. It is one of my first apps using MVVM Pattern, so I am not sure I did right. I would appreciate if you could tell if I did something wrong, or used bad programming practises or whatever.
GitHub
MainWindow:
<Window x:Class... |
I need to write a factory of generic converters to produce converters from/to MongoDB objects to/from Java objects. Here is my implementation, it doesn't look good enough to me, so I would like to see your advice.
public static <T> Converter<T> getConverter(final Class<T> clazz) {
return new Converter<T>() {
... |
I am loading divs from separate HTML files into a div on the index.html page.
This is being done using jQuery's .load(). There is however, a lot of repetition and I'm wondering if there is a cleaner way to achieve this.
The HTML:
<nav class="menu-side">
<a href="#" id="about">About</a>
<a href="#" id="help"></i>Hel... |
I have folder1 that contains other folders (which may contain other folders etc). This process stops at some point where a folder contains only files, and some of them end with the string "img".
I would like to write to a file for each line:
the complete path of the file (if ends with, say "img")
the immediate folde... |
I am trying to modularize the main SKScene of my strategy game. I am not sure that my approach is correct so I would love to get a review of the following code.
The SKScene adds the top level node of this class to its _world SKNode. It calls the update method in a fixed time step that can be increased or decreased by ... |
This code below works as needed, but I am not sure if there is a more elegant way with pure CSS. I have a table with two columns, and 4+ rows. I'll actually upload a picture. It's the first table in grey that I am messing with.
I want to select all the TDs--except for the first TD, because that first one has been cha... |
I wrote a script to save comments and submissions from Reddit using Elasticsearch. Is there any way to improve the speed of inserting new items into Elasticsearch?
import praw
import sys
from elasticsearch import Elasticsearch
subreddit_queue_file = "subreddit_queue.txt"
def pop_task():
task = ""
with open(s... |
I've got this code in my View that just list two type of links.
Here's an example output:
Nounal Pages
cleaners/house-cleaners
Verbal Pages
cleaning/house-cleaning
Here's the view code. How could this be refactored to remove duplicate and push logic and loops out of the view?
%h3 Nounal Pages
%ul.row-fluid
- ... |
I'm writing a program for a game called "Lingo":
def lingo():
guesslst = []
word = list("tiger")
while guesslst != word:
new = []
guess = raw_input("Enter word: ")
guesslst = list(guess)
for x... |
Firstly, let me say that this code works, as posted. It fills a 10x10 grid with a random color (black/white) then runs a cellular automata simulation on the grid, starting or pausing when the button is pressed.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
imp... |
I should have started with this code. I wrote my logging API without writing unit tests, and since I recently wrote an automagic unit testing API I though I might as well go ahead and use it.
So I wrote a MockLogger implementation of the ILogger interface, still with a default instance (like all other ILogger implement... |
The game works, but I was wondering if anyone could help me with better structure for the code, simplification, or just any other improvements.
from random import randrange
# assigns the amount of turns and starts the program
def Main():
print "~A game of Scissors, Paper, Rock!~"
global turns
turns = raw... |
Is this code okay?
import java.util.Stack;
public class DelimiterMatching {
public static void main(String[] args) {
final String input = "[(A+B)]";
delimiterCheck(input);
}
public static void delimiterCheck(String input) {
if (input.length() == 0) {
System.out.print... |
Please have a look at my original question:
Optimizing code using semaphore to control Netty channel pool
I have made some changes as pointed out by @rolfl
The new code is as follows. Is this better? Can i remove the synchronization blocks with some other methodology?
public enum Client{
INSTANCE(Config.getServerI... |
Is there a way to cut-off using "div" elements in my design or it is good enough? I use Boostrap CSS library.
CSS:
body {
border: 3px solid black;
min-width: 1800px;
}
#search_box {
border: 3px solid red;
background-color: white;
color: black;
text-align: left;
margin-bottom: 15px;
widt... |
I needed to add a logger into my flow based on FluentIterable from the Guava library. I have a lot of functions and in some cases I would like to add logging when in other cases (for the same function) I would not.
Of course the natural solution for this problem is to use the decorator pattern, so I created something ... |
I have the following query. Its execution took 15 min and it's too much slow. Is there a way to optimize it?
SELECT
Id,Fees,WeekOfMonth,CONVERT(NVARCHAR(MAX), StartDate, 103) AS StartDate,CONVERT(NVARCHAR(MAX), EndDate, 103) AS EndDate,'Temp Fees ' AS FeesName
,@MonthName AS [MonthName]
INT... |
Take a timer in your hands, then have a look to the following code. What is it doing?
I took 52 seconds to realize more or less what it does..
It compares a list called categories with an actual element. If it already exist in the list it takes it and stores to the category variable. Otherwise it creates this new eleme... |
Anyone have ideas on how to improve this code at all?
string user = User.Identity.GetUserId();
IQueryable<Article> t =
db.Articles.Include(a => a.Categories)
.Include(b => b.Shared)
.Where(s => s.Private & s.createdby == User.Identity.Name);
IQueryable<Articl... |
So far as I've tested it, these few facelets files with JPA database connections work as intended. The queue, MyQueue, is at the heart of this small web application. Each time a user clicks "next" they're presented with the next bird. While the app is running, the queue will only send a bird once, to a single user; ... |
I have made a method which I use to show the exception error through a JDialog window whenever there is one in my program.
For now I can pass it either a String or a subclass of Exception. At first I had two different methods for each one but now I combined them into one.
The showError method:
public static void showEr... |
I am quite new to Clojure and would need some advice on the following genetic programming gist I wrote as my first working clj program. The aim of it is to perform an algebraic regression using genetic programming on syntax trees with +, - and x, 1 genes to fit \$3x + 1\$ function.
The code works, but I doubt it does s... |
I'm writing my first somewhat production ready (or not) Go program and could do with some feedback from someone more experienced with go.
The code reads a list of URLs from a JSON file and then makes a GET request to each URL in a loop to check that they are returning a 200 OK response. I have attempted to do this conc... |
I have a requirement where I have to generate some reports read from a database and write the data to Excel.
I want your help in reviewing the following things in my code:
Database connection
Multithreaded programming
Is my data structure Map<Integer, TreeMap<String,String>> proper?
What design pattern can I apply?
D... |
This draws an xyplot from csv data obtained from RescueTime API for activity time for "http://codereview.stackexchange.com".
# -------------------------------------------------------
# PLOT TIME SPENT ON CODEREVIEW SE
# USING RESCUE TIME API AND R
# -------------------------------------------------------
# -----------... |
I've implemented the queue data structures using array in java. Anything I need to change in my code?
Queue.java
import java.util.Arrays;
public class Queue<T> {
private int front;
private int rear;
int size;
T[] queue;
public Queue(int inSize) {
size = inSize;
queue = (T[]) new O... |
this.Items is a list of products. Each product has a category (product.Attributes["category"]).
I want to render a drop down list, where all the products are grouped by category.
This works well, but how could I improve it? Could there be a way to not use a dictionary?
protected override void RenderContents(System.Web.... |
I've the following code, which checks if one column belongs to the list I provide. After that, it takes the value contained in it.
I've tried and it's 9 times faster than raising and handling an exception. But I don't find this code very readable.
For example, I don't need to define a variable drsIDAgentClient. I've t... |
I have written a class which can time functions, and I'd like to have it reviewed. I'm interested in everything (better naming and commenting, accuracy of measurement, usability, structure, use of lambda, etc.).
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.C... |
I am currently handling some setup of an object on a background thread (I am using a concurrent queue within the following initWithDocumentFileURL method):
+ (TWReaderDocument *)initWithDocumentFileURL:(NSURL *)url withLoadingCompletionBlock:(loadingCompletionBlock)completionBlock{
__block NSError *error;
TWReaderDoc... |
I was trying to solve a question on CodeChef. My code works perfectly fine in my IDE (Visual Studio here) but when I submit my code at CodeChef, it says "Time Limit Exceeded".
What the code does:
Input T number of test cases each with one input N
Let A and B be two numbers chosen randomly from 1,2,3...N
Output the pr... |
I'm writing small tool, which must execute jmap -heap, write output to log, then takes some data from log and calculate used memory.
I added some debug to it.
# JVM with jmap statistic
def java_heap_save(log):
subprocess.call('jmap -heap %s > %s' % (java_pid, log), shell=True, stdout=devnull, stderr=devnull)
with... |
I made a package for Node.js that allowed the querying of game servers (or any UDP server(untested)) using UDP.
What it does is sends the query to the server and adds the query into a queue. When the message is received it retrieves the response from the server, parses it and removes the query from the queue.
Am I usin... |
I have a Tree class, defined as follows:
public class Tree<T> {
private T value;
protected List<Tree<T>> children = new ArrayList<Tree<T>>();
/* ... */
}
I want to implement the toString() method in this class to show the String representation of this Tree, e.g.:
└── root
├── child1
│ └── gra... |
Problem:
Two players pick numbers from a common pool of number to reach a combined total.
The player who get to reach/cross the target value wins.
The problem is to find out if player-1 can enforce a strategy to win - for a given total and a pool of numbers.
My Approach:
Assuming both the players pick the optimal ... |
Please advise if the form validation script below is secure enough to avoid most types (all types?) of contact form exploits? I ahve found this script online, added some extra php finctions in hope to make it safer, but not complitely sure if it is good for the purpose.
if ($_SERVER["REQUEST_METHOD"] == "POST" && !empt... |
I wrote the below method to list out the elements of an array, as well as adding the Oxford comma to the list if desired. However, my for-loop looks, perhaps, a little convoluted. Is there a better way to handle clearly both the Oxford comma and the ability to add a conjunction?
function listOut($array = array(), $oxf... |
Can this query be improved? I iterate over a couple of thousand times, and if I can improve it, it should decrease the run time. Otherwise I might look into using a batch instead of doing one at a time. I'm using MS SQL 11.
job
****
id
name
job_stats
*************
id
job_id
median_runtime
select js.median_runtime f... |
The fourth project, continuing my C++ saga with terrible post names. :P
An approximate value of pi can be calculated using the series given
below:
$$ \pi \approx 4 \left[ 1 - \dfrac{1}{3} + \dfrac{1}{5} - \dfrac{1}{7} +
\dfrac{1}{9} - \cdots + \dfrac{\left( -1\right)^n}{2n + 1} \right] $$
Write a C++ program to cal... |
The following asks for 2 sets of data (with corresponding x and y values), calculates a linear equation that matches the data as closely as possible, then allows you to "play around" with the equation by substituting x values.
import Data.Char
slope :: [Float] -> [Float] -> Float
slope xs ys
| xN /= yN = error $ ... |
I use this code on the app's first run to save about 220000 values into core data. The file Navaids.txt has about 200000 and Waypoints.txt has about 20000 lines, where I get data from each line and put it in an entity in core data.
I am still kind of new to CD but would like to see how I can improve this code on app's ... |
Recently, I had a test and I wrote this code, but they didn't like my code because it was "deplete and nested".
In order to improve my skills, what would be good ways to make this more readable and less deplete and nested?
Exercise
The validBraces method takes a string of braces as a single parameter and determines if ... |
I have this rather ghastly if statement and I'm sure there is a way to condense it, but I don't really know how. I was told a case statement would work but I've never used a case statement and I'm not sure.
public void add(int p, Course c)
{
if (p == 1){
if (course1.isFree() == true) {
course1 = c;
... |
I've been looking for a way to make the database connection easy available directry from any script, and from inside other classes. And since I tend to have different connections based on what action to execute, I had to find a way to easily scale the amount of connection needed.
Here's the solution I come up with.
I... |
I'm currently learning Java along with the Stanford online "Programming Methodology" course and, while it is awesome, I do lack any kind of human feedback.
This exercise was to create a method that took a floating-point value x and an integer k and returned x to the power of k. The method needed to also be able to corr... |
I made some code to test my personal servers uptime. It logs in to my router page and sees if it returns status 200. A cron job runs it every 5 minutes. Please let me know if I can make the code more efficient.
<?php
//Date
date_default_timezone_set('America/Los_Angeles');
$date = date('m/d h:i:s a', time());
//Output... |
I am learning spring and am wondering about this service class's method. Is there a way to split this method up? Is there a way to use spring framework to make this method more readable? Should I move any of it to the controller or the DAO or should I split it into more service methods?
// UserBean has fields: username... |
My logic has to be written in this way, but I think the if expression is too long to read.
How can I make it more readable?
if @tool_cvt_video_info_test.save and check_and_update_firmware_model_and_version(params["camera_ip"]) and save_uploaded(params[:videos])
format.html { redirect_to @tool_cvt_video_info_test... |
I'm working with Python 2.7.5 and I have written the following code:
def func(x):
if x == 1:
list = data.parseJSON(fileName)
person = [l for l in list if l['worker'] == sys.argv[1]]
displayPeople(flatten(person))
elif x == 2:
list = data.parseJSON(fileName)
person = [l for l in list if sys.argv[... |
I've implemented for the first time Doctrine-ORM on my SOAP server application; can you tell me if I could optimize some of the written ORM-related code?
More specifically, is it a good practice to package entities in sub-namespaces, or is it better to simply put them in an Entity namespace ?
I cannot post the XML used... |
I am writing a task scheduler (that will one day grow up to be a windows service when I look into them) that should pretty much loop infinitely until I tell the program to stop. But having while(true) seems incorrect. What is the correct way to implement the loop? Use a dummy boolean variable that the code doesn't actu... |
I have some code that loops through directories named for years (e.g. /2011/, /2012/ etc) which each contain files whose names end with dates in the "yyyyMMdd" format, and builds a list of all the dates in all the directories. But what is the best way to indent this, nothing I've tried is readable:
files = files.Union(... |
Currently my team is building an application involving a database. We have to write a lot of data (approx 2,000,000 records) to the database and therefore we decided to open a connection once and close it afterwards. The connection will become a local connection, so we don't have to worry about unwanted intruders that ... |
In the method getView() in my implementation of ArrayAdapter I have to download image from Internet using the image's url and set downloaded image to ImageView. I have to check in getView() whether downloading of an image from the given url is already started because of recycling views in TwoWayGridView and because of ... |
I want to transpose this matrix input:
1.000 2.00 3.0 4.00
5.00 6.000 7.00000 8.0000000
9.0 10.0 11.0 12.00000
And get this output:
1.000 5.00 9.0
2.00 6.000 10.0
3.0 7.00000 11.0
4.00 8.0000000 12.00000
I have a matrix in a file with thousands of lines and millions of columns, so I can't read it into memory (i.e... |
I've seen so many different ways of doing this all seem very complex and all seem to be done in MySQL. I'm using PDO in my project so I've had a go myself to see what I could come up with.
Is this safe?
Is there something I've missed a better way of doing it?
//build query to insert users_contracts
$sth = "INSER... |
I have three observables:
var itemsManipulationStarted =
Observable.FromEvent<ManipulationStartedEventArgs>(Items, "ManipulationStarted");
var pageManipulationDelta = Observable.FromEvent<ManipulationDeltaEventArgs>(this, "ManipulationDelta");
var pageManipulationCompleted =
Observable... |
I have some code designed to simplify managing multiple asynchronous operations. The code creates callback actions that, when executed by the asynchronous operation, track which asynchronous methods have completed. When all have completed, the class executes a specially-assigned method.
The purpose of this is to wait f... |
I have a class hierarchy similar to this:
struct VideoCapture { virtual open(const string& uri) = 0; virtual close() = 0; };
struct VideoCapture1 : public VideoCapture {...};
struct VideoCapture2 : public VideoCapture {...};
struct VideoCapture3 : public VideoCapture {...};
I added the following constructor and dest... |
I need to select the <table> before the table where the link I clicked. I can't use IDs, because I don't want to edit my jQuery every time I add a new table.
but this looks kinda bloated for me:
$(this).closest("table").prevAll("table").first().css( "background", "yellow" );
take a look here: http://jsfiddle.net/syddm... |
table_with_headers = $(this.dom.table).find("thead tr th").map(->
$(this).text()
).get().join("\t")
Can one write it nicer? I especially don't like the inner function in map syntax enforced by CoffeeScript and jQuery.
|
I was messing around with Javascript in Khanacademy the other day and this "monstrosity" was born. It's a terrain generator that uses a simplified version of the random walk method.
// current tile position
var BlockX = 200;
var BlockY = 200;
// tile size
var SizeX = 2;
var SizeY = 2;
// min and max X positions
var M... |
My background for this review is a university course in embedded systems using MicroC and this question. Now my program appears to run ok, but I'd like to know what you think can be improved or if the solution I've done so far is not acceptable for some reason?
#include <stdio.h>
#include "system.h"
#include "includes.... |
Problem description:
I have a numpy array cps from which I want to extract the maximum value in each of the
subsets of the array (a subset is defined as non-zero values which fall between zeros). The input and how the output should look like are illustrated in the following figure.
Note: cps only contains positive val... |
This code is similar to Underscore. I've added in some functions to fill in different use cases.
For example, one can use someKey to iterate through localStorage and sessionStorage.
Underscore does not have a good way to loop through localStorage / sessionStorage as it is incorrectly detected as an array like object, ... |
I have the following Java class:
import java.util.Random;
public class RandomNameGenerator {
private Random rand;
private static String[] prefixes = { "Ultimate", "Bloody", "Crooked",
"Hallowed", "Magnificent", "Heavy", "Jagged", "Grand", "Shiny",
"Rusty" };
private static String... |
I'm in the process of re-writing a method I've come across in our code base. It's pretty lengthy and a lot of it seemed redundant. It's a Discount object class member. It operates on the discounts DiscountRules property.
DiscountRule can have behave as follows:
Can apply to all brands and a single category
Can apply ... |
I wrote a class which can format input so that it is properly aligned.
I'm interested in all suggestions (regarding structure, usability, style, naming, comments, etc).
I'm especially wondering about:
Is there a better way to write the tests? I want to first test the Content class, and then test the Align class (so th... |
The code appears to work fine. The values are returned as expected from the DLL and the values are added correctly to the DLL.
Will the way I am passing the string to C# cause a memory leak?
Also, I have to return a string from C# as type LPSTR to add to a char pointer, how could I change it so I could use the string ... |
Recently I have been looking into Symfony framework and I am working on a task where I need to upload a file using a form. Once the form has been submitted I need to insert the user input along with image name and path in database using Symfony framework strictly (not standard PHP), the upload process also need to cons... |
Problem statement
The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the monsoon, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
Now, a new Utopian tree sapling is planted at the onset of the monsoon. Its... |
I implemented ArrayList functionality in C as follows:
#include <stdlib.h>
#include <assert.h>
#include "ArrayList.h"
struct _arraylist {
size_t size;
void ** data;
};
struct _arraylist *arraylist_create() {
/* Allocate Memory */
struct _arraylist *list = malloc(sizeof(struct _arraylist));
assert(... |
Please look over my new object-oriented version of my Hangman game I posted here about two weeks ago.
I know I should work more on commenting and be clearer and more descriptive of the methods and their parameters and returns.
Menu class
public class Menu {
public static void main(String[] args) {
//Loop t... |
I wrote this code to show how wrong I was about Random Number Generators.
Context:
From Comments to this answer to Regularity in the "Rusty Towel of Mutual understanding"
that isn't really a percentage of chance though, the chance that the
number returned is under 10 and/or under 50 is not 10% or 50%. you
actuall... |
I have these three helper functions that I've used on some projects as a slightly better alternative to the C memset function. The objective is to simplify and clarify code, as well as add asserts where possible:
// Zero fills a POD type, such as a structure or union.
template<class T>
void ZeroStruct(T & s)
{
std:... |
Based on this answer: MVVM implementation using C# and XAML, I understand that my ViewModel is some kind of a wrapper for my Model.
Being a fan of DI and SOLID principles, I have made my ViewModel Model-dependent.
CustomerDetailViewModel
public class CustomerDetailViewModel : ViewModel<Customer> {
public CustomerDe... |
I've been working on an older project with framework is 3.5 as the target. There is a new user control that displays a list of data from a web service. I hit the web service (Soap/XML) and deserialize the data into a list of a custom model/class (this is in a helper class outside the user control).
Back in the user con... |
This follows on from a previous question I asked which was of huge help to me. I am still only learning Python and Django and I would love to learn how to code better.
The below is a get_context_data method which is used to return a variable to an internal page of a Django SessionWizardView. The SessionWizardView ... |
I am currently implementing a thread-safe in-memory cache mechanism, with the intent of storing objects that are expensive to create or often used by the system.
I also want to include an expiration policy, i.e number of times an object was accessed and when it was last accessed. This will be used to scavenge, so I opt... |
Me and another developer have recently forked and taken over an abandoned, open-source project. I have also been reading articles and watching videos by Misko Hevery.
When I was reading through the project's code, I noticed a lot of no-argument constructors. And that the fields are being assigned via static calls inste... |
I'm currently learning Ruby and need help in editing code to be more idiomatic. I have the method below I could use some pointers on how to make more "Ruby" :-)
def print_cal(day_of_week, month_len)
days = %w(Mon Tue Wed Thu Fri Sat Sun)
days.each { |day| print "#{day} " }
puts
day_num = 1
month_started = f... |
I'm working on code for an assignment and I was hoping you all could point me in the right direction.
Basically I had to write a program that will issue out a multiple choice test. I have 4 options, A, B, C, D and if the user accidentally chooses something other than my options I want it to ask the question over again.... |
I'm writing implementations of some numerical methods to solve linear equations systems, those implementations use the following Matrix class. I'm trying to get this class immutable, due to that the constructor and some methods create a copies of the backing two-dimesional array. The class have some basic functionality... |
In a QGIS 2.0 plugin for windows, I calculate length and update a field with the values. It works, but takes a lot of time. Execution for this part only takes about ten minutes. Can anyone suggest anything to speed things up?
def calculatelength(self):
idx = self.resLayer.fieldNameIndex('Longueur')
caps = self.... |
I have written some VBA to loop through a directory of 15,000 XML files and extract key information from these files into Excel - this is unbearably slow. Can someone please assist me in optimising the module?
Sub ImportXMLtoList()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
oldStatusBar = A... |
The following Awk code was created in order to verify if free memory from the top command is less than 20% of the total.
I've noticed that I actually do not need the top -n1 | grep Mem |, because the FREEM and TOTALM parameters are inside the third awk line.
But on the other hand, I could not run the Awk as:
awk -v FR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.