instruction stringlengths 71 95.1k |
|---|
I wrote a program where the computer guesses a random number.
To do this, I implemented a form of binary search. This correctly handles any edge-cases that I know of, including 0 and std::numeric_limits<int>::max(). This doesn't handle negative numbers (since rand will never return one) but that could easily be fixed.
... |
The gist of my program is to simulate the growth of some virus. I used (attempted) OOP concepts to break down the problem into chunks and have the chunks talk to each other.
Not sure if my implementation is effective but it seems to work pretty good. Currently, the bottleneck seems to be in the plotting. I'm still le... |
I'm trying to develop a web application for documentation..
The tool is functional.. Please review the code & help me with performance tuning & simplifying the JavaScript part..
Any suggestions or comment most welcome. Thanks in advance!
Note: Please type something on the <textarea> to see the live preview
$(functio... |
I wanted to try and learn multi-threading, so I thought it would be good to make a small program normally first and make it multi-threaded, so I made this prime finder.
from time import sleep
def prime_finder(num: int) -> bool:
"""Checks to see if a number is prime"""
if num == 2:
return True
divi... |
I use zypper to download and install for openSUSE Tumbleweed (much like everyone else of course). Unfortunately it downloads packages serially, and having about a thousand packages to update a week, it gets quite boring. Also, while zypper can download packages one-by-one in advance, it can't be called concurrently. I ... |
https://leetcode.com/problems/search-a-2d-matrix/
Write an efficient algorithm that searches for a value in an m x n
matrix. This matrix has the following properties:
Integers in each row are sorted from left to right. The first integer
of each row is greater than the last integer of the previous row.
Example 1:
... |
I finally finished my Conway's game of life in c++ project and i'd love to find out how to improve the code.
main.cpp
#include "Engine/Engine.h"
int main()
{
Conway::Engine Engine(1280, 1024);
Engine.Run();
return 0;
}
Engine.h
#pragma once
#include <SDL2/SDL.h>
#include <memory>
#include "Board.h"
//... |
I have two tables with a 1-many relationship, Device and TestResult.
My application has a filter builder front-end that allows a user to retrieve TestResults based on whatever filters they specify. This generates queries similar to this:
SELECT d.id,
d.serialNumber,
d.createdAt,
r.id,
r.tes... |
I had a coding assignment task(interview) for a senior data engineer role, JSON data validation. Every record in the input json indicates a customer record, I need to write a script to validate that all records confirms to few business rules and few more field type/length restrictions.
I used object-oriented, meta-data... |
I am attempting to animate the series of button presses in the simon game I am creating with tkinter. The animate method is called for each button that needs to be pressed in the series. It currently presses all of the buttons at the same time rather than in a series as it is meant to.
from tkinter import *
from random... |
I'm trying to recreate the method inject (Works like Reduce) from ruby Enumerable Module.
Using Rubocop (A Linter) I got the error:
Cyclomatic complexity for my_inject is too high. [7/6]
The code is:
module Enumerable
def my_inject(*args)
list = to_a if Range
reduce = args[0] if args[0].is_a?(Integer)
o... |
I've built a simple Book list app. It allows users to enter the name, author and isbn of a book into a form. Then when this is submitted successfully, the details get added to a new row in the table.
I've tried to make the code as optimal as possible. Any feedback would be greatly appreciated.
const bookList = document... |
I've always wondered what's the most elegant way of implementing PrintLn in C++. I have not yet come with perfect conclusion. This is my shot.
Shortcut for std::cout, std::cerr and std::clog "print line" version. So you can type
CoutLn << "Hello world!"; instead of std::cout << "Hello world!" << '\n';
CoutLn, CerrLn, ... |
Wrote my first mini-script to get data from the german football league table and save the data to a csv file. Do you like the approach or could I be more efficient? Thanks in advance!
from bs4 import BeautifulSoup
import requests
import csv
url = "https://www.bundesliga.com/de/bundesliga/tabelle"
r = requests.get(url... |
I wrote this to make the "callback hell" more manageable on the part of the coder when using Socket IO, so that there wasn't really any callback hell to go with, just a simple await.
This should work with any socket implementation, so long as it has socket.on, socket.emit, and socket.removeListener.
function emit_and_w... |
I've written a generic data adapter that can make use of a cache, for use in a data access layer. It presents an interface allowing CRUD operations, as well as retrieving all objects of a certain type.
IEntity.cs:
using System;
namespace GenericDataAdapter
{
public interface IEntity
{
Guid Id { get; se... |
My initial problem is to transform a List of Mappings whose values are Lists of values. The transformed list must contain the Cartesian product of all lists (those that are values in the dictionaries) that belong to separate dictionaries (in other words, the values of the lists present in the same directories are "coup... |
Consider the following structure,
let condition = { and: [ { id: 3 }, { pageId: '1' } ] }
I want to get the id property value in a recursive way, it can be also nested inside other conditions.
for example the structure could be like that
let condition = {or: [{ and: [ { id: 3 }, { pageId: '1' } ] }, {age: 10}]}
I end... |
This is a two player dice game where two players each roll two dice. If a player's dice sum is even, they gain 10 points. If the dice total is odd, they lose 5 points.
import random
import time
import sys
print("*****************Welcome To The DICE Game*******************")
abc=input("please type in 'n' if your are a... |
I'm trying to properly write a card class in swift. I've been taking classes in software engineering and I need help in understanding how to take a more object-oriented approach to my class. I have seen a Class for suit and rank and I'm wondering would that approach would be better? I have also seen the suit as enums a... |
One of my react component's methods is using an async fetch() internally. After fetching the response from the server, it is being converted to JSON, then I perform a check on that JSON string. Finally, I return the result wrapped in a new promise. Here is the code:
fetchCalendarData(offset, length) {
return fetch(... |
I implemented the linked-list natural merge sort in Python, and I referred to this awesome if not poetic gist and this implementation in Go. Here is my code:
# Linked list is either empty or a value and a link to the next list
empty = None # empty list
class LL(object):
__slots__ = "value", "next"
def __init__... |
Given a string, find the first repeating character in it.
Examples:
firstUnique("Vikrant") → None
firstUnique("VikrantVikrant") → Some(V)
Scala implementation:
object FirstUniqueChar extends App {
def firstUnique(s: String): Option[Char] = {
val countMap = (s groupBy (c=>c)) mapValues(_.length)
def chec... |
I am trying to solve the following minimization problem:
$$
\min\lvert\lvert{x}\rvert\rvert_1 + \beta\lvert\lvert{x}\rvert\rvert^2_2 s.t. \sum_{m = 1}^M (y - \lvert{c}^{H} . x\rvert^2)^2 \le \epsilon
$$
x: my unknown value (input) with complex elements and known size, here (4x1)
y: the output vector (known)
c: a 'ska... |
I have been looking at homemade CNC and have been wondering how curves are drawn, so I looked into it and found this cool article. I then decided to try coming up with a bezier curve algorithm in C. It seems to work ok, and while I haven't tried plotting points with this exact implementation, it seems to match up with ... |
I have this following module using for adding and enabling/disabling Windows Firewall rules using Python.
I currently use subprocess.call to execute the netsh command inside Python. I'm wondering if there is any better method to do this? Executing the cmd command inside Python seems to be impractical to me.
import subp... |
At the moment, I'm learning and experimenting on the use of web scraping content from different varieties of web pages. But I've come across a common smelly code among several of my applications. I have many repetitive List that has data being append to them.
from requests import get
import requests
import json
from ti... |
I created a linked list in C++ using class with few methods to provide interface for it.
Methods are pushFront(), traverse() and few more as shown below. PushFront is used to insert the data at the head of linked list at any given time. traverse is to display the linked list at any time. My code is shown below:
#includ... |
Write a simple monitoring navigation function.
I feel logic judgment still needs to be optimized.
I don't have a clear idea right now about code logic such as reducing if statements
How can I optimize the performance of this code?
<!-- =panel: start -->
<div class="panel" role="region"></div>
<!-- =panel: end -->
... |
I've been working for a while on locking resources (state objects) so that the only way to access them is by acquiring a lock. This moves the responsibility for locking from the user of the state to the state itself. I wanted something with a lot of syntactic sugar so that once the lock is acquired the state object is ... |
My code-editor "show hints" says that the method length exceeds 20 lines. How can I refactor the setEmailTemplateBcc function?
private function setBcc($bcc)
{
if ($bcc) {
$this->bcc = explode(',', $bcc);
}
}
public function setType($type)
{
$this->setEmailTemplat... |
I have the function which builds and return Slack message with text and attachments. How can I refactor this function to make it easier to test? Should I split it into multiple functions?
def build_list_message(team_id, user_id, msg_state=None, chl_state=None):
if not msg_state:
msg_state = {}
if not c... |
Pretty straight forwards really...I know that it's usually bad practice to repeat your code so I'm wondering how I could join handleAuthorChange() and handleContentChange() into one method. I guess it was hard for me to find a solution because I don't understand how I would know which part of the state I'm updating. I ... |
I'm currently working on a complete overhaul of the CSS of our flagship product with a goal of maintainability and simplification. During the testing, my coworkers and I have found that a lot of pages aren't exactly coping well with extremely long user-defined values, leading to things like long scrollbars, buttons bei... |
This is a very specific question mixing up stochastic knowledge and VBA skills. So very exciting!
I'm trying to compare several methods for generating standard, normally distributed numbers given a source of uniformly distributed random numbers. Therefore I'm implementing the Box Muller Algorithm, Ziggurat Algorithm an... |
I have implemented Dijkstra algorithm to perform Shortest Path problem.
Input:
Adjacency List(Directed Graph): Description is like that
{Source Node, {edge_1, .. , edge_N}}
Cost Matrix (Same format as Adjacency List)
Queue: Priority Queue
Input to "Shortest Path" method are Start Node, End Node; it returns -1 if
there ... |
For an assignment, I had to draw a checkers board, with blue and red checkers, in python. What I have works, but I'm wondering if there's a more elegant and/or efficient way to accomplish this feat? Any and all suggestions are welcome!
import turtle
def draw_box(t,x,y,size,fill_color):
t.penup()
t.goto(x,y)
t.... |
I wrote a simple circular queue. (in order to store characters because of the fact, that I am using UART through the DMA and sometimes my printf's override each other)
I am looking for some review, though my testfile was successful I have the feeling I've overseen something and the queue might be buggy at some point.
I... |
The web-scraping process currently takes quite a bit of time, and I wonder if I can structure the code otherwise or improve it in any way.
Code looks like this:
import numpy as np
import pandas as pd
import requests
import json
from sklearn import preprocessing
from sklearn.preprocessing import OneHotEncoder
results_2... |
I wrote the following program for encrypting PDF Files for checking out the PyPDF2 module.
It takes a path and a password via the command line or user input. Then all PDF files in the provided folder and subfolders get encrypted.
edit: the counterpart to drcrypt can be found in Decrypting PDF-Files
pdf_encrypter.py
"""... |
I thought it might be useful if reading could at least sort of mirror writing. For example, if I write some output like:
somefile << "foo: " << foo << ", bar: " << bar;
...it would be nice if I could read it back in like:
somefile >> "foo: " >> foo >> ", bar: " >> bar;
So, this code attempts to support that:
#ifndef ... |
Fairly new to writing tests. I hoping to get feedback about test writing. I am curious to know if there is a convention/standard for short is better or more informative is better?
A) expect(mqError).to.not.be.null;
B) expect(mqError).to.be.an.instanceof(MonqadeError);
C) expect(mqError.code).to.eq('MongooseValidationEr... |
For an assignment, I had to loop through a text file, and report any positions that a user entered sequence was found. Is there any way I can make this code more efficient, because it seems like I'm writing a lot of nested loops, which I've learned can be dangerous/complicated. Any and all help is appreciated!
import o... |
I'm working on a project which due to the complexity of the business logic has had to pull out some classes to do computation related to some values in a database. To link the code and database, both when inserting and selecting, I need to get a list of all the class names contained within a single file. It works for m... |
So I've been experimenting various way to get data from different variety of website; as such, between the use of JSON or BeautifulSoup. Currently, I have written a scraper to collect data such as [{Title,Description,Replies,Topic_Starter, Total_Views}]; but it pretty much has no reusable code. I've been figuring out h... |
I made an A* pathfinder and it was too slow so i did some research into priority queues, i got it working but i am wondering if there is any improvements i can make for this class.
I opted to make a constructor that allows the option of min or max order, since it runs on the pathfinder the performance of this is quite ... |
Here is a simple reimplementation of most of std::vector. I want to check if I implement it correctly but the standard libraries source code is not very readable for me.
namespace nonstd {
template<typename Ty>
class vector
{
public:
using iterator = Ty * ;
using const_iterator = const ... |
I've coded a React component which should display search result and give the user the option to scroll down and retrieve 25 more objects to be displayed when the scrollbar hits the bottom. What I've noticed when I compile and test the component is that the filter buttons to mark is really slow: it takes a couple of sec... |
I have a assignment to find which season has the biggest temperature amplitude. Input par is the int array with temperatures:
int T[]= {-1,-10,10,5,30,15,20,-10,30,10,29,20}
which means:
winter: -1,-10,10 spring: 5,30,15 summer: 20,-10,30 autumn: 10,29,20
temp is always an int,
int[] T - T.length%4 is equal to 0 (... |
I am testing my repository class:
interface AccountRepository{
void save(Account account);
Optional<Account> findById(Long id);
}
And when writing tests, I ended up with two semantically different tests, but they essentially contain exactly the same code:
@DisplayName("user exists -- account does not exist -- ... |
I'm trying to model a tournament with Python (Django) and I've got a function that assigns teams of the previous stage to the groups of the new one.
The teams in the first stage are assigned manually.
Every Stage have OneToOneRel to the previous Stage.
Team model is related to the Group through Score model, that has F... |
I have a function that looks up in a list the elements which share same values in order to group them.
As a fast summary, this should be the input/output:
[A, A', B, C, B', A''] --> [[A, A', A''], [B, B'], [C]]
I do not care about order. It could also produce:
[A, A', B, C, B', A''] --> [[B, B'], [A, A', A''], [C]]
... |
I have a "GetPersonsPerDepartment()" method returning a IQueryable<IEnumerable<Person>> while I'm trying to get a simple List<Person> or IEnumerable<Person> with all the persons from every department. I wrote a simple method GetAllPersons() that solves this with a loop but I feel I must be missing a simple command to g... |
I developed a maze navigator in Java for a project for my school. It works fine, and it gets through the maze just fine. The program prints to the screen each time it loops through the maze to set the next position. Note: there is only one path because I haven't implemented a multiple path algorithm yet. Is there any w... |
I joined this 2 tables and dropped the user_id afterwards. I am defining the user_id elsewhere in my code based on my session/cookies and I do not want to return this value as a global. Is there a more compact or elegant way to write this:
public function test($user_id)
{
$stmt = $this->conn->prepare("CREATE TEMPOR... |
For a school project, I had to make a keylistener that would output whatever you typed to the screen. A JFrame would be initialized to have the focus required for the listener to work. It uses delete and shift methods to determine what to type/delete. Is there any way to make this more efficient, since I have two metho... |
I got a programming question on an interview where performance was the focus. I couldnt come up with a better solution than the one below which I think has a time complexity of O(n^2 + n) and scored 20/100 on performance.
The question in short was to find the highest result by adding two elements and in an array and th... |
Recently I found a question on StackOverflow that seemed very interesting: How to make HTML elements "zig zag" this way:
-----------------
|A > B > C > D > E|
|J < I < H < G < F|
-----------------
---
|A H|
|B G|
|C F|
|D E|
---
I was able to implement a simple solution for this problem with Flexbox and a bit of ... |
I'm trying to learn how to use Qt (5.11.1) for GUI applications so I've done a simple memory game where 12 tiles are displayed and every time the user clicks on a tile it will show an image, so they have to match them into 6 pairs of images.
There's a countdown of 1 minute. Game ends if the time is up before all 6 pair... |
I wrote an implementation of php FilterIterator objects that allows me to apply them in a "cascade" way, so I can finally obtain an array of objects which is the result of all those filters.
It works fine, but - being new to SPL objects - I'm wondering if there is a better way to achieve the same results with FilterIte... |
I'm trying to extract all files (XMLs) from an ftp site with python and the ftplib module, but it's incredibly slow so I suspect I'm doing something wrong.
The files are in subfolders, and all at the same "depth" eg: 'startingdir/folder1/place1/file.xml', 'startingdir/folder1/place1/file2.xml', 'startingdir/folder1/pla... |
In Encrypt PDF-Files I provided a Python program to encrypt PDF-Files in a folder.
This program here does the oposite. Giving a password and path all PDFs which are encrypted are decrypted in the supplied path. If the password is wrong a message is displayed.
pdf_decrypter.py
"""
Decrypts all files in a folder and sub ... |
I've written a lot of C++ but now I'm learning Swift. I did an exercise, the standard Sieve of Erastosthenes. It works fine, but it seems a bit clunky and I wonder if I'm missing some language features that might streamline it a bit and make it more idiomatic Swift.
Here's the code:
struct Sieve {
let primes: [Int... |
I was hoping that someone could review this code.
My main concern is that the contents of main() are difficult to read. I thought about extracting some segments of code into functions (to aid comprehension) but it felt unnecessary because these segments are not completely repeated.
#include <SFML/Graphics.hpp>
#includ... |
I have written a C# class to perform LZ77 compression ( per RFC 1951 ), to incorporate in my RFC 1951 deflate implementation ( posted on Jan 2 ).
The usual method (per RFC 1951) is to use a 3-byte hash to get started, then iterate through a chain of earlier 3-byte matches. However this can be slow if the chains become ... |
I have a "working sheet" that contains 15000+ rows. In column A is an identifier for that row. There are over 20 different identifiers i.e 9W, AM, AV, BG, CY, HJ etc. etc.
My current code looks for each row on "Working Sheet" that has 9W in column A, cuts and pastes that row into a sheet called 9W. Once finished it mov... |
I made a Flask app that consists of 3 pages.
Index: Indexes to the 2 pages
SubnetOverview: SSH's into the server and executes ifconfig, then returns the output to a webpage.
AddSubnet: Has a HTML form where the administrator can fill in the desired VLAN id and subnet. This gets added to the netplan file and netplan a... |
I was recently asked this question in an interview. Here is the solution I came up with. Please let know if I could have done this differently or in a more efficient manner.
The question is as follows:
Determine The Top Two Clothes Sizes In The Following Array
["XS","S","S","M","L","XL","XLL","XL","XL","M","M","M","XS... |
The The Hardest Logic Puzzle Ever recently came to my attention:
Three gods A, B, and C are called, in no particular order, True, False, and Random. True always speaks truly, False always speaks falsely, but whether Random speaks truly or falsely is a completely random matter. Your task is to determine the identities... |
I have the following code that I managed to make thread-safe but I am not sure if I am using C++ technology optimally.
#include <iostream>
#include <omp.h>
//#include <memory>
class GenNo
{
public:
int num;
explicit GenNo(int num_)
{
num = num_;
};
void create(int incr)
{
num... |
I'm using the flutter_simple_permissions plugin to request permission to read contacts on my flutter application. I want the app to quit when a user denies the permission, and need to show them a custom Dialog.
Future<bool> getContactsPermission() async{
bool hasPermission = await SimplePermissions.checkPermissio... |
I am using PHP, and I am getting the value back from the form. Since I am working with time, I have an array by (1 x 4) x 7, and I feel like I could do a better job at it. I just don't know exactly how should I approach the problem
$schedule = array(
round(abs(strtotime($_POST['mon'][1]) - strtotime($_POST['mon'][0... |
I'm writing a script that's changing the background color depending on hour of day, if it is a weekend or if it is a Swedish holiday. I have a functional script and as I want to improve my programming skills I want to see if there's anything I can do differently or more efficiently.
I wanted to work with separate funct... |
The code below is for a slideshow that shows a slide with class active, pre-loads a slide with class next, and holds the slide with class last in the background.
My biggest issue with this is there seems to be lots of duplication and probably very inefficient code here that I would like to improve upon, but do not yet ... |
I'm writing a server for an MMO game using boost::asio. I would like to know, are there any design or other issues in my code? And what should I improve in it? Thanks in advance.
BaseServer.h:
#ifndef BASE_SERVER_H
#define BASE_SERVER_H
#include <asio.hpp>
#include "MessageProcessor.h"
class BaseServer
{
public:
... |
I need to calculate the BLACKLOG_M value corresponding to the Snapdate of the first of the month. It becomes a constant value repeated for each line of the month
As it is explained in the picture:
SELECT T1.SNAP, T1.PERI, T1.ANNEE, T1.MOIS, T1.[BCKL], T2.[BCKL] AS BCK2,[NBR1]
,[NBR2]
FROM stg.FACTSAL... |
I want to search for a pattern in a time-series while either ignoring the mean/shift/bias or the scale/standard deviation.
Consequently, I've written two functions.
The first function searches passes through the time-series, incrementally calculating the mean for each search-space sub-sequence and using this mean to no... |
This question is the real question asked on StackOverflow. I'm here to review my answer and see how can I optimize it.
Here is the answer text:
This is a basic approach, but it proposes a proof of concept of what might be done. I do it using Bash along with the usage of the GCC -fsyntax-only option.
Here is the bash s... |
I've been working on longest mountain in array on Leetcode:
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:
B.length >= 3
There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]
(Note that B could be any subarray of ... |
I am trying to sort the options within a SELECT element. I wonder if I am doing it stupidly or not, so perhaps someone can look at it and provide suggestions.
// Function Name = sortSelect(jsID, tagAttr)
// Function Purpose = Sort elements within a select element by supplying the ID of the select ele... |
I've created a system to generate tokens that could potentially be used in some sort of program:
# _gen.py is simply to generate the tokens, not to check them.
import string, secrets, random
# String is for getting all ascii letters and digits.
# Secrets is for a cryptographically secure function to choose chars.
# R... |
I have been recently trying my hands on Euler's Project through HackerRank and got stuck with project #3 where you have to find the Largest Prime Factor.
Question: The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of a given number N?
I have written two different codes which both work for... |
I'm trying to expand on the implementation of static_vector on the std::aligned_storage reference page, but would like to split it into two parts. First, an aligned_storage_array that supports perfect forwarding (so that I can emplace into it) and doesn't require a default constructor, and then the actual static_vector... |
I made a simple password cracker using Python. But it's extremely slow. Here is my code:
import itertools
import string
import sys
import socket
def connection(ip, user, passw, port):
s = socket.socket()
s.connect((ip, int(port)))
data = s.recv(1024)
s.send(('USER ' + user + '\r\n').encode())
data ... |
My goal is to go through the list of all English words (separated by '\n' characters) and find the longest word which doesn't have any of these characters: "gkmqvwxz". And I want to optimize it as much as possible. Here's what I came up with:
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h... |
Problem
Given a Dictionary with user_id and a list of alert_words (words
and phrases too look for in an sentence) and a string content. We
have to look if the alert_words appears in the content and return
the list of user_ids who's alert_words appears in the content
Example
input = { 1 : ['how are you'], 2 : ['y... |
I am using this code to forward my syslog logs (converted to json using syslog-ng) to Azure Log Analytics on an ARM board (since there is no official client for ARM). It uses the HTTP Data Collector API to submit the logs.
The idea is to read logs from stdin (each line is a JSON object) in separate thread with a buffer... |
A year ago, I implemented an evaluation algorithm for Conway's chained arrow notation in Python. I'd like to get a review on my code, especially about readability and if it is pythonic. I'd also like to know if there is a bug. I'm not too much concerned about performance since this notation runs faster into unsolvable ... |
This is my Singly Linked List implementation in ES6.
class LinkedList{
constructor(){
this.head = null;
this.size = 0;
}
insert(item){
this.size ++;
let p = new Node(item);
if(this.head === null){
this.head = p;
}
else{
p.nex... |
Initially, I was using the class syntax to structure my code. While it sure did feel nice to work with, I found it lacked some important functionalities, like private properties and interfaces. Things that I had found useful in other OOP languages like Java.
I understand JavaScript doesn't have classes, I'm trying here... |
I have started to learn C. At the time of writing I don't know anything about the language. The following I wrote today in a few hours. Though I do have a lot of programming experience, I find C hard to learn. That may be only a temporary impression, however.
The purpose of the following function is to determine if th... |
I have an assignment to draw rectangles that get larger and larger each time I draw them. Just like shown below. I've labeled them TL = Top Left, TR = Top Right, BL = Bottom Left, BR = Bottom Right. The smallest boxes are 8 pixels by 8 pixels. From this drawing I pulled these algorithms for each box. Where n represents... |
I'm implementing HTTP traffic monitor (proxy) for my project right now. It's performance is satisfactory. I've updated regex settings and improved performance but I think there are also ways to make it better.
//mipt
public class TrafficMonitor
{
private int _port;
private bool _isWorking;
private TcpListen... |
The aim of my code is to decode an image format that is based on the JPEG chain of compression/decompression, however it is not compatible with the default JPEG flow as far as I know, since all libraries I have tried fail to properly decode the data. I am only interested decompression in this case. It follows the stand... |
Could you guys tell me if my code is safe? And i want to know how to improve it. You will see a detailed explanation about the code on the comment blocks inside the code.
profileIMGform.php
require_once 'db.php';
if(!empty($_SESSION['user_id'])){
$user_id = $_SESSION['user_id'];
}else{
$user_id = NULL;
}
//... |
After working on it, my regenerating reserve vector may not be so bad after all. (In this stackoverflow question, I presented a vector with a regenerating reserve, faster at push_back when reserve can't be predicted).
Deque may be cool, but the vector is faster. So, I ameliorated my Vector, with two reserves: one befor... |
I've been learning to code in my spare time for a couple of years. I have covered object oriented stuff before and can usually understand other people's object oriented code. This is the first time I've written an object oriented program from scratch.
It has all the functionality that I want and (hopefully) no mistakes... |
I saw a programming puzzle. Find a string containing letters from a to z such that its MD5-hash starts like 314159265359. I am a junior programmer so I would like to know if I can solve the problem faster that checking firs strings a-z, then aa-zz, then aaa-zzz and so on. As the computation takes time, I save results t... |
I am learning Python for a few weeks. Last time I started object-oriented programming and I feel like it is really hard for me to write the relation between methods and attributes for different objects.
I tried to write simpler version BlackJack card game only with Hit or Stand option.
Could you have a look at my co... |
In the absence of feature-complete and easy-to-use one-hot encoders in the Python ecosystem I've made a set of my own. This is intended to be a small library, so I want to make sure it's as clear and well thought out as possible.
I've implemented things from a previous question concerning only the base encoder, but als... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.