instruction
stringlengths
71
71.9k
For an interview question I made a roman to integer converter: def romanToInt(self, s): """ :type s: str :rtype: int """ mapping = {"I": 1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000} numeral_list = list(s) num_list = [[mapping[i], -1] for i in numeral_lis...
I need to encrypt/decrypt 2D arrays (double pointers) using AES-128/CTR using Intel TinyCrypt (written in C). The following are two helper methods to simplify the library usage. Any comments would be highly appreciated. Thanks in advance. #include <tinycrypt/constants.h> #include <tinycrypt/ctr_mode.h> #include <tinycr...
I have a finance web-application in ASP.NET WebForms using Telerik RAD controls. Two event handlers wound up being very similar in implementation. What steps could I take to improve the organization of and/or the efficiency or DRY-ness of the code? What other issues / code-smells are present? The Code Update Event ...
The purpose of this function is to determine if report_input_file is either in JSON format or XML format, this is what I came up with, just want to know if this is best practice / pythonic way of achieving this? def parse_report_file(self, report_input_file): """ Checks if input report file is of type json or xml "...
This is my code: <?php $begin = microtime(TRUE); $result = get_web_page('WEB_PAGE'); $dom = new DOMDocument(); $dom->loadHTML($result['content']); $xpath = new DOMXPath($dom); // Get the links $matches = $xpath->evaluate('//li[@class = "lasts"]/a[@class = "lnk"]/@href | //li[@class=""]/a[ @class = "lnk"]/@href');...
What are the best practices to writing clean, expandable game code? I always end up getting overwhelmed with my games because the code gets very unorderly. I use OOP (java), but I still feel like my code is unorganized. I will get examples below. The blocker class is basically like a pipe in flappy bird. It moves aroun...
How do I refactor common code with different union types? I'm still struggling with refactoring F# code with different types but same behavior. I have the following function that I would like to refactor: let movePiece destination positions piece = let foundPiece = positions |> List.filter (fun space -> space = Al...
I implemented Kosaraju's algorithm on a graph with 800k vertices and 5100k edges. The time taken by various operations are: building graph took 11.84 seconds ordering took 2.54 seconds finding SCCs took 2.63 seconds My computer has an i7 with 4GB RAM. I would like to know if my code can be made more efficie...
I'm writing some unit tests for testing C# code but I'm using F# and Unquote for the first time for the unit tests and would like some input as to how I might make the tests more 'f-sharpier' to take advantage of and learn more about the functional approach in F#. Here's an example of one of my tests - please make reco...
I am making a simple function to find and match any possibilities what Pokémon the user wants. This is accomplished by taking in the input (what the user thinks the Pokémon is named) and compare its spelling with preset Pokémon names (letter by letter searching). With each successful match, the Pokémon's score (determi...
Pretty standard. Generates the first n primes, input via a scanner. package main; import java.util.Scanner; public class Prime_Generator { public static void main(String args[]) { int n; int status = 1; int num = 3; Scanner scanner = new Scanner(System.in); System.out.print("First n ...
I have written this implementation and I would love to make it more efficient. While I am indeed requesting a code review/suggestion, I would also love to get feedback on readability and coding style. Every bit of input helps The main code for this factory is below: (function(window, q, $, cordova) { "use strict"; ...
I started to learn C a week ago and this is my culminating program of what I've learned but I could use a few pointers. #include <math.h> #include <stdio.h> void binary(int n){ int x = 0, m = 0, z = n; while(n >= 1){ ++x; n /= 10; } n = z; int i[x]; x = 0; whi...
I haven't programmed in a while and need to improve my code in any way possible: efficiency, readability, etc. This program is for getting integer coefficients of any polynomial and factoring: ex. $$ 2x^2+8x^1+8 \longrightarrow 2(x+2)(x+2) $$ What advice can you offer to help me out? factor.py (Main file) #!/usr/local/...
Is there anything I can do better here? I tried looking for ways to simplify this with comprehension but could not figure out how and was told it is better to explicitly use for loops. import re print("This is a email/phone number parser.") print("Type in the name of the file you want to parse:\n") filename = input(">...
This may seem like a lot of stuff? I just need help with 2 small parts the code works, however I have provided the rest of the info in case some one can help. USING PYTHON 3.4 Code below is responsible for comparing multiple CSV files against a cross-reference file and creating a metadata file, information files, also ...
I have subclassed Qt QAbstractTableModel with QJsonDocument as data source which I have reimplemented the setData() method in: bool UeJsonPlacesTableModel::setData(const QModelIndex& index, const QVariant& value, int role) { if(role!=Qt::Edit...
I have the following code (running in LINQPad) which takes tens of thousands of CSV files and concatenates them to create a single file. Each CSV file has two lines: a header line and a data line. I need the header line only once, then the rest of the lines are data. However, it appears to be getting slower as it runs ...
There is a lot of code duplication because it generates hashes using multiple cryptographic hash algorithms. How can I improve this code? package main; import java.util.Scanner; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class String_Hash_Gene...
Somewhat experienced with JavaFX, but this is my first potentially large JavaFX project that I recently started and wanted some feedback on anything that could be done better or more efficiently thus far, before continuing. Note: I am aware that there are a few functions not in use, I'm just leaving them in for future...
I'm developing a Tic Tac Toe game where you can change your pawn look Now as You can see it has 2 buttons one for next one for previous, and You can also pick if you want to edit the O or the X sprite. Now here comes the custom collection I made and the reason for that is because I need something that can remember wh...
I have a situation where I have a program will start up another program and it will do some work. I need to be able to stop this work if certain conditions arise. I want to use a CancellationToken on the worker side but as far as I know these can't be used across process boundaries. I wrote the following code to acco...
A solution for the August 2016 Community Challenge (Rainfall). I've intentionally left out error checking on the file formatting. This seems like a very obvious graph problem to me - we want to partition some graph based off of relative elevations. I've used networkx 1.9.1 to operate on the graphs, and matplotlib to ...
The following Golang code accepts a sequence of numbers (any integer and float type) in the terminal, adds them, and prints the result (sum) to the terminal. Actually in Golang you can't add different integer types together, because of which this script accepts all the digits as a string representation of space-separat...
I'm using the icalendar module to parse (google) calendar entries and the dateutil.rrule module to deal with recurring events. Right now, I'm using the rrulestr class to parse (part of) the RRULE data and rruleset to add EXDATE entries: from icalendar import Event from dateutil.rrule import rrulestr, rruleset from date...
How can I optimize this code? #include<iostream> #include<queue> using namespace std; struct Node { int data; Node *left,*right; }; Node *createNode(int data){ Node *node=new Node; node->left=NULL; node->right=NULL; node->data=data; return node; } Node buildTree(Node *newNode,queue<Node *...
As a puzzle we were asked to bring out the possibilities in breaking a 4 letter wordlock combination. It was to be a four letter word from the English dictionary. There were 10 possible characters in each place. So \$10^4\$ possibilities of random words. I brute forced my code to return a list of possible words by firs...
This code is a server for websocket connections, it handles the low level stuff and delegates incoming messages to handler objects. I wanted performance to win in any trade off against maintenance costs or readability, but security should be as good as possible without becoming unfit for purpose. It "works" and I'm usi...
My job entails me to send a lot of emails. I'm really bad at typing so I decided to create a program to do it for me. I've created an email generation tool (originally posted here.) I've changed everything around so that I was able to push the tool to Github, so now you can actually run it, and fall in love with it's m...
I came across an interesting method of solution for the Tower of Hanoi puzzle and wrote a short version of it as a programming exercise. The program produces the correct results but I have two questions. First is there simpler way to write the alternating step of determining the only valid move which does not involve t...
Trying to implement producer/consumer problem in C++. I have one question: should I use nofify_all or notify_one method here? Also any feedback is welcome template <class T> class Stack { public: Stack(size_t size) : size_(size) { arr_ = new T[size_]; init(); } ~Stack() { de...
My intention is to create a complete HTML parser, so far I made a basic algorithm that iterates trough text and extracts everything in an "a" tag. It works on everything I tried, but I want a review of what I could do better or what I did right. #include <iostream> #include <stdio.h> #include <vector> #include <fstream...
I made a Morse code translator in Java in which a user inputs a word/words into a text field and the program converts it to Morse code and beeps the Morse code. I have a feeling that my code could be much better, and that it is not efficient enough. Please tell me if there is anything wrong with my code, including effi...
I have a function that will try to find a bitmap within another bitmap. If it successfully finds it, then it will return the center point of bitmap #1. I've only seen negativity towards goto which is what this function relies on. I would like some help optimizing my function and possibly having it work without the need...
I'm working on a simple async TCP client server application, i'd like my network code to be reviewed. I really feel that I'm doing something wrong, especially in receiving code. Interface for client: public delegate void ConnectedHandler(IAsyncClient a); public delegate void ClientMessageReceivedHandler(IAsyncClient a...
I've been working through the fifth edition of Lajoie's C++ Primer and decided to write a CSV reader/writer as my first project. Its main features are: Able to explicitly call for: Individual/multiple rows by index and range Individual/multiple columns by name and index Able to write new rows using a map<string,st...
This program implements spell checking by loading a given dictionary file into a trie structure and comparing against a given text file: Usage: speller [dictionary] text. When run, each misspelled word is printed along with benchmarks: This was part of a problem set with a given mess of skeleton code (speller.c), whic...
I'm experimenting in canvas and trying to create pan effect. I've managed to pan succesfully, but I'm curious if I'm doing it correctly. Since I've come up with the following code myself, I don't know if there is a better way to accomplish the task. JSFiddle var canvas = document.getElementById("canvas"); var cont...
In the Firemonkey framework of Delphi, there's a feature called Float Animations, which allows you to control real-time "animation" of float values. However, in the VCL framework, this feature is not there. So I wrote this component as an alternative, called TSmoothMove. I know there's room for improvements, but before...
This is my first implementation the binary search algorithm. I have tested it and so far it is okay. But I need an experienced eye to review the code and recommend best practices. bool search(int value, int values[], int n) { bool x = false; int *max; int *min; int *mid; min = values; max = min + n - 1; m...
I've written code that will take any basic math sum input as a string (for instance, 2*3+4/4) and solve it. The way I achieve this is by splitting the string into sub-strings, with multiplication and division being done first (based on the regular order of operations). So in our example sum we would be left with 2*3 an...
This has a couple of twists which I personally found rather awkward... All code can be downloaded in a read-to-run format from here The problem Consider a classic interview question: "Find given pairs with a specific difference in a given array" Here I impose the unique conditions: The array is non-decreasing Consider...
The recurrence function is defined as follows: \$f(0) = 1\$ \$f(1) = 1\$ \$f(2n) = f(n)\$ \$f(2n+1) = f(n) + f(n-1)\$ I was tasked to calculate the recurrence of a very large number, \$n = 66666666666666\$, using C++. As you can clearly see, the 3rd line applies for even inputs, and the 4th line for odd inputs. If th...
I've made this validation class in PHP that would take inputs, on initialization sanitize them and validate them specific to the type. It works fine, but I would like to know if there's some bad practice involved and how I can improve it. I would also love to hear if there's anything that makes the code awful or hard t...
My friend was asked to implement a hashtable with a binary search tree. I tried practicing it myself, and it turned out to be very verbose. I need suggestions to clean this up! public class HashMapBst<K extends Comparable, V> { private class Entry<K extends Comparable, V> implements Comparable<Entry> { priv...
Consider we have to pay the usage of a machine with the following hourly cost: 00:00 - 01:00 --> $4 per hour 01:00 - 05:00 --> $1 per hour 05:00 - 22:00 --> $2 per hour 22:00 - 24:00 --> $3 per hour If we use that machine from a date of x to another date of y with the given weighted time interval w, var w = new List<...
I'm writing a tiny networking library for learning purposes and personal use and I'm not sure if my approach to handling reading and writing exceptions and synchronization is correct. Feel free to criticize my code harshly as I want to learn as much as possible. Reading packets: @Override public Packet readPacket() thr...
The exercise is part of a React course in which I'm currently enrolled. Description: The way it shall look on desktop-screen: How it shall look on mobile: Here's my solution: HTML <div id="display"></div> JSX // Manager bundles the single components together. var React = require('react'); var ReactDOM = require('r...
I'm writing a parser and I need to iterate through text vertically (down to bottom) and horizontally (left to right). This alone would be easy but some text parts need to be rescanned by another parser and for this I need to reiterate over random lines or a text range. I wrote two enumerators. One for enumerating all l...
I made a simple web server in C, and I would like to have your opinion on my code quality. This would help me to improve. #include "signal.h" #include "string.h" #include "sys/types.h" #include "unistd.h" #include "sys/socket.h" #include "netinet/in.h" #include "arpa/inet.h" #include "netdb.h" #include "stdlib.h" #incl...
I need help cleaning up this monstrosity. Basically this is a user helper method that generates an array of cumulative user sign ups per week (start of week == Wednesday) starting 2016-06-15. So something like this: [ 1, 5, 9, 22, 34 ] Where sign ups each week were 1, 4, 4, 13, 12. In production, this is taking 5 secon...
I have a list of \$n\$ words, and a corresponding \$m \space x \space n\$ frequency matrix (as a NumPy array). I would like to return a list/array of strings of length \$m\$ where the \$m\$th string is comprised of each word repeated according to the frequencies in the \$m\$th row of the frequency matrix. I have manage...
I just finished building a simple random Tic Tac Toe generator. The program will display 3 rows of a random numbers 0-1 and will print a message when 3 of the same numbers align. The program works perfectly, to my knowledge. I am posting this code here in hopes that I can gain some advice/tips in regards to optimizatio...
I'm trying to make a model for checking combo presses in a game. Given a list of Button (enum) presses, it returns the list of possible combos completed. I tried using a suffix tree, but I'm not sure if this is the best solution. It's also my first time writing a suffix tree, and I don't know if this is the correct usa...
This is a simple version from the function strstr. It returns the address of the first occurrence of the substring s2 in s1. I want to know possible problems in the code, and how to improve it, in general. #include <stdio.h> /* Version of strstr, which returns the adress of the first occurrence of s2 in s1, else, N...
Say I'm using Parse Server and utilising the PFObject class from the iOS SDK. Say I want to have a Chat class. To use inheritance code (design 1): import Foundation import Parse class ChatInheritance: PFObject, PFSubclassing { init(parseObject: PFObject, chatStatus: ParseChatStatus? = nil) { self.parseOb...
This program starts with initial balance and the individual book balances which must match the initial balance to proceed. The user then enters the selections for the day along with stake, odds etc., then the program calculates the new balance with the new book balances. def main(): def balances(msg): while...
I started this project after reading Chapter 3 of Python 3 Object-Oriented Programming by Dusty Phillips. At first I just wanted to create RPG-based objects to practice inheritance, but now I am more interested with seeing how far I can take this RPG project. Just for reference, I'll say that I am a beginner programmin...
Suppose we have stock price history, and we are allowed to buy only once and sell only once. The problem is to find the maximum profit we can make. Here is my code that I tested for basic test cases. I'm wondering if there are possible improvements for logic correctness. My major idea is to keep record of in history mi...
Got bored writing a review on an HTML parser and decided I wanted to try. So I threw this together to see I could parse an Amazon page. curl -A 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 Firefox' https://www.amazon.com | parser Look what I found on amazons home page: Comment: ...
I am currently using an implementation of the A* algorithm described here. Currently, when I run my algorithm, my IDE lags horribly and the .exe generated also lags terribly. Using the CPU analyzer, I narrowed down the culprit using around 95% of the available CPU to my PathFind method. I'm not entirely sure where to...
I just completed BNR's bronze challenge for disallowing alphabetic characters, and would love some feedback on what I did right and wrong, and how I can improve my code for reusability and maintainability. Here's a snippet of instruction from their book, iOS Programming: The Big Nerd Ranch Guide (5th Edition) (Big Nerd...
I've recently started working on making my own programming language and I just wrapped up its lexer. I'm too young to take any official training in C, compiler construction, or computer science so I'm having mixed feelings in the quality of my code. It seems rather sluggish when printing but I haven't really found out ...
Does this code fine for database reusability? <?php /** * Database * * Class for handling database connections * * * @category Global Class * @copyright --- * @license --- * @version 1.0 * @link --- * @since File available since Release 1.0 * @created --- * @modified ...
I'm writing a todo app as a test. Having never done Ionic nor Angular apps before, I am not sure if I am following best practices here. What I have done is try to keep my controllers thin by placing all persistant logic in the model (service?). And instead of hard coding links in the view, I am calling a function in th...
This is supposed to be efficient code, but it's taking much longer than what a normal insertion sort would take. I can't identify what's the problem with this insertion sort. Is there an implementation problem? // function to sort a singly linked list using insertion sort void insertionSort(element_t **head_ref) { ...
I created a simple app with Backbone and Marionette. In a view I created an onRender function. I created a page that displays a Report with a date filter, using a select tag and affect to an input when the select tag is chosen. I made that with Backbone and JQuery. And for date I'm using Moment.js and Pikaday....
I am writing automated tests for a web app and at one point I need to make sure that a user can only engage in activities allowed by a set permission. I have written all the standalone methods that perform the required tests and now I need to group all of them together and test. I came up with something that looks like...
Problem Statement Given a list of items each having a type associated with it, group them by the below mentioned rule The list should not contain consecutive items that violate the Group setting. For example. An item of "Type1" can have a group setting of 3. This means that there cannot be more than 3 consecutive item...
I'm writing up a game server on which thread-safety is very important, basically for this approach I've decided to move my entire server in a single brain loop which handles everything in a single thread, connections are ran separately in their own separate thread, whenever a packet is received, the brain loop is signa...
I have a class which will add or edit a child. So whenever I click on "save," I need to check the child image. If it's an image, then I need to upload to the image server. Once that's done only, I need to save all other data to the data server. Here, I am looking for better names for methods save() and updateChild(). ...
As part of my VBA Sync Tool project, I need to partially decode files describing Microsoft Office Forms (file format description on MSDN). The file format has lots of structures following a template similar to this one: Where cbForm specifies the combinaed size of PropMask, DataBlock, and ExtraDataBlock PropMask is a...
I was searching for a implementation of a Linked List with the same power as a native List. I wanted functionality closer to a List. The System.Collections.Generic.LinkedList misses some methods I'm used to work with, like Add Sort or access by index mylist[0] I didn't find one so I made one of my own: I added the sa...
I have written a helper class to manage callbacks from Firebase's asynchronous calls. Can this be implemented in a better way? public class FirebaseHelper { private static String TAG = FirebaseHelper.class.getSimpleName(); private static FirebaseHelper mFirebaseHelper; private DatabaseReference mDatabase; ...
I just implement Dijkstra's algorithm in C99. Can you review my code please? I'm looking for any mistake, performance improvement or coding style errors. main.c #include "src/map.h" #include "src/pathfinder.h" int main() { map *map = init(createTuple_2(11, 11)); addBegin(map, createTuple_2(1, 1)); addEnd(map, cr...
The puzzle consists from something like this: You will receive an array of integer with values, then you will receive X numbers. Each number (call it x) represents an index of a 1-indexed array. Look up the value in the array (call it y), then subtract 1 from all the values in the array in the range [x-y, x+y]. The min...
I'm an Android newbie. I have this function in my code: private boolean isLoginNeeded() { final CookieManager cm = new CookieManager(this.getSharedPreferences(shared_prefs_file, Context.MODE_PRIVATE)); try { cm.getCookie("recordar"); } catch (Exception e) { //Remember me cookies...
I lately got interested into betting systems, dice strategies and algorithms. I took some time to think about it and eventually ended up with an algorithm of my own. Considering that I don't have unlimited money that would allow me to test it on a real dice betting site (duh), I have coded a simulation that allows me ...
I have been messing around with practicing some c++ making a little console game, and I would like to receive some advice and tips on how to improve my code. Some of the code is not done, meaning that some of the functions are not done and some are not called but I have tested it and it does all works. Some of my conce...
I implemented two versions of a Fibonacci heap one using a unordered map (mapping keys to their nodes) so that the client can call decrease in \$O(1)\$ average and amortized time. The other one with a dynamic array of nodes and a maximum size for the same reason but in \$O(1)\$ amortize only. Both seem to be working fi...
I am using the AES class (which I think I got from another post on Stack Overflow) for encrypting strings to a database. How robust and secure (would it be easy to break) is this class? Is there any way I can improve it as it is storing usernames and passwords? Please be gentle as I have to be honest although I have sp...
Currently I'm pushing multiple inputs to a array but this is a lot of repeating code, how can I improve this? var tickets = []; $('.js-ticket').each(function(){ var ticket = []; ticket.push($("input[name='ticket_naam\\[\\]']").map(function(){return $(this).val();}).get()); ticket.push($("input[na...
Working on a problem, for a given input sequence to a stack, check whether it could produce (using stack push/pop operations) the output sequence. For example if input is [1,2,3,4,5], possible output is [4,5,3,2,1] (push 1, push 2, push 3, push 4, pop 4, push 5, pop 5, pop 3, pop 2, pop 1), but [4,3,5,1,2] is not a fea...
I recently found out how to use joblib for parallelization. I want to iterate through this string seq in steps of 1 and count the number that word is seen. I thought this would be really fast but for larger files it still takes long. How could I make this word counter faster? def iterSlice(seq, start_idx, end_idx):...
I've created the beginnings of a Twitch IRC bot. As of current, it only has one command (!echo), though the infrastructure is (hopefully) there to library this code and build an actual bot on top of this base code. This is my first time making a system with this much threaded and i/o operations in it, so I'd especiall...
I've been working on this task (see screenshot). Here's my answer to it so far: var sum_pairs=function(ints, s){ //your code here var ptr_1 = 0, ptr_2 = 0, i = 0, j = 0, len = ints.length, j_min = len, arr_sum = []; for (i; i < len-1; i++){ for (j = i+1; j < len; j++){ ...
Input given is an int array, which may or may not contain positive, negative or zero values. Write a program to find out the two numbers which gives the highest product. (Both numbers should be positive or negative.) Below is my code whose time complexity is O(n2), I believe. Is there any improvement I can make t...
I'm watching Uncle Bob to improve code maintainability and readability. I've built a system in which can upload various file formats. Bellow I've posted the pdf one. The below code works perfect but I need help if there is a way to improve code design and quality. Any suggestion is welcome. I use an abstract class File...
In this program, I have to check the range of a given age and then print a message as per the age. I want to optimize the if else logic. /* Sample code to read in test cases:*/ import java.io.*; public class Main { public static void main (String[] args) throws IOException { File file = new File(args[0]); Bu...
I just made a Rock, Paper, Scissors game and I have read some of the previous threads about them. Just wondering if there was any advice to optimize or just suggestions for naming or doing something better for my code. I have learned Java for only about 2 weeks so bear with me if I don't understand some of the function...
I want to convert my_long_variable to myLongVariable in sed. This works: echo "my_long_variable" | sed -r 's/(^|_)([a-z])/\U\2/g' | sed -r 's/^(.)/\l\1/g' Is there a more elegant way to do that with sed?
Our Project architecture is AngularJS + MVC + WebAPI. Angular JS would call MVC action and MVC action further calls API methods. Below are some of the action methods we used for calling api methods. Note that our project is in its final stage, and as such we cannot modify the existing architecture. We have to use Ang...
Based on the feedback I have got from the guys reviewing the code as posted in my previous question. Create database connection and run the insert, delete, update queries class I have used interfaces and wrote the following code /* */ namespace SampleInterfaceT1 { public interface IDbConSetup { DbConnection Open...
Often when running exprimental code to empirically investigate an algorithm, you tweak a parameter, then rerun the code, and generate a bunch of saved models for various parameters. To make sure I don't loose what the parameters were set to I defined a macro that saves there values. module Util using JLD export @param...
I'm looking for ways to speed up the process of adding entries to a zip-archive, in a web app, using DotNetZip. The problem currently is that the response times out before all files has been added to the archive. There can potentially be between 200 - 500 entries in each archive, each entry between 1 - 4 meg in size. I...
For few days I'm thinking about making my code faster and using less CPU. This code is a statusbar that runs in a loop. I'm asking because there's a lot of perl and I'm wondering if it could be done better. date=$( date +"%F %R" ) battery=$(acpi -b | perl -n -e '/(\S+),\s+([0-9]+\%),\s(\S*)\s/ && print $1," ",$2," [ "...
I am creating a simple app to find vowels, digits, whitespaces and consonants. the basic idea is to practice multi-threading and writing readable code. import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javafx.scene.control.TextField; import javafx.application.Platform; import ja...
I've been working on refactoring a project of mine and need some help. I'm looking to apply some design principles and patterns to make the code cleaner and easier to maintain. It looks like I'm clearly violating the DRY principle as there seems to be quite a bit of repetition. Also, I think there is a design pattern ...
I have written this piece of code to check if a string contains a set of characters, regardless of the order. Eg: 'ruby is best' / 'bysbe' => true Code: def find_chars(s1,s2) s1.chars.sort.join =~ Regexp.new(s2.chars.sort.join(".*")) ? true : false end I need to optimize it to reduce executing time. How? What is slowi...
Since the last post, I have ported it to WPF (semi-MVVM) and added support for Excel and PowerPoint files, and custom fields and scripts. The conversion is done by interop with office. Apparently consistency is too much to ask for from Microsoft, and the libraries for Excel, PowerPoint, and Word are all slightly differ...