instruction
stringlengths
71
71.9k
I have written a client for streaming video playback. The client uses two threads, a receive thread and a decode thread. Events are fired off periodically for drawing a completed frame onto a SDL window. SDL mutexes is used for creating and locking shared resources. Currently, I am trying to split things up so I create...
I have made a procedure to display the highest and the lowest popular Items for a particular time of a given date. The procedure works with no errors or exceptions and everything is functional. As you can see, the queries are repeated twice for the purpose of showing the first record on Items, but the only differences ...
I have an implementation of the reduction approach used in this document. Furthermore, I extended (crudely) this so I can reduce-by-key. In my setup I can assume that a key array variable is constant through subsequent calls to a reduction kernel and that it is sorted in increasing order, and can thus pre-process and m...
I tried implementing TLV(https://en.wikipedia.org/wiki/Type-length-value). Actually my implementation is more than TLV because it supports additional "Tag" elements (which you can use for naming certain TLV objects) for TLV objects. My goal is to serialize the array of TLV objects to byte array and vice versa (this I d...
Given is an array which contains sub-arrays. The elements in this sub-arrays are numbers. The task is to implement a JavaScript-function which returns an array with the smallest / largest numbers in the single arrays. I have figured out this solution: // Returns the smallest / largest // numbers contained in a // ...
My program takes static input, and then number crunches for a few hours. I am currently using Macros, but is there a better, more "user friendly" way to do this without losing on performance. I have written a program in C to generate Seed programs from a Befunge program. It is a very long, brute force calculation. So t...
I have created a site for practice and I have already asked a question on Stack Overflow about XSS. Someone tell me to show your php functions on this site that i created using filter_Var These are two PHP functions I created that sanitize/validate user input and after passing the the user input in these function I ...
I have created a reusable code for jQuery tab functionality for my client site. Every thing works fine but the only thing I am worried is that the lines code I have written for this small feature is very high. Can any one help me to shrink lines of code or any suggestions. Here is my JavaScript code: /** * @param lin...
I'm just learning JavaScript and jQuery, and I've got some code that works, but I know it can be optimized. I have a page that when a button is clicked it adds 1 to a label, and then increments a bootstrap progress bar by 1. I have 6 functions that could probably be reduced to 2 by passing in arguments instead of havi...
The following class monitors the clipboard and raises an event whenever the contents change. The monitoring starts when the class is created and ends when Dispose is called. To achieve this a message-only window (a term that comes from the Win32 API) is created using an instance of HwndSource class (since I am using WP...
I have two very similar SQL statements INSERT INTO user_profile (user_id, setting_id, value) SELECT id, 18, true FROM users WHERE NOT EXISTS ( SELECT user_id, setting_id FROM user_profile WHERE id=user_id AND setting_id=18); INSERT INTO user_profile (user_id, setting_id, value) ...
In a JSP page I have a number of Span elements. Each of this span element will be floating point numbers. All these span elements has class "format-decimal-precision": <span class="format-decimal-precision">${info.flaot_val}</span> I would like to display all this floating point numbers with 3 decimal point precision....
After following the tips from @VoiceOfUnreason on my previous question, I want to post the revised code. The purpose of the code is to simulate a Shop and a Customer that use the Box service of the Shop while have a Paypal account that he must deposit money into before being able to use that Box service. Main.Java pack...
I'm new to Flask and Python and am trying to sort out the most pythonic way to modularize my utilities. I have models.py which have my sqlalchemy models and views.py which handles the routes, etc... My util.py basically handles the queries and data manipulation between the two but I want to know if I'm doing it right....
Overview I have 165,000 *.rds files that are around 200,000 obs x 13 variables each. These files are unique to grid files (2.5 square mile data) so I need to keep them in their unique grid numbers. Currently, I'm loading each individual file, performing some function on the data, and resaving them to another director...
I am a beginner at web development and I write code as a hobby. Would you please critique this code? I created a Tic-Tac-Toe game using HTML/CSS and jQuery. I did it for fun as a personal challenge. An image of a game board shows up initially. Each empty square can be clicked. Depending on if the turn is "even" o...
While looking at PHP.net this afternoon, I saw a comment in round() for two functions for rounding UP and DOWN (as opposed to just HALF_UP and DOWN). I liked the suggestion, but wanted a solution that was one function instead of 3, so I came up with the following: define('PHP_ROUND_UP', 11); define('PHP_ROUND_DOWN',...
I've created a program that will take, a bunch of numbers from a range of 1 - 255, and then put them into 3 different strings(servers) equally. It does this by having a count that starts at 1 and loops to 3, once the count has hit 3 it restarts until three servers have hit a max capacity of 100 numbers within it. Once ...
Exercise 2.20.   The procedures +, *, and list take arbitrary numbers of arguments. One way to define such procedures is to use define with dotted-tail notation. In a procedure definition, a parameter list that has a dot before the last parameter name indicates that, when the procedure is called, the initial parameter...
After finding a piece of code on StackOverflow that drew the Koch snowflake fractal, I made a ton of modifications to it and used it to produce an animation divided in two parts: Constant size, recursion depth increasing. Constant recursion depth, size increasing. You can see the animation here. I am interested mainl...
I am an Angular.JS beginner and this is my first application. I hope you give me some advices what to do to have better, optimized code. This application manages the data from database, shows it in table, allows to add new rows, edit existing records and delete them. Here is a content of my controller. I have only one...
The original question can be found here. While looking at PHP.net this afternoon, I saw a comment in the documentation for the built-in function round(). The comment offered two functions for rounding UP and DOWN (as opposed to just HALF_UP and DOWN). I liked the suggestion, but wanted a solution that was one functio...
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...
One of the reports I am working on requires me to locate searches a customer makes, and graph them in certain manners. I have one query I'm particularly concerned about. This one takes the most amount of time (relative to the batch) and seems quite ugly to me. Essentially, this should graph the search results by the da...
I created this JavaScript class using ES6-ES7 syntax to return an array of page numbers and ellipsis points (null) to be consumed by a function which will create a styled paginator. What I am looking for in a code review is how the code could be improved for optimal readability, improved for speed, and simplified if po...
I wanted to try multithreading out in C, so I did Dining Philosophers using C11 threads with the approach of having one of the philosophers left-handed. Any suggestions? #include <stdio.h> #include <threads.h> #include <stdlib.h> #define NUM_THREADS 5 struct timespec time1; mtx_t forks[NUM_THREADS]; typedef struct {...
My latest inspection for Rubberduck determines whether a procedure should be a function by checking whether it has a single ByRef parameter (either explicit or implicit). The quick fix takes this procedure, changes it into a function, and updates all calls. This inspection starts deep down, involving the parser: priva...
I am trying to use a custom sql query to display different attributes for a product i.e. Size and Price. The query I have when running in console displays as it should SELECT products.id, products.name, variant_properties.description, LEFT(variant_properties.description,1) as short_desc, variants.price FROM products ...
Project Euler #4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. Any reviews are accepted. #include <iostream> #include <algorithm> #include <string> bool...
At first I calculate the total of each data then give each data of data a percentage base on total. The percentage is calculated by adding its percentage and sum of all percentage before it. I then calculate a new value by multiplying percentage and total. I finally sort them from largest to smallest. How can I reduce ...
I gave problem #22 on Project Euler a try in Python3. Other than suggested in the instructions, I used requests to fetch the file to work on. The code below does produce the correct result but takes no measures to catch exceptions if something breaks, e.g. when the download is not successful. I managed to split a strin...
I've seen the code for this function in John Resig's book 'Secrets of JavaScript Ninja' yesterday. I considered it useful at once because I've disliked repeatedly typing console.log for some time. Here's my implementation of a helper function to reduce typing: // -- Function definition ------------- // Helper function...
I tried to create a very simple Webview with embedded video's in it, that can change to vertical and not reset to its default when changed to vertical or vice versa, even tho its working just fine I'm still feeling like the site is a bit heavy (its a simple wordpress website with some textual data and images, nothing h...
I'm coding a very simple reverse shell in python, and I want to encrypt the communication between the server and the client. The idea is to exchange an AES key using RSA then use it to encrypt everything sent on the network. Right now I'm trying to use PyCrypto's Crypto.Cipher.PKCS1_v1_5 module for RSA and it seems to ...
My Application looks something like this (Screenshot). To Control the URL Routing i am using a Angular Js Router. On Click of Store of the Side Panel the StoreList Appears. And on Click of the Edit, the portion template gets fetched from Spring MVC and displayed along with the details. I have written the Code for app.j...
Inspired by this meta question I decided to take a look at Rosalind. Their first challenge seemed easy enough: An example of a length 21 DNA string (whose alphabet contains the symbols 'A', 'C', 'G', and 'T') is "ATGCTTCAGAAAGGTCTTACG." Given: A DNA string s of length at most 1000 nt. Return: Four integers (separated ...
I created a load balancing server at work and have to keep track of which server it adds the user to, so I wrote a little Ruby script that will do just that. I'm looking for any critique of my work, can I do anything better at all. Source(user information, directory information, and server information changed for secur...
I have a service that raises multiple events, some of them can be raised at the same time. I need to process those events and run a potentially long running method based on the event arguments. What I did is to create a BlockingCollection<T> that will store the events and a Task that will keep taking one event at a tim...
This is sort of a follow-up to Replacing elements from a list and its sublists but now there are arbitrary numbers of words that would be replaced stored in a list. Now write substitute2 that takes a list, a list of old words, and a list of new words; the last two lists should be the same length. It should return a c...
To keep it succinct, I created a simple way to input dates and times into an input box without worrying about formatting. As an alternative to date time pickers, dropdowns and all the other various datetime libraries. Repo Demo page /** * Loosetime.js * * Author: Bruce Taylor * URL: brucetaylor.xyz * Date: ...
I'm starting a project in which I'll generate random graphs and use algorithms to solve them. The first necessary step is obviously to build a graph. My graph has the following characteristics : It can be directional or not, implying that the Edge between NodeA and NodeB can be traversed from B to A if the Graph is ...
From SICP Exercise 2.5: Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2^x*3^y. Give the corresponding definitions of the procedures cons, car, and cdr. Please review my code. (define (cons x y)...
I've made more improvements from previous iterations and my own, including: Added the -n flag (print owner and group IDs instead of names) Eliminated some bools by allowing certain flags to turn on others Added a Date struct for keeping the current date in one place Added an Entry struct to ease sorting and informatio...
Problem 21: Let \$d(n)\$ be defined as the sum of proper divisors of \$n\$ (numbers less than \$n\$ which divide evenly into \$n\$). If \$d(a) = b\$ and \$d(b) = a\$, where \$a ≠ b\$, then \$a\$ and \$b\$ are an amicable pair and each of \$a\$ and \$b\$ are called amicable numbers. For example, the proper divisors o...
I am trying to program a skew logistic distribution function to return the PDF, the CDF, and (later) the inverse CDF. Although there are several forms of skew logistic, this is for perhaps the most widely known, a variation of the skew normal distribution introduced by Azzalini and covered by Saralees Nadarajah. Asid...
I attempted a problem from the Cracking the Coding Interview book. The following input: aabcccaaa should give the following output: a2b1c3a3. Any advice is much appreciated! #include <stdio.h> #include <stdlib.h> #include <string.h> char* compress(char*); int main(int argc, char** argv) { if(argc==2) { ...
In the app I'm creating, when a user upvotes a post, the post should be upvoted, as well as the user that wrote the post. But this updates two MongoDB documents. This presents a number of issues. I'll first provide an overview of the code and then list the issues. A user clicks on an upvote button, which calls the vm.u...
I was working on this game for while and I have made it for education purposes by using SFML. The game works fine but I would like to know how I can improve it. #include <SFML/Graphics.hpp> #include <vector> #include <utility> #include <array> #include <random> #include <iostream> #include <algorithm> #include <functi...
With the festive season mood and the new year coming, I thought I would make my first question this year, a tree implementation. Blame me because it doesn't have anything to do about Christmas. public interface ITreeITem { object Key { get; } object ParentKey { get; set; } } public class Tree<T> : IEnumerable...
If I have a oneliner in C such as size_t maxSizeOf(const char *s) { return strlen(s) > M_MAX_SIZE ? M_MAX_SIZE : strlen(s); } would it be better to have a macro defined such that #define MAX_SIZE_OF(s) (strlen(s) > M_MAX_SIZE ? M_MAX_SIZE : strlen(s)) or would it be better to have size_t maxSizeOf(const char ...
This program offers 8 notes C, D, ..., A, B, C on keyboard keys 1, 2, ..., 8. Also, by typing Left or Right, you can cycle over MIDI instruments. KeyboardPiano.java: package net.coderodde.music; import java.awt.Canvas; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.sound.midi.Instrumen...
The objective is to create a lightweight object pool that should be as simple as possible, but not simpler. It should be able to create and pool any type of object, be configurable (i.e. pool size) and be able to be replenish exhausted pools or timeout waiting for returned objects. It should be thread safe and able to ...
One thing lead to another and eventually I wanted to know the "proper" way of writing the permutation generating function in C#. Below is my code for generating permutations. This will go into an internal library, so the calling context is really generic. Expected calling is in a single-threaded context /// <summary> /...
As a self taught developer I never did any of the Project Euler problems, so I decided to just start with Problem 1 which states If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. The...
I recently implemented a subset of the ustar archiving utility as my first year programming one project. I would like to get it reviewed and if anyone has anything to point out. dir.c #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <dirent.h> #include <string.h> #include <stdio.h> #include <st...
I've just written code for generating all permutations of the numbers from 1 to n in Java. It seems to work, but I think it's a bit more complex than it needs to be. import java.util.*; public class ProblemFour { private static int n; private static void printResult(int[] result) { Set<Integer> set = ...
After I have tackled the first problem I come to Project Euler Problem 2 which states Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence wh...
Inspired by this question I decided to write an alternative that uses polymorhphism and a Factory pattern. The code works for the subset of implemented types, namely BYTE, WORD and STRING but I have a few concerns: I'd like to get rid of the big ugly switch in the TLVFactory. Is there a way to make the TLVFactory::...
This is a data structure that supports the push(), pop() and isEmpty() operations and returns the least element on every pop(). In a sense, this works like a PriorityQueue, only in \$O(n)\$ runtime against the \$O(log n)\$ runtime of a PriorityQueue. My implementation: public class SortedStack<T extends Comparable<T>> ...
I've created a class that holds an EAN13 code. This class is an attribute of the Product class. In the Ean13 class, the string that represents the EAN code is passed as a parameter to the constructor and the validation is performed in the constructor. I created some utility methods in that class, like sumEven, sumOdd, ...
I've been told that using God objects at all is a Bad Thing™ In object oriented languages, God objects know all, they control too much. I'm trying to build a game (or for the scope of this question a generic app with a GUI) and I'm using a Main object that holds all the other objects needed to make it all work. At the ...
I want to create a predicate nearby(X,Y) which represents "X and Y are integers 1 apart from each other" and fully satisfies: %%! nearby(+X:Int, +Y:Int) is semidet. %%! nearby(+X:Int, -Y:Int) is multi. %%! nearby(-X,Int, +Y:int) is multi. In other words it must work for any combination of two bound inputs or one bound...
I have solved the day 6 adventcode problem: --- Day 6: Probably a Fire Hazard --- Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've decided to deploy one million lights in a 1000x1000 grid. Furthermore, because you've been especially nice this year, Santa has...
I have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits: 59853 -> 83559 Please let me know if there are any better solutions. I would like feedback how to improve this. def next_bigger(num): numlist = [int(i) for i in str(num)] index_of_repl...
I have come up with the following method to post a transaction to a database, in the context of an e-commerce Java web application. The transaction consists in submitting a new order alongside its details: public long insertOrder(Customer customer, Hashtable<String, CartItem> shoppingCart) { long returnValue = 0L; ...
I created a simple 15-line number guessing game in Python 2.7: # Guess the number game username = raw_input("What is your name? -> ") guess = input("%s, I'm thinking of a number between 1 and 10. -> " % username) answer = 7 # sets the answer answer = guess if guess < 7: print "That's too low." if guess > 7: ...
I left out the helper() function because it is gargantuan and is a problem for another day. Basically, this program asks for: Your name Your parents Number of siblings Marital status Number of spouses Number of children for each spouse It then dumps everything into a helper function which draws said family tree to a...
I am wondering if there's a better way to structure my code. I want to keep my controllers thin but at the same time want to keep the model methods flexible. As you can see below, it's almost as if I can write active record code directly on my controller itself (Which not be a good thing?) The line of code in the contr...
I've been trying to find a way to collapse all these methods into one. Current I have these methods default byte readByte(long address) { return read(address, 1).get(); } default int readShort(long address) { return read(address, 2).getShort(); } default int readInt(long address) { return read(address, 4...
I have this program that compares performance of two algorithm for multiple exact string matching: Given a set of patterns and the text, find in the text all occurrences of any pattern. For example: Text: habababa Patterns: aba, ha Above, aba occurs 3 times, and ha occurs one time (matches are allowed to overlap)....
I wrote a function to reverse an array. The first argument is an iterable object, the second argument is the size of the array element in bytes, and the third argument is the length of the array. void reverse(void *object, int size, int length) { int i; int j; int k; for(i=0, j=length-1; i < j; i++, j...
I was doing a basic problem on coding a factorial \$n!\$: function factorialize(num) { if (num < 0) { return undefined; } else if (num === 0) { return 1; } else { return num * factorialize(num - 1); } } The site I'm learning from accepted this solution, but they're only testing for nonnegative integ...
I've seen a tutorial where a dbcontext base class is created like so: public class BaseContext<TContext> : DbContext where TContext : DbContext { public BaseContext() : base("name=Context") { Database.SetInitializer<TContext>(null); } protected override void OnModelCreating(DbModelBuild...
I am trying to learn how to professionally work with unit testing, so I have refactored a medium sized project of mine (a sort of article aggregator that also does some NLP processing) and tried to apply some patterns to allow efficient testing (based on answers proposed here). Current structure of the application: Co...
Based on the previous question, I have implemented all suggestions. Also, I added new features to the game. Summary of improvements: Implemented smooth movements to snake instead of tile movements to give realistic impression Added fixed timestep Game relied on radian and degrees instead of enum of directions for com...
Title is pretty self explanatory, this program just takes in input (not from command line arguments), removes the extra spaces in the input, then prints that to output. /*replace string of blanks with single blank*/ #include "stdio.h" int main(int argc, char const *argv[]) { int nb,c = 0; while ((c=getchar(...
This question is an improvement I did based on recommendations from these other questions: Simple object-oriented calculator Simple object-oriented calculator - follow-up Simple object-oriented calculator - part 3 To those looking at this question for the first time, I'm trying to find a correct OOP model I can use in ...
I've written the following code to determine if an Internet connection is available in mind of this article at Microsoft's technet. In short, there are two methods of prove: Check if the response of http://www.msftncsi.com/ncsi.txt is Microsoft NCSI. If not, check if the IP of dns.msftncsi.com is 131.107.255.255. //...
I am learning clojure this week end and just starting to develop a simple checkers engine. I currently coded some basic functions to create the board and display it. I would love to get some feedback ! (ns sandbox.checkers) (def standard-size 10) (defn empty-board [size] (vec (replicate size (vec (rep...
I have been working on a project for several days. It is a command line program for viewing files in hexadecimal. It is usually very fast, but is there any way I could make it more efficient? #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]){ if(argc == 2){ FILE *in = fopen(argv[1], "...
Below are two functions that work no problem in my current script. They are written to be ran in Python 2.7.x def tor_browser_initialise(): """ This function checks whether the Tor Browser is running. If it isn't, it will open the Tor Browser. """ processlist = [] for p in psutil...
I am making a Sudoku game and I have managed to add random numbers, add numbers, and to checklines (if there is 2 numbers on the same line). I am trying to check the 3x3 boxes if the number is twice or more in the same box. I have managed to do it one way, but is this the easiest way? In that case I need to do this 81 ...
I'm learning JavaScript and decided to build this mortgage calculator as a starting point. For the most part it was reasonably straightforward, but when I implemented the graphs using D3 I found myself with two similar functions that contained a lot of the same code. I could have used one of the many D3-based charting ...
I had to create this makefile to build and debug a C++ console app. I just need some hints and tips on how I can organize my makefile. CC=g++ CFLAGS=-c -Wall LDFLAGS= SOURCES=helloWorld.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=helloWorld all: $(SOURCES) $(EXECUTABLE) debug: CXXFLAGS += -DDEBUG -g debug: CCFLAGS += -...
I am making an HTTP request with the Google Maps API and I have to pass in parameters (adresses/coordinates): $.ajax({ url : 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=' + $("#origin").val() + '&destinations=' + $("#destinations").val() +'&mode=driving&key=AIzaSyASanevdiCI4t1h8LMf5FgWHMD...
Source: Rosalind("Consensus and Profile") Brief summary A T C C A G C T G G G C A A C T A T G G A T C T DNA Strings A A G C A A C C T T G G A A C T A T G C C A T T A T G G C A C T A 5 1 0 0 5 5 0 0 Profil...
Inspired by this question I thought I provide my implementation. I tried to go with the spirit of the *nix tool chain - read from stdin and write to stdout. This has the added benefit of making buffering very easy (current and previous characters and the count). All kinds of reviews welcome (best practices, error handl...
I have written an isRotation function that calls on isSubstring only once(I am allowed to call it only once). I have implemented my own version of isSubstring as well. Any advice is much welcome! //Checks if one string is a rotation of the other #include <stdio.h> #include <string.h> #include <stdbool.h> bool isRota...
I need to get the distinct sums of naturals of a natural What I came up with is: type Sum = Stream[Int] //should maintain the invariant that //* all Ints are positive //* is non-strictly decreasing //* is non-empty def makesums(i: Int): Stream[Sum] =...
How can I improve my code and make it more idiomatic? package pascal func NextRow(prevRow []int) []int { x := make([]int, len(prevRow)+1, len(prevRow)+1) x[0], x[len(prevRow)] = 1, 1 for i := 0; i < len(prevRow)-1; i++ { x[i+1] = prevRow[i] + prevRow[i+1] } return x } func Triangle(x int) ...
For my current project I need a basic UDP server. The first priority is to make it as fast, but as resource friendly as possible (it will be run on Raspberry Pi-like devices). I would like a review about the general code 'quality' and logic. I know that I am missing some error-handling at the moment. The Server class: ...
My primary concern is that this has been written as a global function. I think it would be better if this was a function of the SignalProducer class but I am not sure that is even possible. Is this thinking justified or is the use of global functions acceptable? (The following code uses ReactiveCocoa 4 and is written...
I completed writing a dice roll script in Python but I thought it looked too messy. Is there anything I should change here? import random, os class Dice: result = [] total = 0 def __roll_(sides=1): return random.randint(1, sides) def roll(sides=1, times=1): for time in range(0, times)...
I am brand new to coding in Python, and programming in general. I have picked up the Learning Python book and have been slowly making my way through it. I decided that I would try to implement what I have learned by writing a simple word-based game that I could run through the Mac OS Terminal. I would love to hear any ...
Background and Purpose For those unaccustomed to Ruby, Ruby supports range literals i.e. 1..4 meaning 1, 2, 3, 4 and 1...4 meaning 1, 2, 3. This makes a Ruby for loop pretty sweet: for i in 1..3 doSomething(i) end It works for non-numeric types and that's pretty cool but out of our scope. A similarly convenient t...
It seems odd that state must be passed around all the time. Can't State module hold itself, so I could do something like state = %State{size: size} case state.is_full? do ... Here state is always passed. I suppose this is how it is in FP? defmodule Chatter.Room do use GenServer defmodule State do defstr...
I'm not great with JavaScript. I've written a small jQuery function and I've now got it working, but I just wanted to check if the code looks good or if it can be improved. I wanted a function so that I can easily add the function to any textarea and input so that it counts characters remaining and so I can just change...
This working macro converts Hindi Devanagari proprietary font to Unicode font. It reads the conversion table from a tab delimited file, and converts one by one by finding all matches and then does some ligature shifting. I don't know how efficient it is and how much time and resources it uses. Feel free to tell me if s...
This is a section of code in a program I have created to store and review the results of a game based upon the "class_number" the user gives. This section is very bulky and I was wondering how I could make it more efficient. if class_number in ['1','2','3']: if class_number == 1: query = """ INSERT...
I am printing subsets from an array whose sum has been specified, while avoiding duplicates. I think there may be improvements, potentially on how using map is bad idea, or how can I avoid map to filter the duplicates. Additionally, in my code I want to reverse the sort order of an int array using streams which is aske...