instruction stringlengths 71 71.9k |
|---|
I am having performance problems with the following python function:
def remove_comments(buffer):
new_buffer = ''
lines = buffer.split('\n')
for line in lines:
line_wo_comments = line.split('--')[0] + '\n'
new_buffer = new_buffer + line_wo_comments
return new_buffer
When buffer is very ... |
This is a pretty straightforward library function I've got here. I've had to build it in to about 3 different forms but I never heard of this kind of function anywhere else.
I'm trying to make it as readable and clear as possible, but I also am not too familiar with the best way to capture values in JavaScript. As far ... |
This is an implementation of a practice problem from cprogramming.com: Temperature Converter Challenge
The problem:
In this challenge, write a program that takes in three arguments, a start temperature (in Celsius), an end temperature (in Celsius) and a step size. Print out a table that goes from the start temperatur... |
This is a game that is supposed to be based on strategy and guessing.
The letters need to match in a ABCD fashion on each button on buttons[0] - buttons[3] ... and buttons[n] - buttons[n] in each square, kind of like a matrix, although there is no matrix math involved.
This is how the game starts:
Each time a user cli... |
I have implemented a recursive binary search in Python and tried to implement some verification to my code. Other than that, is there any optimization I am missing?
def isSorted(ary):
for i in range(1, len(ary)):
if (ary[i] < ary[i - 1]):
return False
return True
def binSearch(ary, elem, f... |
I was trying to write a dynamic programming algorithm using a bottom up approach that solves the subset sum problem's version where the solution can be either an empty set and the initial set can only contain positive integers.
The following is my implementation, but I am not sure it is correct for all cases.
def _get_... |
I have 3 tables:
Table couples consist of save_id, id_candidate_red, id_candidate_blue
Table candidates_red consist of save_id, id_candidate, enter_match
Table candidates_blue consist of save_id, id_candidate, enter_match
And I am running the query
SELECT *
FROM couples as c
LEFT JOIN ... |
I currently have a JavaScript file that I'm using to fix the navigation on a website I've built. The code is by no means 'DRY', though, and I'd like to fix that issue.
//fixing the nav dropdowns for mobile
//concrete and joint repair dropdown section
$(document).ready(function() {
// Optimalisation: Store the re... |
The helper should be able to set a default value if the value can't be fetched with the provided key. There is also a bool that will throw an error if the key value or the default value could not be fetched or converted.
Can I make it more compact, safer, and still have the same functionality?
It feels like I am using... |
First play with the game a little bit, and it is quite fun (a little hard but very satisfying when you win, be sure to put it full page):
<!DOCTYPE html5>
<head>
<title>Lights on</title>
<script>
document.addEventListener('DOMContentLoaded', randomize_and_color, false);
function random_zero_or_one() {
... |
Part 1
I've followed some of the suggestions:
Adding newlines to error messages
Implementing options (I decided to use boost instead of getopt)
Using strerror for fstream failure
Allow multiple files to be compiled (to produce one binary - I wasn't sure if the suggestion meant one binary for each file)
Things I did n... |
Part of me thinks that it would be simpler to ditch Apple's move API and just updated position with a timer. I know that's what I did with a JS canvas snake game I built a while ago. But I'm also trying to learn the iOS API so unless that's clearly the best choice I'd prefer the most idiomatic way.
Also, I'm pretty sur... |
I have updated the code and the program now works as it should. If you could critique my code that would be great. I am new to C so I guess I will have made some rookie error :)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
// Function to check if alphabet characte... |
I have a REST web service that uses OAuth 2 for authenticating and authorizing requests.
I have an endpoint, that when receiving the correct credentials, responds with an access token that will be used in consequent requests.
This avoids persisting a session and using cookies, which is what we wanted to accomplish when... |
I happened to come across one question:
Given an integer 'x' (Only positive), write an algorithm that returns
integer 'y' such that it has the same number of bits set as 'x' and is
not equal to 'x' and the distance |x-y| is minimized.
Example:
x: 01
y: 10
Now I wrote some bit manipulation as follows and it's wor... |
I have the following Greasemonkey script that fetches some data from a Yahoo webpage and injects it into a webpage. It has the feature that it only fetches the data once per day instead of fetching it every single time the page is loaded.
I think my displayresults function is a little messy just because it has to acces... |
I haven't done much programming in C++, so I figured I'd try making an Optional class. I'm mainly concerned that I didn't follow good conventions or that I didn't use exceptions well. I know that there are no comments, but for now, let's ignore that.
The idea is that my Optional class can be used instead of pointers an... |
I wrote my solution to Project Euler #18 and #67 in C++ (which I'm relatively new to), and was just wondering what everyone else thinks of it. It executes in 3-4ms and works flawlessly (even for triangles not given by the website). But I'm not a professional programmer or anything, so I wouldn't know if it's necessaril... |
This is a text-based RPG game I've made in C++ and would love some review on it. I am a 100% complete newbie with maybe 2 weeks of C++ experience so I'd love some lessons on what I did wrong and how I can improve! I mainly just use a lot of switch statements and if statements.
If there is anything wrong or things that ... |
I was looking for a unit testing library for C++, and I found many. Unfortunately, I decided I didn't want to use any of them. I decided to make my own.
This is the result. I made heavy use of the preprocessor, and followed the convention of leading underscore to mean non-published. Everything is done in all-caps, to t... |
When using the pimple idiom it is necessary to represent your "impl" as a forward declared pointer in the header file. This necessitates a lot of boilerplate code to implement the rule of five.
Instead, I want to wrap std::unique_ptr with a template class DeepPtr which automatically deep copies on copy construction, a... |
This script's only responsibility is to keep a process alive. Forever.
It's sole dependencies shall be bash and coreutils. I'm not sure if it would be compatible with sh, that would be even better.
#!/bin/bash
#
# (c) Netcetera AG
# Author: Christian Mäder
date="10.07.2015"
version="1.0"
#
respawn() {
while true;... |
This code solves a challenge problem that a local company is hosting to attract/screen applicants. The link to the challenge is here.
In brief, we are given a wordlist containing approximately 100,000 words and we are asked to find the combination of words which has MD5 hash 4624d200580677270a54ccff86b9610e. The constr... |
squish is an onomatopoeic string function provided by Ruby on Rails that works on strings.
Given a string, squish condenses all the consecutive spaces into one.1 (Imagine that you take a string at both ends and compress it with both hands, spaces will be merged and you will hear the typical squish sound).
I went I litt... |
I made a program that contains a root-finding algorithm for polynomials as a function and contains 3 test polynomials. The algorithm is Brent's method and is based entirely off the pseudocode from Wikipedia. Is there anything I should change to make the code faster/easier to understand/etc?
The code does run and prints... |
The situation is that a certain asynchronous operation is called multiple times, which is basically to consolidate results. But I want to abort every time a new request comes in, which means that only the last call will run completely. Does this solution look reasonable?
I have tried replicating the process in a test p... |
From: Principles of Computing Part 1 Course on Coursera
I got -2 pts on my OWLTEST which uses Pylint for style guide. The error states:
Too many branches (17/12)
function "merge", line 7
What does that mean?
I worked really hard on making this program work and wrote it from scratch. I would also like to know i... |
I'm currently working on an implementation of a CSRF protection. What is the best practice when we detect a CSRF? Is it better to 404 the page, 403 (forbidden), 200 (OK) with an error message, something else?
Bonus : here's my code.
I'm not very proud of the preg_replace and ob_*. If you also have suggestions on how to... |
#!/usr/bin/python
file=open("C:/python27/python operators.txt","r+")
wordcount={}
for word in file.read().split():
if word not in wordcount:
wordcount[word] = 1
else:
wordcount[word] += 1
for k,v in wordcount.items():
print k, v
|
Now I have this circular array-based list in C. Circularity allows pushing/popping to the both ends of the list in constant amortized time. Inserting/removing at random locations runs in linear time, yet I optimized it a little bit: Suppose we are inserting an element at arbitrary location. We can shift the left elemen... |
This is a update of this question since the requirements for this task changed.
I have a function that takes a description as a String and returns a shortened version of the description.
The shortening is done by checking if a word matches the key of the Map<String,String> MAPPER and replaces the word by its abbreviati... |
Summary
I am experimenting with a plugin pattern for a generic Python application (not necessarily web, desktop, or console) which would allow packages dropped into a plugin folder to be used according to the contract they would need to follow. In my case, this contract is simply to have a function called do_plugin_stu... |
Recently I had an interview project, which I did and sent, so this question is not for avoiding thinking. I am just struggling to build my own opinion about it so I decided to ask in public.
My question in general is that: is the code design is too complex?
I know the opinions may vary, but in general: do you PHP prefe... |
In simulating physical equations (such as fluid dynamics) it is common to write an application that deals with 1, 2, and 3 dimensions. A common C/Fortran approach is to make all vectors (for example) have a size of 3, and then to carry around a global constant to say how many elements are valid.
We have tried to use C... |
I wrote my own version of a search binary tree in Java. Could someone kindly review it?
public class Tree {
private Node root;
public Node find(int id) {
Node current = root;
while(current != null) {
if (current.getId() == id)
// Node found
retur... |
This is an updated version of: Class to manage updates coming in from another thread
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also too many little tasks getting sta... |
I'm wondering if there is a better (cleaner?) method than my current implementation. I'm currently encoding a PHP SimpleXMLObject (USPS Tracking API) to JSON and looping through said JSON object via JavaScript to operate the front-end.
Examples from my current implementation below:
Function to display dialog implemente... |
I wrote a simple GUI applications to help me select 'positive' regions of a bunch of photos for the purpose of training an object detectir using OpenCV Haar Cascades.
For training purposes, you need a series of 'positive' images which show the kind of item you want, closely cropped, and then you need a bunch of negati... |
Introduction
I am preparing to use a basic script to cover how you can connect to a MySQL database using PDO. This script is meant for educational purposes (introductory class on PHP/MySQL) and does of course not cover all security aspects of database connections.
Points of focus
Conformity to the PSR-1 and PSR-2 stan... |
The given code find the minimum element in a sorted array rotated by some fixed distance.
Eg: [1, 2, 3, 4, 5, 6, 7] -> [3, 4, 5, 6, 7, 1, 2]
The elements in the array are all unique. Just wanted to check if the code handles all edge cases and is correct.
def findMin(ary):
def recurse(lo, hi):
# Base cases ... |
How can I improve this code?
public virtual HttpResponseMessage Get(int pageNo, int pageSize)
{
pageNo = pageNo > 0 ? pageNo - 1 : 0;
pageSize = pageSize > 0 ? pageSize : 0;
int total = repository.Table.Count();
int pageCount = total > 0 ? (int)Math.Ceiling(total / (double)pageSize) : 0;
var entit... |
I would like to have a review of this basic CRUD application so I can improve and learn from your experience. The code can be found here.
Design pattern/coding principles improvement that could be used
Exception handling
Readability
Coding best practices
ProductManager.java
public class ProductManager {
privat... |
This is my first template implementation. I'm trying to learn C++ and Algorithms. Any constructive criticism on code quality, readability is welcome. Everyone has their own style, but there are certain rules which all good programmers should follow. Kindly remark as to if I have followed those and what rules are missin... |
I've got a complex object tree that I need to instantiate. The object tree is a bunch of specialized classes that don't have a common root object (other than Object) and has generic objects (that I need to configure), and custom objects (all the "My" classes in the example code).
I've created the factory below to encap... |
Here is some of the code in my library. If there any inefficient things in my code, let me know.
UPDATE: The following code is deprecated. All of your fixes have been incorporated. The project now lives at InitializeSahib/Inverse
InverseAPI.cpp:
// InverseAPI (Cobalt)
// Developed by Sahibdeep Nann (@SahibdeepNann)
// ... |
I'm looking for a code review on a class that I've written. It was my first attempt at lockless programming and I'd love any feedback I can get.
#pragma once
#include <atomic>
#include <thread>
#include <memory>
namespace Pro {
namespace Util {
/*! Thread Safe Lock Free Pipe
*/
template... |
This question contains some C# code I've written as well as a XML format I have designed. My C# code runs a series of "jobs" by loading the XML file and then calling different SQL stored procedures and E-Mailing the results to different addresses. My question specifically relates to the C# code to parse the XML documen... |
This code hides a message in an image by altering the blue values in the top left part. This is just for fun as I think it would be easy for a cryptographer to find and decrypt this.
Original
With message We will meet at London bridge at dawn
As you can (cannot) see, as long as the message is short enough, the naked ... |
I am a new guy to Java. I want to find the longest sequential same character array in a input character arrays.
For example, this character array:
bddfDDDffkl
The longest is DDD. Next example:
rttttDDddjkl
The longest is tttt.
I use the following code to deal with this problem but I want to improve my code. Could you... |
I'm getting myself acquainted with Rust and decided to implement the classical overlapping intervals problem.
Here is a statement of the problem:
Given a collection of intervals, write a function that merges all
overlapping intervals and prints them out.
For example, given [1, 3], [2, 6], [8, 10], and [7, 11], the ... |
I'm learning python and I have written a bank program incorporating all the skills I've gathered so far. Using the program, one can create user profiles (name, password, account balance) which will be stored in three different text files. One can then do the normal bank transactions: deposit, withdraw, check balance or... |
I have written VERY simple code that converts a string to a character array and then displays the ASCII value of each character. Let me know if this is the most effective/safe way of doing what I described above.
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
//Declare Variables.
... |
Inspired by MATLAB's tic/toc I've written a short helper function for calculating execution time.
from time import time
def tic():
"""Simple helper function for timing executions.
Returns a closure that holds current time when calling tic().
Usage:
toc = tic()
//some code
print(toc())
"""... |
My project manager is saying that there are many bad things in my code, but they are not helping me to correct it. Can you please specify the bad things they mean?
I have 7 projects in my solution that work together to save a role to the database. Here are the details:
Project - 1 - Object Model(Class Library Project) ... |
Now I have this C implementation of the famous algorithm:
dijkstra.h:
#ifndef DIJKSTRA_H
#define DIJKSTRA_H
#include "directed_graph_node.h"
#include "weight_function.h"
#include "list.h"
#ifdef __cplusplus
extern "C" {
#endif
list_t* dijkstra(directed_graph_node_t* p_source,
directed_graph_node_t*... |
As part of an online course exercise, I was supposed to implement Merge Sort in C. Pointers were still not discussed prior to this exercise, so I have to work with arrays. Memory efficiency is not something I'm supposed to be focused on.
#include <cs50.h>
#include <stdio.h>
#define DEBUG
void getArray(int[], int);
vo... |
I have a graph represented as an adjacency list. I need to find a triangle in this graph. A triangle is a triple of vertices u, v and w, such that (u, v), (v, w) and (u, w) are edges of the graph. The graph does not necessarily needs to be undirected.
I found the following pseudocode for solving the problem:
function c... |
Recently came upon this question asked in interview with major tech company.
Implement Java's next and hasNext function in your favorite
programming language.
Here is the solution I came up with. I am not sure whether next() is implemented correctly. Here is the iterator documentation.
#include <iostream>
#include ... |
I wrote this for a CodeWars challenge while trying to learn ECMAScript and would really like to have some advice on how it could be improved.
What I don't like about this code myself, but am unsure on how to improve:
I didn't yet found a way to have a class in ECMAScript that mixes public and private methods in a way,... |
Exercise 1: skips :: [a] -> [[a]]
The nth list in the output should contain every nth element from the
input list. For example, skips "hello!" == ["hello!", "el!", "l!",
"l", "o", "!"].
The question UPenn Homework 3: skips function and it's associated answers inspired me to write a solution in Javascript. I used ... |
It has been bugging me for a while that while I understand how the basics of Brainfuck works, I can't get a firm grasp on the advanced features of the language. So I started to re-evaluate what I know about the language from the ground up.
Brainfuck's memory consists of a tape of cells. Every cell can be modified by po... |
Given a text, this program will output a Brainfuck program, that when executed will print the text back.
Writing Brainfuck in this style to print a sentence is pretty straightforward. Iterate over the sentence and do the following per character:
Calculate the difference between the current character and the previous
... |
I use the module os specifically for Windows since I am familiar with Batch. Batch alone didn't allow me to execute more complicated mathematical functions, I began to use Python.
import os
import math
os.system('cls')
os.system('')
os.system('color a')
os.system('title Quadratic Equation Solver')
#This is used for pr... |
I'm writing a little script that encrypts a file using the user's SSH identity.
I read the RSA private key from ~/.ssh/id_rsa (default)
Use the private key to encrypt a random 32 byte symmetric key (PKCS#1 OAEP)
Encrypt a stream of data with AES-256 in counter mode (no extra padding)
Write all of this to the output st... |
When writing this code I found myself getting more and more complex. When I got to the solution I trimmed the excess parts I'd thought I needed from before, but didn't actually need. The example of wc.c had some definitions for IN and OUT. Why didn't I need those for writing this example?
If there are any bugs or impro... |
Now I have this implementation of A*. Basically it is the same as the Dijkstra's algorithm in my previous post, yet I bothered to make it more cohesive by making functions for handling all the state data structures.
astar.c:
#include "astar.h"
#include "directed_graph_node.h"
#include "weight_function.h"
#include "unor... |
I have written the following code, and so far in all my tests it seems as if I have written a working Mutex for my 4 Threads, but I would like to get someone else's opinion on the validity of my solution.
typedef struct Mutex{
int turn;
int * waiting;
int num_processes;
} Mutex;
void enterLock(Mutex * loc... |
I am developing a form on bootstrap, and I'd like to know if what am doing is best practice and a clean code or not.
Here's a form I'm working on, please help me make it "clean code".
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/cs... |
I made a tower-defense game in Python with Pygame called "Bunny and Badgers". You're a bunny and must kill the badgers before they come into the castles. You can use W, A, S, D and the arrow keys to move around and press a mouse button to shoot. You can also use a joystick to control it. The game dures 1 minute and 30 ... |
Textbook style program that generates the values of two, six-sided dice; which are used to perform simple calculations. Recently, I saw an example using similar criteria that was able to utilize 360,000,000 rolls. However, I have not been able to initialize an array or vector containing more than 100 million elements.
... |
I am not sure how to properly make this readable. I have been trying to find examples online but I cannot find any that are specific to this simple program.
import java.util.Scanner;
public class KifahUnit3 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
String ... |
Introduction
I wrote three functions that aims to log errors and exceptions as well as show a user a generic error page. Would appreciate some feedback on it with regards to the PSR standards and if I have left out anything of value.
Memory issue:
I am aware that the memory issue has not been addressed in this code, i... |
Many Brainfuck implementations I've come across generally are obtuse, verbose or over-the-top. But I've always seen Brainfuck as "easy to implement", especially for beginners.
My original need for this was to be able to have an actual Brainfuck "machine" that executed instructions to aid with code generation. However, ... |
I'm having troubles with a coding problem. Yes, I need to write a C++ program which sorts dates. I've tried several methods. Using 2D arrays and now parallel arrays.
The problem I have with my parallel array to keeping tract of those which haven't been sorted yet. That is the YYYY has been sorted. I need to keep track ... |
Following up on CommandBars, Buttons and Commands: Take 2, I've refactored quite a lot of the Rubberduck code base (like, a whole third of the entire code base has been affected), and successfully untangled the RubberduckMenu and gave each command its own place to be.
So, "Shared" commands that can be executed from the... |
Interactive Wandbox example
Inspired by this Stack Oveflow question, I've implemented a function that, when called with a desired arity, a callable object, and a variadic amount of arguments, calls the passed callable object forwarding the passed arguments in groups of the desired arity.
Example:
auto printAll([](auto.... |
I converted a C# analyzer for removing empty argument lists from attributes to be a C# and VB.NET analyzer:
public override void Initialize(AnalysisContext context)
{
context.RegisterSyntaxNodeAction(AnalyzeCSharpSymbol, CSharpSyntaxKind.Attribute);
context.RegisterSyntaxNodeAction(AnalyzeVisualBasicSymbol, Vis... |
I'm trying to dynamically create a table of input fields (two per field) that I will then send off to a Python script.
Here's the expected behaviour:
User chooses "manual entry," specifies rows, columns, of table, clicks button.
Table is printed with two input fields per cell (e.g.: A(i,j), B(i,j)), user fills in all ... |
I have an Android app with three different Activity classes. Each of the Activities uses and changes config and user-customization data stored in a wrapped SharedPreferences. The code could stand some refactoring, so I'm thinking that rather than have each Activity instantiate the SharedPreferences by calling Preferenc... |
I wrote this .cmake script when I needed to make smallest possible executables. It makes CMake prefer static libraries, and adds custom command to strip and UPX the end result. I used it only with MinGW on Windows with MSYS2.
My questions:
Can this be made more short and readable?
Are my checks portable enough?
Any wa... |
It works, but I'm sure there's a lot of improvement I could make here. I didn't try to get it to work for words over 10 characters in length, and I also didn't want to use built in properties like .length to do the work for me (I don't know why, I just wanted to figure out how to do it on my own).
#include <stdio.h>
/... |
I was trying to write an iterative search function for my Ternary Search Tree class based on a pseudo-code, and now it seems to work, but I think it can definitely be improved.
def search(self, key: str):
return TST._search(self.root, key)
@staticmethod
def _search(node: TSTNode, key: str):
"""Note that node.k... |
Just decided to make a quickie Fibonacci Sequence via jQuery and I was wondering if anybody can think of a faster way to interpret it? I can type pretty much any number in and it returns in a fraction of a second.
Can anybody think of a quicker method to calculate a specific Fibonacci number?
http://jsfiddle.net/st9sgr... |
This code is in a really early state in the lifecycle. I'm still in the process of implementing some core features, but nevertheless the code up to here works and accomplishes its task.
I have no idea as to how well, though.
This code is intended to give a dead-simple way of creating growable and shrinkable form conten... |
I'm building a library for myself to use to store user passwords. The library itself shouldn't do the retrieval of data, but it should provide container classes for the data.
I would like to know what I've done wrong in it, what could be improved and what's concidered a bad practise with passwords on the way I've done ... |
This is a warm-up programming exercise for learning string methods in Python from HackerRank:
You are given a string S.
Your task is to find if string S contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters.
Input Format
Single line containing, string S.
Constraints
... |
I have a class with 3 properties, and I would like to know how I can write my code better. I want to use Single.TryParse so that if any token is unknown string, I could still get 0. But using this method, I need to use a temp variable, and as my properties list increases, I will have more temp variable, and this is not... |
Im looking to improve my search algorithm in my battleship game. Code is not perfect but would appreciate any suggestions or recommendations.
Running the simulation using a 100x100 grid (10,000 possible locations) Im averaging ~30% accuracy.
Games played 500 Average = 0.31108
Im using a forward and backwards diagon... |
I have created a brute-force algorithm class in C# and I was wondering if I could speed up the process of creating a new string. There are two methods inside the class: one returns the brute-force string and one returns the number of strings created.
public class BruteForce
{
int IntPasswordsGenerated = 0;
publ... |
How should I rewrite an if-return-else condition in the middle of this function?
def import_excel_to_database(xls_file_path)
q_param = { report_type:report_type, item:product, exchange:exchange, product_exchange:row[0], date: row[2]} # timestamp_utc: row[2].strftime('%Q').to_i
# if exsisted then return or continue... |
Is it possible to remove the inner loop by assigning data.Data.Tables[0].Rows[i].ItemArray directly?
object[,] arr = new object[52784, 21];
for (int i = 0; i < data.Data.Tables[0].Rows.Count; i++)
{
for (int j = 0; j < data.Data.Tables[0].Columns.Count; j++)
{
arr[i, j] = data.Data.Tables[0].Rows[i][j]... |
This is actually an old 'problem' that I never really knew how to improve, but I'm wondering now if there is a better approach for this problem.
I'm creating MineSweeper with Java and struggling with an OOP aspect of the game. Basically I have a class Square.java, SquareBoms(extends Square) and Field.java. My approach ... |
I don't truly understand how OOP works and It's stopping me from creating good programs! Below I have a program that will check to see if there are 3 tiles from a gridview in a row.
Here's a screenshot of the game.
Basically you're not supposed to get 3 of the same colours in a row! But at the moment I've been adding... |
I have a simple ASP.NET Web API project. Now I want to make all basic methods as asynchronous. I tried to do something, and it's working but I'm not sure that it was implemented properly.
Please check whether I properly implemented async/await in my project.
I had implemented methods like below in my repository:
... |
Suppose I have a class of complex numbers called Complex and I wish to implement a class of generic matrices with transpose operation.
doubles and ints don't require special care, but you have to calculate the conjugate of complex numbers to transpose. Therefore, I implemented a "specialized transpose()".
template <cla... |
Input
A list of words separated by any number of spaces.
Output
A horizontal ASCII art histogram, where the n-th line is composed by as many asterisks (*) as the n-th word is long.
Example usage
The > signals user input, you should not input it when testing the program.
> This is an example histogram of word length
***... |
I have a uniform grid in this application. After resizing the window (when width < 300) it removes the right column from the grid, and deletes items. After reverting to the previous size (width > 300), it adds back the deleted column and its elements.
But in my code I have two global variables public ObservableCollecti... |
Here is a piece of code that draws superellipses:
#include "std_lib_facilities.h"
#include <iostream>
#include "Simple_window.h"
#define PI 3.14159265359
template <typename T>
int sgn(T val);
vector<Point> generateSuperEllipse(double CoeffA, double CoeffB, double expN, double expM, int centX, int centY, double prec... |
This is a follow up post for this question.
There aren't a lot of changes. The changes (all of them major) are:
I've decided to ditch my previous approach using Math.ulp() and adopt Tim Leek's suggestion: comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within th... |
[DataContract(Name = "jobDateTimeFilterRequest", Namespace = Constants.ManagementNamespace)]
public class JobDateTimeFilterRequest : TimeFrame
{
[DataMember(Name = "jobType")]
public BackgroundJobType JobType { get; set; }
}
[DataContract(Name = "timeFrame", Namespace = Constants.ManagementNamespace)]
public c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.