instruction stringlengths 71 95.1k |
|---|
I'm a newbie playing around with Fortran 90 and openmp and wrote the code below (a simple 2D heat transfer simulation) for testing purposes.
So far I don't see any speedup by using openmp / parallel processing. In fact, it gets slower when I use more procs. I understand that the parallelization requires some extra over... |
My goal here is to make data driven nested forms in React. I've created a function that points to a form configuration JSON, which can contain both components and references to other configuration files, with their own components. I'm splitting it to separate files to keep things DRY and to get an easier overview (hier... |
Here’s my code, the traps are the slightly visible squares. The user controls a red square (with arrow keys) and cannot touch the walls or traps or else the game resets. Additionally, if the user touches the green line, the game ends.
Code:
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Maze Game</t... |
I am a beginner Java programmer and am in need of someone to read over it and help me condense my repetitive coding. I wrote code for a Bingo game and feel like I repeat code too often. If anyone could help me with my over obsessive use of repetitive code it would be greatly appreciated
package bingo;
import javax.sw... |
The problem is stated in Encrypt this!:
Your message is a string containing space separated words. You need to
encrypt each word in the message using the following rules:
The first letter needs to be converted to its ASCII code.
The second letter needs to be switched with the last letter
Keepin' it simple: There ar... |
I was presented with a coding challenge:
Given two integer arrays (in this case, the two given arrays have the same length of 6). And a target of 24. Find two pairs of numbers from those 2 arrays whose sums are closest to the target.
I kinda find it lengthy. How can I improve it?
#include <iostream>
void which_no(int... |
How would I clean this code/shorten it (most of it is login)
What the program does:
Only authorized players are allowed to play.
Input from user should be validated where possible.
5 rounds.
Score cannot go below 0.
2 players roll 2 6-sided dice.
Points rolled on each player's dice are added to their score.
If total is... |
This is the Haskell version of my recursive Fisher-Yates shuffle in JS.
import System.Random
pick :: Int -> [a] -> ([a],[a])
pick _ [] = ([],[])
pick 0 (x:xs) = ([x],xs)
pick i (x:xs) = (,) <$> fst <*> ((x:) . snd) $ pick (i-1) xs
shuffle :: [a] -> IO [a]
shuffle = runner =<< length
where
runn... |
I am a hobbyist programmer trying to learn modern C++. My son had an assignment in his C++ class to fill in some functions that populate draw the cave in the "hunt for the wumpus" game. When I viewed the instructors skeleton code I found it to be very C-like rather than C++-like. So, I decided to rewrite it so I could ... |
Here's a password generator I created.
### THIS PROGRAM WAS CREATED FOR LEARNING PURPOSES ###
### AND SHOULD NOT BE USED TO CREATE PASSWORDS! ###
import string
from enum import Enum
from random import randint, shuffle, choice
class PasswordError(Exception):
__module__ = Exception.__module__
# Types of chara... |
I've been working on a personal project. There's this game called TFT which is an autochess game. Each match is played by 8 players and there's a shared pool of champions. Each champion has their cost and how many of each there are, below is the table:
12 Champs that cost 1 gold, 39 of each champ.
12 Champs that cost 2... |
This is a simple Java application, which adds songs to a playlist, removes songs from playlist based on indexes. A database is not used in this. I am creating dummy data through a Utility class. I want to get feedback on design and code, so that I can refactor it.
MusicApp main class, creates a random playlist. Adds/Re... |
this is my code for watching IP packets. I am doing project for my self because I want to learn how this things works.
This is my IP Packet class:
public class IPPacket
{
private IPHeader _ipHeader;
private TCPHeader _tcpHeader;
private UDPHeader _udpHeader;
public IPPacket(IPHeader ipHeader, TCPHeade... |
The task
Given an integer array, move all elements that are equal to 0 to the
left while maintaining the order of other elements in the array. Let's
look at the following integer array.
After moving all zero elements to the left, the array should look like
this. We need to maintain the order of non-zero elements... |
I wrote a JSON parser for C++. It is not particularly fast, efficient or elegant. I'd like to change that and primarily I'd like the code to be more elegant. How do I improve it and get rid of all the code smell?
Aside: I have never taken a computer science course in my life and I'm not sure how far this deviates from ... |
The code below is a program I'm writing to help myself budget.
I am still new to programming and was wondering what you all thought about the code, or what I could improve at and what is good.
This works by gathering data and information from the income and bills to help show you your budget. My end goal with this is... |
Each client application would send a filepath and search term to the server. The server then takes that file path reads the file and returns any lines that contain the search term, the server then watches the file for any size increase and if the new lines contain wanted information it gets transmitted.
The first for l... |
I have this code, and the point is I want to dynamically change the mongo connecter to change between ssl, not ssl and with and without username in the same connecter function.
if auth_required:
if config.getboolean(component, 'ssl', fallback=False):
client = MongoClient(
'{host}:{port}'.format(... |
I am a beginner with regards to C; I'm used to using high-level languages (Java, Python, JS, etc) and this is my first project in a lower-level language. I wrote a simple Brainfuck interpreter, given that my Python implementation was super slow.
Here's the code:
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.... |
Syntax Checker is a very common question of c++ programming using the data structure stack. However, this is the advanced level base on this question I found in a reference book. Here is the question:
Base on the question checking the string parentheses balance, the output is to print “Success” if all the brackets [] {... |
Project Euler 18
Project Euler 67
As problem 67 is harder, I'll go with that one:
By starting at the top of the triangle below and moving to adjacent
numbers on the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
... |
I made a minesweeper game in c# as a method of studying, and right now its fully operational.
I tried to use inheritance, recursion, and other fundamentals as clean as possible. Also I tried to use commenting as much as possible as I see many people do not do this, and it makes the code all the more confusing, both for... |
I'm currently modifying a research project (massive test and benchmark of diverse conjectures to try and eventually solve the SSW conjecture) so that it can run on a big HPC architecture, which does not handle most of the 'classic' multi-process/multi-thread methods (like fork-based in C, python multiprocessing module,... |
Followed-up here.
I've written a partial z80 emulator in C++. It has a decent part of the instructions that can be reused implemented but I've had some issues with duplicated code.
I'd also like to note that this is my first C++ project; before that I've primarily dealt with C and Assembly.
emulate.cpp:
#include <std... |
Given a class where the methods return this you can chain them.
const e = new Example()
e.add(1).add(1).add(1).add(1).add(1)
However this breaks does not work if one of the methods is async and returns a promise.
I created an alternative method on compose the class Meow2 below that adds this kind of functionality.
con... |
I was given this coding challenge when a applying for a summer internship but didn't get selected for the next round and I was curious if it could be improved.
The problem says:
Given a number in base "-2" divide it by 2.
For example:
Given [1, 0, 0, 1, 1, 1] (-23) the output is [1, 0, 1, 0, 1, 1] (-11)
Given [0, 0, 1... |
This is a HashMap implementation written in Python. All the methods are based on the java implementation of a HashMap. Any and all critique is welcome.
This implementation is just a rewrite of some java HashMap methods. Yes, it's basically a wrapper class for pythons dict. This implementation is a simple exercise to se... |
I am learning about GraphQL so I decided to make a schema for some sort of social network. Please let me know if there are any best practices I should follow based on my schema below.
scalar DateTime
type Query {
# user
currentUser: User # use request "Authorization" header to get credentials
ge... |
Please review my code. I would love to know what improvements I can make in terms of efficiency as well as readability. Thank you!
using System;
using System.Linq;
public class Bojo
{
public static long NextBiggerNumber(long n)
{
//check if bigger number is even a possibility
if (N... |
I've made this module in Lua as a mod for Project Zomboid game.
In future I will develop my mods in a small team (of 2-4 programmers).
At this moment I have no experience in teamwork, because most of the time I was programming alone.
My question is:
1) What are my main mistakes (in terms of code architecture)?
2) How t... |
My code below creates a folder based on the passed data from my client-side(VueJs) and checks if there's already an existing folder and deletes it if there is otherwise it will create a new one.
My problem here is that I think my code is too long and unreadable although it accomplishes the task that I want to happen.
... |
I've created 2 helpers for std::regex.
The first helper match fills the given std::vector<std::pair<std::string, std::size_t>> with the first match with all subgroup matches and their positions. match_all builds on match and sets the given std::vector<std::vector<std::pair<std::string, std::size_t>>> to all the matche... |
Hey I'm trying to optimise particles.js library from Vincent Garrau in order to get 60fps @ 500 particles ~.
I've already refactored the code to use a quad tree instead but it does not seem to be enough. In fact, I saw no improvement using the quad tree. Maybe I implemented it incorrectly ?
What I'm doing ?
Generatin... |
I created this program originally for Project Euler 14.
Here's the code:
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)
def memo(f):
f.cache = {}
def _f(*args):
if args not in f.cache:
f.cache[args] = f(*args)
return f.cache[args]
return _f
@memo
def collatz(n):... |
I recently worked with some pickle files which had a really strange format where the keys are sometimes delimiter separated with colons and placed in the same depth but also mixed with ordinary key value pairs.
This is a basic example of this mixed format:
{
"objects": {
"list::1": {
"attr1": "f... |
In an angular application I would like to set the browser title to something that is helpful. (Helpful means that the user gets a meaningful history and can identify tabs easily). Setting the title should be as automatic as possible. That means:
If the route changes and the component that becomes active has title, the... |
I was practicing divide-two-integers question from leetcode
Question: Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.
Return the quotient after dividing dividend by divisor.
The integer division should truncate toward zero.
Question Link: https://le... |
I am creating a dialect of ActionScript 3.0 and now have a working verifier, or “symbol solving” verifier. The language upgrades ActionScript 3.0 with few operators, light syntax facilities, numeric enums and way more compile-time semantics.
To test verifying, run:
$ git clone https://github.com/shockscript/sxc
$ cd sx... |
I inherited this code and have to fix it. It does work and I know I can refactor the code using If Not Intersect(Target, Me.Range()) Is Nothing Then syntax. I am wondering if using a function to pass the cell references in this case would be best, but im not really familiar on working with functions yet and would lik... |
Given a vector of maps:
(def my-list
[{:a 1 :b 2 :c 3}
{:a 1 :b 5 :c 6}
{:a 7 :b 8 :c 12}
{:a 10 :b 11 :c 12}])
and a blacklist:
(def blacklist
[{:a 1 :c 3}
{:a 10 :c 12}])
the expected output is:
[{:a 1 :b 5 :c 6}
{:a 7 :b 8 :c 12}]
I came up with:
(defn not-excluded?
[blacklist item]
(not... |
Yes I know context managers are a much better way to do this, but I spent four hours working on implementing a switch construct using generic decorators, and I'd like to hear feedback on how I did. I'll do it with context managers tomorrow.
I don't think I qualify as a beginner anymore (I'm looking to start getting... |
I have the following code for separating out overlapping rectangles vs.
non-overlapping rectangles in C++ 11:
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
#include <math.h>
#include <array>
int main() {
auto detected = get_detected();
std::vector <Rect> singl... |
I am working on a PHP MVC project for my portfolio. Its an web app where you can store contacts (email and phone number). I am having trouble with filtering contacts based on filter form that has 3 options https://ibb.co/8dJbSWd
I wrote code that works fine but I am sure there is better way of doing this. Here is the c... |
I'm learning racket and did simple code challenge in a literate programming style with org mode
The problem:
Given a matrix of integers and the top left and bottom right coordinates of a rectangular region within the matrix, find the sum of numbers falling inside the rectangle.
1 2 3 4
5 6 7 8
9 0 1 2
should give 24... |
The code is doing everything that I need it to. It's taking much too long though upwards of a couple minutes to complete the macro. Does anyone know how I code optimize this VBA code to run quicker? I'm new to VBA and I'm not quite sure how to proceed. This code will be running on roughly 35,000 lines of data.
Public S... |
I need to be able to cancel a long running query programmatically through our application. The code below will kick off a long running query and give control back to the main thread. At any arbitrary time, a user could choose to cancel the query. It both cancels the Task as well as cancels the query in SQL Server. I... |
I have a class method that is set up to make requests to an API and I'm having issues handling the possible errors that could arise by trying to communicate with that server. The idea is if an error were to pop up, then it would call on itself until either it no longer needs to (because it worked), or it reaches a limi... |
I am learning Go by writing a simple CRUD REST API using gotilla/mux and Gorm.
I would like to get some feedback on the application code and on unit tests in particular. Please suggest me what to improve, what to do better, what not to do and generally tell me what comes to your mind.
func TestGetAllStudents(t *testin... |
I've made a function that outputs the highest and lowest values from a string containing a space-separated list of numbers.
For example, if given "123 956 334 421 -543", my function returns 123, -543.
def high_and_low(numbers):
m = [int(i) for i in numbers.split()]
h = max(m)
n = [int(i) for i in numbers... |
I'm learning C++, data structures and algorithms and decided to implement some sorting algorithms
using generic iterators instead of array indices.
This post contains code for insertion sort and
other three variants: insertion sort with binary search, insertion sort with interpolation search and
shell sort. As implied... |
I'm working on a (naïve) algorithm for portfolio optimization using GA. It takes a list of stocks, calculates its expected returns and the covariance between all of them and then it returns the portfolio weights that would produce the highest return of investment given a certain maximum risk the investor is willing to ... |
Sorry if this has been answered to death—I'm working on a pig latin translator for Odin Project. The code below works fine for individual words, but when it receives two words ("eat pie"), the output is nil. Please let me know if I've left out any details. Thanks in advance for any suggestions.
def translate(word)
con... |
The following is a solution to the knapsack problem and supposed to be my entry to this weeks perl challenge. I wonder if this is a good use of dynamic variables or is it too confusing?
I use them so I don't have to put the variables $n, @things and @result in all the signatures of the multi-subs and carry them throu... |
I am currently in between semesters at school and am using that time to improve on my knowledge of C++ classes by making a node class and a linked list class that inherits from the node class. There is a list of areas in need of improvement at the start of the code, but I was also hoping to get some external input on t... |
The code below will scrape data from three APIs. The APIs are for property listings. So, for each listing, I will have one request. There will be around 20000 requests. That's why I use ayncio to make the request. However, I will be banned by their server if I request frequently. So, I use Tor and user-agent to get rid... |
Here is an earlier attempt to solve the original problem:
Solving Sierpinski Triangle in Haskell
I was never satisfied with my solution and found it was awkward and twisty. Here is another attempt to solve the same problem using Data.Array and I found that by using mutable arrays the solution becomes much shorter and e... |
I am creating back-end for a web-application in Play framework with Java, using Couchbase for storage. This class is saving and fetching User details from Couchbase.
My questions are:
Will my DAO implementation work for high volume traffic (thousands of users saving and fetching User details simultaneously)? If not, h... |
This code is used to check opening hours data from OpenStreetMap can be handled by an editor app. In case where opening hours is not too complex data is also turned into an usable form.
It is a part of a StreetComplete editor app. This specific file will be part of pull request that will add ability to resurvey opening... |
I have implemented a Merge sort in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism.
def merge_sort(nums):
if len(nums) == 1:
return
middle_index = len(nums) // 2
left_half = nums[:middle_index]
right_half = nums... |
I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues:
import numpy as np
#len(protein_sequence)~500, len(rna_sequence)~1500
def affinity_matrix(protein_sequence, rna_sequence):
python_matrix = [[] for _ in range(len(p... |
I have a class that creates an object, PlannedYear, and then passes that object into several other classes to manipulate it. The ultimate goal of the class is to manipulate and add items to this PlannedYear object.
I have, however, ended up going down a rabbit hole whereby I am updating the same PlannedYear object in m... |
Method 1:
public void removeFirst() {
if (first == null) throw new NoSuchElementException();
if (first == last) first = last = null;
else {
var second = first.next;
first.next = null;
first = second;
}
}
Method 2:
public void removeFirst() {
if (first == null) throw new NoSu... |
The following program is comprised of three files and is aimed to be used as a Debian-Apache-MySQL-PHP-HTTPS version-agnostic environment bootstrapper.
It is aimed to be used on raw Debian systems (anything that doesn't come with the OS wasn't installed) and to establish web domain associated web applications.
The prog... |
This code works, but I don't know if there are better and especially safer ways to do this.
For context: this is a Django view (Python) and I wanted to unify the deletion methods because there were many of them.
def delete(request, class_name, object_ID):
obj = get_object_or_404(eval(class_name), id=object_ID)
... |
I have the following arrays which save the MAC-adresses of a lot of bluetooth beacons and their positions in a building:
private static final String[][] MAC_ADDRESSES_A_BLUETOOTH = {{"B09122F5D126", "210.105"}, {"B09122F5F26B", "136.121"}, {"B09122F5F619", "181.172"}};
...
private static final String[][] MAC_ADDRESSES_... |
Does anybody know how to find pair of adjacent prime numbers in two-dimensional array, quicker than this? I'm talking especially about this part which looks for adjacent numbers not about function finding prime numbers or anything else in the code.
//looking for first prime number of pair
for(w=0; w<5; w++)
... |
When learning a new language, one of my first tasks I like to go through is writing a few different sorting algorithms in that language to help familiarize myself with the syntax and see if there are creative ways that algorithm can be conceived in the language.
In Go, I wanted to use this as an opportunity to work wi... |
I would like someone to review my code on find indices of 2 numbers in array that sums up to an number. Following is the code that I have tried and it works.
The real issue in the code is I am doing Map.lookup twice. Is there a way to avoid it.
Input [1,2,3,4,5] 5
Output [2,1]
Input [1,2,3,4,5] 4
Output [2,0]
Code
... |
I want to make sure that I am writing the code correctly and fully understand what is needed. My biggest concern is what tags to use, (? * | etc.)
The element stories
5.1. The element stories contains 0 or more story elements.
The element story
6.1. The element story has an enumerated attribute updated that ca... |
I'm looking for optimized code with faster execution time. This writes CSV to parquet with the max size of 64 MB chunks.
we are trying to concatenate the csv file contents being written as an parquet file until the parquet file size reaches 64MB
The loop would continue to run until reads all the csv files content bein... |
This is my attempt to build a simple simulation of a direct mapped cache, I'm new to C and trying to learn some low level concepts. I had some difficulties with the design, because I'm used to program in a object-oriented style.
#include <stdio.h>
int create_mask(int num_of_bits, int pos) {
return (1 << num_of_... |
Apologies for the cryptic title, I don't quite know how to title this question. I'm asking here rather than StackOverflow since I've got a working query, I'm just wondering if it can be improved.
Anyway, I've got three tables, administration, mapping and used_mappings. Administration holds details of individual financi... |
A dataset consisting of N items. Each item is a pair of a word and a boolean denoting whether the given word is a spam word or not.
There shouldn't be a word included in the training set that's marked both as spam and not-spam. For example item {"fck", 1}, and item {"fck, 0"} can't be present in the training set, becau... |
I wrote code to upload multiple(2) files.
1.Check if this is image: mime/extension/getimagesize.
2.Remove execute file permissions from the file(chmod).
Is this script secure? What can go wrong?
Class photograph
class Photograph extends DatabaseObject {
protected static $table_name = "photographs";
protected s... |
I am new to python and coding in general and I recently found HackerRank. I have been mostly doing easy problems until now.
Today, I saw the problem "Queen's Attack II" (https://www.hackerrank.com/challenges/queens-attack-2/problem), wrote my code, and it didn't execute in time for some of the testcases. I optimized it... |
Quincunx is that little game where you drop a ball or disk down rows of nails in a pyramid formation until they land in a slot. This was a project for my class, but it's already been submitted. I am just looking for personal feedback since the professor does not give much in-depth feedback on these assignments. The goa... |
I have been trying to get a better handle on the operator<=>, so I wrote two different string wrappers. The Strong_String wrapper uses std::strong_ordering to allow the std::sort function to sort words like a dictionary sorts words (i.e. a capitalized word occurs before the lowercase word, but not before all lowercase ... |
I wrote this program which generates anagrams for a given word.
The init function will create a dictionary of words. it can be read from a text file or array. Here I'm reading words from an array to create my dictionary.
I would like some advice on how to optimize this code or any changes or suggestions needed to impro... |
This is a simple strlen function with registers documented:
;in rdi - string to measure
;out rax - len
.my_strlen:
test rdi, rdi
jz ptr_error
or rcx, 0xFFFFFFFFFFFFFFFF
mov al, 0
cld
repne scasb
mov rax, 0xFFFFFFFFFFFFFFFF
sub rax, rcx
ret
NOTE: This code assumes a "C-Style string"; that is, a NUL-terminated string.
|
I am new to writing utility functions. I wrote a python program to return a Python logger with custom settings. Please review this code and provide comments on how to improve it. I am looking for comments on
Coding Style
Coherence & Coupling
Readability
I am intending to share this code across all projects. So any c... |
I have finished a raycaster, and I want to optimize it before I add other features, such as variable height walls, texture mapping and lighting. I'd like someone to review the code so I can improve it further.
Pastebin
#include <stdio.h>
#include <SDL2/SDL.h>
#include <sys/time.h>
const int RESX = 960;
const int RESY ... |
I am fairly new into asp.net MVC c# I am working on request holiday app where an employee can request holidays. The problem is the app works fine, however, I am trying to set 8 hours a day when an employee requests a holiday I have scratching my head from 2 days already seen every topic in StackOverflow and here and s... |
I'm trying to process numerical input arguments for a function. Users can mix ints, floats, and "array-like" things of ints and float, as long as they are all length=1 or the same length>1.
Now I convert them as follows:
convert to float convert to np.ndarray; dtype==float
---------------... |
Review on this draft please: clang-8 -std=c++17
Simple wrapper class template for std::map & std::list (or alternatively std:unordered_map & std::vector) for the purpose of "retaining insertion order". This is quite a frequently asked question, eg
https://stackoverflow.com/questions/2266179/c-stl-map-i-dont-want-it-to... |
A quine is a program whose only job it is to reproduce the source file that was used to create the executable in the first place.
This stackoverflow post provides some reasoning about its usefulness.
Below I present 5 different quines.
The nice quine
This program has an embedded copy of its complete source (minus that... |
I wrote this code since I'm going through the hackerrank challenges, however, it takes way too long to run.
Its function is described on the title, but just to clear it up, we need to count the minimum amount of swaps needed to order a set of ascending integers.
def minimumSwaps(arr):
count = 0
correct = [(x+1)... |
I started learning VBA for an internship, 3 months ago. This is the last project I have worked on.
It does all the tasks it has to do, it's all about code review. I will be grateful for all suggestions for optimization of solutions/other solutions, good practices (writing, commenting on the code) and everything else th... |
I'm growing a web server in Haskell that interfaces with TCP sockets using network. To read the HTTP header of the client's message, I use the following function:
import Network.Socket hiding ( recv )
import Network.Socket.ByteString ( recv )
import qualified Data.ByteString ... |
I want to significantly tidy this code as its cluttered and repetitive
var myDate = "No MOT"
if ((myData[0]["motTests"][0]["expiryDate"].string) != nil) {
let theDate=myData[0]["motTests"][0]["expiryDate"].string
let msYear = theDate!.prefix(4)
let msMonth = theDate!.suffix(5).prefix(2)
let msDay = th... |
I made a function that outputs the sum of the value of each letter in a word. For example if I input hello my function would output 52.
def words_to_marks(s):
import string
values = {} # dictionary to store value of each alphabet
values_of_words = [] # to store final value of words
for in... |
Is there a better way to write this code.
Suppose I have 10 files to delete and I have to repeat code (public function destroy() ) 10 times.
First remove the database entry.
List item, then remove the file.
OOP - "don't repeat yourself", it works but I repeat the code.
public function image_path() {
return ... |
I am in the process of trying to teach myself Python, and am at a point where I feel some general feedback on my styling/code efficiency would be super useful in order for me to progress.
I have created a simple banking system in order to practice OOP (which I am still finding a little confusing).
Would anyone be able ... |
UPDATE: Current best state of a solution incorporating feedback and further development is in this answer.
Review on this Design#2 please:
Simple wrapper class template for std::map for the purpose of "retaining insertion order". This is quite a frequently asked question, here and here.
This is the follow on 2nd Desi... |
I've started learning Rust recently using the Rust book.
In one of the chapters, the authors encourage the reader to experiment with closures, and try to create a generic cache implementation.
I've managed to get it working as below. However, it irks me that I need to add Clone trait on the input argument in the get() ... |
I have written a matrix class using python, allowing me to perform a variety of operations on matrices. I'm pretty happy with how it performs, and everything works fine. However, I feel like the way I've handled the initialiser could be much improved.
I wasn't sure how to handle different possible cases for the argumen... |
This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner?
format ELF64 executable 3
segment readable executable
entry $
prompt_user:
mov edx,prompt_len
lea rsi,[prompt] ;<------ String
mov edi,1 ; STDOUT
mov eax,1 ; s... |
I have two buttons
1) Chat button
2) Annotation Button
On tap each view comes from bottom and when tap outside view hidden back (Please refer the screen shot)
On tap On annotation
On tap on Chat
To Handle This I have created following classes
//Annotaion Card
struct CardInfo {
enum CardState {
ca... |
I'm trying to make a dice game with three dice and with rules.
It costs 10 credits to roll the dice.
If you get 6 6 6 you win 90 credits.
If you get 5 5 5, 4 4 4, 3 3 3, 2 2 2, 1 1 1, you win 40 credits.
If two of the dice have the same number you win 0 credits (because it costs 10 to roll).
Here's what I've done so ... |
I have a HashMap and I want to convert data in it to a Response object. Is it possible to achieve this code that parses the string in a better and optimized and cleaner way, maybe by using streams?
class Converter{
public static void main(String[] args) {
Map<String, Long> map = new HashMap<String, Long>();
... |
GitHub and NuGet
I would like to use DynamicObject derived types to execute REST API/NodeJS module calls. It would also help to capture API shape in a strictly typed manner, so here comes an interface proxy which hides low level machinery allowing to do tricks like this:
[TestMethod]
public void Call()
{
dynamic c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.