instruction
stringlengths
71
71.9k
I've been taking a stab at implementing test cases using the Jasmine testing framework. To do so, I've made an application which has a User object. This User object is created by the server, but its ID is stored in a couple of client-side data storage locations. When a new User model is initialized I check those storag...
I need to write a function which will do the following functionalities I would get a string and a array as input parameters The string would be like one of the following for example catalog level1Cats level2Cats The String array would be containing the data for the strings mentioned above for example catalog:("12605...
I am just about to embark upon a massive job of multi-threading a cost-engine. I could use TPL of which I am very familiar, but would like to leverage the async/await keywords of .NET 4.5 to make life that little bit simpler. Is my understanding of what is going on correct? How can I improve this design? Cancellation...
I've been writing a small site which is essentially just a service API for other applications but deals with the caching and serving of files. In an effort to make the site as scalable and maintainable as possible I did some research into the most efficient ways to serve files to the client, using PHP for access contro...
I'm implementing a Java version of the game Mastermind. My version uses numbers to represent colors, for example 2315. This function compares a string of numbers to the secret code the object stored. It works, but I'm wondering if this could be done in a more elegant way. public Answer evaluate(String guess) { boo...
I have a class file that would be used to connect and execute queries into the database. The only thing I am confused about is this: do you really need to drop tables and re-create them everytime you run the application? Or does this depend on your coding or class file? I followed a tutorial on the Internet and kind of...
I have a view model with properties that represent years and months: public IEnumerable<SelectListItem> Years { get { return new SelectList( Enumerable.Range(1900, 112) .OrderByDescending(year => year) .Select(year => new SelectListItem { ...
In the interests of improving my Python coding skills, I wanted to post a program I recently built and get it critiqued by you fine folks. Please let me know where you think I might improve this program. I tried to stick to PEP8 and follow other standard conventions mentioned here. ### This program will filter a list o...
I wrote this class to make it reusable in any project. It uses PDO as the MySQL connection. Beside not using Setters and Getters, is this code secure and good practice for CRUD? class ContactsRow { const PDO_CHARSET = PDO_CHARSET; const PDO_DBNAME = PDO_DBNAME; const PDO_DRIVER = PDO_DRIVER; const PDO_HOSTNAME = PDO_HO...
This technique is more general than just for config files which is why I'm not using Config::Any in this example. I have a config file with lines like this: userid foo-admin # foo-comment directory /some/dir # bar-comment And I'm using some very awkward code to get the values. my @userline = grep /userid/, <$configfh>...
Just looking for some critiques hopefully from haskellers of how I might be breaking monad laws or just monadding all wrong. My or is something like the mplus for either and usable as a catch for failures from then which behaves mostly like the error monad. I'm barely a haskeller so this was a big stretch for me, but I...
I have an event recurring on the first friday of the month (at 7pm), and I need to output the date of the next first friday coming up. This is the first bit of PHP I've written, and I was wondering if there is a better way to implement this? Server is running PHP 5.3 Here's what I wrote: $todays_date = strtotime('today...
I saw a posting on Hacker News this morning that was ranting about people not being able to solve an interview question. I thought I would give it a shot, but I would like to know how my attempt could be improved. def get_pascal_row(n): """ Returns the nth row of Pascal's Triangle for a given n. Uses Gray's...
I am trying to model a domain of metrics for use in a BI application. I recently read the Designing with Types series, and felt that it could be useful, so I wanted to give it a try. What I'm not sure is if I'm trying too hard.... The metrics are application-defined, meaning they are finite and won't change during r...
My function converts an improper fraction to a mixed number (it does not AND should not simplify the fraction). // Improper fraction to mixed number // n = numerator // d = denominator // i = number function improperFractionToMixedNumber(n, d) { i = (n / d) >> 0; n -= i * d; return [i, n, d]; } // Con...
From what I understand this site help to check if my solution is proper or not..so forgive me if the header is bad. This is my solution for the question: #include <stdio.h> int main() { double num1, num2, different, product, answer; printf("please enter 2 floatig point numbers:\n"); printf("number one ...
For the first time I have to play with Threads in java. Basically, my code is a simple FIFO job queue. The main thread regularly puts jobs in the queue wich need to be executed. The code below is a striped down version of what I am doing : public class JobPerformer implements Runnable { private final ArrayList<Job>...
The query works fine but I'm just intrigued to know if there is a cleaner solution. The data are results from a survey and I'm obtaining the counts per question within a zone and an overall zone count. With Cte1 (ZoneId, QuestionId, Count1) AS ( Select tz.ZoneId, qn.QuestionId, Count(1) as...
This is the code I implemented so far to create a single instance WPF application: #region Using Directives using System; using System.Globalization; using System.Reflection; using System.Threading; using System.Windows; using System.Windows.Interop; #endregion namespace MyWPF { public partial class MainApplicatio...
I'm creating cards for a game of SET. Can the following be rewritten in a more programmatic way, possibly getting rid of the embedded for loops? function createCards() { var cards = []; var i, j, k, l; for(i = 0; i < 3; i += 1) for(j = 0; j < 3; j += 1) for(k = 0; k < 3; k += 1) ...
I was solving some Haskell exercises as a way to refresh some of the language concepts. I encounter the following exercise: data LTree a = Leaf a | Fork (LTree a) (LTree a) crossing :: LTree a -> [(a,Int)] crossing (Leaf x) = [(x,0)] crossing (Fork e d) = map(\(x,y) -> (x,y+1)) (crossing e ++ crossing d) The above fu...
I've been working on converting some legacy code from T-SQL stored procedures. My aim is to use DDD to make the transition. Below is an attempt to do this. Any comments on how well this is following DDD? Also any comments on the AreaGeneration domain service and its CalculateLocationsInArea would be most appreciated. ...
Please tell me if this function is correct (I believe it to be), efficient, and clean. Function to check: ::CURLcode CURL_DownloadFile( __in ::LPCSTR URL, __in ::LPCSTR Destination ) { ::CURL* Curl; ::CURLcode Return_CurlCode; std::FILE* File; if( ( Curl = ::curl_easy_init( ) ) ) { File = s...
I wondered if anyone has any ideas to make this cleaner or more efficient. Mostly this was an exercise to generate the data once (So speed really isn't too important, but I'd love to see what techniques you could think of) This is an algorithm I derived and implemented without external guidance of any kind, so I'm ask...
I have this code that generally creates directories within a directory. File userFolder = new File(rootPath+"/media/"+userBean.getUsername()); File userPhotosDir = new File(rootPath+"/media/"+userBean.getUsername()+"/photos"); File userAudioDir = new File(rootPath+"/media/"+userBean.getUsername()+"/tracks");...
I've recently discovered the wonders of the Python world, and am quickly learning. Coming from Windows/C#/.NET, I find it refreshing working in Python on Linux. A day you've learned something new is not a day wasted. I need to unpack data received from a device. Data is received as a string of "bytes", of arbitrary len...
I'm having concerns about the readability of this piece of code: messages_dict = {'error':errors, 'warning':warnings}[severity] messages_dict[field_key] = message and I'm to use this instead: if severity == 'error': messages_dict = errors elif severity == 'warning': messages_dict = warn...
I am trying to write an idiomatic trim function in C. How does this look? Should I instead malloc the new string and return it? void trim(const char *input, char *result) { int i, j = 0; for (i = 0; input[i] != '\0'; i++) { if (!isspace(input[i])) { result[j++] = input[i]; } } }
I have a view model that I'm migrating to RxUI. It exposes a collection of brokers along with a bool indicating whether there is a market (ie. at least one broker). In addition, it has a property for the currently selected broker (the user can choose a broker via a drop-down): private IReactiveCollection<SourceViewMode...
I need to lock on my AesManaged instance _Aes to call CreateDecryptor() however the CreateDecryptor() method is not thread safe and this function could be called by multiple threads. Is this the correct way to create a disposable object while needing to use a lock on the parent creating the object? byte[] encryptedText...
Please tell me how bad is the code...in the book he said it's possible with either nested loop, or 1 loop The user should provide the 8 double numbers for the program to set the cumulative totals in the second array. This is the code: #include <stdio.h> #define ASIZE 8 int main() { int index = 0, x, index2; d...
When the page loads, it checks to see if the user is trying to update an existing book or create a new book. Something about my code just doesn't seem right. It feels cumbersome and not very logical. Could someone put me out of my misery and let me know that I wrote this bit ok? Public Property modID As Int32 Protect...
If I need to create a IDisposeable object from a factory, but if the factory object is not thread safe and requires me to lock on it is this the correct pattern to use? public void DisposeExample(FactoryClass factoryClass) { DispObject dispObject = null; lock(factoryClass) { dispObject = factoryCla...
My recipes model is as follows has_many :quantities has_many :ingredients, :through => :quantities, :uniq => true has_many :sizes, :through => :quantities, :uniq => true And the controller action im trying to refactor class Admin::QuantitiesController < Admin::AdminController layout 'admin' authorize_resource :cl...
I know there are a few recursive ways to solve this problem but the code below is what came to mind for me. void create_bst(node *root, vector<int> arr) { int len = arr.size(); add_nodes(root,len-1); //Make the tree structure inorder_traversal(root,arr); } void add_nodes(node *n, int len) { queue<node *...
I am a programming novice. I've written this simple PHP script to run a very basic comment form and would appreciate any feedback, especially on these three topics: Efficiency (not sure the right word for this): basically, am I doing anything in a clearly awkward/inferior/inelegant way, in terms of using significantly...
I was solving the "Find the Min" problem on Facebook Hacker Cup. The code below works fine for the sample inputs given there, but for input size as big as 109, this takes hours to return the solution. Problem statement: After sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing ...
I have the following example app: http://dev.driz.co.uk/jsfunction/ Which runs two types of script files with the same outcome. Script1: var script1 = { showMessage: function( message ) { var el = document.getElementById('example1'); el.innerHTML = message; } } and script 2: window.script...
I have an algorithm and the idea is to move over an array choosing as index the index of the neighboring cell that has the max value. I.e. if array[i + 1][j + 1] has the largest value among the 3 then move there. I have 2 versions of this, but I think it can be cleaner. version 1: int maxI = i + 1; int maxJ =...
I am building a web app with a single (not pooled) full time (jdbc) connection between static classes and the database. This is expected to be a low traffic site and the static methods are synchronized. In an effort to speed up access to product information, I am trying PreparedStatements for the first time. As I test,...
I'm continuing to work on the Head First Design Patterns book in an effort to become a more efficient and better Python programmer. Code review for the Strategy pattern in Chapter 1 is here with helpful explanations from the community. I've tried to implement the Observer design pattern from chapter 2 below in Python. ...
I have the code below I probably did not need to post the entirety of it but you can see in the code that I make multiple data base queries to generate each of the multiple tables. I am curious if there is a way to make one query and yet get the same results, and possibly clean up the code. <!DOCTYPE HTML PUBLIC "-//W3...
Here's a small module I've written that implements an animation which fades through the child elements in a container div on a continual loop. I realise I could have done this way quicker using JQuery, but I wanted to write it from scratch in this case. The module works well enough, but I'd be very grateful for any co...
I am writing a small oauth2 library for Play! 2.1 scala. As I am still learning I got stuck trying to TDD and ended up writing the code first, then refactoring for testability. By testability I mean two things: make the code testable by me as the author make it easy for users (since I will be a user) to stub/mock it o...
I'm still teaching myself C out of KN King's C Programming: Modern Approach. Actually pretty excited I go this problem solved in under 2 hours. I asked this over on Stack Overflow and it was recommended I post it here. The exercise is to print a magic square. My solution works but it feels incredibly convoluted. I'm wo...
I am choosing to learn F# for my own enjoyment. I am getting to the point where concepts of F# seem to be pretty easy, but understanding some of the whys and whens is a bit harder. Before I get into the code and the explanation, let me put my question up front. I am asking where can I find better advice on formatting F...
I am trying to solve the 8 queens problem using a heuristic similar to "the accessibility heuristic" used in Knight's Tour problem. this heuristic simply means that each square of the chess board has the value of the numbers of squares that will be attacked if the queen is placed on that square. and asks me to place th...
I am developing game portal content management system using java and j2ee technology. However i am stuck in my design implementation. Here is the scenario: Each Game object has attributes like id, name, developer, price, platformType, platformName and so on... However the release date may be different for each platform...
My task was to build a multi-thread file server and a client that can upload or download a named file over sockets. It is assumed that the client will finish after its operation and there is no need to supply a file list from the server (although I plan to add that). There is no error check if the client enters a file...
Am supposed to capture user input as an integer, convert to a binary, reverse the binary equivalent and convert it to an integer.Am getting the right output but someone says the solution is wrong. Where is the problem? x = 0 while True: try: x = int(raw_input('input a decimal number \t')) if x ...
I am trying to set a OnClickListener to a image in a loop. If the params platform is "android" then use market app, instead of default browswer. Is there a better solution to my exception handling or eliminatingsome of the if-else ? private void setupListener(ImageView image, final String platform, final String...
My code converts repeating decimals to fractions. It works but I am interested in feedback on how I could improve and/or simplify it? jsFiddle: http://jsfiddle.net/tfgTu/ <script> // Repeating decimal // 21.83(35745857) var decimal = 21.8335745857 // Total length of the decimal var decimalLength = 10; // Length of th...
The following is an implementation of Guava's Equivalence for Jackson's JsonNode for the needs of JSON Schema: in certain situations, all JSON numbers need to be compared mathematically (ie, 1.0 is equal to 1) but JsonNode (accurately) considers them non equal. So, instead of extending JsonNode, I use this code, which ...
This code for the Raspberry Pi board waits for serial input then plays an arrow with a sound and message. I'd like any constructive comments or suggestions. #include <termios.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/signal.h> #include <sys/types.h> #include <signal.h> #include <bits/si...
My objective has been to build a custom dropdown like the one on Amazon's search scope selector. I do this by positioning a styleable element on top of a standard select list. I then use jQuery to keep the styleable element in sync with the select list. My code works fine, but I would love to learn how to do it cleaner...
I was wondering if someone could take some time to look over my portfolio script and see let me know if it's secure enough to be uploaded live and connected to my database. My previous mySQL script was VERY insecure... The Database Connection: public function __construct($server, $databaseName, $username, $passwor...
I've recently discovered how cool reduce() could be and I want to do this: >>> a = [1, 1] + [0] * 11 >>> count = 1 >>> def fib(x,n): ... global count ... r = x + n ... if count < len(a) - 1: a[count+1] = r ... count += 1 ... return r >>> >>> reduce(fib,a,1) 610 >>> a [1, 1, 2, 3, 5, 8, 13, 21, 34, 5...
I have a list with contentlets and want all languages from every contentlet (I get these with the method languageAPI.getAllValuesByKey(key , contentList). I get a HashMap and iterate over it. There are 1000 keys available. In the beginning it only takes 2 ms per key. But after a while it increases. And the last one tak...
I'm developing an Android app that performs several requests to a server using the AndroidAsynchronousHttpClient. One of these requests (as an example) is responsible to send the username and password. I created a class Sign that has a static method (see below) to which I provide a callback to handle the server's respo...
I am new to jQuery, and after spending weeks to convert my pages using jQuery, I am now reading about jQuery optimization. In that effort, I'm rewriting one of my functions. Please comment whether it is right (both are working). Previous $("#mydiv").empty(); var i = 2; $("#axisa option").each(function() { $("#mydiv...
I have PostgreSQL 9.1.1 running in a shared hosting environment and I'm running this query: SELECT a.id, CASE WHEN a.idpai IS NULL THEN a.nome ELSE concat(a.nome, ' (', b.nome, ')') END AS nome, a.idpai FROM localidade a LEFT OUTER JOIN localidade b ON a.idpai = b.id WHERE a.idcidade = :idcidade AND normalizar( CAS...
I'm pulling data from a list of images and passing it into an information container after click. After looking at my logic I assume there is a better way to do this. Any ideas would be helpful. var getData = function() { $('.guest-image').html('<img src="' + $($this).data("image") + '" />'); if ($($this).data("know...
My task is: Write a program that reads integers until 0 is entered. After input terminates, the program should report the total number of even integers (excluding the 0) entered, the average value of the even integers, the total number of odd integers entered, and the average value of the odd integers. But I had to use...
Write a program that reads input up to # and reports the number of times that the sequence ei occurs. Is this a decent code? #include <stdio.h> int main(void) { int index = 0, combinationTimes = 0, total = 0; char userInput; char wordChar[index]; printf("please enter your input:\n"); while (...
Here is a program which keeps track of the longest path in a graph. I think it can be written much better. from Tkinter import * ''' This program tries to compute the longest path (largest number of consecutive edges) currently in the graph at any point. The edges will be labelled as roads, connecting 2 nodes. These ...
I'm using the following technologies: Google App Engine, GAE Datastore, Struts2. Common lang java library were also used. Because of the limitation on aggregation for datastore, I'm using jagg for aggregation on List of Profile for some sort of report. Profile object have basic properties like email, name, gender, coun...
I am attempting to refactor my app using the MVC paradigm. My site displays charts. The URLs are of the form app.com/category1/chart1 app.com/category1/chart2 app.com/category2/chart1 app.com/category2/chart2 I am using Apache Rewrite to route all requests to index.php, and so am doing my URL parsing in PHP. I am wor...
I want to perform standard additive carry on a vector. The base is a power of 2, so we can swap modulus for bitwise AND. def carry(z,direction='left',word_size=8): v = z[:] mod = (1<<word_size) - 1 if direction == 'left': v = v[::-1] accum = 0 for i in xrange(len(v)): ...
My task is: Write a program that requests the hours worked in a week and then prints the gross pay, the taxes, and the net pay. Assume the following: Basic pay rate = $10.00/hr Overtime (in excess of 40 hours) = time and a half Tax rate: 15% of the first $300 20% of the next $150 25% of the rest Is my code ...
I am working on a webforms project using c#/aspx/jquery. I'm not sure where to handle my Onclick. Both options (doing it in C# or jquery) seem feasible. Which would be better practice? Here is the scenario: I want to build a checkbox which will toggle a textbox's textmode, altering it between Password and SingleLine. C...
I'm trying to learn how to write functional code with Python and have found some tutorials online. Please note that I know Python is not a promoter for functional programming. I just want to try it out. One tutorial in particular gives this as an exercise: Write a function flatten_dict to flatten a nested dictionary b...
This is a working mergesort implementation I wrote as I'm trying to get back into C. I am not so much interested in feedback on the optimality of the algorithm (as I could read up countless articles I'm sure), but deep criticism of my style would be greatly appreciated. #include<stdio.h> #include<stdlib.h> #include<str...
My task is ask this from the user: Enter the number corresponding to the desired pay rate or action: 1) $8.75/hr 2) $9.33/hr 3) $10.00/hr 4) $11.20/hr 5) quit If choices 1 through 4 are selected, the program should request the hours worked. The program should recycle until 5 is entered. If someth...
I was interested in feedback on this architecture. Objective: serialize / deserialize a network application protocol stream. Approach: Create a class for each layer/object which exposes attributes as well as encapsulating the stream reader/writer. If instantiated for serialization the object is instantiated with the ap...
I've got server running to make serial data available on a TCP/IP port. My goal is to collect data coming from a realtime device connected to the serial port and deliver it to web clients connected to an express server using socket.io as the data is collected from a backend socket. I want the backend socket to reconnec...
This is my first code in C++. Since I'm new to the language, I'm just looking for pointers on what can be made better. I tried to cut out unnecessary stuff, but there are some comments in there. I know Java, so if you're trying to explain anything in Java, I can understand it. Feel free to mention anything, whether ...
I have some entities in use in my project, and to make things easier, I would like to have the type of the key for that entity defined via a generic. E.g.: public abstract class Entity<T> { public virtual T Id { get; set; } } This way, I can pull the Id field into the base entity and not have to define it every ti...
My task was: Write a program that accepts an integer as input and then displays all the prime numbers smaller than or equal to that number. And my code is: #include <stdio.h> void FindPrime(int number); int main() { int userInput, counter; printf("Please enter a limit number to test all the prime numbe...
I think understanding basic data compression and pattern finding / entropy reduction primitives is really important. Mostly the basic algorithms (before the many tweaks and optimizations are made) are really elegant and inspiring. What's even more impressive is how widespread they are, but perhaps also how little they ...
I'm new to Python and GAE, but years of procedural programming. I have this code, but I know that there must be some better solution to avoid retyping code. The first and last section of code are identical in both GET and POST methods, so I suppose there must be another way to share the identical code. # This class man...
List<int> types = new List<int>(); foreach (var d in myTableList) { if (!types.Contains((int)d.item_type)) types.Add((int)d.item_type); } I have a table in db called myTable. There is a column in it called item_type. It is integer. I want to make a list which would have all item_type which are in myTableLi...
I wrote my own version of endswith just like in high-level programming languages in C which I would like reviews on. There are 2 versions. One is my own and the other is from ccan. For some reason, I feel that ccan's version is better than mine until proven wrong. ccan/str's version: static inline bool strends(const ch...
I'm building a symfony project and at some point I've come up with a switch case to manage the acl rights. I would prefer using a dynamic access to the constant but havn't find a good solution. I've seen reflection but that doesn't seem to be the proper solution to me. $mask = null; switch ($participant->getRight()) {...
I have the following bit of code the calls out to two different command line components (each wrapped in their own Task) public async Task<FileInfo> RasterizeAllPdfs(IEnumerable<Uri> targetUris, FileInfo destination = null) { // rasterize uris to files in the rasterizedOutput directory await rasterize(rasterize...
I created a quick program to test the precision of randomness generated by the .rand method. The primary question is whether I can use the .times method in place of the while code blocks to increase efficiency and: Whether such a practice would reduce the amount of processing required/if this would be at all signific...
A basic shell function to create a directory and change to it goes like this: mkcd () { mkdir "$1" && cd "$1"; } This works well in many cases but breaks in unusual cases (e.g. if the argument begins with -). I'm writing a more sophisticated version. This version calls mkdir -p to create parent directories if needed a...
My code blinks text for an interval of time then clears the text. I plan to use this code in a quiz web app. When the user gets an answer right, "CORRECT!" will blink on the screen for 10 seconds. When the user gets an answer wrong, "INCORRECT!" will blink on the screen for 10 seconds. I'm looking for feedback on how I...
I have such method and have a hard time optimizing it to run better. It takes roughly 1 sec with 100 units to get between NSLog(@"Debug2") and NSLog(@"Debug3"). And 2 sec on iPhone. Method idea: Input: NSMutableArray times - containing times (2012-12-12, 2013-01-19) and etc NSMutableArray objectArray - contains Log...
Someone asked me if I can create factory pattern in java without using If-else construct. So I come with the following. Please provide your inputs if this seems a good example for using factories. public enum EnumButtonFactory { RADIO(RadioButton.class), SUBMIT(SubmitButton.class), NORMAL(NormalButton.class); private...
I'm currently using this pattern to create and extend a globally accessible custom plugin to be used in a web application: ; // defensive programming: script may be concatenated with others (function($) { "use strict"; // allow Plugin to be extended from other scripts var window.Plugin = window.Plugin || ...
Could I code differently to slim down the point of this Python source code? The point of the program is to get the user's total amount and add it to the shipping cost. The shipping cost is determined by both country (Canada or USA) and price of product: The shipping of a product that is $125.00 in Canada is $12.00. inp...
I need to write a procedure, that will take a dictionary consisting of server names and their available slots and a number of slots required, and redispatch it over the servers, so that every server would accept only that many assignments as he has free slots; servers with higher number of free slots would be assigned ...
I am learning MVC, and trying to understand routing. I understand that if I want to show an individual blog post for site.com/54, my route would be something like //index.php $controller = new Controller(); if ( preg_match("#/(0-9.)#", $uri, $matches) ) { $controller->showAction($matches[1]); } which would lead to...
I have the following logic: bool a; bool b; int v = 0; //code here to set the values of a and b... if(b) { v = a ? 1 : 2; } else { v = a ? 0 : 1; } I believe that there may be a way to minimize this logic (or rewrite it in a more clever way) that I am not thinking of.
Anyone have any comments? Just trying to better my code if can be done. public class SacWidget extends AppWidgetProvider { String roseUrl; AQuery aq; public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; ...
I testing F# code which calculates "nearness" of two N-dimensional points using a least square euclidean distance algorithm. The class library is written in F# and the calling will be from VB.NET. The code will eventually be used for scientific binary data, however I wanted a simple real world test environment. I ch...
I came up with this jQuery snippet to add/remove a class on <label> tags that contain either checkboxes or radio buttons, in order to improve usability so users can see what item(s) they have selected. But I would like to know if there's a way to optimize the code (or not if that's the case). $('label input[type=radio]...
I am new to Python and I want to see how can I improve my code to make it faster and cleaner. Below you can see the code of Margrabe's Formula for pricing Exchange Options. I think the part where I check if the argument is None and if not take predetermined values, can be improved but i don't know how to do it. Is usi...
The problem with computing a radix using a non-imperative style of programming is you need to calculate a list of successive quotients, each new entry being the quotient of the last entry divided by the radix. The problem with this is (short of using despicable hacks like log) there is no way to know how many divisions...
This library is a markup parser which is intended to be used in node.js and browser environment. I've decided to use Jasmine for tests. The library's name is ivy-markup. URL: https://github.com/AlexAtNet/ivy-markup It would be great to get comments on its usability and code structure. Main engineering ideas: Parser pa...