instruction stringlengths 71 95.1k |
|---|
This is my scraper for AWS ECS (Elastic Container Service). My primary use for this is to grep through the resulting file to see which cluster a given service is in.
I've been coding in python for a few years now, but I don't feel like my code is as pythonic as it should be. I've run this though pylint and it passes ... |
The goal here is to notate and produce essential PDF reports.
The For loop takes an id number and puts it into specified calculator worksheet. The workbook is set to automatic calculation so all of the necessary values update. Then it copies the result then saves as PDF a set of worksheets labeled Report
The code works... |
Users input their pin-code which is checked against the database and returned with the locality, district and state associated with that pin-code. Multiple localities may be returned so the options are passed to a select element so the user can choose theirs.
Old values are also passed as props to the Vue component and... |
This is my first big project. I missed ArrayList a lot in C and thought that it would a very good learning exercise if I implemented my own in C. I tried to take all the features from Java's ArrayList and Python's list. I'd be really glad if you guys could give me some reviews on it.
The only code that needs to be revi... |
This is my first ever created game. I been slowly but continuously learning PHP for the past 2 months and just last night I thought that I might be able to create a simple and very basic game.
Due to my lack of coding experience I am aware that my code could be pretty bad to the point of making anyone to cringe.
But be... |
My form comprises of a mandatory file input.
The form is validated according to the jQuery validate plugin.
The file input has attribute required so that the validator recognises it as a mandatory field.
Problem statement:
Each time the user selects a file, the value of the file input is immediately reset to "". ... |
I have designed and Online Book Reader System as considering the previous reviews on this platform. You can find the classes below. I would be appreciated for the valuable reviews.
Assumptions: "Online Book Reader System" is a system that includes online books and serves its customers to read books online. Users should... |
I wrote this variant of Bresenham's for fun. I am looking to see what I can optimize as it is still slower than Bresenham's.
The idea here was that if I could isolate out the IFs in Bresenham's loop it'd be more efficient. Well go figure, the added multiplication (A) or array lookups (B) in the pre-calc destroy said ef... |
I'm learning C++ using a book and currently, I'm reading the section about formating output data using manipulators. There is a program written to output data once without showing the base and again with its base. It is a simple program as follows:
#include <iostream>
using namespace std;
int main()
{
... |
Hi guys Im very very new To Angular/Typescript Im teaching my self section by section by just messing around and figuring things out.
Currently im just doing loop's and outputs so I decided to write a Randomizer for a Moba
Its. 5 Arrays then I select a Random item from each Check that they dont match and output
But I j... |
class ChristmasTree
{
private static void byHand()
{
System.out.println( "Chritsmas tree, yey." );
System.out.println( " *" );
System.out.println( " ***" );
System.out.println( " *****" );
System.out.println( " *******" );
System.out.println( " ********"... |
I have a macro created by my predecessor that I run on a monthly basis. However, it does take a while to get through, and I would like to clean it up for efficiency please.
It copies data from multiple Workbooks:
Wholesale\Reporting\Market6 Scorecard\Templates\52 Wk Data.csv
Wholesale\Reporting\Market6 Scorecard\Templa... |
Aware that this is a very common exercise; but I'm getting a bit obsessed about creating a simple, clean-ui todo app, at least for myself.
It's not quite finished yet, but I guess it will be much easier to review now than at the end, in case you look at the javascript code (react)
I'm looking any simple advice, best pr... |
I've implemented a Game of Life in Kotlin.
There are some major requirements on this solution:
Purely object-functional production code.
As close to an infinite universe as possible.
File src/test/kotlin/…/PointTest.kt
package com.nelkinda.training.gameoflife
import org.junit.jupiter.api.Test
import kotlin.test.asse... |
I've included the files that I felt were relevant (i.e I haven't included the individual pieces in the inheritance hierarchy). I'm particularly curious as to whether the system as a whole is constructed well. I've used MVC along with the Observer pattern to decouple the model and view.
Controller.java
package chess;
i... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
For an integer n, we call k>=2 a good base of n, if all digits of n
base k are 1.
Now given a string representing n, you should return the smallest good
base of n in string format.
Example 1:
Input: "13... |
I created a music player using swiftUI.I need to ask a question when I break up my player into usable components. How should I take this approach with the music player? because the music player is one view can't break up?
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
... |
I'm new programmer and I'm working on Xamarin MVVM app and I have a pin view like
So, basically I have numbers from 0-9 if you pick one number its visible then if you pick a second one first one changed to * and I store all numbers into string called PinCode
ViewModel Code:
public string PinCode { get; set; } = str... |
I have completed this question and I am wondering what is the fastest way to solve it.
The question is "There is an array with some numbers. All numbers are equal except for one. Try to find it!"
Example:
find_uniq([ 1, 1, 1, 2, 1, 1 ]) == 2
find_uniq([ 0, 0, 0.55, 0, 0 ]) == 0.55
I came up with the solution:
from col... |
I recently created a program that could get information from a client, a name and some text, and then put that into a text file. From there the user can get open the text file straight from the program. I made it in two days. Please give me some tips in ways I can improve it, thank you!
The Server:
import java.io.*;
im... |
So this is my first time writing a Lexer, and I want to make sure I'm doing it right. The lexer is not complete for a programming language right now, because I think I can easily add more stuff later. Here is the code:
main.cpp
#include <iostream>
#include <fstream>
#include <memory>
#include <unordered_map>
#include "... |
I'm new to programming and this is the first thing I'm doing on my own. I would appreciate it if you could point me ways to optimize this RPG dice roller code in Python!
import random
def dice_reader():
##this should read messages like '2 d 6 + 3, 5 d 20 + 2 or just 3 d 8'##
message = input('>')
reader = mess... |
I'm currently building an application using Passport and bcrypt for user authentication. I've created the registration part. Is there anything I could improve on? I'm still getting the hang of writing in JavaScript and I'm not sure if I'm using arrow functions correctly.
require('dotenv').config();
const express = requ... |
To practice learning x64 AT&T Assembly (GAS), I implemented three solutions for Project Euler Problem 1 (find the sum of all the multiples of 3 or 5 below 1000).
The codes and a rough pseudocode sketch of each are shown below. I'd like some open-ended feedback (some more specific questions are at the bottom). To clarif... |
I need to manipulate chunks quantity until total will be as close as possible to the requirements. Decimals are ok in the quantity.
Again: I can change only quantity property.
So if the requirements are {a:500; b:1200; c:1500}, then the quantity field in the chunks array should be changed so that when I run this:
// su... |
I have a ViewController and ViewModel. Here I am using the .subscribe() method too many times to bind title property and etc.
As you can see in the bindActions method I am subscribing to action.fetchCaregivers inside and calling fetchCaregivers().
How can I make this code a bit better?
import UIKit
import RxDataSources... |
I am trying to work with a list of Person objects where the Person object has a property called "children" which is an array of same type. I idea is to have methods called “addChildrenToMain” and “removeChildrenFromMain”. In case of addChildrenToMain I want to take the child objects and insert into the array just of th... |
I've understood the method used in post How can I render an html from a JSON-like string?
I guess I can use a for loop to create a bunch of elements as well as go through each of them, setting attributes and textContent.
This code snippet
f1=open('./notes.html', 'a')
num_attributes = 0
num_insert = 0
for i in json_arr:... |
I am fairly new to GUI programming and I am interested in improving my code from every aspect. Performance, security, readability, conciseness, and the look-and-feel aspects are all important to me.
Here is the non-GUI part of the code:
import java.util.Random;
public class Universe
{
private int generation;
p... |
I am currently working on a project for an online course, my goal is to create a bookmark manager web app. So I created this python script to parse a chrome/firefox HTML bookmarks file (Netscape-Bookmark-file) into a JSON object, while preserving the hierarchy and location of the folders and urls.
The code works fine a... |
Just wanted a general review of the code to make sure I'm doing it properly/efficently. New to JS and don't use RegEx too often.
// ==UserScript==
// @name Youtube Subscriptions Redirect
// @namespace https://github.com/spacegIider
// @version 1.0
// @license MIT
// @description Shows all subscrib... |
This code imports a list of equipment (around 8000), and then filters the errors and creates some lots for the processes that come next. The code is working, but I'm sure it can be improved, especially in terms of performance, as it takes a bit. I think the slowest part is in the "ErrorProcessing" sub.
Any suggestion a... |
I have to process raw sql user input with Laravel. I've backed them up as follows:
$query = DB::table('table_name');
function escapeString($str) {
return DB::connection()->getPdo()->quote($str);
}
$column = escapeString($rule['query']['operand']);
$value = escapeString($rule['query']['value']);
if(in_array($rule[... |
I have asked this question on stackoverflow... here, I am asking for some feedback on the solution that I have implemented.
I am using ASP.NET MVC default template to logout user:
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuth... |
I have a array-object which should look something like this and is used to create a form
const questions = [
{
condition_action: "selected",
label: "What is your name?",
question_type: "free_text",
required: true,
},
{
condition_action: "selected",
label: "Where do you live?",
question... |
I have the following Java 8+ code (on Java 14). I have a (terminal) forEach call and I am adding each mapped object to a newly created ArrayList.
Is there a more idiomatic way this could be rewritten using Collectors.toList() and potentially flatMap?
public List<SearchSuggestion> suggest() {
List<Watchlist> watchli... |
This is my second C program (an improved version of the first one). I want to optimize this simulation.
Algorithm
The simulation algorithm is:
The system can go from \$i\$ to \$i+1\$ with probability \$e^{-L\theta(\rho_i)}\$, where \$\rho_i=i/L\$, and \$\theta(\rho)=\rho(2b-\rho)\$.
When system reaches \$n=0\$, it is ... |
Hi I'm trying to create a c++ code based node editor (GUI versions to be implemented). Here is how it works, each node has ports which can be of INPUT or OUTPUT (they only connect with each other so INPUT->OUTPUT or OUTPUT->INPUT).
Here is the code so far:
main.cpp
#include <iostream>
#include "addition_node.h"
#includ... |
I recently posted here about an implementation of the Besenham's line algorithm that I wrote. I've been hard at work improving it and redoing it from the ground up. However I still can't seem to beat BLA--not sure if I'm testing wrong or if it's something else.
void bresenprecalc(int x1, int y1, int x2, int y2) {
/... |
I've recently been learned how to implement a token based authentication with ASP.NET and I would love to get some input on how my code & structure is as well as how I can make it better.
The code I'd like to share consists of the ASP.NET web API controller, and the client Xamarin application.
One question I have been ... |
I have a dataset and I want to search task name inside initialTasks array.
const stagesTasks = [
{
"dataTestID": "stage-0",
"headerText": "Backlog",
"initialTasks": ["task 1", "task 2", "task 3"]
},
{
"dataTestID": "stage-1",
"headerText": "To Do",
"initialTasks": ["task ... |
I made a Three Monte Card game using Java
Problem:
This is the original "ball and cups" game where you try to find out which cup has the ball under it. You may play with three cups and a ball, three cards (two jacks and an ace), or three doors and a car. Basically, randomly select a cup to hide the "ball". Let the pla... |
I'm doing my first big unity project and I'm really unsure about my current code I use for my level generation.
I would greatly appreciate any feedback. I'm very new to c# and I'm not at all aware of all of my options with MonoBehaviour and such.
On the editor side of unity I have Prefabs that have sprite renderers wit... |
The function uses the Windows "Cryptography API: Next Generation" (bcrypt.h)'s BCryptGenRandom function to generate random bytes - one for each character.
It returns the number of characters (excluding NUL-terminator) written to the buffer, -1 in the case of a bad argument, or -2 in the case of an error.
Example usage ... |
The preeminence is to have every method of the formatter return the formatter as a reference. This allows it to add and format text in chain. Such as:
ShapeTextFormatter.Create(Shape).AddText("Hello ").FontSize(16).Bold(True).AddText("Cruel ").StrikeThrough(msoCTrue).FontSize(6) _
.AddText("World!").FontSize(16).Bold... |
I'm a newbie trying to write my own push() and join(). This isn't very serious, just an exercise.
This is what I got so far
function Errey(...values){
this.name=values
}
Errey.prototype={
constructor:Errey,
//join method
myJoin(union = ' '){
let result=""
const length = this.name.length
for(let ... |
I am new to python and to the StackExchange sites. I made an age calculator but i want to improve it till it's a reliable thing. Can i shorten the code? What can be Done more? Does it need any additions?
Thanks in advence.
from datetime import datetime
print("A simple program to calculate your age")
print()
date = da... |
Many people tell me that C++ is a significantly better language for writing compilers than JavaScript is. So, I've decided to rewrite the compiler for AEC (the programming language I've made) from JavaScript to C++ before extending it to be able to target WebAssembly (right now, it's only capable of targeting x86). So ... |
I've made a short simple strip poker game. It follows the traditional rules of poker (4 of a kind>flush>straight,etc.), one round of betting followed by an option to change cards, then another round of betting (if cards were exchanged). It is played in the terminal, and uses Tkinter to display/change the photos dependi... |
This bot uses the PRAW package and jisho.org API. While running, it looks at recent comments for summons. A user either requests a random Chinese character/Kanji and associated definitions or specifies a query to look up, which can be anything, but definitions are not guaranteed to come up. The bot replies with the req... |
I tried to solve the Problem Euler 67 with golang, because I started to study Go recently.
This is my solution:
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
"time"
)
func calculateMaxPath(trianglePointer *[][]int, lines int) int {
trisums := make([][]int, lin... |
The following code should return an array (flatFeatures) which will include feature.name and the most far subscription.expDate. for example if I have some subscriptions with the same features, the flatFeatures array will include distinct of all features from all the subscriptions but for every feature we will have the ... |
I have implemented an in-memory filesystem - this is a design question from LeetCode. Is there a better OOP approach to represent files and directories? The current code uses a boolean flag isDirectory to distinguish between files and directories and I'm not confident that it is the best approach. See the code below. I... |
Is there a way to simplify this script using in keyword or anything like this:
searched_value = 3
data = [("a", 1), ("b",2), ("c",3)]
### can be simplified ?
test = None
for i in data:
if i[1] == searched_value:
test = i[0]
break
###
print(test)
|
I am using fluentvalidation to validate my object model. I have to make sure that the first two characters of an ISIN must be letters / non numeric. The way I did it is to convert the string to a char array and then perform regex on the first two characters. I was wondering if anyone has a nicer way of doing the valida... |
I am trying to capture the screen content of each monitor I have and divide each captured bitmap into small blocks (wxh=128x128). I managed to do this using the GDI+ API, but my implementation (on Windows using VS2019) is a bit expensive in terms of CPU usage and since I am looping it and constantly capturing the scree... |
I have always been amazed at the number of things you can do in a constexpr function, yet I have not thought much about them until recently when I found out that c++20 added the ability to pass user-defined types as a template parameter. Meaning there is a way to pass strings as a template parameter which made me think... |
I am new in NodeJS and I try to write code based on tutorials I find online. I have a NodeJS app (based on Strapi) and an external API from a Cloud Servers provider. The process I follow is as:
Call the cloud servers provider to authorise and get an access token
Call the Strapi to get the list of servers I have added... |
Below is the code I wrote to perform basic Trigonometry without using the math module(except for 1 place) for the purpose of teaching myself basic trig and to improve my python. I have never taken a trig class, so please consider this fact when explaining some fallacies in my trig logic, and please help me correct it.
... |
I am wondering if the following code can be modified to be used with latest version of spring APIs?
The following code works fine. However, I wanted to know if servlet APIs can be avoided which i have used in the code below.
public void download (HttpServletRequest request, HttpServletResponse response, @PathVariable S... |
This is my first Vim plugin and is intended to assist with adding, and editing, MarkDown headings. Features include changing the heading depth, auto-update heading reference links, and adding link title (on hover) text. Currently everything seems to function as designed, however, as this the first Vim script project th... |
We have three methods, the first calls the second one. How would you refactor so the third one can call the second one too as they have similar code?
public async Task UnpublishPersonAsync(string id)
{
await QueueAndUpdateStatusAsync(id, PersonStatus.Unpublishing, QueueNames.Unpublish);
}
private async Task Queue... |
The goal was as much code reuse as I could get. Shooting for a pure-function-y style.
Would love any feedback on general architecture, adherence to standard practice and usability - as well as ideas for improving which I may not have considered.
Would also love advice for making these shapes more generic, in order that... |
I am beginning the cycle of creating my role based access control into my framework. I now want to log the user into my application and my _user table looks like this:
CREATE TABLE `_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`hash` varchar(255) NOT NULL,
`session` varchar(... |
At work, my team hosts a daily standup, in which we discuss what we're working on, what we did the day before and any potential blockers for future development.
I thought as a fun little side project that I would write a script in bash to go through each directory in my /dev/ folder and get all commits from the previou... |
I wrote a program to implement to find the count of words for a given string.
I have applied two different approaches.
The test works for these two approaches and I am looking for other approaches to solve this problem.
Thanks for your valuable comments advance.
package test;
import main.algorithms.WordCount;
import o... |
I have implemented binary search solution by using recursion and iterative approach.
I there any way to improve it?
Tests
package test;
import main.algorithms.BinarySearchDemo;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class BinarySearchTest {
BinarySearchDemo binarySearchDe... |
The parser function is immutable and is completely based on the forest of strings with associated properties (String,Set a).
Changing the forest changes the behavior of the parser.
The use of Data.Tree allows very compact data storage and fast access to the string properties, especially in the case of large databases.
... |
I updated my Instagram API and I read that HttpClient is now the preferred way in .NET Core 3.1. I would like to get a code review, because there are too many examples and too many ways and I'm not quite sure if I did the migration correctly.
One more question: The reason I added _client.Timeout is in case the user is ... |
I have been trying to do a simple query and return the results with node-mysql however I had several problems. Originally I wrote it where there was no promise, but if I tried to access user after just doing a query if returned undefined
The solution I came up with is the following, is this a good way of doing it? I ne... |
This is my latest effort on RFC 1951 compression ( the widely-supported compression standard ) in Rust. It uses 2 extra threads to compute the LZ77 matches and the checksum in parallel with the Huffman coding. Currently it appears to out-perform the standard Rust library by some margin. On my standard test ( compressin... |
To familiarize myself with Javascript (and in particular NodeJS) I embarked on a concrete project.
In this project I need to "build" the URLs of different IP cameras.
All Cameras Information are in a JSON file
Everything works correctly, but I think to use some "bad" coding part and that there is certainly better to do... |
I'm porting my site over from .NET Framework / MVC 5 / EF6 to .NET Core 3.1 MVC / EF Core. MSSQL Server for the database.
EF6 has SqlFunctions of which one method is SquareRoot, which translates to using SQRT in sql queries against MSSQL Server.
EFCore does not have the SqlFunctions class. It does have an equivalent Db... |
I implemented the Largest Triple Products algorithm, but I use sort which makes my time complexity O(nlogn). Is there a way to implement it without a temporary sorted array?
The problem:
You're given a list of n integers arr[0..(n-1)]. You must compute a list output[0..(n-1)] such that, for each index i (between 0 and ... |
In my app I have 3 components:
MovieSearchComponent to "house" the other 2 components
MovieSearch to search an API and retrieve the data
MovieResultList to display the data in the browser
Both components are wrapped in a parent container MovieSearchComponent.
My MovieSearchComponent looks like this:
interface Movie {... |
My code provides the following functionality for interacting with Pinnacle Bets API:
retrieving betting history
retrieving fixtures (future events)
retrieving odds for the given leagues (competitions)
retrieving odds for the given events (games)
placing a bet
Should you need to get acquainted with the API, it provide... |
I wasn't quite sure whether I should do it this way or create a validation service and inject it, but this works:
Controller:
[HttpPost]
public async Task<IActionResult> NewUser(NewUsertVm viewModel)
{
if (UserValidator.NewUserIsValid(viewModel, ModelState) == false)
{
return View(nameof(NewUser), viewM... |
I need to randomly erase 33% of the non-zero elements in each line of a matrix.
Side note: The end goal is to train a denoising autoencoder to remove this noise.
My solution:
import numpy as np
matrix = np.random.rand(1000,3000)
for i in range(matrix.shape[0]):
clean = matrix[i, :] # original matrix line
# fi... |
background story my girlfriend watches about 12 TV-Show episodes everyday and i keep telling her it's not good. I have made this script that kicks her out of my account for 20 times in an hour.
However, After 20 logouts it gives out a Technical difficulties error and i want to improve as to why?
import sched, time
from... |
I have implemented a Producer-Consumer by Semaphore implementation.
I am looking forward to for your code review comments.
Thanks.
package ProducerConsumer.Semaphore;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util... |
I have completed an implementation for finding the first unique character.
Is there any way I can improve it?
package com.datastructures;
public class FirstUniqueCharacter {
public static void main(String args[]){
String string = "neslihan";
System.out.println(firstUniqueChar(string));
}
... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and
Y are similar if they are equal.
For example, "tars" and "rats" are... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and
Y are similar if they are equal.
For example, "tars" and "rats" are... |
I finished a code that sorts and compiles daily work data into a weekly summary. Its triggered by workbook changes so it refreshes automatically.
Trying to respect "good code writing", and using my background in matlab, I tried to split my code as much as possible. It's an intership projet for a company and the Excel s... |
I am using below command to assign a value, Is there a alternative way to get by tweaking the code
var=hdfs dfs -ls /hdfs_path/ | grep col=2020_03 | awk -F' ' '{system("hdfs dfs -count "$8)}' | awk -F' ' '{if ($3 != 0) print $4}' | awk -F'=' '{print $2}'|sort -nr | uniq | head -1
Basically i am need to find the latest... |
I want to build my own link shortening system. Therefore I need a way to create unique strings from the record ids stored in my database table.
So far I came up with this. I wonder if you now a faster or better idea? Or are there any caveats to my method?
// generate unique alphanumeric string from id with map
function... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and
Y are similar if they are equal.
For example, "tars" and "rats" are similar (swap... |
This is a project that I remade to help me understand function definitions better. It may not be great but I am proud of it.
I would love to have you review this project and tell me what I could improve in this project, as well as in general.
from all_wrd import words
import random
import re
class Game:
def __init... |
can someone review my code for me.
Here is my algorithm:
initialize dataQueue with all elements to be added into the nodes in order
initialize parentQueue as empty queue
create the tree's root node with the first element of the data queue
enqueue the root node on parentQueue
while dataQueue has elements
a = dequeue fro... |
I have a lot of Command objects. Each command has lots of Task objects. Tasks and commands are related. Each command wants to know which task belongs to it. Where each task wants to know which command it belongs to.
class Command:
def __init__(self, date):
self.deadline = date
self.tasks = []
... |
My code down below generates entries for my program, but it's veryyy slow. I'm looking to generate about 10 million, is there any way to speed it up?
FirstNames, LastNames, and Objects (.txt) are all files with one entry per line
TempList=[]
maxData=10000000 #The maximum amount of entries that can be produced
import ra... |
I'm writing a tiny Python library that fetches data from Horizons, JPL's solar system data and ephemeris computation service. An overview of their batch CGI is here. While the script is simple, I would like to make it as clear and standardized as possible.
The idea is to initialize the HorizonsRequest class with a loca... |
This is basically based on the following question on stackoverflow which was based on a codewars assignment that can be found here
Problem statement
Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false.
Notes:
Only lowe... |
I'm just returning to Java after a multi-decade hiatus -- there are some nice new packages, such as java.nio.
I need to convert an array of floats into bytes and vice versa. The floatToBytes() function feels okay, but I'm pretty certain that bytesToFloats() could be implemented better. Thoughts?
(P.S.: ignore the pub... |
I need to get car info from a 3rd party web service and persist the data in my application DB. If my DB already has the car, I only update property values that may have changed. Otherwise, I create and save the car:
@Transactional //Spring Transaction
void saveCars() {
//get CarInfo from a webservice
List<CarInf... |
Purpose of Code
The purpose of the main function (get_player_penalties()) is to:
Generate simple SQL statements from user input and a template
Query a database using the generated SQL and return a summary table to the user
Ultimately, I will reference this code to create similar functions (and SQL templates) that r... |
I'm absolutely dumbfounded by this. I was trying to demonstrate to myself how much faster C++ is than even modern PHP. I ran a simple CSV parsing program in both that have the same output. The CSV file is 40,194,684 parsed down to 1,537,194 lines.
EDIT: This sparked alot more conversation than I had anticipated, here's... |
I found a simple series named the Lebniez series for finding Pi.
$$1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \dots = \frac{\pi}{4}$$
I made this in Python. I then realised that because it is an infinite series, and it will give an approximation. Additionally the convergence rate is very slow.
Here is ... |
Looking for a most efficient way to replace some specific exception and to leave others exceptions treatment the same the same.
try
{
// some business logic
}
catch(UniqueConstraintViolationException uex) when (!uex.IsFatal() && !ShouldRetry(descriptor, command, uex, ref retryResult))
{
throw new ItemAlreadyExistsEx... |
I'm trying to write an extension (method chaining) for playing around a bit.
What I made work is an extension to add an item to the list (what is pretty easy):
IEnumerable<int> myList = originalList.Add(12);
What I now want to do is:
IEnumerable<int> myList = originalList.Add(12).If((list, @new) => !list.Contains(@new... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.