instruction stringlengths 71 95.1k |
|---|
I am doing Advent of Code 2019 in order to learn Rust (it's been fun, but challenging!).
I am looking for help and feedback from more experiences Rustaceans on my solution to Day 6: Universal Orbit Map in Rust.
Specifically I am looking to see where I am not doing it the idiomatic Rust way, where my Java background s... |
I encountered a use case where it was needed to store each element of a tuple into a list of their respective type of the tuple element. To streamline this feature I wrote a method extension that I overloaded for different sized tuples. The code is quite basic and does not do a lot but I thought you could give me some ... |
Asked in interview today:
You want to paint a skyline on your wall using only horizontal brush strokes. You are given an array of numbers, each representing the size of the column/building in that position. E.g. [1,2,1] - you can use two (horizontal) brush strokes. The first will paint the entire first row, and the sec... |
Was asked in an interview today -
You are given an integer (in finite range [-N, N]) and you wish to maximize the number by inserting somewhere the digit '5'.
My solution - the idea here is going from left to right and checking if the digit is bigger than 5 or not. The first time you reach one that isn't you insert t... |
After working on the project for 15 hours of I had my layout set 1 row and 1 column per square, no problem. Then I decided that I needed each square to have multiple rows. I would have never guessed that it would take almost 6 hours to work this out.
The reason that I changed the layout
I had most of the logic work... |
This is my solution for Day 2 of Advent of Code 2019.
It's the eval function I want to get reviewed. Is this acceptable Haskell code? Is it even close to being idiomatic? Also, is it OK to leverage laziness this way?
module Day2 where
import Data.Vector (Vector, fromList, head, (!), (//))
import Data.List.Split (split... |
I am trying to write my own implementation of a hash table (hash map) in C++. It turns out that my code is unoptimized as I can't pass performance tests. Can you please give some advice for optimization of the program?
I am using open addressing for resolving collisions with quadratic probing.
Hash function for string:... |
I need help to dynamically create an array with nested objects holding again an array of objects each. The structure is as follows:
tiles=[
{ "row": [{isChecked: true, src: ''}, {isChecked: true, src: ''}, {isChecked: true, src: ''}] },
{ "row": [{isChecked: true, src: ''}, {isChecked: true, src: ''}, {isChec... |
Please review the following code for thread pool in C (I wrote it to implement a threaded web server for my personal project). I have been programming in C++ and Java but never did any serious programming in C.
threadpool.h
#ifndef THREAD_POOL_H
#define THREAD_POOL_H
#include <pthread.h>
#define MAX_THREAD 10
typede... |
The following piece of code will print a text based on the divisibility of number.
If the number is not divisible by 3, 5 and 7, then the number gets printed.
Does making use of a f-string make the type cast of integers to string implicit?
def convert(number):
result = ""
if (number % 3 == 0):
result +=... |
I created this package PXP.
PXP enables markup to instantiate objects, call methods, and generate
HTML. It works similar to a server-side templating engine, but rather
than enforcing braces it enables developers to use markup to build
dynamic web pages.
I'm interested primary in feedback related to core implement bel... |
I am new in developer role, and I have my code which I would like to simplify or make it better.
And wondering if someone can do a quick check.
The code calculates the Score of the Bowling game, which is input as a string of the whole game (ex. as following: "X|7/|9-|x|-8|8/|-6|x|X|X||81").
Program.cs
public class Pro... |
I have polylines in a GIS database. The polylines are stored using a user-defined type called ST_GEOMETRY.
ST_GEOMETRY has lots of spatial functions. However, it does not have a polyline midpoint function.
Therefore, I have written a custom PL/SQL midpoint function to fill this gap.
As a novice programmer, I'm wonderi... |
My application (legacy code) reads a CSV input file with an expected format with regards to Column names as follows:
1st column - Should say "Marker"
2nd column - Should say "Category"
3rd column ... to ... N columns - These are the actual data columns. Should have number starting with 1 and increasing by 1 going righ... |
I have modelled a series of school classes as follows.
The part I am not sure about is having a separate table for cancellations and substitute instructors.
With this setup every time you looked up the class schedule for a given week you would have to search the class_exceptions table in order to
see if the class was... |
Context
Me and my team which I'm part of, for most of the time code in Excel VBA. Writing code in it self is pretty enjoyable, but combining our work in a shared repository is pretty painful. The ease our pain of combining/merging binary files, we have decided to help ourselves and create the Source Code Manager modul... |
This code will generate a pseudorandom alphanumeric string of given length.
I would welcome suggestions on how to make it more random. Beyond that, have I made any convention violations, Exception cases, and the like?
Also, is there any way to make it faster?
public class Test
{
public static String getRandomAlphaN... |
I'm also doing the fun little Advent of Code challenges in order to learn Rust. Until now things went quite smoothly, but while I'm proceeding with the tasks I'd love to learn where I can actually improve my Rust coding (and not only getting the correct results).
I'm specifically looking for feedback where I'm violatin... |
I've written a lock-free state machine in go and I would love to receive some feedback on it.
Writing this library my main concerns are keeping it lock-free and very light-weight (no bells and whistles like hooks and such).
Because this is lock-free I had to use atomic.CompareAndSwap which meant that the underlining st... |
I'd like to know there's a better code than I did.
interface AnswerProps{
itemId: string;
value: Array<string>
}
This code works like checkbox. If answers has a value, I try to put the same value again. It would be deleted like toggle.
const App = () => {
const [answers, SetAnswers] = React.useState<AnswerProps... |
I have two datasets. The first dataset “insideMarke1” contains the Best Bid / Best Ask (=BBA) data for a given day, starting at 8.00 am. Every time the BBA is updated, there is a new row with a new timestamp.
The second dataset “orders1” contains order data. The order entry timestamps (‘Entry date and time’) in this da... |
The goal of this code is to handle processes in multiple platforms, Linux initially. Windows later. The high level handler starts and stops a process or a list of processes. The platform specific drivers must conform to the following interface: open(), close() and is_open(). This system is used in test automation.
My o... |
I am attempting to construct a background service for an IIS-hosted ASP.NET Core project that basically queues tasks and runs them, and I decided to go with the IHostedService interface in Core 2.1 because of this tutorial. The tutorial does describe the case of running tasks one-by-one and in the order received, very ... |
I dont now how to optimize me code. The game i created lags 15 fps, how i can it be reduced and optimize.This my code, I try to do optimize, but i cant. Please
help:
import pygame
from random import randint
import time
import os
pygame.init()
name = os.getlogin()
path = r'C:\\Users\\' +... |
Motivation
Python's Abstract Base Classes in the collections.abc module work as mixins and also define abstract interfaces that invoke common functionality in Python's objects.
While reading the actual source is quite enlightening, viewing the hierarchy as a graph would be a useful thing for Python programmers.
Unified... |
I have built an open-source project based on FluentAssertions in order to solve some recurring tasks I was doing while testing the .Net Core APIs I'm developing.
I find the capability of doing in memory end-to-end tests of the APIs I build a great addition in terms of productivity and validity.
With this project I want... |
EDIT1: Suspicion that mariadb++ is affecting my performance results compared to the raw "mariadb/mysql Connector-C"??
EDIT2: I did a barebones C-Only implementation and it comes in at 222ms vs the 262ms using mariadb++. 40ms is significant, given the fixed DB overhead.
EDIT3: Changed mysql_store_result to mysql_use_... |
I have written a function to calculate all strong components in a graph.
How do I make this cleaner and nicer?
import java.util.*
import kotlin.math.min
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of... |
I recently solved Advent of Code 2019 Day 6 in C#.
Part 1:
You've landed at the Universal Orbit Map facility on Mercury. Because
navigation in space often involves transferring between orbits, the
orbit maps here are useful for finding efficient routes between, for
example, you and Santa. You download a map of t... |
Basic idea is to use a Class, with static methods to add and remove references in a static vector, that keeps track of these references, and check that vector upon exit.
The class is detecting intentional leaks that I create, but maybe you can find a case where it does not detect the leak, that I am not seeing
#include... |
I have a sample list which contains nodes and their neighbors, if they have any. The task is to find the node which have the highest number of neighbors.
neigh = [['A'],['A','B'],['A','C'],['B','D'],['C','A']]
The input is undirected. Meaning that ['A', 'B'] are neighbors. While ['A'] doesn't have any neighbors since ... |
My VBA code currently loops for 5,000 iterations and takes about 25 minutes to collect the output data in the Output excel sheet. Is there a way to reduce the time taken for instance by improving the copying and pasting of values, collecting the output data in some kind of array etc.? Given that I will be looping it fo... |
I am an old python newbie here, migrating from fortran77 ;)
Still unsure of the python terminology at the moment :(
The python3 script below fetches a large list of matching files in a folder tree, in the format:
[ fully_qualified_folder_name, [list of matching files in this folder] ]
Being only a python newbie, ther... |
Just for fun, I created a script called TinyBF which can compress Brainfuck programs into a format half their size. For example, take a famous hello world program clocking in at 78 bytes:
--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+.
When put into TinyBF format, it is only 39 bytes:
7#... |
I am in the process of setting up WordPress with WooCommerce, one of the requirements is a bit of integration that takes a person from another website directly to a specific product. I have set the external product references in tags on the products.
An example incoming query would be:
http://localhost/TestSite/search?... |
I have a fair few years experience with programming, and am currently working in a software development role, writing internal web applications in C#.
This is the first C++ code I have ever written, so I therefore don't know the conventions, code smells, do's/don't's of the language.
I decided to write an extremely bas... |
I am creating a small library for controlling bars of leds and have some doubts about my design.
I have 2 basic entities in the design so far:
BarService (and implementation)
template<class T>
class BarService{
public:
virtual void turnOnLeds(T* bar, int end) = 0;
class PinBarService : public BarService<PinBar>{
pu... |
My code here loops through my folder and my files inside the folder and use .find and copy the strings into a new Excel sheet and then with all the data in the new sheet, I will use .Find(What:=) to find the strings inside the new worksheet and then either split or use Right, Left, Mid functions, sometimes using replac... |
I've written this decorator to avoid too many requests to a backend. Did I get it right? Do I need some locks or can I assume some things are atomic / thread safe because this is asyncio?
def batch_calls(f):
"""Batches single call into one request.
Turns `f`, a function that gets a `tuple` of independent reque... |
I'm working on one easy question (Leetcode 1275. Find Winner on a Tic Tac Toe Game) and am wondering how I can make the code even cleaner.
class Solution:
def tictactoe(self, moves: List[List[int]]) -> str:
from collections import Counter
def is_win(pos: List[List[int]]) -> bool:
pos = ... |
I am new to Ctypes. I am writing a piece of code that brings an array of unknown size from C to Python using Ctypes. Unknown size here mean that Python initially doesn't know the size of the array. C code has the algorithm which creates the array.
Somehow after lot of trails, I managed to write code for that:
python c... |
I have a 2D array matches where I store the game id and another array of objects games where I store gameId with the playerId.
Here is what I have done so far:
Step 1: I get the opponent's gameId against the gameId from "matches" array.
e.g. gameId "2" has an opponent "1"
Step 2: check opponent_game in games and retu... |
I am a technical reviewer/writer and I use VBA for Word a lot to manage issues in Word documents I receive. I have frequently come across niggles when using Collections, Scripting.Dictionaries or Array lists. Then I saw some posts on creating a C# library for consumption by VBA. After much reading and research I eve... |
DO NOT RUN THIS EXAMPLE BLINDLY, IT REMOVES ALL FILES UNDER argv[1]
Hello,
This little programm should read all files from a given directory and do some work with them. New files are constantly written into the directory by an outside process. For the duration of the processing, the file should stay in the input direct... |
I made a 26-bit binary Wiegand calculator for an ESP32 following this format:
This is "Arduino C" :
unsigned int * getWiegand(unsigned int dec) {
unsigned int* wiegandNum = new unsigned int[26];
Serial.println();
// transform dec number into binary number and store it in binaryNum[]
int n = 1;
for(int i = 2... |
This is my first post here so I hope you will be patient if I'm doing something wrong. I made a small website with create-react-app and I would like to request feedback about. This website was a test and I had a limited amount of time to complete it, hence there are no tests nor license, which for the test purposes wer... |
This is my script. I want it to run on a weekly basis on my linux server on a Raspberry Pi 4, to back up all files that may have changed. On the GPIO are just LEDs. It requires a program called notify_run, and a file called "BackupSettings.ini" in its own directory that looks like this:
[Sources]
Folder1=/home/pi/Deskt... |
I've tried to solve AoC day 2 challenge in Haskell (here - don't worry, it's not a competition so sharing a solution here is OK).
The goal is to implement a very simple VM with opcodes 1 (add), 2 (mult) and 99 (exit).
I feel like my solution is incredibly verbose. That maybe be because I rely heavily on the state monad... |
Following scenario:
this is the code that resides in Ajax Controller class.
It is responsible for handling input in one of the form fields.
The logic is as follows:
If user-inputted data validate as either Tax Number or Statistical Number, it's supposed to: check for presence of such data in database, and, depending o... |
I am looking for a cleaner, more pythonic way to get a list of the name of the months starting with the current month and ending 12 months later.
For example, it's December so my list should be
['Dec', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov']
Here is how I'm currently doing it:
fro... |
I am collecting 3 years of data and building a string that will be used with an ASP Literal control. The method GetListOfMeetingBygroupId takes in a groupID and year and will return meeting for that group and year.
MeetingService ms = new MeetingService();
int groupId = 574;
//Meeting
int totalYearCou... |
I'm using advent of code 2019 to start learning Python. I've read the Python style guide, and I'm trying to write readable and reusable code.
This piece of code is an implementation of the IntCode computer used in many of the assignments. If you'd like to see code for the specific assignments, it's on my Github.
Here's... |
I wrote a function that I use to preprocess pandas dataframes before running them through a machine learning model. The function works perfectly, however I don't think it's the most pythonic way to write it.
This function accepts a list of words:
['here', 'is', 'a','sample', 'of','what','the','function','accepts']
def... |
This is the first time I am writing R code to access/manipulate and save data. The SQL query I would normally run then save to a spreadsheet, read it into R, save to another sheet then copy and paste that yet to another spreadsheet, then import back into SQL-Server.
Too much going on so I wanted to put it all together ... |
I have created a wrapper for displaying messages with ArcPy and IDLE (as that is all I have available to myself due to certain circumstances) as I frequently use both to test and develop new tools. However I find myself repeating print statements and arcpy functions to display feedback.
Unfortunately, it has to be in c... |
This is a simple password generator. What do you think about it? I am learning C for a while at school and at home. This just has a mix of symbols, lowercase, uppercase and numbers, with a configurable length.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i = 0;
int n = 0;
int r... |
With some basic knowledge of Python and referring a lot of sources, I have written the code below. But it takes half an hour for execution. How can I reduce the time? I read about vectorization but not understanding how exactly I can use it here.
In this, I have to read 2D skeleton images( Size 1980x1080) and Depth ima... |
I need to implement async_read_some from Boost Asio. The reason is here https://stackoverflow.com/questions/59223064/implementing-behaviour-of-boostasio-for-a-class but I don't think it's relevant. Mainly because my code does not use I/O, but I want to fool OpenVPN3 into thinking it's using I/O.
async_read_some passes ... |
I was playing around with the "eight queens" problem, just to see how I could use C++ algorithms to write less code.
I figured out a way to find the next unused column using find_if_not. I am showing both ways of writing it. Assume we are looping over every valid "file" on a given "rank" ( in C++ terms, I am looping ... |
I'm developing a toy project for monitoring some network parameters. Now I'm implementing a feature that will allow to measure a packet round trip between hosts by measuring time between TCP SYNC and TCP SYNC/ACK. One of the options for feeding this application with packets will be setting up capture on network device.... |
This is another review on a program I've asked about before, now translated from VBA into C#. I'm sure I've brought over a lot of bad habits with me, so I'm spotlighting some key areas I'd love open-ended feedback on.
This is a WPF desktop app.
Program Function
As before, this program makes emergency changes to medica... |
I am studying C while listening to a lecture by myself.
When I was studying coding and listening to a lecture, I heard that writing code should be concise and maintainable.
But I didn't know if I was doing well, so I felt the need for feedback.
But it's hard to find anyone who can give us feedback, and I don't know whe... |
A bit of background. In the application I work on there are emails sent to notify users about articles they need to review. Each email+recipient pair is stored in database and may be assigned a different creation date ( called DateCreated ) due to emails being generated over some time.
I needed to calculate how many ti... |
Advent of Code 2019: Day 4
I'm doing Advent of Code this year. Below is my attempt at day 4:
Problem
Part One
--- Day 4: Secure Container ---
You arrive at the Venus fuel depot only to discover it's protected by a password. The Elves had written the password on a sticky note, but someone threw it out.
However, they do... |
The function should return a string with balanced parenthesis. The code I wrote is working for all the inputs below. I am using stack data structure. I suppose this should work for all the edge cases. Can this solution be optimized further?
import java.util.ArrayList;
import java.util.Stack;
public class BalancePare... |
I have written the following program to read from a file (entire input in single line) and check for:
ASCII punctuation characters
a final newline
import re
file_name=input("Please enter the file name ")
with open(file_name, 'r') as fp:
context=fp.read()
regex = re.compile('[@_!#$%^&*()<>?/\|} {~]')
if re... |
I am doing a project to compare the time complexity of 2 string search algorithms.
I lost my previous code due to some issues and so have had to rewrite the majority.
However, this time around, my KMP algorithm seems to be running a lot slower, and I can never actually get it to run faster than my Boyer-Moore no matte... |
I am writing one logic to iterate numbers first and then additional logic to putting them into particular subset of array.
What does this code do:
Code accept first $n
It creates an array of $n number from 1 to $n
Then started converting to subset of $main_array to possible one like
['1'] [1,2] [1,2,3] [2] [2,3] [3... |
I wrote a function which picks a two different random elements from a closed range of ints and returns them as a tuple.
I would like to take a your feedback, if the solution is a "Clever", "Best practice" or "non of them"
func pickTwoRandomElementsFromRange(_ range: ClosedRange<Int>) -> (Int, Int)? {
guard range.c... |
I am trying to implement a basic circuit breaker design for my internal API calls. I would appreciate some criticism and feedback about my code. I am also planning to implement an interface off of the class once I am happy with it. As mentioned this circuit breaker design will be used for internal gRPC calls between my... |
I wrote this method and I would like to refactor it so it is easier to understand and looks cleaner. However, I don't know how or where to start. If you could give it your best shot and explain your approach to how you did it, it would be very helpful to me. The function reduces the size of elements until the parent co... |
I have been using this code for a while. I got it from a tutorial 5 years back. Now I'm wondering if it still is secure, or if it's time to find a new one? Maybe it has never been secure enough.
LOGIN
<?php
//Connect to database
require("include/config.php");
//Empty Variable
$submitted_username = '';
//Check if som... |
I've created a library, TomHart/laravel-route-from-model, and looking to get a review on it. As well as the usual code review, I'm also looking for feedback from a users point of view, if you were to use the library, is there anything extra you wish it did, anything different etc.
The key class is:
<?php
namespace TomH... |
I am following CIS 194: Introduction to Haskell (Spring 2013) online to teach myself Haskell. Following is my response to first exercise of Homework 3. Since I don't have anyone to show my code, I am posting here to get a little feedback. In which ways I could improve this, without getting too much into advanced topics... |
I'd like to improve this operator code if I can. I don't know enough Raku
to write idiomatically (or any other way for that matter), but suggestions
along those lines would be good also.
use v6d;
sub circumfix:<α ω>( ( $a, $b, $c ) ) {
if ( $a.WHAT ~~ (Int) ) {
so ( $a >= $b & $a <= $c );
}
else {
... |
I've wrote a little program that encrypts text by using the caesar-cipher.
Also it contains a little GUI, created by using swing.
Here's the full code:
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.Dimension;
public class caesar {
public static void ... |
So, I have a project that has a lot of methods that look alike.
In the below method as you can see it just fetches a bunch of rows from database and maps it to a model class.
In this case ParkingSlipDetails class.
There are several such methods in the project that do the exact same thing only with a different set o... |
I'm currently learning python and created a simple music quiz. the rules of the game are as follows:
The user has two chances to guess the name of the song If the user guesses the answer correctly the first time, they score 3 points. If the user guesses the answer correctly the second time they score 1 point.The game r... |
As the title suggests, I'm a complete beginner in Haskell. I've just made my way through the "Input and Output" section of Learn You A Haskell For Greater Good and I thought it would be good to try my hand at a simple project like a "Guess The Word" game in Haskell.
The idea behind the game is to guess all the letters ... |
I now processed the suggestions you can find here. I've deleted some duplications and corrected some other minor mistakes.
Here's the code:
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.Dimension;
public class caesar {
public static void main(String[... |
I am trying to solve a codewar challenge (link):
Your job is to create a calculator which evaluates expressions in Reverse Polish notation.
For example expression 5 1 2 + 4 * + 3 - (which is equivalent to 5 + ((1 + 2) * 4) - 3 in normal notation) should evaluate to 14.
For your convenience, the input is formatted such... |
I programmed a Neural Network in python. Feedback every kind is appreciated.
I tried to use some vectorization but it turned out to become quite a mess. Because you can't append to numpy arrays I sometimes needed to use numpy arrays in list and sometime I could use just numpy arrays.
Is there a way to make It look clea... |
I have a password validation class that takes values from our database and depending on their values, checks if the password is valid. If it is not, I built an error message containing everything that is wrong with the entered password.
I want it to be easy to change when I add a validation attribute in the database.
I... |
I'm new to TPL Dataflow and was looking for an action block to basically push an object on a timer - specifically to produce heartbeats on every interval. I was unable to find anything out of the box so I decided to create a wrapper class on action block that would give me the desired functionality. I also wanted to i... |
Below is an example of a simple converter. In the first example temperature I have used a function within a function. In the second example milli I have used a more direct approach. Which would you consider is the better method to handling calculations in functions and why? Also feedback on my approach and examples of ... |
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; th... |
I have RGB Images, Depth images and OpenPose Images(generated from RGB Images).
The number of RGB and Depth images are different so I have to find the exactly which RGB images corresponds to which depth images. This is done using the time stamp values I have for both RGB and Depth Images.
The problem here is this code ... |
This is my first big project that I've decided to release publically. It's available on my Github, and through pip3: pip3 install delicioussoda.
This is a simple parser for robots.txt files for a website. And yes, the name "DeliciousSoda" is a play off of "BeautifulSoup".
As I intended to keep developing and adding mor... |
I'm writing a toy vector library in C to learn a bit about the language. The excerpt below shows my vector structure and two functions:
vec2_magnitude calculates the magnitude (length) of a vector
vec2_unit uses the magnitude to calculate the unit vector
#include <math.h>
// A fixed-length vector w/ 2 elements.
type... |
Here is my code:
defmodule LineScanner do
@spec scan(String.t()) :: [Token.t()]
def scan(line) when is_binary(line), do: scan_(line, {[], ""}) |> Enum.reverse()
### The function below needs some refactoring ######
@spec scan_(String.t(), {[Token.t()], binary()}) :: [Token.t()]
def scan_(line, {acc, ... |
This is a follow-up on Change size of elements until parent reaches certain height
The goal of the function is to find a size for the elements inside a parent, so they all fit in a single row. I tried it with a loop (check previous question), and now I changed it to if statements. However I would like to simplify it, b... |
The below code is either inserting or updating a list of person with a lot of properties of these persons. The code is repeating itself a lot but is working as intended.
Unfortunately making all the types implement a common interface is not an option for me.
public void BulkInsertPeople(List<Person> persons, User reque... |
i am trying to learn mvc (model view controller). there are many texts out there explaining what mvc is. but not many explaining how to actually code mvc. i found a bunch of questions here asking about mvc. some seem to contradict each other (view observe model or not, controller listens to view or not).
i made a simpl... |
I just wrote a short function to parse SO jobs XML feed and return dicts containing information about each job entry.
Now, each job entry page is visited to grab info not present in the xml feed (company logo URL, salary info, etc.) through bs4 with couple functions in the get_so_extras module.
parse_feed.py:
from date... |
I've implemented the cryptographic method of the Fleissner-grille aka Turning-grille .
Here's the code:
import java.util.Scanner;
import java.util.Random;
public class fleissner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Scanner scanner2 = new Scanner(System... |
My professor told me to optimize my perl code, but he wouldn't tell me what exactly - just make it simpler.
I changed some little things but nothing major. Am I missing something?
The task was:
Perl program that allows the user to simulate the simultaneous
throwing of several cubes. The simulation result is then a t... |
I'm implementing LZ77 compression algorithm. To compress any file type, I use its binary representation and then read it as chars (because 1 char is equal to 1 byte, afaik) to a std::string. Current program version compresses and decompresses files (.txt, .bmp, etc) just fine – size of raw file in bytes matches the siz... |
Could you review the approach and let me know if there is a better way to implement the same using different java techniques (also performant)?
Requirement as follows:
The products that are returned for a request, need to be ranked to offer the most relevant product to the user. we will rank based on weight and then o... |
I have this code snippet comparing two slice references:
fn compare(&self, a: &[u8], b: &[u8]) -> i64 {
let mut p1 = a.as_ptr() as *mut u8;
let mut p2 = b.as_ptr() as *mut u8;
let mut min_len = cmp::min(a.len(), b.len());
let mut ret = 0;
while min_len > 0 {
unsafe {
if *p1 != *p2 ... |
I needed in my project to import .txt files without knowing their encoding, but knowing, they will most likely be in Czech or Slovak language. Sadly there is bunch of possible encodings so I decided to create code, that will try to detect encoding based on content of this ByteArray.
Idea is to:
Convert all characters... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.