instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I've been reading the Chapter 8 of this book. Here's the view I'm currently coding. It list all characters/guilds according to the type of URL. /ranking -> List Top 50 Characters /ranking/guild -> List top guilds /ranking/pvp -> list top killers def ranking(request, type): if type=='': queryset_list = ...
stackexchange/codereview
I'm developing an iOS application where data is fetched from a third-party REST API. Each request must contain an authorization token. In order to implement this, I've written a fetchToken withCompletionBlock:(void (^)(ASToken*) token,NSError * error) method in AppDelegate: -(void) fetchTokenWithCompletionBlock:(void (...
stackexchange/codereview
I thought it would be helpful to put together an example of what I'm talking about in the second part of my answer to this Stack Overflow question. The idea is that there's some data that is updated very quickly (i.e. faster than the main queue can reasonably process blocks) on a background thread that needs to be disp...
stackexchange/codereview
The code is meant to find the longest substring that is in alphabetical order. I would like to know if I can do it more efficiently than I have done here. I am in my first week of my first introductory course, so I'm not looking for more advanced solutions. I just want to know if I'm not making it more complicated than...
stackexchange/codereview
How can the following code be made idiomatic in ELisp? Can the temporary f variable be removed? (global-set-key [f3] (lambda () (interactive) (let ((f (ffap-file-at-point))) (start-process "test" "output" "mpv" f))))
stackexchange/codereview
I have some survey data that represents individual's responses to multiple survey questions. There are about 10,000 people in my actual dataset, and each person answered 35 questions. From these 35 survey questions, I create 1 composite score for each individual by taking the average of the values of all the question...
stackexchange/codereview
I have here a modified version of a web scraping code I wrote some weeks back. With some help from this forum, this modified version is faster (at 4secs per iteration) than the earlier version. However, I need to run many iterations (over 1million) which is so much time. Is there any way to further enhance its performa...
stackexchange/codereview
I have created a generic repository for my MVC 3 page. I am using interfaces and a UnitOfWork. But before I set out to do this? Is this the right way to separate my databaseaccess from my viewmodels and views? WHY I DID IT: I want to seperate my databaseaccess from my viewmodels and my views, I also want the option to ...
stackexchange/codereview
The original problem statement is here, here is the super short summary: Your binary search tree iterator must implement the following interface: pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } struct BSTIterator {} impl BSTIterator { ...
stackexchange/codereview
I have a URL query string "key={value}&key2={value2}&key3={value3}" and have to produce a key-value pair of the string by splitting & and =. Also, I have to watch out for corner cases such that if a key isn't present do not add it to the hash map but if a value is missing the key can be added with an empty value. One w...
stackexchange/codereview
This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_print Function For Various Type Arbitrary Nested Iterable Implementation in C++. Besides the usage with single Ranges input like recursive_transform...
stackexchange/codereview
Hey everyone I have a very simple go REST API that is running CRUD operations on an in-memory object. I would love some feedback on how I can refactor this code, and how/if I should break this up into more than one file (main.go). I am extremely new to Go and want to learn the best way to write something like this. Som...
stackexchange/codereview
I've written a very simple command line parser/dispatcher library. This is an extension of a previous review, which I've refactored, found here. Basically, a user can add functions to a Cmdr struct, then invoke them using a &str. I've made the library generic so that a user can define their own Result<T, E> to be retur...
stackexchange/codereview
I would like to use this in a program to save users' names even after they relaunch the script. I was just wondering if there were some ways I could clean up this code. Note: this currently was made to not support name changing, but could possibly be implemented in the future. if os.path.isfile('names.json'): # if ther...
stackexchange/codereview
I have a merge statement that takes around 10 minutes to process 5 million or more records. The merge statement is part of a stored procedure that takes my newly bulk loaded staging table then runs data integrity checks, transforms the data into the proper format, and inserts that data where it should go. Here are the ...
stackexchange/codereview
Is this a smart method? public static ArrayList<Integer> getWordLengths( String s ) { String str = " " + s + " "; ArrayList<Integer> list = new ArrayList<Integer>(); for ( int i = 0; i < str.length(); i++ ) { if ( str.charAt(i) == ' ' ) { for ( int j = i+1; j < str.length(...
stackexchange/codereview
I recently posted an earlier version of this code on Code Review, and now with the given suggestions and many other improvements, I am back. I included the description of exactly what Cyther is supposed to do inside of my source code. Cyther's repo can be found here. My objective is to make sure that this code is as cr...
stackexchange/codereview
I want to make a booking entry. I want to ask whether the code that i wrote below is rightly format or not? I haven't tried it, because there's still more code that needs to be written. I just want to ask this before I continue to write. <?php require 'Connection.php'; //Check Connection if ($conn->connect...
stackexchange/codereview
I wrote this code so I could figure out the number of molecules within a plasmid and an insert of DNA. I then get the amount of insert DNA I would need to use (in uL) for a ligation with the DNA at different insert ratios and dilutions. How can I clean up this code? It works correctly. However, I feel like I typed this...
stackexchange/codereview
This code finds which "secure file erase" command exists on the system. It used to simply test for "shred" and pick "rm" as a default. Now it is a bit more complex since I've ported the code to operating systems with "srm" and "rm -P". Is this still cleanly written? How can I improve it? var shredPath, shredFlag st...
stackexchange/codereview
This code processes a basic contact form with a name, email and message. It also asks for a code to be typed in. The data is then transformed to avoid malicious placing of HTML script on the server, and if the name and email are valid, sent to my email. Is this code really secure against the attempt to place malicious ...
stackexchange/codereview
This is simply an extension method which checks if a string str contains all the values in values. However, there are cases when str might be null, values might be null, or any item in values might be null. I am handling those cases by using the ternary ?:, null-conditional ?. and null-coalesce ?? operators. Should thi...
stackexchange/codereview
I have a JS file that creates an object with notes from a music scale when given a key (aka tonic/ note). The code works and does what I want it to do. I need a critique on the way it's written, what could be made better, quality of code — even if it's indentation. please. I've never written code so I have no frame of ...
stackexchange/codereview
I have never done testing, and I have 5 end points which have methods such as GET, POST, and DELETE to test. I wrote test cases using the go's in built testing package. I'm worried that I'm missing some cases which are not striking to my mind. For example: I have an end point which goes like this: a.Router.HandleFunc(...
stackexchange/codereview
(Inspired by this question) The digits of the cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. Find the smallest cube for which exactly five permu...
stackexchange/codereview
I wanted to do some statistics over the history of a Git repository. At first I tried using GitPython, but it wasn't as trivial as I imagined it to be. In the end, I just call the necessary git commands with the submodule module. Can this code be considered clean and readable or does it have some style issues? import a...
stackexchange/codereview
I come from the R language and I gradually switch to Python (Numpy and Pandas). I coded this python code for fun to solve a Sudoku grid. Could you tell me if my code is pythonic enough? For example, did I use the numpy functions correctly. How to make the code more readable? import numpy as np from functools import red...
stackexchange/codereview
I am looking for advice if the below code is a good idea or not. If not, why? I am building a website which allows a user to purchase items. The user account and cart items will be stored in Session. My approach is to create a singleton class that will manage all the sessions. Is this approach good or bad? public class...
stackexchange/codereview
Since implementing my Interactive Brainfuck interpreter in Haskell I figured that it would be a good idea to build upon an Abstract Syntax Tree. I have also decided to drop replacing the IO monad by some other structure for the time being as what I have now works fine, and fast. The code consists of the following: The...
stackexchange/codereview
I have an immutable Point class and a CollectionPoint class which manages instances of my Point class. The CollectionPoint class owns points under its control and must synchronize concurrent activity. I have below what I think is a thread-safe solution but would like another opinion. Is this solution thread-safe? class...
stackexchange/codereview
Just decided to make a quickie Fibonacci Sequence via jQuery and I was wondering if anybody can think of a faster way to interpret it? I can type pretty much any number in and it returns in a fraction of a second. Can anybody think of a quicker method to calculate a specific Fibonacci number? http://jsfiddle.net/st9sgr...
stackexchange/codereview
This is a LeetCode problem called Word Ladder: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, where only one letter can be changed at a time. Each intermediate word must exist in the dictionary For example, Given: start = "hit" end = "co...
stackexchange/codereview
I wrote this code to speed up my daily work. I want to ask for help on how to further accelerate this code. Operation of the code It copies 1-1 worksheets from 3 different workbooks to 3 worksheets of the new workbook. Inserts, copies, and formats different columns. Then, by examining different criteria on a worksheet ...
stackexchange/codereview
I'm looking for the most simple and efficient way to track the number of string elements in a container. Previously, I used std::vector but I tried changing the container to std::unordered_map since I hear that it can be easier and more performant for my use. My Code : #include <iostream> #include <string> #include <un...
stackexchange/codereview
To update parameters in our main.js file, which has a lot of configurable variables, we can do the following A . module.exports.setVarA = function(val){ VarA = val; } module.exports.setVarB = function(val){ VarB = val; } ...so on for VarC up to VarZ B. module.exports.setAllVariables = function(valA, valB.......
stackexchange/codereview
I wrote a set data structure with some useful functions. I'm not sure if it is a good implementation and if there are other essential functions that a set should support. class CustomSet def initialize(list=[]) @cs =[] list.each do |n| put(n) end end def size @cs.size end def each(&...
stackexchange/codereview
I'm beginner java programmer and would like to ask you to take a look at my code. I wrote small rest service among with tests. Now I have to questions to ask. The test methods: @Transactional public class CustomerControllerTests extends RestApplicationTests{ @Autowired private WebApplicationContext context; ...
stackexchange/codereview
I've written a class I call ReceptiveMapQueue. Its purpose is to organize the internal structure of an AFKable RPG. It only has two public methods - dumping entries into the queue, and extracting values from the head of the queue. I won't waste time describing it in paragraph form, since it is fully documented. The exp...
stackexchange/codereview
During an interview I was asked to design the menu for a coffee shop employee so that the employee would go and add different items to the menu. This is the design that I came up with. I just want to know what other things I'm expected to think of. Are there any problems/complexities that I haven't taken into account?...
stackexchange/codereview
This is only the front end side of things which I have at the moment, as the back end is still being worked on. But as this is my first attempt at a react component, I'd like to know if there is anything I can improve on it. The component has a text area for viewing the current data stored in the cache within our appl...
stackexchange/codereview
Here is my second version of a bash program I'm writing, as per @hjpotter92 I've updated and cleaned it since last: This script is run directly after a fresh install of Debian, to do: sets up LS_COLORS====> colors in /bin/ls output sets up Portsentry (security for ssh and defence for ports) sets up syntax highlighting...
stackexchange/codereview
I have written a series of Regex.Replace() lines to take an input like {"id":36} and convert it to id 36 and I was wondering if it is possible to combine all the calls I am making into one. Results = Regex.Replace(Results, @"\{", ""); Results = Regex.Replace(Results, @"\}", ""); Results = Regex.Replace(Results, @"\""",...
stackexchange/codereview
Is it possible to improve this bit? def append_nones(length, list_): """ Appends Nones to list to get length of list equal to `length`. If list is too long raise AttributeError """ if len(list_) < length: nones = length - len(list_) return list_ + [None] * nones elif len(list_) >...
stackexchange/codereview
I am a new developer therefore I have many questions: In this class I get file path on the disk (wireshark file that needs to be converted to pcap format extension) and convert it with the method convertFileToPcap(), in the constructor I am calling convertFileToPcap() and from the main after create the Editcap object I...
stackexchange/codereview
In order to learn the basics of Monte Carlo I calculated pi with it. I also wrote an explanation of the reasoning behind the code. Down here you can see the circle with random points that I simulated in my code. """ This programme calculates pi with Monte Carlo Given a square and a circle inside it. We have ...
stackexchange/codereview
I am trying to write A C# version of a method in the Java Stream API called Collectors.teeing() (It's like Aggregate but with multiple accumulator functions), just for educational purposes. I want to make sure that I: don't enumerate the source more than once (because that is trivial) don't store the elements from the...
stackexchange/codereview
Purpose Implement a binary search algorithm that takes a sorted int array and some int target value and returns the index of the target value, if it exists. Discussion The way I thought about implementing a binary search algorithm was the following Given an array of sorted int values, pick the first, last, and middle ...
stackexchange/codereview
I wrote a simple parser for input-output operators. What is wrong with this code and how could it be better? #ifndef PARSER_H_ #define PARSER_H_ #include <string> class parser { public: typedef std::string::const_iterator const_iterator; private: static const_iterator start_position(bool b, const std::string...
stackexchange/codereview
I recently had an interview problem where I was asked to find a compact representation of nodes in a tree. As an example, consider the following tree: A / | \ B C D / | \ | \ E F G H I /\ ...
stackexchange/codereview
I am having problems with my code because I am using a system called styleci. Can you please check it? How can I make it better and more secure? <?php /* * Tecflare Corporation * Copyright Tecflare Corporation * Provided by the Tecflare Corporation System * * Code has been scanned by styleci.io */ $host = $_POST['...
stackexchange/codereview
I am currently making a very big blogging system for my Website where I want really neat code! So, I was wondering: is this method safe/does it have any problems with security? Yes, I'll be encrypting the password anyway. I also want to know if there is a better way to achieve the same idea. Also any tips on implementi...
stackexchange/codereview
EDIT: Changed title, few mistakes in code were resolved (now working properly) The GUI I am trying to make will be a simple QTabWidget, leading a user straightforwardly towards the end tab by tab. For now, I have three *.py files - main.py, tab1.py, tab2.py. In main.py is the main window of the app and function to run ...
stackexchange/codereview
I've written a Binary Search Tree Monad in Scala. I would like to hear your thoughts on how to improve it (e.g. making insertion/deletion/search faster and more scalable). Also, is there a better way to implement this kind of data structure the Scala way? The whole code Here is the trait: trait BST[+A] { def +[B >: A...
stackexchange/codereview
Original question: Python PBKDF2 using core modules I'm looking for commentary on the following code, which converts from a hex seed to mnemonic (12 word phrase), and vice versa. It's for Bitcoin (BIP39 to be exact), and is going to be running in conjunction with pybitcointools, however I believe the commented URLs sho...
stackexchange/codereview
I have just started to learn to code as it always been a pipe dream of mine but I found it hard to understand, however, with the rise of LLMs I have found the experience not nearly as daunting as before. Using ChatGPT and Phind.com I finally began my programming journey and decided a good place to start would be with P...
stackexchange/codereview
I just built an audio player in Angular 2 using a player component and a player service. It's all working fine, I just feel like there is a much better way to do this. Should the audio object be in the service or the component? I'm skeptical because I'm using three different observables and I don't think that is the be...
stackexchange/codereview
I read time complexity of radix sort is O(wn) or O(n log n), if all n numbers are distinct. After implementation it look to me as if I have implemented radix sort which has time complexity of O(n ^2). Please take a look at my implementation and suggest, if there is some implementation problem or my observation about ti...
stackexchange/codereview
I am writing simple program to reverse its input and output the reversed version. I came up with this code. So how can I improve it? Something tells me that int lengthSoFar is bad in both printArray and reverse functions. #include <stdio.h> #include <string.h> #define ARRSIZE 1000 //function declarations... char *re...
stackexchange/codereview
I wrote a solution in Java to solve the problem here. I use BigInteger to convert first from base 16 to base 10, then base 10 to base 64. This seems quite inefficient to me, and I would have no idea how to do this if I couldn't use BigInteger. I'm sure there's a nice and clever way to do this using a lot more bit ma...
stackexchange/codereview
I would like to get some feedback from the community regarding a plugin I recently moved from requiring jQuery to a stand alone JS implementation. It is meant to handle browser communication protocols such as XHR, XDR, WS & WSS without a lot of fuss. The project can also be found @ comm.js. /** * Description: Handles ...
stackexchange/codereview
I wanted to get some feedback on this JS I am working on. It works wonderfully on my desktop, but on my and my friends' laptops (especially Safari) it is very slow. I need some pointers on improving the efficiency so it works nicely across browsers/computers. http://www.dapper-apps.com // If jQuery was not loaded, offl...
stackexchange/codereview
I have a problem similar to the question, namely reading in text which describes a date - in various formats. I want to use the parseTimeM function from Date.Time module in time package. My current solution can probably be improved style wise but it should remain easy to read and easy to extend. Suggestion? readDate3 ...
stackexchange/codereview
I am working a a C# program that will manipulate bitmap images. The first step is to read in the File Header and the Windows BITMAPINFOHEADER. That will give me enough information to loop through pixels and do my manipulations. Here is the class that reads the file header, using System; using System.IO; namespace Bitm...
stackexchange/codereview
This is my attempt of implementing an efficient, cache-friendly, vector for polymorphic objects. From now on I will refer to "virtual functions" as functions which are dependent on an object's underlying dynamic type, though they might not be strictly marked "virtual". Memory model of polymorphic vector Rather than sto...
stackexchange/codereview
I'm writing a program to process log files. Currently, I have a script that will extract the desired information from each log and put it into a list - I have about nine different lists all containing different information. Currently, I'm loading the file, extracting the desired information, and storing it in a list, ...
stackexchange/codereview
I come from a fairly strong background of C and thought that this project would be a good way to get a handle on Rust. Right now, I have everything in one file because I wasn't sure the best way to organize the code (at least not yet). Let me know if I should post anything else (the .toml for the project, things like t...
stackexchange/codereview
Background I have a REST API using MongoDB, Node.js and Express that makes a request to my NoSQL DB and depending on different results, I want to differentiate which error I send the customer. Problem The current version of my code has a generic error handler and always sends the same error message to the client: api.p...
stackexchange/codereview
I am doing a redesign and have some previously existing content in HTML that is similar to <p class="testimonial-text">Bacon ipsum dolor sit amet aliquip est tail occaecat bacon ad qui short loin exercitation.Strip steak sint dolore et ut, elit kielbasa quis.</p> &ndash;<span class="person-name">Name Surname</span> <h...
stackexchange/codereview
The following Function is one of the main analysis functions of a larger subroutine. The subroutine is responsible for translating codes that look like this "1|G|XNYM:O:LO:201611:P:44:+1/XNYM:O:LO:201611:C:51:+1" to something similar to this "LIVE WTI American X16 44.00/51.00 Strangle". There are multiple scenarios ...
stackexchange/codereview
I have this legacy code and I don't really think this is easy to read/maintain it. Can you suggest a way to make this more readable while still saving the performance? template<typename T> void static ConvertBayerToRgbImageDemosaic(T* BayerChannel, T* RgbChannel, int Width, int Height, ColorSpace ColorSpace) { ...
stackexchange/codereview
I'm quite new to React and was working through the "Thinking in React" example, I noticed they used refs for updating state, but I also read on SO that using refs isn't that good in the long run, so I tried to redo this without using refs: JSFiddle var SearchBar = React.createClass({ handleChange: function(event) {...
stackexchange/codereview
In Python it is really easy to get sliding window functionality using a deque with maxlen: from collections import deque deck = deque(maxlen=4) deck.append(0x01) deck.append(0x02) deck.append(0x03) deck.append(0x04) deck.append(0x05) for item in deck: print(item) # outputs 2, 3, 4, 5 This does two things - it gro...
stackexchange/codereview
Currently I'm using this code: <?php /* Clean, Simple, Minimal. */ $pages = array('home', 'login', 'register', 'logout', 'test'); if (isset($_GET['p'])) { $page = $_GET['p']; if (in_array($page, $pages)) { include('pages/' . $page . '.php'); } } else { echo 'Hi'; } ?> I want this to be as...
stackexchange/codereview
I have implemented a metaclass in Python 3 that, apart from the usual instance constructor (i.e. __init__), enables you to define a class constructor (as a class method that I called __init_class__). The metaclass extends abc.ABCMeta so it supports abstract classes, i.e. the class constructor is not called if a class i...
stackexchange/codereview
Description A class representing an undirected graph. At the moment, it supports integer values as vertices. An example of the type of graph represented is shown in the following diagram: It is represented internally as an array of adjacency lists. Each index of this array corresponds to a vertex number, and contains ...
stackexchange/codereview
Using Bootstrap 3 and PHP, I create my navigation bars in the following way: <?php $page_url = $_SERVER['REQUEST_URI']; $active1 = (strpos($page_url, "one.php") !== false ? " class=\"active\"" : ""); $active2 = (strpos($page_url, "two.php") !== false ? " class=\"active\"" : ""); $active3 = (strpos($page_url, "three.php...
stackexchange/codereview
I'm developing a Go application that has lots of packages. Many of the packages use the same type from a 3rd party library. Should an interface be defined for the type in each package, and let the interfaces only contain the methods that are used by the package? Or, we should define a single interface for the whole app...
stackexchange/codereview
I'm working on an article about encapsulation in OOP, and I'm using the FizzBuzz problem to demonstrate what I think is so great about it. I'm hoping to share this with developers that might also be intermediate, as a way to start building a bridge for understanding common OO principles. To this end, any feedback, crit...
stackexchange/codereview
In SE chat, there are two different ways to mention people: A "ping" to just get a user's attention, and a "reply" that points out a specific message by the user. This script makes it so that beginning a message with (by default) @username@, the message is made a reply to username's most recent message. Additionally, a...
stackexchange/codereview
I have a csv that is exported from SolidWorks, the input looks like this: 1,A-00034,1,Approved,"Rotating Conveyor Top Level Assembly, 88-1/2" Long 2.5" Rollers, 57-1/2" BF",01,,,,STRUCT,ASSEMB,, 1.1, P-001991,2,Approved,Hex Bushing to Convert 1/2 NPT to 1/4,01,,,44605K245,Pnuematics,Purchase,, 1.2, P-012527,2,Submit ...
stackexchange/codereview
I'm looking to port a Python script I have over to Swift, partly for some performance benefits, and partly to dip my toe into a new language. My program computes what is called the downset of a permutation of \$[n] := \{1,2,\cdots,n\}\$. For me, a permutation of \$[n]\$ is a tuple containing each integer precisely once...
stackexchange/codereview
I wrote a chatbot in Ruby for turntable.fm, a chatroom where users can listen to music together. It interacts with users in a room, who can type in specific keywords and get responses from it. It also enforces some rules. For example, if people playing music go AFK for too long, it will force them to stop playing music...
stackexchange/codereview
For an outsourced job (implementation of a network client) I will provide a simple server for protocol-testing. This is the code. Do you consider this code readable/ comprehensible? using System; using System.Text; using System.IO; using System.Net.Sockets; namespace SimplePictureReceiverServer { class Program ...
stackexchange/codereview
The program should (and does) the following (paraphrased assignment): There is a catalogue with a list of motorcycles. They have a - Name (spaceless string of 20 chars) - Price (int < 99 999 999) - Weight (int < 99 999 999) - Speed (int < 99 999 999) I have to output two lists, the first list is ordered...
stackexchange/codereview
I have this program for counting calories. There isn't a whole lot to it yet. It's a moderately sized project, so I'll do my best to make it as short as possible, posting only the main of the program and my global variables. It's a Windows Forms project. Before anyone tells me, yes, I should fix the global variables. I...
stackexchange/codereview
A bowling score calculator is my go-to exercise for learning the basics of a language. I recently had to pick up Perl so I did this. I'm concerned that I'm doing subroutines wrong. I had a hard time figuring out the syntax for dealing with arguments and what exactly @_ is. I'm just looking for feedback on any egregious...
stackexchange/codereview
C++ doesn't (yet) have a 'map' higher-order function, certainly not one which applies to a compile-time sequence of values like a tuple. We have std::transform, and there's an equivalent of it for tuples listed on SO, but that's iterator-based, and anyway - I don't want to use any reference to the output. I want to pas...
stackexchange/codereview
I was able to pull the records I wanted but I have a feeling it could be written better for these particular MySQL query strings. SELECT ID,XAxis,YAxis,Player,Castle,Alliance FROM SC75 WHERE Snap = (SELECT MAX(SavedSnap) FROM DataSnap WHERE Server = 75) AND hex(Player) IN (hex('Vandiel')) UNION SELECT SC.ID,XAxis,YAxis...
stackexchange/codereview
I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with: fluent_arrays.h: #ifndef FLUENT_ARRAYS_H #define FLUENT_ARRAYS_H #define REQUEST_THREAD_LOCAL 1 #ifdef REQUEST_THREAD_LOCAL #define THREAD_LOCAL __thread #else #define THREAD_LOCAL #endif /*****************...
stackexchange/codereview
Everything works as expected. This will look for the value of pptText in Sheet1 and then copy it onto Sheet2 to form a table. I will add something that copies then pastes the tables on Sheet2 onto another sheet after each iteration of the arrayLoop, but this works for now. This is what Sheet1 looks like: And this is...
stackexchange/codereview
I'm new to Python, but I really want to get into the swing of doing things the pythonic way. First, does my code follow the pythonic path? Or does it run screaming bloody murder, as it zig-zags through my C++ thought of mind? Probably the latter. import sys, random, string #import pdb #pdb.set_trace() def read(nam...
stackexchange/codereview
I am working on Android applications for last 2 years and about 80% applications I have developed involve web-services consumption followed by some sort of XML or JSON parsing. Initially, when I had to call a web service, I had to create a separate AsyncTask class and then parsing was also the part of that AsyncTask cl...
stackexchange/codereview
I decided to write a function that would generate an index of the Fibonacci sequence making use of Python's mutable default parameter. It's inspired by a question I answered on Stack Overflow where someone was converting a script with this idea from JavaScript to Python and I wanted to expand on it to see how I could h...
stackexchange/codereview
I'm designing a table cell based map design for a little game I'm building, and I was hoping I could get some cleanup pointers or design tips to "perfect" my engine's design. Basically, in the end result, you'll walk around the map one tile at a time. On any visible tile you can walk to it, but only the tile you're on ...
stackexchange/codereview
The following is a script that is supposed to act as a wrapper for ltl2ba, a program which transforms LTL formulas into Buchi Automatons encoded in the Promela language. The wrapper adds a limited set of functionalities to the original program. I tested it on my local linux machine and it works. Now, in addition to the...
stackexchange/codereview
I am new to javaScript, I just coded a method where I can convert a minute to a time in hh:mm AP/PM. I was then displaying the time in a table. I was wondering if there is a better approach to this? Because my code seems quite messy, with many if and else statement. function convertMinsToHrsMin(minutes) { ...
stackexchange/codereview
I programmed the extended Euclidean algorithm together with the inverse modulo because I am making an RSA system from scratch. Any feedback regarding efficiency etc. is welcome :) def ext_gcd(a, b): a0, a1 = a, b x0, x1 = 1, 0 y0, y1 = 0, 1 while a1 != 0: q = a0//a1 ...
stackexchange/codereview
The task: Given an integer n and a list of integers l, write a function that randomly generates a number from 0 to n-1 that isn't in l (uniform). Solution 1: const getRandNotInList = (n , list) => { const rand = Math.floor(Math.random() * n); return list.includes(rand) ? getRandNotInList(n, list) : rand; }; co...
stackexchange/codereview
This is my first attempt at anything functioning within elisp. This script is part of my configuration file that I use across multiple machines, one of which is hi-dpi and the other is not. To avoid having to reset my default font size every time I pull from my remote repository, I thought it would be nice to write a f...
stackexchange/codereview
I'm currently writing an API to work with Bioinformatic SAM records. Here's an example of one: SBL_XSBF463_ID:3230017:BCR1:GCATAA:BCR2:CATATA/1:vpe 97 hs07 38253395 3 30M = 38330420 77055 TTGTTCCACTGCCAAAGAGTTTCTTATAAT EEEEEEEEEEEEAEEEEEEEEEEEEEEEEE PG:Z:novoalign AS:i:0 UQ:i:0 NM:i:0 MD:Z:30 ...
stackexchange/codereview