instruction stringlengths 71 95.1k |
|---|
Need some advices to create class that handles sql query operations with given array (having full control of the array and obtaining record information). My code works properly (it is just example), but need some check it is safe, or there's a better way to reach result. I want to note that all dangerous characters bef... |
Below source code is my solution of the K&R exercise 1-24.
Exercise 1-24. Write a program to check a C program for rudimentary syntax errors like unbalanced parentheses, brackets and braces. Don't forget about quotes, both single and double, escape sequences, and comments. (This program is hard if you do it in full ge... |
Task description:
Write a function commonPrefix, which takes two strings as parameter and returns the common prefix.
Example: parameters abcdef and abc1gv would return abc.
My implementation:
fun commonPrefix(str1: String, str2: String): String {
var sRet = ""
var i = 0
val length = if (str1.length >= str2.... |
I am trying to overwrite an object in an array if the title property exists, otherwise just push it to the array. I found two approaches and I wonder which one is the preferred one.
Performance is not really and issue but I wonder whether mutability could be, or just there is a better way to do this altogether.
On this... |
I've been playing around with Go and finally found a use case for a little web service I could build.
It takes JSON data via an HTTP POST request and sends me an email via Mailgun's API (it's used for a contact form on my website).
I'm new to Go and would love some feedback on what I could do better, anything I missed ... |
I'm trying to get into object oriented javascript programming. I have written a class for collapsible elements as a test. These elements all have a certain class and no matter how many elements there are on the page, they should all be collapsible.
It works so far, but I don't think it's very elegant yet. For example, ... |
Original review here: AI for OpenTTD - A* Path Finder
If you'd like to run the code yourself: https://github.com/marlonsmith10/empire_ai (use_smart_pointers branch)
Changes have been made based on the previous review. In particular, using std::priority_queue and std::unordered map have dramatically improved performance... |
As a player of the online game Pokéfarm Q, I'm making a fan-made extension to help players search through forum threads and CSS codes/userscripts. So that I can easily fetch data from a Pastebin I created, I added a function that ignores the CORS headers when the user is visiting https://pokefarm.com and the browser ex... |
this is my second post here, and the second project I made. I wanted to know, how to improve my code of connect-4 made in c# for console.
using System;
namespace Connect_4
{
class Program
{
// computer's board, that computer checks if someone wins
static string[] BoardColumn1 = { "a", "b", "c",... |
As an exercise in learning ARM64 assembly (aka AArch64), I wrote this function to convert 64-bit binary to hexadecimal with SIMD instructions. I'm most interested in feedback on the algorithm, instruction selection, and micro-optimizations for size or speed.
This was inspired by x86 SIMD implementations of this functi... |
I need to calculate the average value of points around a given point in a wider field.
For this I have a function:
fn local_average((x,y):(i32,i32),n:i32,(width,height):(i32,i32),space:&[i32]) -> i32 {
let y_range = cmp::max(y-n,0)..cmp::min(y+n+1,height);
let x_range = cmp::max(x-n,0)..cmp::min(x+n+1,width);
... |
I made a simple JavaFX app. It is just a Pomodoro timer, it works as expected.
The Pomodoro study pattern is a technique where you study for 25 minutes and take a 5-minute break and after 4 periods of this, you get a longer 15-minute break (and then repeat the whole thing). I made a simple countdown timer that keeps tr... |
#include <iostream>
#include <cstring>
using namespace std;
int main() {
system("chcp 1251>nul");
int i = 1;
int x;
cin >> x;
if (abs(x) >= 1) { cout << "The series is divergent"; }
else {
double eps = 0.000001;
double sum = 0;
double lastElementOfSequence=1;
do {
sum += ... |
I am new to asynchronous programming in python. Below are two scripts(which perform the same operation) one in Fastapi + aiohttp while other is basic Flask + requests library:
## Flask
def fetch1(url):
x = requests.get(url) # First hit to the url
data = x.json() # Grab re... |
I have a class Tcp_Server that implements a TCP server. This is the base class for the other types of servers available in my program. For example Tcp_Chat_Server. Packet is a struct that we send/receive.
Here's the implementation:
packet.hpp
#ifndef PACKET
#define PACKET
#define MAX_NAME_LEN 24
#include <stdio.h>
stru... |
I am trying to improve my Java skill, so I wrote a simple ATM program.
I would like a review, to help me make the code more effective.
Main
public static void main(String[] args) {
ATM a = new ATM("A", "S", 20000);
Scanner in = new Scanner(System.in);
while(true){
System.out.println("Please choose: ... |
I have a series of images ("1.bmp", "2.bmp", "3.bmp",... ,"30.bmp" in "F:\Images" folder) and I am trying to insert these images one by one into Microsoft PowerPoint with VBA program. The base slide (as template) has been set down in page 2. The image object which is named Image1 in that template slide is going to be r... |
I am working on an online newspaper/blogging application with CodeIgniter 3.1.8 and Twig. (I use the Twig template engine only for the front-end views).
The application, of course, has a registration and login system, which includes the password reset functionality.
The Passwordreset controller:
class Passwordreset ext... |
Would you be so kind as to review my TicTacToe implementation I wrote in C? I wrote this blind (not looking up other implementations). You can find it on Github here.
Any input and/or suggestions would be appreciated. Any pointers on style would also be appreciated.
I have used fflush(stdin); to clear input buffer betw... |
I've created a two-player number guessing game in Haskell. My main objective was to practice dealing with "state" in a purely functional language (such as player scores, whose turn it is, etc.).
Here are the rules:
Gameplay:
Two players will take turns guessing a random number between 1 and 10. Answers will be typed in... |
I work with the Oracle JGeometry method which returns (or takes as method argument) 2D segments as double array (x1,y1,x2,y2 ... xn,yn). I need to extend this array to contain 3D segments as double array (x1,y1,z1,x2,y2,z2 ... xn,yn,zn) by default Z value or reduce to 2D (by removing of all Z coordinate). I wrote simpl... |
I use the following code which works ok!
The code is installing helm charts in loop in k8s cluster, and I want to verify that I'm writing it ok.
tmpfile, err := ioutil.TempFile(kp, kcp)
if err != nil {
log.Error(err, "error")
}
defer os.Remove(tmpfile.Name())
if _, err := tmpfile.Write(cfg); err != nil {
ret... |
I'm just getting started with frontend development. I tried to make a pretty barebones cookie consent notice. I still don't fully understand flexbox and positioning, so the code is messy.
HTML:
<button id="shownotice">Click to ask</button>
<div id="consent_elem" class="consent_notice" hidden="true">
<p>Are you ... |
In my application I have a class responsible to save in a file the current status of the application (model) when it change :
public class BackupAgent
{
private readonly Model _model;
public BackupAgent(Model model)
{
_model = model;
_model.Changed += Save;
}
private void Save()
... |
I work on a small Web Component that converts an amount of money to another currency. For that, I use an API that returns the exchange rates.
I want to use the component multiple times on a page and thought that it would be a waste of traffic if every component fetches the same exchange rates. So I wrote some logic tha... |
Task description:
Declare a function twoInThree(a: Set, b: Set, c: Set), which returns the set of all elements, which are contained in exactly two of the three given sets a, b, c.
My solution:
fun main(args: Array<String>) {
var a = setOf<Int>(1, 2, 5)
var b = setOf<Int>(2, 7, 0)
var c = setOf<Int>(3, 5)
... |
I am doing exercise 1-13 of K&R. The problem is to print a histogram of the lengths of words in the input. This is the easier problem, printing the histogram with horizontal bars. This is what I came up with. Is there a better way to do this? Are there any bugs?
#include <stdio.h>
#define MAXLEN 10
int main(){
in... |
I have a following abstract class Listener which encapsulates boiler plate code for a client. I can then have multiple listener for various events.
As a self learning excersice I converted this to functional way.
Is this is correct way to implement in functional way?
I am trying to avoid creating class for each type o... |
I've done a program and it works fine as I want to but I feel it could be better and more advanced so I want some master advice on my program which is going to take many numbers and return the number with the most prime divisors and the number of its divisors in front of the number like this 678 3 as the output
code :
... |
I want to execute a number of tasks that may enqueue other tasks, and do all that in parallel, ending only once all tasks are finished.
For example, some sort of crawler that starts with node A, discovers B, C, and D, then visits each of those and discovers other adjacent nodes.
If one task has an error, that error sho... |
I have the function below, I want to access the context globally and I don't know if it's a good idea, I'm getting the context from the Application, I have TestAppliction in the test environment and I don't have access to the Application class, so I decided to add an optional context parameter to my function.
String ge... |
I have took the advice on some people and improved my dhondt method calculator, which is a system that takes a file of data for a number of political parties and try to find which party to assign seats too, and this all depending on how many seats the data file wants to assign and the total votes for each party. Can so... |
I am uploading and selecting code from my MySQL DB and I have a feeling some of it could be written in a much shorter way but I don't know how. Can someone tell me if this is clean code or if it's too much?
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'config/connect.php';
$con = new mysqli(...... |
The following is my attempt at writing a getline() function that makes it a bit easier to work with. I suppose an easier way would be to use fgets, but hopefully the following is good enough for some feedback:
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
#define TITLE_MAX 50
void mygets(char buffer[], s... |
I reimplemented the functions https://rdrr.io/cran/fclust/man/RI.F.html, https://rdrr.io/cran/fclust/man/ARI.F.html and https://rdrr.io/cran/fclust/man/JACCARD.F.html of the R package https://rdrr.io/cran/fclust/ in Python. However, it seems - even though I use numpy a lot, that the result is pretty slow. Much slower t... |
I am attempting to create a Linked List where someone can enter in some movie titles and their rating for it. Here is what I have thus far:
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#define TITLE_MAX 50
void mygets(char buffer[], size_t limit);
// linked list
s... |
This is a rewrite of the Dependencies program submitted previously at https://codereview.stackexchange.com/questions/255635/detecting-dependencies-in-common-lisp-project-files/256336?noredirect=1#comment506766_256336 that incorporates the many insightful changes recommended there.
I'm requesting another review to check... |
I originally posted this on Stack overflow and was told to post it here, so here it is. Here's the stack overflow question: https://stackoverflow.com/questions/66528393/generic-class-for-a-gson-linkedhashmap
I have been working on this solution for months and I have come to the conclusion that there is no clean way to ... |
I'm a Python beginner.
I have the following array of unique tuples I'm playing with:
array = [(1, 2), (1, 7), (1, 5), (2, 5), (2, 7), (2, 9), (3, 4), (3, 5), (4, 5), (4, 7), (5, 8), (6, 7), (8, 9)]
I want to find the index of a given tuple (u, v) in this array. I wrote the following line which I believe can be improve... |
This cipher takes a byte array and applies a relatively 'random' offset for each byte. In order to keep track of the offsets, to allow the encryption to be reversed, I decided against maintaining a list of offsets, like the old school one-time pads, and went with using the first byte of the hash of the key, then rehash... |
I'm writing a comparison of a simple word-counting program in various languages. The task is to count the frequencies of unique, space-separated words in the input, and output the results most frequent first. Case should be normalized to lowercase (ASCII is okay).
But it's been a long time since I've written C++ (befor... |
In this program, I'm going to take some information about student's height, weight, and age and return the average of all of them to compare. there are 2 classes to compare and the program works fine but I want to know, is there any way to improve this program and make it better?
information = []
for i in range(8):
... |
I've created a simple worker service, which uses FluentFTP to sync either files or directories from one ftp client to another, or simply to a local machine, depending on how appsettings.json is configured. Overall I'm pretty happy with the code, but there's certain points I find the code repeats itself or looks a bit m... |
I'm trying to solve the sorting problem but I always get TLE(Time Limit Exceeded/ 1s) so... can you guys suggest a more efficient way to solve this problem?
(i can't link the exercise because it is on the closed server)
code reads test count t , <int, string> pairs then sorts by integer in ascending order and prints ... |
I have a flat list of rectangles, in the following format (id, x co-ord, y co-ord, height and width):
[ { id: 4206, x: 360, y: 700, width: 60, height: 50 } ,
{ id: 6621, x: 1260, y: 1100, width: 60, height: 50 } ]
I want to index this by range of X values, and then use that indexed object to speed up a search for a... |
i have recently built this simple weather-app.
I would be happy to get some criticisms to improve my code.
Structure:
app.js:
import '../sass/style.scss';
import '@fortawesome/fontawesome-free/js/all.min';
import 'regenerator-runtime/runtime';
import elements from './modules/elements';
import update from './modules/... |
As a general rule of thumb, it is required to run baseline models on the dataset. I know H2O- AutoML and other AutoML packages do this. But I want to try using Scikit-learn Pipeline,
Here is what I have done so far,
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import BernoulliNB
from skl... |
So I received the following prompt for a code interview:
"Please create an iOS app that downloads a text file from our server, parses the
contents, and displays the results. The file is a standard Apache web server access log. We’re interested in knowing the most common three-page sequences in the file. A three-page s... |
I have a product that needs to have users put content in a form that potentially contains HTML and display it back to other users. I'd like to mitigate the risk as much as possible, and I can limit users to a subset of html. My primary goal is to make sure that users can't compromise each other, and that the page itsel... |
Introduction & Test
I would like to create an object which associates employees to X/Y coordinates. Multiple employees can be associated to each coordinate, but each employee can only be associated with one coordinate.
Also critically: employees must be able to have identical externally-configurable attributes, for exa... |
I'm making some small board game and wanted to code a very simple greed AI with this algorithm. It turns out it doesn't play the most greedy moves, it is simply not working. I'd appreciate any comments around this code.
First, the position evaluation functions are:
uint8_t get_piece_value(PKind kind)
{
switch (kind... |
I've been assigned a tast to implement an SMTP client-server protocol providing limited functionality and the Solution for this is to execute a typical execution simiilar to this transcription:
S: 220 [ip]
C: HELLO [email]
S: 250 Hello [email], pleased to meet you
C: MAIL FROM: <email1@email.com>
S: 250 ok
C: RCPT TO: ... |
I have some code here that basically takes in a list of IDs (sequencing read names) using STDIN, and then filters fin (a gzipped FASTQ file) to just those reads with a read name which matches one of the IDs, and then writes the name and sequence to fout (a gzipped FASTA file). Fairly standard data processing problem in... |
This is what I implemented in Rust to get the maximum number of consecutive 1s in list of binary numbers.
impl Solution {
pub fn print_values(nums: Vec<i32>) -> i32{
let mut result = 0;
let mut count = 0;
// let mut end = 0;
// NotE: Change the if so that it check
// if 0 el... |
I'm trying to write a Python program to predict the most likely substitution for a Caesar cipher. I managed to get it working, but it just seems very clunky and slow, especially because I need to preserve cases and non-alphabetical characters.
Would it be cleaner / more pythonic to use the chr() and ord() functions in... |
I tried to get the all unique pair combinations from a list.
Here is what I have done so far,
import itertools
# Unique Combination Pairs for list of elements
def uniqueCombinations(list_elements):
l = list(itertools.combinations(list_elements, 2))
s = set(l)
# print('actual', len(l), l)
return list(s)... |
I have already addressed this issue and corrected something .really..now the graph looks different
Please tell me if the program works correctly?You can see the results in the picture above.I will be grateful if you find any mistakes (if there are any, of course..)
/I'm just not sure if the average number of swaps and... |
I started programming in Python after learning the basics of C, which is why I like the user-defined functions to be described after the main() function's job is over. Also, I like to specify the sep and end parameters of every print() function in my programs.
After some research, I came to know that the majority of pr... |
The task that I have to perform is to take an array of a specific length, and figure out which sub-list has the closest sum to another given number. Then, I need to print the index of that sub-array.
For anyone that doesn't understand this problem, we add up indexes of the given list and the moment their sum exceeds or... |
Any idea how to shorten and improve the program?
it's going to take a list included of 22 people and split them into two teams and return the names and teams
import random
# list of teams
teams = ['A', 'B']
# list of players which is inculded of 22 people
players = ['a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i... |
I have made a random password generator using a class called password and a method called generate.
My program works as it should. It generates a random password determined by the users preferences for length, upper or lowercase, numbers and special characters.
I was just wondering if there was a way to refactor the nu... |
I want to calculate the scipy.stats.ttest_ind() for numeric columns in a pandas DataFrame with the binary target variable.
import pandas as pd
from scipy import stats
def calculate_tStatistic(df, target, numeric_cols):
"""
Calculate the t-test on TWO RELATED samples of scores, a and b.
This is a two-side... |
I have 3 checkbox's with 8 different combinations and outcomes.
Selecting no checkboxes shows no divs.
Selecting one checkbox shows the colored div.
For example; clicking the red checkbox.
Selecting two checkboxes shows the color1+color2 div. But doesn't show either of the single colored divs.
For example; clicking th... |
I have built a housekeeping script and I would like to improve it.
I have a JSON file with the details such as directory path, number of days after which the directory or file should be zipped, deletion period for the zip as well as if it's files or directories that we are zipping.
Config JSON file:
{
"foo": [
{
... |
I have written a short function as part of my program that strips the quotation marks (") from a list of lists. An example of the input data is:
[['"foo"', '"Spam"', '123', '"Angry Badger"'],
['"dead"', '"Parrot"', '321', '987']]
The target result would be:
[['foo', 'Spam', '123', 'Angry Badger'],
['dead', 'Parrot',... |
I'm using a script that converts a CSV file into GeoJSON in order to display it on a map. You can see it for yourself here. The CSV has about four thousand rows. It's quite slow. I'm wondering what is slowing it down and how I can speed it up.
function latLonColumnsToNumbers(data, latName, lonName) {
return data.map(... |
I have a plan to make something to solve this stuff:
You have 7 chips that are on the run. each has some cargo loaded. And also there's where record on each.Latter could be either track means running(or gone offroad) or tobeauty means it reaches its finish. Where .cargo = -1 means it's gone . And finally i need one ... |
Let's say I want to write a super simple Python program to ask a user for their personal information and list it back out in a "pretty" format.
def get_info():
first = input("enter your first name: ")
while not first.isalpha():
first = input("enter your first name: ")
last = input("enter your last ... |
This is a student project of mine. I got 4/5 points but I suspect there's a lot of weird stuff in there. I never had a chance to hear my teacher's feedback about it and it bothers me so I figured somebody could take a glance at it and provide some feedback.
Quick documentation
First we run "Server" program that opens ... |
I just started learning Python and this is the first code I wrote. It's a Random Walk generator. I think I got it to work pretty well but I'm also sure there are more effective and less clunky ways to do this. Could you give me some tips on what to change to make the code shorter/more optimized and just objectively mor... |
I have started a hobby project and would like to integrate better and more thorough testing practices. Since I am not too used to it, I'd love to have some feedback on the sample code below. In particular, I'd be interested in the best practices surrounding setting up data necessary to feed a particular testing functio... |
I'm programming a multithreaded application (server-client UNIX socket) implemented for the server-side. I have two thread check_cmd_thr and server_thr.
I use check_cmd_thr to check data input from keyboard, if the input is start then the server is allowed to receive messages, if the input is stop then the server is no... |
Trying to generate fractals image with given IFS equations. I have two classes:
Shape - Gives co-ordinate to form a shape.
Ifs - Takes the given IFS equations and generates a fractal image.
Code:
ifs.py
class Shape:
@staticmethod
def square():
x1 = np.concatenate(
(
np.lins... |
I made my own custom OpenGL shader loader for C++. Please tell me is I'm doing anything incorrectly or anything to improve on. I've tested this and it works perfectly fine.
main.cc
std::vector<ShaderInfo> shader_info {
{GL_VERTEX_SHADER, "shader.vert"},
{GL_FRAGMENT_SHADER, "shader.frag"}
};
GLuint shader_progr... |
So I created a wrapper class to authenticate user via POST HTTP request.
class Nucleolus
{
public const AUTHEN_USER_URL = "localhost:8000/authen/user";
protected $ch;
public function __construct(string $token)
{
$this->ch = curl_init();
curl_seto... |
The following code creates a simple tree structure and then walks through the tree looking for node with the value 9 that appears after we have seen a node with the value 1 and a node with the value 4 (order of the 1 and 4 don't matter).
type N = Value of int | Children of N list
type S = {oneFound:bool; fourFound:boo... |
Use-case in a nutshell: Interpolate fixed-sized data (a lookup table) that provides output values for combinations of a (fixed) number of inputs. The appropriate scaling is done externally, each axis starts at 0 and increments by 1. The output is a floating point value regardless of the table data type, the idea being ... |
Summary
I have finished creating a secure login functionality. I have used 1 resource to help me with the security. The security section was copy and pasted but implemented into a class to suit it in my own way, but all the logic and properties, commands etc.. is all my work. https://medium.com/@mehanix/lets-talk-secur... |
I have an array of object and I want to group/order some inner properties in a map according to a key.
I did this code but I would like to know if there was a way to optimize the code ?
const myArray = [{
getValue: () => {
return {
country: 'France',
city: 'Toulouse',
};
},
},
... |
In an attempt to create a function that returns x with the n bits that begin at position p inverted, leaving the others unchanged - following the exercise in K&R - I've come up with the following piece of code.
Still, I find it unclear where to start counting, i.e. the result would be different if starting from the rig... |
I've been toying with Haskell again and implementing a simple text replacement program that replaces all consonants c in a text by coc, i.e., inserting an 'o' in between:
> robber_simple "abcdef"
"abobcocdodefof"
This is rather simple to implement:
robber_simple :: [Char] -> [Char]
robber_simple [] = []
robber_simple ... |
I have a function that I've been trying to make faster that computes \$XA + B\$, where \$A \in \mathbb{R}^{n \times n}\$ is a tridiagonal matrix, and \$X, B \in \mathbb{R}^{m \times n}\$. In the code, the lower, main, and upper diagonals are represented by dl, dm, du. The naive implementation of this is,
/* Compute BA ... |
The problem is basically this: Return the permutation of the set of the first n natural numbers which satisfies the following property:
|pos(i) - i| = k
∀ i ∈ (1,n)
where pos(i) is the ith number in the permutation
If no such permutation exists, return -1.
Note: the input is the integer n.
The full problem is on Hacker... |
I am a beginner in C# and trying to learn how to program with OOP in mind. I am 100% that the code is not OOP-friendly at all, but the game is running and working, so if anyone could look throw the code and give me feedback on how to improve it, that would be helpful.
The game is a simple snake game with three players ... |
The original Javascript slider is on W3 schools. I modified it to work as a slider for my homepage. The goal is to call it into index.js (which works) and use it at the top of the page (which works) and if I want to swap out an image, I could load slideshow.js, add a new static image or remove an old one (also works).
... |
I am trying to stay ahead of my Year 12 Software class. Starting to work with records and arrays. I have answered the question, but the solution feels very clunky. I am hoping someone has suggestions/links for completing this task in a more efficient way.
The task: read in lines from a text file and into a structure, a... |
I am attempting to implement a converter which can convert two dimensional array (such as string[,]) into markdown table.
The experimental implementation
The experimental implementation of Converter class is as below.
public static class Converter
{
/// <summary>
/// Align formats
/// </summary>
public ... |
I tried my hand at a contact-us PHP script. I came up with the following. First the markup, then a little client-side validation and then the email script. I just need to know if this is usable code.
I actually got to the point where I can make some cash developing websites. I just need to know if this is valid
HTML
... |
I have a code that scrapes list of URL and appends dataframe as below:
from selenium import webdriver
import pandas as pd
from tabulate import tabulate
import os
os.chdir(r"C:\Users\harsh\Google Drive\sportsintel.shop\Files")
cwd = os.getcwd()
print(cwd)
browser = webdriver.Chrome()
browser.get("https://www.oddsporta... |
I wrote a math vector implementation using expression templates to add a little boost to "chain operations" like:
tnt::vector res = -v * 2 + d / 2 - 4 * c; // v, d, c are some vectors.
by avoiding the creation of the temporaries. The implementation uses C++20's concepts for safer and more readable code, generic lambda... |
This is a website Question on Hackrrank called Hash Tables: Ransom Note:
Given the words in the magazine and the words in the ransom note, print "Yes" if we can replicate the ransom note exactly using whole words from the magazine; otherwise, print "No".
Here is an example input:
6 4
give me one grand today night
give ... |
I am currently learning C++, so I made this basic password wallet for Ubuntu.
Its source code is in the /opt directory and it has a symlink so i can launch it from any directory using pw in the terminal.
Here is what it does:
It asks for a password (pass) and a site (which is related to the pass). It decrypts the file... |
I had to populate the fields of a Service object using a Set (HashSet) with any configuration parameters -> ConfigurationMap (Class with 2 attributes: key and value).
The problem is that the attribute quantity of Service object can be set from two distinct parameters ("service_quantity" or "publications_amount") based ... |
I finished my first real C project and it was Conways Game of Life. The code is working fine and the game runs. Since this was my first project though I don't know any of the real code conventions for writing C. I wanted to implement some tests so I had to split up the functionality from the main file into a new one.
I... |
dlfcn.h is a library of C functions to work with dynamic dependencies (shared objects). I've been experimenting with wrapping them in a C++ API, mostly as practice in making a C++ wrapper.
This is an excerpt of my process of wrapping the Dl_serinfo parts of dlinfo(...) in the C library. For reference:
typedef struct {... |
I have a C# application which needs to encrypt string and save the key as a hash. The key is saved as a hash to check the right key has been input before trying to decrypt the message.
First, I have these method to generate the hash string - hopefully "off the shelf" and ready to go
public static byte[] GetHash... |
I have written a class that acts like a stopwatch using C++11's std::chrono library. I wrote this because I find it difficult to benchmark my cpp code properly, this class just combines chrono's functionality and gives it a nice interface
I have two classes, stopwatch.h and lapwatch.h. The second one has the functional... |
I've implemented a simple vector-like structure. I would appreciate all criticism relevant to code.
I have also published code under github. Here is the link to source code + unit test for most functions:
https://github.com/Nethius/mystd
const double_t expansion_ratio = 1.5;
namespace mystd {
template<class T>
... |
I have written some Go code that produces the output I would like, but I am unsure if the code itself "smells" good. I would like to know if it contains any anti-patterns, exemplifies bad practices, or lacks the proper idioms one would expect to see in a program written in Golang. Details of the program follow.
I have ... |
Looking for more simple one liner for environment variable check with default value in csharp, any help is appreciated.
public static string GetEnvironmentVariable1(string envName, string defaultValue)
{
var env = Environment.GetEnvironmentVariable(envName);
return string.IsNullOrEmpty(env) ? defaultValue : env;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.