instruction
stringlengths
71
71.9k
I'm trying to learn more efficient coding so I'm doing some challenges. I have a challenge where I'm given some hex data. I know that hex data is XOR encoded with a four character long ASCII key. The only thing I know about the clear text data is that it contains "a lot of '#' and space characters". I don't know what t...
Each field is prone to throw an exception if not found. If one element not found, then the next should be checked. I have put each element in a separate try/catch. Is this a correct approach or can it be optimized? def getLinkedinDetails(self, gearman_worker, gearman_job): driver = webdriver.PhantomJS('/usr/local/b...
Please review my code and tell where I can improve my program. #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #define BUFFER_SIZE 1024 #define TOKEN_SIZE 32 #define TRUE 1 #define FALSE 0 int isKeyword(const char* token) { const char keywords[32][20]={"auto","break","case","char", ...
During the past few days, I have written a small C++14 library which mainly provides the cppsort::sort function. It is designed to efficiently sort small arrays when their time is known at compile time, and to fall back to the standard library std::sort otherwise. While I am rather confident that the new sorting method...
I am creating instance of the same object to populate its properties twice. I need to give this object to another developer who just don't need constructor at all, as he is sending me object through WCF service. var a = new Earth(); a.ID= 11; a.UpdateUniverse= true; a = new Earth(a); // use age and Taxrate to populate ...
- INTERRUPT HANDLER - > READ FROM IN.1 THROUGH IN.4 > WRITE THE INPUT NUMBER WHEN THE VALUE GOES FROM 0 TO 1 > TWO INTERRUPTS WILL NEVER CHANGE IN THE SAME INPUT CYCLE I was stuck on this one when I went to bed last night. But of course, like any good programmer, sleeping is when I get most of my work done. M...
I have added the full code of my current Gmap component, which is a convenience object to abstract Google Maps functionality: define(["jquery", "gmaps"], function( $, Gmaps ){ var CompGmap = function(){}; CompGmap.prototype.makeGmap = function( el, params ){ return new google.maps....
Having answered this question over on Programmers.SE, I found myself wondering how much effort it would be to write a descriptor that can automatically figure out what the 'destination' attribute would be, e.g.: class Demo(object): foo = Something() would redirect access to the foo attribute to _foo by default. T...
In order to perform form validation, I have created a custom object: define(["jquery", "validate", "activities/new/common/components/BaseFormdata"], function($, Validate, BaseFormData){ var FormData = function(options){ this.defaults = { name: "", privacy: "", ...
I have made my first program that draws a colored rectangle on-screen. I want to know the best practices of making OpenGL and GLSL programs. #include <GL/glew.h> #include <SFML/Window.hpp> #include <iostream> #include <string> #include <vector> #include <stdexcept> #include <cassert> #define GLSL(src) "#version 400 co...
I've created a UserControl that should act as a control inside a Window: XAML: <UserControl x:Class="MyApplication.UserControls.DateTimePicker" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conver...
Imagine you have a series of n points randomly generated in a box in 3D space. You also have a list of distance bounds, e.g. points 5 and 3 should be between 1.0 and 2.0 Angstroms apart. There are various methods to get from random coordinates to a solution that fills some or all distance bounds. Below is an implementa...
Is it okay to return IEnumerable<KeyValuePair<string, string>> from a private method instead of returning a read-only dictionary? This allows for shorter/simpler code. Note: In the below code, PropertyDictionary is a static property that returns an IReadOnlyDictionary<string, PropertyInfo> that was created through refl...
Recently, I have started to enter the realms of embedded systems programming. And, as my first major project, I thought I'd do the obvious: FizzBuzz. However, this is a little different: this is a game. Like my FizzBuzz Challenge, the user must enter either Fizz, Buzz, FizzBuzz, or the number itself. Here is the genera...
This code works and does the job, but it's poor, rudimentary and has some issues with the scrolling event. Can somebody help me to optimize the scrolling event? Prototype Structure and desired behaviour: There are two containers, .layout__left (red) and .layout__right (green). The green container will have the main co...
I use PDFminer to extract text from a PDF, then I reopen the output file to remove an 8 line header and 8 line footer. Is there a more efficient way to remove the header/footer, either in place or without re-opening/closing the file? Please mention general best practices I did not follow. # convert PDF to text def writ...
I am interested in removing leading/trailing whitespace in a .csv file, and I was wondering if there's a better way to execute this: with open("csv_file.csv", "rb") as infile: r = csv.DictReader(infile) fieldnames = r.fieldnames #Creates list of fieldnames for row in r: for f in fieldnames: ...
I got bored and started making a game using HTML5, CSS3, and JavaScript/jQuery. I've been working on it for about 2 weeks and it was running pretty well. Today I opened it and was moving the player's ship around the screen and noticed that it became very slow as the game went on, starting at 10 seconds after the page ...
I want to know if my code is good, with reasonable efficiency, and if it is possible to improve my code and how. What would you suggest? import java.util.HashMap; import java.util.HashSet; import java.util.Set; public class FindAllPermutationsWithRepetitions { public static void main(String[] args) { Stri...
Just wanted to run through my PHP session handling and get some feedback and tips with regard to what is good (if anything!), what could be better and what is either plain wrong, or using out of date methods. Just as a bit of background, I have only ever dabbled with PHP (and many years ago that was) and want to try an...
I would like to create two date formatters only on first call. In Objective-C I would use dispatch_once() but now working in Swift. Am I doing it correctly? My code is based on example that was using class instead of static but it looks like it's Swift 2.0 doesn't support it yet. class HomeContentItem : NSObject { ...
I'm having a hard time rewriting this method to something more legible and understandable for the reader. static Stream<Class<? extends MyType>> collectMyTypes(Object o) { return Reflection.lineage(o.getClass()) .flatMap(c -> Arrays.stream(c.getDeclaredFields())) .map(Field::getGenericType) .filter(...
This code simply receives a very basic 'password' (numbers, letters, nothing fancy). After you press enter, it will display it back. The only special key I'm handling is backspace (code 8 in ASCII). uses crt; var pass: string; key: char; len: integer; begin clrscr; key := chr(0); pass := chr(0); write(...
I have a Python class for which I'm often going to want an instance with the default arguments, but I want the class to allow creation of instances. For brevity I'd prefer that the default instance be accessible as a property, so that it can be accessed without a method call. However, the code to achieve this in the wa...
I'm working on a script that focuses on faster mousing. It has hotkeys to: snap the cursor to hard-coded locations, swap the cursor to the location where it was last swapped from, and save and snap to custom locations. I've been steadily refactoring with an eye to DRY and other principles. For example, the script us...
I'm writing an Python application that uses frequently datetime and Unix timestamp. I know Python is 'batteries included', however, I found that converting between datetime and timestamp in Python 2.6 is not trivial. That's why I wrote this utility class. This code works as expected, for Python 2.6, 2.7, and 3.4. I wan...
I'm trying to parse Double from String in Java. The string input is not necessarily a number, any non number input should be treated as 0. Given below is a solution using try-catch, where a Array of string is converted into a Array of Double: public static void main(String[] args) { // Array of strings to be parsed...
I am working on a payment process. Upon a successful payment process, I have to create multiple records. For that, I have made this class: class DatabaseMaintainer def initialize(merchant, card, payment_method) @merchant = merchant @card = card @payment_method = payment_method end def maintain_recor...
I have the following two unsafe methods that I would like to refactor: public static unsafe void UnsafeMethod(byte[] array, int pos, short value) { fixed (byte* numRef = &(array[pos])) { *((short*)numRef) = value; } } public static unsafe void UnsafeMethod(byte[] array, int pos, int value) { fi...
Here is an attempt to extend the Kadane's Algorithm to return the sub array itself instead of the sum of maximum sub array. This must work irrespective of the original array having all positive or negative numbers. public class MaxSubArray { public static void main(String[] args) { int array[] = {10, -9, ...
Following-up on CommandBars, Buttons and Commands: Cleanup is on the menu, I decided to try a more ambitious approach, as suggested in Nikita's answer. It works, but there are a number of "gotchas" that I'm not sure how to clean up. So I have an ICommand interface, and its generic counterpart: public interface ICommand...
A while ago I've written a custom validation method for .validate(). It is a local validation plugin, with some limited validation. I was required to write a validation method with the following requirements: Must accept a custom string. Must allow a maximum value. Must allow a minimum value. Has to allow to have dyna...
I'm receiving an language string out of an PHP file which returns an array like this: DIR_LANG\en\home.php: return array( 'welcome_string' => 'welcome @ home! ' ); And my Lang class: <?php class Lang { private static $langArray = array(); private static $lang = DEFAULT_LANG; public static func...
I want to make my code more efficient by instead of repeating my code again for level two, as the only change from level one to level two is the random numbers change from 1-10 to 1-100. I think I can make these a variable making max_number = 10 for level one and max_number = 100 for level two and use the same code, ha...
This code adds the toggle functionality for mobile devices. So, for width lower than 990px, the panel collapses, and the user can toggle to open / close it. angular.module('app') .directive('ngContentToggle', function($window) { return { link: function(scope, $element){ var w = angular.element...
In order to reduce redundancy in my app, I have added the method self.find_or_keep(object) to many of my models in order to find existing records with the same values, so I can reference the already existing ones instead of creating new records. Basically, this method checks most attributes for equality between two obj...
The idea for the code I have written came about due to the acts_as_versioned gem which automatically nests a Version class onto an ActiveRecord model. I wanted to use this same type of concept where a class has a companion class, however, one drawback of the gems implementation is that sub-classes don't get their own ...
I am testing the WIFEXITED to see if a child process exited abnormally or normally. According to documentation, it should return a non-zero status for a child process that terminated normally. #include <wait.h> #include <unistd.h> #include <iostream> #include <sys/types.h> int main(int argc, const char* const* argv) {...
I'm working on an PHP application that will allow (but not require) chunked file upload (from jQuery File Upload on the front side). I tried to find appropriate code and was only able to find the example from the JS library, that is, in my opinion, too bloated (it includes image resizing, etc). I made my own, really ba...
I wrote a simple dll which is able to calculate all common holidays, but, I would like to optimize the code in readability and flexibility. Federal state public enum Bundesland { BadenWürttemberg, Bayern, Berlin, Brandenburg, Bremen, Hamburg, Hessen, MecklenburgVorpommern, Niedersach...
I am working on rewriting an application in Laravel 5.1. I am new to the exception handling technique introduced in 5.0. I have overlooked taking advantage of throwing/catching exceptions frequently in the past, but am working on this now. I am most likely not up to speed on some of the best practices. public function ...
The existing design of class DList and DListNode is taken. The main criteria is to do successive updates in \$O(1)\$ time. Part III (3 points) Implement a "lockable" doubly-linked list ADT: a list in which any node can be "locked." A locked node can never be removed from its list. Any attempt to remove a locked no...
Any suggestions for improving this? I'm hoping for some JavaScript object structure / code integrity type recommendations rather than style or CSS. var list = [ {name: 'Afghanistan', code: 'AF'}, {name: 'Åland Islands', code: 'AX'}, {name: 'Albania', code: 'AL'}, {name: 'Algeria', code: 'DZ'}, ...
I'm trying to figure out a better way to have one query here. I want to be able to send something to last where statement a wildcard so I can select all vendors. Right now if I don't include that line it doesn't filter by vendor so I essentially get all the purchase requests. Any thoughts of a cleaner way to do these q...
I have this controller that I call via Ajax, where I update the likes of a post. I have two methods in the user model: already_like_post?: Where I pass the posted ID and return true or false if the post is already liked. dislike_post: Delete the user like for given post. class LikesController < ApplicationController...
What I need to accomplish is matching the QR code to the one I have created. This code works, except it takes at least 30 seconds to verify that it has matched my QR Code. How can I make it faster? QRCodeVC.h #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface QRCodeVC : UIViewController <AVCaptur...
I am a newbie at programming and I helped my dad with making this program which orders multiple products to a website from a table of Excel. It involves 3 processes: Passing orders from Excel to website by injecting JavaScript. The website provides a function for ordering a product: (in JavaScript) updateProduct('{ref...
This is my final project for my second Java class! I would like to get some feedback on it to see where and what I can improve. There are five class files: GuiMusic This contains all all of the the Swing and AWT components and the key listeners. ScrollPaneSync Synchronizes the scroll bars on each JPanel. Stringbillde...
This is a little tricky to explain, so bear with me. Suppose you have an integer X and a list of integers A. Let A` be a copy of A where all values A[i] != X are replaced by -X. For example, X = 5 A = [1, 3, 5, 5, 1, 5, 4, 1, 8] would result in A` = [-5, -5, 5, 5, -5, 5, -5, -5, -5] The task is to find a subsequenc...
After playing Mancala with my brother, I thought coding the game would be a fun project to practice my abilities in C++. I am relatively new to programming, having only done a few small projects to experiment with the basic features of the language. So I consider this to be my first legitimate application of my skills...
This code takes an image and detects a global shortest path from the top to bottom row, with the requirement that top and bottom column index be the same. For this, it scans through each element on the top row using Dijkstra's algorithm towards its corresponding point on the bottom row. The shortest path is defined as ...
This is a BitSet wrapper class to act as a Sieve abstraction for a prime calculator. Review for performance and Java/Java 8/Guava best practices. package info.simpll.immense.prime; import com.google.common.base.MoreObjects; import java.math.BigInteger; import java.util.BitSet; import java.util.Objects; import java.ut...
I'm trying to think of a better way to write the below Javascript/NodeJS code without having to check the value of the boolean using an if statement. I know this can be accomplished with a ternary, but that would look ugly. This is of course only an example, I'm sure there's a better way to write this; however I'm spec...
I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different titles. Here is an example two different titles: vision_am_2015-08-04.mp3 vision_am_2015-08-03.mp3 vision_am_2015-07-31.mp3 vision_am_2015-07-30.mp3 lum_pro_2015-08-04.mp3 lum_pro_2015-08-03.mp...
This is an algorithm that takes in an ArrayList of objects that store information on meeting/event schedules. This algorithm's purpose is to check and see what the user's status is based on their current time. The case scenarios are: The user's current time is before all meetings The user's current time is during a me...
Oftentimes I find myself converting pandas.DataFrame objects to lists of formatted row strings, so I can print the rows into, e.g. a tkinter.Listbox. To do this, I have been utilizing pandas.DataFrame.to_string. There is a lot of nice functionality built into the method, but when the number of dataframe rows/columns ge...
I wrote this program in response to a CodeGolf challenge that required generating this sequence of "untouchable" numbers. This sequence can be found on OEIS as A005114. My initial implementation was prohibitively slow when asked for anything other than the first few terms so, I wrote this implementation with the goal ...
This is actually a function from the first commit of the git source code, for the purpose stated in the title: static int verify_path(char *path) { char c; goto inside; for (;;) { if (!c) return 1; if (c == '/') { inside: c = *path++; if (c != '/' && c != '.' && c != '\...
Using JavaScript cloud code, I'm trying to bulk convert a huge number of URL entries into actual files uploaded to Parse.com. This code works; I just want to make it cleaner/nicer. Parse.Cloud.job("convertFiles", function(request, status) { //Cuts the rundata out of poor runs function sleep(milliseconds) { ...
I am creating a class project which involves two classes: Library and Book. I would like a general review on the code. public class Book { private String title; private String author; private String summary; public Book() { title = ""; author = ""; summary = ""; } publi...
In a response to this post I wrote a solution in Python. It passed all the test cases given, so I would like help making it more pythonic and reducing the almost repeated lines. Link to the source of the question on HackerRank. # input M, N, rotations = map(int, input().split()) matrix = [] for row in range(M): mat...
I wrote this method that adds two integers in the form of strings together. This way I can add large integers without overflowing. How efficient is the code that I wrote? I am by no means a great coder, but I would consider myself somewhat decent. Is there anyway that would make it better? I am a self taught coder an...
I have an .mdf DB file and I want to use this DB for integration testing. In every test I should: Create a copy of an .mdf file. Attach DB to an .mdf copy file Do testing Detach DB copy Delete DB copy Just to make all clear, integration testing should look something like this: [TestFixture] public class WebJ...
It is a set of edges of a graph given. An edge is given as an array of its endpoints, e.g. [:a, :b]. The array can contain an arbitrary amount of endpoints. Therefore [] and [:b, :c, :d] are also valid edges. I want to find all islands which means that I looking for unconnected sets of nodes. Here is my Ruby solution. ...
namespace Impl { template<typename T> class SharedPtrCounter { public: SharedPtrCounter(T* e) : element(e) { } void IncrementFlimsyCounter() { ++flimsyCounter; } void DecrementFlimsyCounter() { if(--flimsyCounter ...
This method is written for much larger Web application, but I just extracted it and added class and main method around it so that it can be debugged locally. Browser detection is done in another method, then this one is called to precisely determine IE version, i.e. if it is in compatibility mode or not. All other chec...
I'm currently working on this for my own practice. I get 4 digits and an operation. The input is x1 y1 op x2 y2 and the fraction is x1/y1 and x2/y2. If I get the input: 1 3 + 1 2 then it's 1/3 + 1/2 and the answer should be given the minimal fractional so it's 5/6. I pass the testcases I get and I can't figure out what...
I have written this linq-to-sql query to insert a bunch of customer care database analysis detail records: DataClasses1DataContext behzad = new DataClasses1DataContext(conn); var query = (from p in behzad.Customer_Care_Database_Analysis_TEMPs select p).ToArray(); for (i...
I've already written this macro that does exactly what I want it to do. However, it's quite large, and I may wish to expand on it in future. Basically, the purpose is to copy and paste items from a horizontal list (where RNG is equal to the number of items there), and take one cell from each. Any suggestions in cutting...
I'm working on a skill tree calculator for a game and I made a method that checks whether or not it can subtract a point from the skill and then proceeds to do so. Everything is working as it should, however it's very slow when this method is executed in rapid succession (i.e. when 5 points are subtract at the same tim...
I am building a JAX-WS client with a GUI that connects to a server by accepting self-signed server certificates (when it uses HTTPS). The accepting of the certificates is not automatic, it is similar to what happens in any browser when you try to connect to a website that is not trusted. That is, usually a security pop...
I'd like a little help here calculating the view matrix for OpenGL based on the lookat type function: vec3f eye = {0, 0, 0}; vec3f center = {10, 2, 21}; vec3f up = {0, 1, 0}; mat4* vm; mat4LookAt(vm, &eye, &center, &up); mat4print("lookat",vm); Matrix output: lookat [ -0.902861 -0.036833 -0.428353 0...
This copies data from a project into Excel to be calculated into a final report. The code runs pretty slowly at this point and I would like it to be a little bit faster. Are there any blatant coding mishaps that are slowing the calculations down? Sub Update_Schedule() Dim appProj As MSProject.Application Dim aProg As M...
I have these two queries and they work just fine. I use the values they retrieve to populate a title for a view in my application. It seems though that I should be able to accomplish this with one query and I do not know how. Dim firstName = (From row In db.ItemDetails Where row.Unique_Location_ID = locationID An...
I've written a small app using the kivy framework, which aims at reviewing your times tables. My major concern is about making this app easier to improve in the future. That is, how to organize the code to make it more clearer (by adding a User class that would store the data associated to the user, for instance). Sinc...
I am working on improving the runtime of code that undistorts every pixel point in an image. Currently each point is undistorted via a call to cv::undistortPoints() as shown below: cv::Mat src(1, 1, CV_32FC2); // Create src and dst cv::Mat objects for cv::undistortPoints cv::Mat dst(1, 1, CV_32FC2); float* ptr...
I wrote a program to solve a magic numbers puzzle. The puzzle works like this: You have an NxN square where each row, column, and diagonals add up to x except some of the numbers in the square are switched. Find the numbers that are out of place and switch them. Here's an example: 16 16 11 09 14 17 09 29 13 ...
Here is the code I use to get the different weather forecasts from the Environment Canada website: public static void Main() { string url = "http://dd.weather.gc.ca/nowcasting/matrices/SCRIBE.NWCSTG." + DateTime.Now.ToString("MM.dd.HH") + "Z.n.Z"; string allStations = Decompress.zDecompress(url).ToString(); ...
I have a remote hosted server that's running Java VM with custom server code for a multiplayer real-time quiz game. The server deals with matchmaking, rooms, lobbies etc. I'm also using a MongoDB on same space which holds all the questions for the mobile phone quiz game. This is my first attempt at such a project and a...
I wanted to implement Java's Scanner in Scala. The goal for this class is to: Implement a Scala collection interface (probably Iterator[String]?) so I can access all the Scala collection goodies like map, .toList etc. Have better performance than java.util.Scanner Please review my code for bugs/design advice/performa...
The code below is the Index Action from a User Controllers. Basically this code returns a list of users from Azure Active Directory using Azure Authentication Library (ADAL). However I need to show 2 custom properties, in Azure AD, they are called Schema Extensions, they are just custom attributes where I saved custom...
I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and the possible dangers, pitfalls, or improvements. var CWD = process.cwd() var assert = require('assert') var path = require('path') var os = require('os') var ...
I have to two datepickers. I want achieve the following functionality: the return date cannot be selected before the selected departure date and the departure date cannot be after the selected return date. Mainly I am interested in correctness of my angular architecture. I have moved datepicker into my custom directive...
I just started learning programming in the past two or three months. I started with Python, and now I'm learning lua. I started game programming this week and this is a game I made with the Love2D engine for lua. If you don't know how it works, there are these three main functions: love.load() -- Runs at game startup...
In my question to learn F#, I've decided to get one step closer to creating a programming language, and implement this simple Reverse Polish Notation "interpreter" of sorts. It does not allow for parentheses in input ( ), and only accepts expressions containing the following valid tokens: 0 1 2 3 4 5 6 7 8 9 + - * / H...
I have following Java class called TheNewMario. It reads a String path and iterates through the path from S to F. If the path is closed, we assume the runner can jump. The class returns the amount of steps it takes to get from S to F. I have added two path files. In the first example path, it works fine, but when the p...
I am restudying graph theories and I want to write a Graph class that would allow me to implement those methods. Is there a better way of implementing a general Graph class? Main function: int main() { using namespace GraphUtils; Graph<char> graph; Node<char> a('a'); Node<char> b('b'); Node<char...
The Goldbach Conjecture asserts that any even number over 2 will be the sum of exactly two prime numbers. I've created a function to find two prime numbers that add up to the number entered, but would like some help streamlining it and making it more robust. One thing I would like to add is the ability to find all pr...
This is a problem in CodeEval, moderate level. The problem is very easy for this level. But I am not able to get more than 60 points for any solution I submit. (Moderate levels highest score is 65 and they take speed and memory into consideration.) The problem statement is: There are two strings: A and B. Print 1 if s...
I'm working with a database that has typos in the values. To compensate for them I've made a function called standardizer() which removes spaces and converts all letters to uppercase. I do this so the value red in from the database can correctly be interpreted by the program. Also in values starting with the prefix 'sp...
MVC 5 doesn't seem to like JavaScript that much. I am creating link in JavaScript to a success method in my Ajax call. Razor: @Html.ActionLink("Amount", "Action", "Controller", new { id1 = "a", id2 ="b"}, new { target = "_blank"}) JavaScript: $('#element').html('<a href="' + '@Url.Action("Action", "Controller", new { ...
I am working on a KNN implementation for sparse datasets (that I apply to text analysis). My points are represented by a Dictionary<string, double>, each key represents a word of the text and the value, its count or TFIDF. I am using index inversion to reduce the number of distances to evaluate. However, evaluating th...
I had a task to realize ReadWriteMap public class ReadWriteMap implements Map { private HashMap map = new HashMap(); private ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); private Lock readLock = readWriteLock.readLock(); private Lock writeLock = readWriteLock.writeLock(); @Override ...
I have created this code for both boolean and integer values to display a truth table for an "AND","OR","XOR", "NOT" gate. However I think that my code needs reviewing as it could be simplified. public class LogicalOpTable { public static void main(String[] args){ boolean p,q; System.out.println("...
I have the below code to list all tables which have columns DataAreaId and CountryRegionId. This works, but requires me to change the code in two places if I amend the column list (i.e. both the name in ('DataAreaId','CountryRegionId') code to list the required column names, and also the having COUNT(1) = 2 to match th...
Refer to the help message and title of this post for what the code does. I'm looking for tips on: Efficiency: While the find-and-replace approach I have works perfectly fine and does so in a relatively quick manner, it feels far slower than it could be. Idiomaticness: As always, I like writing code that abuses every f...
I have a procedure for conducting ANOVA, the details of which can be viewed in this white paper. I would like to be able to make the routine scalable to handle any number of groups. Below is the R code for a 2 group example. Any insights or comments are appreciated. Partial Moments: LPM<- function(degree,target,variab...
This code embeds a hyperlink into a cell of your choice of an Excel file. /** * @param pathName the path for the Excel file which you will update * @param string the string you want to put in the cell, and if you put an empty string, it will default to * "Empty String" * @param hyperlink the h...
What can be made better? How ugly is my code? If it's terrible, where can I improve? DECLARE @startDate char(8); DECLARE @endDate char(8); DECLARE @termStart char(12); DECLARE @Facility nvarchar(255); -- ************************** IMPORTANT ********************** -- SET THE START AND END DATES TO PULL DATA FOR THE DAT...
This just adds fractions. For example, if we have a text file with: 1/3 1/2 It will print: 5/6 I would love to hear some remarks on how I can make this more Scala-like. class Fraction(c: BigInt, d: BigInt) { val divisor = c.gcd(d); def counter = c / divisor; def denominator = d / divisor; def lcm(a: BigInt, ...