instruction stringlengths 71 71.9k |
|---|
First attempt at dynamic programming. I want to make this run faster and better.
fibonacci.cpp
#include "fibonacci.h"
std::map<int, unsigned long long int> initializeMap() {
std::map<int, unsigned long long int> m;
m[0] = 0;
m[1] = 1;
return m;
}
std::map<int, unsigned long long int> __fib_result_map... |
I have created a simple event manager and I want it to work properly in a multithreaded environment:
public enum EventType {
EVENT_TYPE_A,
EVENT_TYPE_B,
EVENT_TYPE_C;
}
public interface Observer {
void onEvent(EventType eventType);
}
public class ObserverManager {
private Set<Observer> m_weakRef... |
Problem
There are two kangaroos on an x-axis ready to jump in the positive
direction (i.e, toward positive infinity). The first kangaroo starts
at location x1 and moves at a rate of v1 meters per jump. The second
kangaroo starts at location x2 and moves at a rate of v2 meters per
jump. Given the starting locat... |
Hey guys have a bit of code below I'm looking to optimize, the code is working, just feel it could be shorter as I had to ignore DRY principles sadly - couldn't think of a better way.
Objective: Minimize the if ($isMulti) { } else {} statement
PHPDoc:
/**
* Syncs an array key => value pair to database column => value
... |
I finally got around to redoing my Temperature conversion program. I incorporated many elements of everyone's comments, and am uploading the finished program. Any new, or problems that I missed? Maybe a few very late here where I am working. Main focus of this redo was keeping my functions short and single purposed.
#... |
I'd rather not use this long code. I want to retrieve table/rows from database and insert into JavaScript to create a table in HTML.
This is what it looks like so far and I'd like to keep the design if possible:
https://i.stack.imgur.com/rDUqk.jpg
var time = 10
var wrongs = 0;
var wrongs2 = 0;
var next = 0;
var right... |
I am trying to come up with the most performant way of calculating the statistical Modes of a std::vector, obeying two conditions:
1) my function should not duplicate memory usage (which would required for most usually mentioned faster methods of calculating mode);
2) my function should be able to handle multi-modality... |
This is how I made a cross context join.
What do you think?
How would you do this better?
using (var context = ContextFactory.Create())
{
var users = await context
.Users.AsNoTracking()
.OrderBy(user => user.DisplayName)
.Where(user => user... |
I'm working on a logger that has a name of the module that called the logger (when I create an instance of a logger in my program, I call LoggingHandler(__name__)) to send all the messages, including info and debug, to the log file, and print the messages specified by max_level to console (so, by default, it will not p... |
I've been trying to write an image scaler in C# with a focus on improved performance over the GDI+ scaler.
My current bicubic implementation when running with a single thread is slightly slower than the GDI+ HighQualityBicubic interpolation mode, and multi threaded performance is over 3 times faster. Note that this is ... |
I'm currently studying the book
From Algorithms to Z-Scores: Probabilistic and Statistical Modelling in Computer Science
In the first chapter of the book the ALOHA network protocol is introduced as an example of probabilistic modelling. I decided to write a python simulation and run some tests to check the overall pe... |
I'm new to object oriented PHP, so I'm sure of the good or bad practices. The below code is working perfectly, I just don't know if it is a bad or good approach to use most of the methods as static and declare class properties as public.
Could someone provide me some advise?
In users.php
<?php
class Users{
public $... |
I need to perform SQL query which will get products from database based on few dimensions which I will pass in URL.
import itertools
sql_where = ''
dimensions = ['a','b', 'c', 'd', 'e', 'f', 'f2', 'g']
for dimension in dimensions:
for onetwo, direction in zip( range(1, 3), itertools.cycle('><') ):
globals... |
Problem statement : There is a windmill which collects and stores wind data for various cities. The data is maintained in an xml file by the aggregator part of windmill. Now I am trying to implement the publisher part of the mill.
The responsibility of publisher is to notify the registered clients for their respective ... |
I've created a simple toggle menu in jQuery, which is capable of specifying a breakpoint, but I'm afraid my code is too complicated. How can I make it simpler?
I also have a question about performance of code on window resize. I want to invoke a function only once if the window's width is smaller than a given breakpoin... |
I'm not that good when it comes to templates, especially when it comes to variadic templates. I want to show you some code where I use both - templates and variadic templates - to call a lua function. I'm proud that it works, and it works great, but I want to get some feedback on what I could've done better.
template<t... |
I've been working in some tools lately that analize long streams of data and extract frequent patterns, histograms, etc. for personal use. Lately I've been coding a histogram generator; that is, given a long chunked data stream, generate a histogram with all distinct chunks; typical case, given a text, generate a word ... |
This is a follow up to my previous question: Serializing objects to delimited files
I've added some feature enhancements, and based on suggestions from rolfl in chat, I've fixed up a couple inconsistencies with the serializer.
First, if you don't mark any properties with DelimitedColumnAttribute, I added a DelimitedIgn... |
Output formatting:
Input Format
Every line of input will contain a String followed by an integer.
Each String will have a maximum of 10 alphabetic characters, and each integer will be in the inclusive range from 0 to 999.
Output Format
In each line of output there should be two columns:
The first column contains t... |
I've created a System.Threading.Timer wrapper in C#. The tasks to be triggered when the timer elapses have highly variable execution times. My design criteria are:
Provide a strongly typed timer state in the callback
Run the timer callback on a periodic basis
If the timer's period elapses before the timer callback com... |
I have a time, in seconds, which has the possibility to be very large. I wish to convert said time into the "appropriate" rounded, readable format.
I already have code which achieves this, however it's not very efficient (and contains a whole bunch of magic numbers):
String readable = decayTime + " minutes";
if(decayTi... |
I overloaded some C# operators to get a pseudo version of the Brainfuck symbols in the effort of understanding the flow of this language.
I got this version:
void Main()
{
/*
* Write `Hello World!`
* using operators overloading for brainfuck symbols
*/
var _ = new brainfuck();
_ = ... |
Below are two examples of arrays I have, with some given length:
For some value z, I want to find the column the value is in. MATLAB code I wrote:
if z == 1
column = ceil(length/2);
elseif logical(mod(z,2))
column = length - (z-3)/2;
else
column = z/2;
end
It is correct I think. But ugly and possibly slow... |
I am working on brushing up my data-structures knowledge, and was hoping to have my code/thoughts reviewed.
Interface:
package dataStructures;
import java.util.NoSuchElementException;
public interface QueueInterface<E> {
/**
* Puts an element into the queue and returns this interface to allow method chai... |
After reading an exceptional article here about the decorator pattern applied to functions, I saw an opportunity to reduce a lot of boilerplate code in a console application project I've been working lately.
The app gathers information about the workstation it is run from, and saves that data to a central database. So... |
I'm using jQuery to swap images on hover. There's a main image, and a gallery of thumbs. When the thumb is hovered over/touched, the larger version of it populates the main image, and the smaller version of the original populates the thumb. This happens via swapping src and data- attributes.
This all works, but being r... |
In each shared library that I build, it need to call __gcov_flush but that call should only be made when building the instrumented binaries for code review.
In that case I'm passing
-D__CODE_COVERAGE__
option as a compilation flag.
And in each .so file.
#ifdef __CODE_COVERAGE__
void cscomm_gcov_flush()
{
__gcov... |
I was once asked in an interview to build a factory that makes cars.
All cars has common features like price, rating and color and they have some features like fuel injection which can on specific car but not mandatory. Moreover there can be several types of the same feature like fuel-injection v1, v2 ect, and you shou... |
I am trying to implement the Repository Pattern with a Unit of work but I don't know if I am on the right direction. This is my Model:
public class Resource
{
public string RessourceUID { get; set; }
public string RessourceName { get; set; }
public List<Team> Teams { get; set; }
public string Loginname ... |
Here is my first try at F#. My only functional experience is from JS.
This program takes a path as an argument and presents the user with numbered subdirs in that path. The user then selects one of the subdirs by entering it's number and the program opens explorer with the newest subdir of the selected subdir.
Any comm... |
I need to check number of messages in a jms queue for that i am using queuebrowser.
Actually i have 2 queues. I check if there are more then 10 messages in second queue then the first queue should not send messages to the second queue.
This is my code snippet
connection = connectionFactory.createConnection... |
I'm trying to get an array of all "form" objects within a large "masterFormObject" object. Is this the cleanest way to do so, or is there a better way I can check if the form objects themselves are not undefined directly and check both the applicant and account portion of this form object without having two separate bl... |
I've coded this class that lets me search through an ArrayList displayed into a RecyclerView. This is the class:
public class SearchActivity extends AppCompatActivity {
ArrayList<Accordo> chords;
RecyclerView rv;
SearchView sv;
ArrayList<Accordo> filteredList;
@Override
protected void onCreate(... |
Recently, I wanted to change my vim colors to something new. So I went to the vim colors website and then I decided that I wanted to download ALL the colors.
So I wrote this simple Python script that will download all the files from: Vim Colors
I'm still learning Python and it would be amazing to get some feedback / s... |
For a set of 2D or 3D points \$\{\mathbf P_0, \mathbf P_1,\cdots,\mathbf P_n\}\$, their parameters \$\mathbf T = \{t_0,t_1,\cdots,t_n \}\$ could be computed as follow:
$$\begin{align}
t_0&=0\\
t_i&=\frac{\sum_{j=1}^{i}||\mathbf P_j- \mathbf P_{j-1}||}{\sum_{j=1}^{n}||\mathbf P_j-\mathbf P_{j-1}||} \qquad i=1,2,\cdots,n... |
This program is basically a rhyming dictionary. It makes use of Sphinx's groups phonemic dictionary of English which includes a lot of words broken into their respective phonemes, and if we assume that, at least for most cases, anytime the two last phonemes match, the two words rhyme, then it's very easy to whip up a p... |
I have a JSON file like
{
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "RESOURCE_NAME",
"Type": "A",
"TTL": 60,
"ResourceRecords": [{
"Value": "RESOURCE_HOSTS"
}]
}
}]
}
where I need to repl... |
This is in continuation from the project posted here: Making a report from payroll details part II
Basically, based on the user input in columns F, G, H, the macro generates a varying string in column I.
Eventually this spreadsheet is combined together in a mail merge in Microsoft Word (if anyone knows how to do that i... |
I have written a program to generate a pascal triangle of predefined size.
Code
#include <stdio.h>
#include <assert.h>
#include <pthread.h>
#include <gmp.h>
#define N 50
#define SIZE(x) (((x) >> 1) + 1)
#define NTHREADS 8
int min(int a, int b) {
return (a < b) ? a : b;
}
mpz_t row[2][SIZE(N)];
typedef struct ... |
I have a very simple directive <my-card> that lists out some data.
Example Usage
my-card(ng-repeat="item in parentCtrl.items" item='item')
The only main functionality I have is a button that toggles some additional data.
Here is my directive/controller definition. Should I use the link function instead of creating a c... |
Inspired by a previous question, I was looking into converting a table to a sorted list (ascending) -
Resulting in this -
I used a very simple bubble-sort, but I don't know how efficient that would be with larger data sets, either in records or if I wanted to sort on more than one condition. Basically, this was an ex... |
This is a follow-up review request to the first one for this same utility/file/script. The first review can be found here: Cross-platform file hash sum generator in Python
I'm back with the modified version of this script/utility, looking for some more follow up on the original review.
This iteration of my hash sum ... |
I was doing a programming challenge and the object was to validate an email address, I wrote a simple little email validator and would like some input on how I can make it more efficient.
How it works, it has two validations, one with a regex, and one validating the length (most email addresses are over 12 characters, ... |
Recently, I was burdened with the task of finding a bug. It turns out the problem was strings from different systems containing different newlines. Comparing two strings with different newlines (but same "text") still are not equal. E.g. "new\nline" (Unix flavor) and "new\r\nline" (Windows flavor) are not equal.
Since ... |
I am updating a class in legacy code and having some issue with my calcPressure method. I want to make it nice and clean but there is some convolution in the process.
Namely the calcPressure method I have does this:
computes a value from existing values
writes that value into an in-class parameter
returns the value ... |
I wrote a bash script for the Raspberry Pi 3 (Raspbian) which has the main task of setting up a LAN to WLAN router. In addition it makes some things nicer for the intended users who have Windows background only. It will be used on a Pi 3 with built-in WLAN and the official 7" display only.
Preconditions to run the scri... |
I'm doing Python programming challenges and have come across one where the object of the challenge was to create a script to change passwords. The script must validate that the password contains, one upper, one lowercase, and one number. After everything has been validated the script should save the password to a text ... |
This code copies files to our Test server and places the executable on a file share for the tester to access. I'm new to Powershell, so I'm sure I'm not doing this in the most efficient way. Any criticisms would be appreciated.
# the destination that we are copying TO.
$codeToDeploy = "\\deployment_server\App-Shares\... |
Can someone please take a look at these recursive functions, offer some advice on the code, or just critique my attempt into thinking recursively?
Problem:
We’ve seen that % (the remainder operator) can be used to test whether a number is even or odd by using % 2 to see whether it’s divisible by two. Here’s another w... |
Preface
I was trying to review this question on the same topic, but in the end many points I wanted to make were excellently explained by @ferada so I felt that posting my code and explaining the concepts around such changes would just be repetition.
Instead I am questioning whether my approach is over-engineered consi... |
I receive a weather forecast for 5 days, but in 3 hours intervals.
This classes represent the weather forecast:
public class Forecast : ILocation
{
[JsonIgnore()]
public string City { get; set; }
[JsonIgnore()]
public string Country { get; set; }
[JsonProperty("list")]
public IList<WeatherTimePo... |
In an attempt to hide from the sun outside, I gave the community challenge "Rainfall" a try.
Code here, specific questions below.
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.stream.Collectors;
public class RainfallChallenge
{
public static void main(String[] arg... |
I'm writing C# applications that store their data in MS Access databases, (I'd rather use a different type of database but currently have no other option).
The applications are in use by multiple people at a time and so when there are multiple connection attempts (or someone mistakenly opens a table), some of them fail... |
I'm making a program where I need to check if files in the directory are correct (46 files and all 11 chars).
I've got two methods to do it but I don't know which one is better.
Using opendir/readdir:
int checkfiles()
{
DIR *dir;
struct dirent *dp;
int count = 0;
if ((dir = op... |
What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the [provided] 20×20 grid? [source]
This solution works, and works effectively instantly.
The algorithm is \$ O ( n ) \$, as it loops through the entire field a total of four times.
However, it seems ... |
I have put together a stored procedure to load and parse the Stack Exchange Data Dump into a relational database (akin to Stack Exchange Data Explorer). Each site has 8 XML files like these:
The stored procedure below performs the following steps:
Fetch the Badges.xml file for the target site from the local file syst... |
I'm trying to pass my logger to a Logging Aspect that I've created with PostSharp. I have one logger per job run (because I need to send each job's logs to different folders), each job runs in different threads using BackgroundWorker. This is the code that I have:
[Serializable]
public class LogExecutionTimeAttribute ... |
The task is to provide a function that returns the earliest time point when a worker is allowed to start duty.
The function uses two parameters:
Time stamp when the rest starts
The number of local nights which is necessary according to a table
I wonder if there is anything wrong with void convertTimeStructToLocalTime... |
I'm working on load/save application sessions functionality, and came up with this code:
public class SessionManager
{
private static ISessionStorage storage = new DbTableSessionStorage();
private static StudySession session;
public static StudySession Current
{
get
{
if (ses... |
I'm fairly new to python and decided to build something useful (I believe). So I made this script to track changes in user's files with DB with ability to "Accept changes", so end-user might track which files were removed/added/changed. This db then is being used in Django project.
Any help will be greatly appreciated,... |
I calculate the moving averages of a specific measure. However, multiples threads can access this class in order to compute the average.
public class AvgUtils {
/** The alpha. */
private static final double ALPHA = 0.9;
private double avgOldValue = 1.0;
public synchronized double computeAvg(double p... |
The task at hand was to ensure that certain columns in the database are encrypted in case the database data is stolen. I have a feeling that a lot can be improved here (naming, DSL, encapsulations) while keeping the functionality as simple as it is. Let me know what you think, I'd appreciate any suggestions and ideas!
... |
Is there any way that I can improve the performance of my x12_reader? The main functions that seem to be the bottlenecks are read_line() and get_element() they are both called upwards of millions of times.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
n... |
This is a list class which allows users to "turn" the list while keeping track of the current position.
For efficiency, the list is not actually rotated on each rotation, but instead an offset keeps track of where the "0" in the list is. However, this makes addition and multiplication less efficient as these operations... |
I've implemented a VHDL program that sums up the positions of switches and shows it on a 7-segment LED, but I've had to use lots of temporaries and a division. Is there a better way?
library ieee;
use ieee.std_logic_1164.all;
entity light is
port(
LEDR : out std_logic_vector(0 to 9);
LEDG : out std_l... |
This file contains the main functions of my tool, rac. In particular, I care a lot about the Shannon function.
Would you please give some hints to make the file cleaner? I have a perversion for concise and good indented code.
#include <math.h>
#include <stdio.h>
#include "headers/utils.h"
double ccount(char * foo)
{... |
I am using SharePoint 2010 and get values from a list using the code below.
It might be called like this: getValueFromList("addresses", "secondName", "city", "manhattan");
It will return the "secondName" of the first entry that has "city = manhattan". Is there a way to make it more efficient?
private string getValueFro... |
I have implemented the Gabor Filter of which I provided the source code as bellow.
The code is deadly slow.
Applying the filter on a grayscale image of Lena 512x512 takes 7577 milliseconds.
And the filter bank (12 filters) freezes and doesn't even display any value.
Source Code:
Gabor kernel,
public class GaborKernel... |
While trying my hands at the beginner codechef problem I came across this . So basically doing that problem with Dynamic programming is an overkill but why not try that and get some DP practice.
Nice, I almost solved that problem in minutes but the problem is this takes too much memory , and ends up with a Segmentation... |
I have the use case of needing to find the parent path of a sub path for which I have written the following function:
#! /usr/bin/env python3
from os.path import sep
def pathbase(main, sub):
if main.endswith(sub):
parent = main[:-len(sub)]
while parent.endswith(sep):
parent = parent[... |
Some context: I have some existing code to populate network header structs from istreams. A motivating excerpt:
struct l2_eth_frame {
using mac_address_t = std::array<std::uint8_t, 6>;
mac_address_t dest, src;
std::uint16_t type;
std::uint32_t vlan;
};
template<typename StreamLike, typename T>
void rea... |
This time, I have rewritten my radix sort implementation from C++ to C:
integer_sort.h:
#ifndef INTEGER_SORT_H
#define INTEGER_SORT_H
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
void int32_sort(void* base,
const size_t num,
const size_t size,
... |
I am looking for suggestions of improving this function to check whether a memory address is appropriate or not.
def isweird(addr, cpu_name):
"""Check if a memory address is weird
Args:
addr (str): a memory address
cpu_name (str): cpu name
Returns:
bool: True if the address is weird
... |
Can this if-else statement be simplified and/or cleaned up?
var path = require('path')
var express = require('express')
var app = express()
app.get('/*', function (req, res) {
var page;
if (req.params[0] === '') {
// if requesting root dir, add `index.html`
page = path.parse(path.join(__dirname, 'index.html... |
I've got some experience with Laravel but for fun I started a small project (basically a CRUD with also Google Maps) without a framework because I considered that is oversized.
This is the directory structure.
+---assets
| +---css
| +---img
| \---js
+---classes
+---inc
| +---templates
| \---views
| \---... |
I recently posted a program that I wrote that would change a password after being validated, the program can be found here.
I have rewritten this program, it has a couple new features:
Usernames
Decryption
Program related errors
How it works. At the beginning of the program you asked to make a username, that username... |
I wrote a function that will pixelate an image using the average color of each 4x4 cell.
The function will "split" the image into 4x4 cells, and find the average color of each pixel in the 4x4 cell, and set the 4x4 cell to the average color.
I'd like some help optimizing my function so it can pixelate an image as fast ... |
Let’s say we copy some file using retry strategy (it might be blocked, etc.):
class Processor
{
public void CopyData() =>
CopyData(Try.Slow);
public void CopyData(Try loop) =>
loop.Execute(() =>
File.Copy(@"c\a.txt", @"c:\b.txt"));
}
What do you think about names chosen for the fo... |
In this code, I tried to integrate my little knowledge of (and great fascination towards) functional programming. I'd like to make this code more functional, and faster, if that's possible.
'use strict';
var insert = require('./insert');
const STEP = 50;
const WIDTH = 200, HEIGHT = 100;
var ptr = [[0, 1, 0, 0, 0, 0,... |
Suppose I have a string with a length always a multiple of four:
'CodeReviewSE'
My goal is to create a permutation. First, I arrange the string into a matrix (where each row has a length of 4):
C o d e
R e v i
e w S E
And then I simply read down, starting from the top-left corner. I get four segm... |
I'm making an experimental Java algorithm that translates binary data from a file into a (very large) base ten integer. I am using BigInteger since this number may have millions of digits. I am trying to translate this number into a sum of powers of 2.
I tried this code, which theoretically works, but is sluggishly slo... |
I have an algorithm for generating permutations in Python
from collections import Counter
def permutations(A):
def permutations(A):
if len(A) == 0:
return
if len(A) == 1:
yield A
else:
for i in range(1, len(A)):
for p in permutations(A[i:]... |
I was inspired to throw this class together by an SO question and thought I'd subject it to some welcome criticism here.
The class is basically just a wrapper around the shell utility dir, and is intended as a replacement for the built in Dir$ function. The rationale for replacing the function is that it has many mo... |
I'm trying to measure the time taken to copy a std::vector<someObject>. Would like to know if this is a correct approach. I tried to do some trivial computations on the copy to prevent the compiler from optimizing out the copy. Should I explicitly write a copy-constructor?
#include <iostream>
#include <new>
#include <c... |
I've been trying to look for a better way in which a user has up to 5 inputs in which they can search for results in a database.
I have 2 EditTexts in which the user can have alphanumeric values and 3 Spinners. As you can see in the code, it's badly designed in the way it consists of if or else if statements which is j... |
I wrote a simple console application that reads contents from a CSV file, and using that input, checks a database table to see if the contents are within it. If there is a match, then the program will output the name of the file that the input is included in to a text file.
I feel like I should break this application u... |
I made a small program that tests numbers against some properties:
Welcome to Numbers!
Is it odd? 4
No
Is it a multiple of 18? 38
No
Is it big? 100
Yes
That's basically it :)
My code is:
import System.IO
import Text.Read
askUser :: String -> IO Double
askUser str = do
putStr str
num <- fmap readMaybe getLine
... |
I recently posted this script:
VIM colors downloader in Python
But since I'm not allowed to update the code there, I wanted to get an idea on this version, that uses multiprocessing:
import os
import json
import requests
from bs4 import BeautifulSoup
from multiprocessing import Process
class Spider:
def __init__(... |
I am trying to apply this simple macro to merge two big sized sheets (around 30000 rows each), but the process is too slow and never ends. The macro works perfectly with smaller sheets. Could you give me any advice for the optimization of my code please ?
My Macro consists in an Userform :
Public listChoice As String
... |
I recently was playing around with the idea of having an image appear when the user scrolls and came up with the following. Is there a better or more efficient way to do it?
var pastScroll;
jQuery(document).scroll(function () {
var currentScroll = jQuery(document).scrollTop();
if (pastScroll == currentScroll) ... |
Two quick notes: I'm targeting 4.5, and the server already has newtownsoft's json library. I'd prefer not installing anything additional on the server.
using Newtonsoft.Json.Linq;
using System;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Thread... |
I have been tinkering with various ways to clean this up and I was wondering if it is more ideal to break this into small methods or way to accomplish this on a single line?
def run_counters
@num_attempts ||= 0
@num_attempts += retry_attempt
@all_attempts ||= 0
@all_attempts += retry_limit
end
|
I am picking up a code smell from this code and I am not sure of the best way to rid myself of it.
I have a validation class that has a function that returns a list of IValidationRule<T> implementations (RuleOne, RuleTwo, RuleThree).
public interface IValidationRule<T>
{
ValidationRuleResult Validate(T instance);
}... |
So someone challenged me to write FizzBuzz using CSS only. This was the best I could come up with, but I think the "divisible by 5, not divisible by 3" CSS rule is a bit clunky. So I'm looking for advice to provide a more readable and maintainable solution.
ol li {
list-style-type: none;
counter-increment: listCo... |
There are frequently things I miss when using C; one of them is a nice error-handling (exception-like) system. After trying Rust, I realized I could implement something similar in C itself. So here's my attempt at writing a Result type in C.
The idea of the Result type is similar to that of an Optional type: if the val... |
This is a bot for Twitter where you can upload an excel file with text in as many rows as you want but in a single column and it posts every row as a tweet every certain time.
It stores the credentials in another Excel file, I know this very insecure but I couldnt find a better way to do it, if anyone has a suggestion ... |
Previous version
Now supports async operations and cancellation.
Let’s say we copy some file using retry strategy (it might be blocked, etc.). App code comes bellow:
class Processor
{
public void CopyData() =>
CopyData(IOTry.Slow);
public void CopyData(Try loop) =>
loop.Execute(() =>
... |
This is probably my final submission to Code Review regarding this making a report from payroll details series. Basically, working in the human services sector, the funding agency requires A) Weekly documentation of services provided and B) Monthly documentation of general progress for each of 60+ developmentally disab... |
I would like to know if this is a good way to make sure the user enters a valid number.
#include <stdio.h>
#include <ctype.h>
void clear_stream(FILE *in)
{
int ch;
clearerr(in);
do
ch = getc(in);
while (ch != '\n' && ch != EOF);
clearerr(in);
}
float retreive_input()
{
float input = 0;
... |
I am developing WPF application keeping MVVM and using Prism. Here is simplified scheme:
I need to invoke model logic in UserControlResult when executing command in view-model of UserControlButtons. Real case: UserControlButtons contains buttons (and one of them triggers start of data processing), while UserControlRes... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.