instruction
stringlengths
71
71.9k
Is there a better way to write this? $query = $db->getConnection()->prepare("INSERT INTO `users` (first_name, last_name, email, username, password, unique_id, date_joined) VALUES(:fname, :lname, :email, :username, :pass, :uniqueid, :date_joined)"); $query->bindParam(':fname', $first_name, PDO::PARAM_STR); $query->bindP...
This method allows the user to choose a start and end date in human readable form, then convert it to epoch. The method will return a array of longs composed by the epoch start date and the epoch end date. I handle some exception so if the user types anything else than the date it will end the iteration and start agai...
For no particular reason, I wanted to create a function that would take a string and "encrypt" it via Caesar cipher. This function takes a string and shifts the letters left or right (in the alphabet) depending on the input. Shift right(2) for instance would be - ABCDEFGHIJKLMNOPQRSTUVWXYZ CDEFGHIJKLMNOPQRSTUVWXYZAB T...
I'm currently working in a Windows.Forms project where its very common that I need to show a responsive feedback form while a task runs. These tasks take typically around 5 to 10 seconds to complete and the user can't do anything else until the task has successfully finished or failed. To keep the UI responsive I've co...
Every week I've got to send a report to a clerk. I also have to add his deputy in case the clerk isn't available. For not to forget the second recipient and the attachment I've wrote myself this VBA-Macro. Perhaps one could enhance it in a way that it works with more then two recipients? Any comments and suggestions...
I'm using the Jquery date time picker link here In the four methods below I am initializing the DT pickers but they are all pretty similar except for the ID in the onChangeDateTime. Is there a way I can reduce the duplicate code? $('.jqDatetimeDateOne').datetimepicker({ defaultTime: '07:00', lang: 'en', cla...
I am currently trying out code for timing efficiency (how fast it runs, basically). The general consensus is that code with ActiveCell,.Select,Selection and so forth are basicly rejected for being slow and buggy, whereas code that uses variables and not ActiveCell,.Select,Selection are considered quicker and less buggy...
I am doing Project Euler problem 67 which involves finding the heaviest path through a triangle of integers like this one (this is a smaller version from an earlier problem) 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33...
As an exercise in learning, I'm creating a bugs/issues tracking and "aggregator" web application. A simple app consisting of products, issues, reviews and links related to it. The links will be urls pointing to issues/reviews already created on external sites (bugzillas, stackoverflow, etc). Here is my initial effort t...
The required behaviour is : The yellow span must be positioned relatively to viewport (position:fixed;) when it is inside the pink div. The height of yellow span must always be the same as viewport height minus 100px. It has a fixed width in px. The yellow span must be verticaly centered in the viewport (this rule is ...
I am experimenting with ES6 using BabelJS in a codepen project you can find here. I am confused as to why my code breaks when I decide to use let instead of var in the following function: function getUnits(country) { const imperialCountries = ['US', 'BS', 'BZ', 'KY', 'PW']; if (imperialCountries.indexOf(country) === -...
Considering that: the passed parameters are all numbers the passed date is a valid date It should return: true if the date is 18 or more years old false otherwise function isDate18orMoreYearsOld(day, month, year) { var maxBirthDate = new Date(); maxBirthDate = new Date(maxBirthDate.setYear(maxBirthDate.get...
The program shows three phones with prices, and you need to select one of them. The program will then calculate the price based on the payment type you selected. I'm very new to the world of OOP, and because I'm studying OOP on my own (I actually go to school and we have a computer subject, but I'm taking advance lesso...
I'am writing on a spatial clustering algorithm using pandas and scipy's kdtree. I profiled the code and the .loc part takes most time for bigger datasets. I wonder if its possible to speed up the points.loc[idx, 'cluster'] = clusterNr somehow. import numpy as np import pandas as pd from sklearn.neighbors import Nearest...
I've been working on improving my C coding. I wanted to write two string algorithms: to trim white space from the beginning and end of a string to compact a string I have a few problems with this code that I was hoping to get some advice on: The casts from const char * to char *. Is there a clean and idiomatic way o...
Assume I created an image in NumPy: image = imread(...) And the image is RGB: assert len(image.shape) == 3 and image.shape[2] == 3 I want to check (i.e. get a boolean mask) which pixels are (R=255, G=127, B=63) in a cleaner and efficient way: mask = (img[:, :, 0] == 255) & (img[:, :, 1] == 127) & (img[:, :, 2] == 63)...
I have a list of non-unique values. I want to output a list of the same length where each value corresponds to how many times that value has appeared so far. The code I have written to do this seems over-complicated, so I think there has to be a better way. x = [1,1,2,3,1,3] def times_so_far(ls): out = [0]*len(x...
I did a maze thing ages ago that could support any number of dimensions, but it was very slow to generate. To get an idea of how it generally works with the multiplier and stuff, here's a gif of something I made with it: One thing that always bugged me was I couldn't figure out pathfinding, and I thought there'd be so...
After reading LYAH and using RWH as a reference, I've been doing the exercises from CIS194, which is often suggested to beginners on irc://freenode.net/#haskell and by this author. I've just completed Homework 12, which goes with Lesson 12 and focuses on Monads, using the template provided here. You can find the comple...
I am in the process of creating a program that allows a user to input known parts of a right triangle and the calculates all of the unknown parts if it is possible. I am using a class that I wrote in order to do the calculations. I wanted to know if there is a more efficient solution to this problem or if my code is go...
I'm putting together some RESTful services using ASP.NET Web API. This is the first time I have done this, so I'm looking for general feedback on this controller to make sure I'm not doing anything that doesn't make sense or that will be confusing to future maintainers of the code. The factory is brought in using MEF, ...
We are working on an assignment where we have to generate code that will play player one in the game Cows and Bulls. I am working on a function that generates the code based on the values for codeSize and codeChars. CodeSize being the size of the code, CodeChars being alpha or numeric, depending on what is selected by ...
Several times we need to be able to revert the data the user is inserting to a previous state (cancel data update). In order to keep DRY and for the sake of separation of concerns I thought about a way of just allowing that. public class RevertableObject<T> : ViewModelBase //implements INotifyPropertyChanged where ...
I'm developing a simple application that crawls web pages to obtain some information. For this I used and tested some libraries, like crawler4j, jsoup, jaunt and htmlunit. I change the crawler APIs several times because sometimes perceived that one served me better in a certain feature than the one I was using. I may h...
I put together this simple query to calculate the percentage of downvotes each user is responsible for and displaying them in order of downvote percentage. It's generating the desired results, but I am uncertain about style and best practices. WITH DownVoteCount AS ( SELECT DownVoteCount = CAST(SUM(DownVotes) AS float)...
I wrote a basic JavaScript plugin that allows you to specify what specific JavaScript files and CSS files to be loaded in, and in addition specify attributes for each file. To specify where to load in scripts, you just have to add a data-script-loader attribute to an element, and all scripts will be inserted after that...
I've gotten a solution for Project Euler #7 in C (find the 10,001st prime). I came up with the very simple algorithm myself (from what I can tell it's similar, if not identical, to the Sieve of Eratosthenes). #include <stdio.h> #include <stdlib.h> long prime_finder(int amount_of_primes); int main(void) { int amount_...
I've made an attempt at writing a skip list in Python. I'm using NumPy to generate geometric random variables, but since that's a bit of a heavy dependency to drag around I could easily implement that myself. I based my implementation on the basic (none of the improvements such as capping node height etc.) algorithm he...
Following this linked question and the feedback it generated, I put together a new query which utilizes a JOIN. WITH UpvotedComments AS ( SELECT PostId, Score, Text, --Comments.UserDisplayName doesn't return users' current display names Commenter = ( SELECT DisplayName FROM Users ...
I'm coding a "encryption" algorithm for learning and and don't know how good is it or how could I make it better: private static byte[] encrypt(byte[] data, int session_id, byte[] password) { int session_key = (session_id & 0xFF); if (session_key == 0) session_key = (session_id << 4); byte[]...
Please review the following in-place implementation of Heapsort in Python: def heapsort(l): def plunge(l, i, n): lchild = 2 * i + 1 while lchild < n: rchild = lchild + 1 if rchild < n and l[lchild] < l[rchild]: child = rchild else: ...
I have written a BST using one class. Is my code okey or something could be better? /** * BST using one class * @author Mateusz Stankiewicz */ public class Node { private Comparable data; private Node left; private Node right; private static Node root; /** * Tree constructor */ public Node() { root = null; } ...
I have this small function for reading the TSC (time-stamp counter) in *nix. Using it seems to report my CPU frequency more or less correctly. #include <stdint.h> #include <stdio.h> #include <unistd.h> uint64_t read_time_stamp_counter() { uint32_t my_edx; uint32_t my_eax; asm ("cpuid\n\t" /* Discourag...
I have written this file in PHP using MySQL. However, I have a lot of code that looks like it could be simplified. Can someone suggest a way to make this more efficient? i.e. I want to follow the D.R.Y method. <?php require_once('database.php'); try{ $result = $conn->query('SELECT id FROM documentaries'); }...
The code looks for the specified .tgz file, if it's not present, it creates it. It looks for files ending in .txt in the cwd and adds them to a list. It decompresses the gzip, checks for the .txt files in the tar, adds the missing files to the tar and then recreates the compressed gzip with the new files in it. It then...
I am writing a brute-force method to search for a word. Please review my code and tell me how I can improve it. public class Searcher { private static String filepath = null; private static final String defaultPath = "//sample_text"; private Searcher() { this.filepath = defaultPath; } private Searcher(...
I made an implementation of the Bridge Pattern to handle ever-changing in crawler APIs that I'm using in my APP. public interface CrawlerApi { // common constants to serveral implementations. String CHARSET = "ISO8859_1"; int TIMEOUT = 20000; /** * Visit an url and return contents in String format...
A few weeks ago, I asked for another DIC review, but didn't get any response (but only for one about my error handling). So I tried to rework my DIC without any outside insight on it, and the first thing that came to my mind is that my DIC wasn't really ergonomic. So I tried making one with dynamic setters/getters. The...
I'm putting together a simple application container for learning purposes, and I would like to hear how you see this code. The application is the main class that will contain services, configuration and other related stuff. I have identified 3 position where I can't decide on the design: Each application should be sup...
I was hoping for a bit of advice on cleaning a couple of areas of this code up. In particular, the hex-to-binary section, the checksum is in hex, and the rest is in ASCII. I tried for a good day to do it with tables etc, but in frustration I ended up going with this. Is there a better way of handling the "Store individ...
This is code from my android client which communicates over wifi to a small server program (not coded in java). This is my first time playing around with sockets, so I'm sure there are lots of little gotchas to worry about. For this project I am limited to Java 7. The protocol for sending a message is 4 Bytes for an ...
For a game I am playing, OGame, I am trying to calculate the fastest strategy to reach a certain state in the game, relevant parts of the game for this question are: You can build different types of buildings. Buildings take time to be built. In particular the Metal Mine, Crystal Mine and Deuterium Synthesizer buildin...
I just want to know if my code can be weak. Can anyone also spot a mistake in my code? Encrypt public static String byte2hex(byte[] b) { //we know exactly how long the resulting string should be so pass that information along to minimize allocations StringBuilder hs = new StringBuilder(b.length*2); for (int...
When writing an answer to another question here, I came across the problem of producing lists of integers having a certain total and only consisting of a certain number and an optional rest. So for total 21 and number 5 you would get List(5, 5, 5, 5, 1). Solving the problem is obviously not hard. However, I have the fe...
I'm a beginner at coding and the past days I tried to write the famous "Conway's Game of Life" in Angular.js. Right now I'm done with the code and the game works. But if the size of the playground grid gets too big (e.g. 100x100 cells), my program is kind of slow. I wanted to ask you where I could improve my code to ma...
I made two functions: one to get process id and the other to get a handle with all access to that process using the process id. I'm looking for help with making these easy to use on all types of projects. The only thing I know is maybe letting the person chose the open process properties. DWORD getProcID(const std::wst...
This code is a Parser that parses numbers according to R5RS. #b1001 - binary #o2127 - octal #h02d - hexadecimal #d1231 - decimal 3923 - decimal It is working at the moment, the only problem is the parseNumberBase. I am really new to haskell, but it does not look very good to me. How could I improve it? (readabil...
I'm new to parsing, and there's only one way to learn anything, and that's to do it yourself. So I did. I wrote what is essentially a calculator. But instead you will send it a string and it will be evaluated. It's syntax is as follows: 5 + 5 2 * sin(45 * 2) 2 * sin 90 2*sin(90) 2*sin90 As you can see, it does not hav...
I'm playing around with database designs to use for a new system. This system at its core revolves around various types of items (users, accounts, images), their meta (names, titles, file sizes), and item's relation to each other (users mapped to accounts, images mapped to users). Comments I created the uid solution ...
I wrote the below function which successfully creates pairs of dates in the format I need. However, I'm fairly new to Python and feel there must be a way to make this easier to read. Can this code be improved? def getNextTenDays(): dates = [] arrive = datetime.datetime.now() for n in range(1, 11): a...
Is my implementation of AVL tree correct? It is my second Python program and I am not sure if do code properly. ''' Created on 30 sty 2016 AVL tree - my second python program :) @author: stanek ''' class Node: def __init__(self, data, left = None, right = None, height = 0): self.data = data self...
Earlier today I tried to implement an example of the bridge design pattern, but I ended up misinterpreting it. I made a lot of changes: public interface VisitorAPI { String visit (String url); } public class JsoupVisitorAPI implements VisitorAPI { @Override public String visit(String url) { try {...
I wrote a script to change a static image by hovering over navigation links. It works great, however, the script is very long and I'm guessing there is a much more efficient way to write this code. Can anyone give me tips on a better way to do this? HTML <ul id="navigation"> <li><a id="1" href="#">Link 1</a></li> <...
I am taking input from a text file, performing matrix multiplication, then outputting to another text file. I just want to be a better programmer, so please be a detailed as you want. Comments, naming, formatting, etc. import java.io.*; import java.util.*; import java.util.stream.*; public class MartixMain { ...
import java.io.IOException; import java.util.Scanner; public class Main { private static int random = (int) (Math.random() * 100 + 1); private static int data; private static int go; private static int attempt = 10; public static void Start() throws IOException { Scanner scanInput = new ...
I made a tool set to facilitate bit manipulation as follows. Any comments are welcome, be it about the interface design, the implementation, or even the naming. Also, I want to make sure that the tool set is not lacking something for use-cases I failed to catch :-) Original code and unit tests can be found here and her...
I recently started up again on a 2D game engine I have been working on over the last couple of years. I managed to implement a version of the a* algorithm that seems to work fine for my game, but it seems to be having a dramatic impact on my games performance when I have multiple enemies using it. Currently I am callin...
import random import operator import pickle classname = "" while True: classpick = input("Enter class name (\"A,B,C\") ").upper() try: if classpick in ["A","B","C"]: classname = "class"+classpick+".txt" break else: raise ValueError except ValueError: ...
(See the previous iteration.) I have incorporated some points made by ChrisWue and refactored my Fibonacci heap implementation: fibonacci_heap.h #ifndef FIBONACCI_HEAP_H #define FIBONACCI_HEAP_H #include <stdbool.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif typedef struct fibonacci_heap fibonac...
I recently wrote an entry on my blog regarding unit testing using prime numbers as an example. When I wrote the entry, I wrote my code keeping in minding that proposal SE-0007 has been accepted for Swift 3.0. That is, C-style for loops will no longer be available in Swift as of 3.0, so I want to completely discontinue...
Here is my issue.I have two classes: public class Role { public string RoleTitle { get; set; } public string Office { get; set; } public string Department { get; set; } } And public class Employe { public string Name { get; set; } public List<Role> Roles { get; set; } } As you can see, class Employee contai...
I have written this function that returns the common divisors of two integers. When called recursively 10 times with big integers ranging in 100000000, it takes over 5 seconds. How can I improve it so that it is faster (less than 5 seconds)? commonDivisors :: Int -> Int -> [Int] commonDivisors x y = if x > y then divis...
Can you say, is this a bad code for registration in Django? Do I need to fix something or use a pip instead? (I am learning) def register(request): error_messages = {} if request.POST: form = UserCreationForm(request.POST) if form.is_valid(): new_user = form.save() us...
Just wrote a program to check if a string is Palindrome. If that's true, return 1. Else, return 0. How can I improve it? #include <stdio.h> #include <string.h> #include <ctype.h> int palindrome(char *s) { int i = 0, length = strlen(s) - 1, n = length; int boolean = 0; for (; i <= length && n >= 0; i++, n-...
I'm working my way through some basic OpenGL tutorials and have decided to offload the shader loading/compiling/linking to a separate object that I'll use for the remainder of the tutorial material. Ideally, I'd also like it to be useful later, when I get on with working my own OpenGL projects. And, who knows, maybe so...
I recently reinstated the unit tests in Rubberduck. Previously, our parser was a synchronous parser, with everything running in sequence, and we could just request a parse result. Now, however, it runs asynchronously and we can only request parses. As a result, I have to somehow perform a blocking call to the parser...
I have the following. How best to refactor it: def self.search(search, organization_id, is_admin) if is_admin == false where("record_no LIKE ?", "%#{search}%"). where("organization_id = ?", organization_id) else where("record_no LIKE ?", "%#{search}%") end end Basically this means, ...
Is there a better way to organize the methods within this program without compromising the clarity? Running through digits 0-9 with separate functions seems very bulky. // Prototypes void display(); void zero(int digit); void one(int digit); void two(int digit); void three(int digit); void four(int digit); void five(in...
While reviewing @Martijn's Distinct sums of integers (finding all combinations of positive integers that sum to a given number), I proposed the following solution: /** List of non-increasing positive integers */ type Sum = List[Int] def sums(n: Int): Iterator[Sum] = { /** Prepends the head of the stack repeatedly un...
I have written a simple Ruby program to model a transit card system which aims to address the following user stories. I wanted to see whether I could get any feedback on it. My main interest is understanding where I have made fundamental mistakes that violate OOP(SOLID) Principles with a real focus on Single Responsibi...
I'm in need for clarity. I'm at an annoying step in my development of a website, and I have read a lot about semantic structure etc, but I'm a bit nervous for my current structure, so I would like to ask your expertise to see, if I might get problems with search engine bots with this setup. <body itemscope itemtype="ht...
I'm currently in the process of making a 2D tile based game. This game has an "infinite" world that can be traversed and modified as needed. I am creating the chunks with a mesh and I apply a texture to them. The chunks texture updates every time I set a tile with a new Sprite. Each time I set a new tile, the surroundi...
I have a Laravel project that has courses. I want to take the related courses from one. Should I create the method in the model (the php class) or in the controller? Currently I have this code in the model: class Course extends Model { public function relatedCourses() { $all_courses = new Collection; ...
This function produces a decoded string, decoded, for all keyspaces against a given cæsar cipher ciphertext. Punctuation is not changed and string.upper() is used to make working with ord() easier. I am looking for a more Pythonic way to work with my decoded variable. I keep finding myself assigning empty strings or No...
Everybody knows this river crossing puzzle solving game. I was playing a river crossing game in my cellphone and decided to try to implement every single game mode this app has. In case by any chance someone doesn't know what this popular river crossing puzzle is about, here's an explanation: A man once had to travel ...
I am creating a few functions that wrap around jQuery's Ajax function to make it a bit quicker and easier to perform a request. For this I have this JavaScript file: $( document ).ready( function () { var ajax = { url: "", type: "", success: "", beforeSend: "", preform: function ( $url, $type, $succ...
This script is used for gathering fragmented documents from your computer, and organizing them by extensions. Here is the main things my algorithm does: Search through path(s) Stores documents' paths Detects existing extensions Copies documents by extension to categories in a directory created in the current working d...
I've got the below SQL statement which runs in MySQL on a WordPress installation. I'm looking for meta data that matches certain criteria and was created after a certain date. However, WordPress doesn't store the date that metadata was added to posts, so I've created the metadata itself (wpcf-post-likes), the date it ...
Most of the VBA I write is to produce tabulated reports from spreadsheet data. So, here is my attempt at creating a CLS_Data_Report class. Properties: a 2-dimensional Data Array 3 dictionaries to, respectively: Map headers to column indexes Map external (user-set) descriptions to data headers Store number formattin...
I've recently started playing the X-Wing Miniature game, and there is quite some math behind some of the dice rolls, as they are affected by many abilities and so on. Manually calculating these is quite burdensome, so I decided to write a simple C++ program to approximate the expected damage by running many simulations...
I'm not sure if this is the right question but didn't come up with something else. I have this huge for{} loop which prints out some HTML Tables with some infos from some devices. This code looked totally wrong to me and it had bugs. I tried to make it look as idiomatic to JavaScript as possible (started learning JS 4 ...
I am interested in calculating odds of winning UK Lottery. The format is that 6 numbers from 1-59 are drawn. I am interested only (at this stage) in the odds of winning the jackpot (matching six balls). As an aside, I'm interested in the odds for a total balls count of 49, and 59, to see the change in chance of winning...
There have been a few questions over on SO recently about securely storing credentials in Powershell scripts. Because ConvertFrom-SecureString uses DPAPI it makes the output only valid for that user, which makes creating credentials for service accounts etc. occasionally awkward. I have had this script lying around for...
I have a view that displays posts created by users that actual logged in user follows. It works, by I think the way I've done it isn't good. BTW, UserProfile is my default user model. UserFollower model class UserFollower(models.Model): followed = models.OneToOneField(UserProfile, related_name="followed") foll...
I got a problem I'm finding pretty hard to solve. I'm trying to generate calendar months for a datepicker but at only 12 months I see a perf of around ~4-7ms. This doesn't sound like a problem but it becomes one on lower-tier devices such as smartphones that basically are 1/10th of the speed of a desktop (so double tha...
I just wrote a snow animation in Python. I think this is fairly clean but I have a few things that I don't like. from random import randrange import time # Snow animation # Snow is simply the `#` symbol here. Half of the snow moves at 1 char # per frame, while the other half moves at 0.5 chars per frame. The # program...
I have a database containing a high amount of data. I want my app to filter and select only some of it, and save it into a CSV file or JSON. For the moment I have this method which takes the data from the database and puts it in a CSV: void viewAllCounters (String tableName, long startDate, long endDate, Connection c) ...
The code finds all the combination of alphabet with length 5 and saves it in a list(its ASCII value, minus 97). I want to optimize the code to reduce execution time. from itertools import product def permuteKey(): def pp(chunks): return map(''.join, chunks) k=pp(product('abcdefghijklmnopqrstuvwxyz', ...
So I'm almost 100% certain I've done something wrong simply due to the inefficiency of what I've written, I'm entirely a novice to coding and am working on an assignment for my introductory programming course. The only way I could think to display the input from 4 check boxes was to go down 16 different branches to cov...
Currently this is the store procedure I am working on, it is working according to some testing that was done. I feel that it could be improved though, could use some optimization, feedback or recommendations. What is it supposed to do? For given policy id passed in, grab all coverages associated with the policy. For ...
Solving the maximum subarray problem with added cases of finding non maximum non contiguous subarray as well. I used divide and conquer approach and tackled the 'all negative' case by keeping a counter for that and branching it. #include<stdio.h> #include<limits.h> #include<stdlib.h> // finding maximum non contiguou...
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, @"\""",...
I made a simple scene manager in C99. I tried to make it readable, reusable and reliable. I would be grateful if you would help me to improve it. I want to use it for my upcoming OpenGL game. I think that code is sufficiently self-documenting for you to skip the comments. The headers scene_manager.h // Defines client i...
I wrote a Risk battle simulator that returned the odds of every possible outcome and put it up to be reviewed here. I used the comments to improve it, and am wondering if it can be optimized further. #include <iostream> #include <iomanip> #include <cmath> #include <vector> using namespace std; class battle { publ...
I wrote a little A* implementation by my own and would like to have some feedback ;) The code is in OOP way, thus we can use an other pathfinding algorithm easily. The "Base" is just the interface class, thus is should not matter here. Before we look at the code, let me say one or two senteces about it behaviour and mo...
I’m currently aiming to make my first app for the Universal Windows Platform (UWP) / windows 10. It’s a small app but should follow some best practices patterns (although I’m considering it as a first step on new grounds, as I am more used to MVC/ASP.net programming and a bit WPF some time ago). I’m using following fr...
I want to post my tiny program here and hope to get feedback improving the performance of my code and understanding Python better. My main issue is the slowness of the program and the corresponding bugs due to incorrect image checking since the game has already advanced in that time. It's a slow 2D game that I try to c...
I'm playing with async/await, but I have yet to discover a standard method to safely cancel an intensive task. I have tested the following, and it works exactly as intended, though I remain unsure if a standard method exists. abstract class PageLoader<TPage, TElement> where TPage : Page { private TPage page; p...
I wrote this Pin class as a part of a project to learn SOLID. What do you think about it and what can be made better? Interface public interface IAuthorization { bool Verify(object obj); void Change(object obj); } Class public class Pin : IAuthorization { private int _pin; ...
I'm new to Java and is trying to solve the beginners problem of finding out the number of words in an user input string or a text file. I was just wondering if there are any alternatives to any of the steps that can improve efficiency as well as simplicity. import java.io.BufferedReader; import java.io.FileNotFoundExce...