instruction stringlengths 71 71.9k |
|---|
Here's the code:
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <exception>
const int PRECISION = 100;
typedef boost::multiprecision::number<boost::multiprecisio... |
The goal is readabilty. Performance is not much of a concern, since it's not going to be used with large amount of data.
Except for degenerate case when the length of the incoming byte array is zero, the dump does not end with a new line character. This is regardless whether ASCII part of the dump is shown or not. The ... |
I am a Python beginner, and I wrote a simple Python program, which does the following:
search the pattern in the lines of a file (contains messages)
pick the information from the lines and save it to disk
remove the messages which matches with the regex (regular expression)
saves remaining messages to another file,
... |
I work on a project with time series data. So there are samples (\$y\$), and each sample has a timestamp (\$x\$). The data will be visualized, but often there are time series which contain samples that do not change over several timestamps. In a visualization (a \$y(x)\$ plot) those repeated samples can be removed, sin... |
I implemented a function to shift an element after another in a logical circular array. Shifting in this case simply means moving element at position i to in front of element at position j. Of course I can't simply swap the elements at position i and next(j), because I would alter the positions of two elements in this ... |
I wrote a scheme procedure that converts strings such as "Two hundred and fifty" into a number like "250" that I can use in math calculations (It's for some Natural Language Processing project).
Is this the most efficient way of implementing it in (Guile) scheme?
; This scheme procedure convers strings like "two hu... |
This is my implementation of a Ceaser's Cipher in Python using OOP principles. I'm looking for feedback for any code starting from the function build_shift_dict (line 89) as I wrote that code myself. Feedback on the earlier parts will be useful but not as much as it's not my actual code (but is included so the whole pr... |
Problem
Currently my project utilises local caching wherever possible. There is a lot of similar looking code throughout that takes the form:
private static readonly ConcurrentDictionary<int, object> GetPMLocks = new ConcurrentDictionary<int, object>();
/// <summary>
/// Retrieve a PM by it's unique ID
/// </summary>
... |
Tidyr is an R package for creating tidy data.
(tl;dr)
In short, it provides an interface (gather) for restructuring a table into a "tidy" format. For our purposes here, it suffices to explain that each row should only contain a value for one observation. The row could contain several fields, but these are fixed factors... |
This HackerRank problem (based on Project Euler problem 160) says:
For any \$n\$, let \$f_b(n)\$ be the last five digits before the trailing zeroes in \$n!\$ written in base \$b\$.
For example,
\$9! = 362880\$ so \$f_{10}(9)=36288\$
\$10! = 3628800\$ so \$f_{10}(10)=36288\$
\$20! = 2432902008176640000\$ so \$f_{10... |
I have list values with their IDs like this:
ID Value
A 1.2
B 4.2
C 7.2
D 10.2
In C#, I want to find the ID with the closest value to a given value say 3.9. In this example, B will be the answer as it has the value(4.2) closest to the given value.
My solution to this problem involved following steps:
... |
Ok, so I'm querying a webservice. This webservice is slow with multiple o's. I want to cache the results of the query, because I only want to query on a given set of parameters once during my transaction (In addition to the query being slow, it's also rate limited, so I don't want to perform unnecessary queries). Final... |
I am trying to speed up my current implementation of a function that converts [UInt32] to a [UInt8] which in turn is split up into [[UInt8]] with 6 arrays at each index.
extension Array {
func splitBy(subSize: Int) -> [[Element]] {
return 0.stride(to: self.count, by: subSize).map { startIndex in
let... |
I am trying to extract names from a body of text to use as stopwords. I tried a few different approaches to identifying names (or proper nouns in general) below. The second approach is much faster than the first, but is admittedly a much more naïve approach (misses out on names like 'PETER' or misspellings like 'jOHN')... |
An includable select to pick the first day of quarter:
<cfparam name="dtFirst" default="#now()#"><!--- first date in select --->
<cfparam name="selQtrName" default="selQtr"><!--- name attr of select --->
<cfparam name="selQtrCss" default=""><!--- special style css --->
<cfparam name="howManyOpts" default="10"><!--- how... |
I have coded a fully working permission system for my gaming emulator to determine permissions for users.
What I really want to know is:
Is my code standard good enough?
Is the design of the class good? (Not sure about so many Initialize methods)
Are there any parts of the classes that can be improved (even small impr... |
I've written a short python script that attempts to solve the problem of finding the longest common substring using the dynamic programming technique. It is meant to be generalised so I could plug in any number of strings and it would find the longest common substring.
def longest_common_substring(*strings):
table ... |
I have the following code where EnableForm() is called in response to various conditions. Now I had to add one more condition and this makes it even more complex. How can I simply it?
void CValidateDialog::ProcessTime(string time, const int min, const int max)
{
if (!time.empty())
{
if (min > 100 && max... |
I'm trying to get some information on how to improve this function in Javascript using ES6/ES7
function inclusive(min, max, input) {
var difference = function(a, b) {
return Math.abs(max - min)
};
return Array.apply(0, Array(difference() + 1))
.map(function(element, index) {
var integer = index + mi... |
I have created a recursive function call in AngularJS and just wonder if is there a better way to solve this problem? The code works perfectly.
My code is the following:
function getLocation(query, map, object, delay) {
var deferred = $q.defer();
var service = new google.maps.places.PlacesService(map);
serv... |
My code:
# Filename: P05_Numbers.py
# Author: Joseph Chua
# Date: 10/24/2016
# Purpose: Evaluating an input and comparing them.
# Other: http://repeatercreeper.me
#========================================================#
# Variables/Input #
#=====================================... |
I solved the HackerRank version of the Largest palindrome problem (similar to Project Euler 4) in Python:
Find the largest palindrome made from the product of two 3-digit numbers which is less than N, where 101101 < N < 1000000.
How can I make this more efficient? My solution keeps timing out.
Here is the Code:
# Fin... |
I've implemented a generic data structure to keep track of the median in a streaming list of numbers. I was hoping to gather the community's feedback on code style and taste.
package ad.collections;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.*;
/**
* Created by adhulipa ... |
In my controllers, I have the following:
[System.Web.Http.HttpPost]
[Route("api/report")]
public async Task<HttpResponseMessage> Report(ReportDto report)
{
await _profileService.SubmitReportAsync(User.Identity.Name, report);
return Request.CreateResponse(HttpStatusCode.OK, true);
}
... |
app.js
var employees = require('../models/employees');
employees.read(req.params.id, function(body) {
console.log(body.firstName);
});
models/employees
var request = require('request');
var employees = {
read: function(id, callback) {
request
.get('http://api.mysite.com/employees/' + id,... |
(https://github.com/trvshrmn/slim)
This is more of an entire project review... if this is 'off topic' I apologize. I attempted to make Slim into an mvc structure. I added a few controllers, views and models to allow users to signup, login, make a couple changes to their account, and also allow admins to view the users ... |
I'm implementing my very first Go application and I would like to receive an hint on how to make a certain check faster.
I have a huge txt file in which each line is structured like the following:
key text
key text
.
.
key text
Where key is ALWAYS 6 HEX digits long and text is ALWAYS 16 HEX digits long.
I need ... |
I navigate with IE, do various things, then select all results option from a list and fire on click event. Once all results have been listed, I loop through their URLs, using the following code to gather data inside these URLs.
What can I do to improve speed of data scraping (apart from VB Script
multithreading)?
With ... |
An API (I have no control over) gives me a bunch of Collections (Lists, to be precise,) and I need the elements that are common to all of them. In this concrete case, I'm trying to find Selenium WebElements that match several selectors. But I went off on a Yak-Shaving spree and tried to figure out how to make an inters... |
Recently I came across this problem in the IARCS server,here is an little excerpt from it,
A well-known bandit who used to haunt the forests around Siruseri was
eliminated by the policemen a few months ago. There are several
stories about a valuable treasure that he is alleged to have buried
somewhere in the for... |
I'm creating a robust bubble sort for VBA when sorting stored arrays in VBA. Mostly this would be used when an array is stored in a single cell with a delimiter. Otherwise, one could just sort on the sheet during intake.
I'm trying to make this as robust as I can so it can be used as a tool rather than just continually... |
This code snippet is a research attempt to find means for dealing with dynamic polymorphism (in C): two or more related "classes" share a common interface. Here is my best shot:
#include <stdio.h>
#include <stdlib.h>
#define CALL(INTERFACE_PTR, METHOD_NAME, ...) \
INTERFACE_PTR->METHOD_NAME(INTERFACE_PTR->object, ##__... |
We have a working implementation that is doing I/O operations, returning data from blobs in an async/await manner from Azure Blob Storage.
//Method1 is not async, this is what is called from the controller
public IEnumerable<Data> Method1()
{
//Running the async method and returning the result from task
return... |
Here is a moderation library that I have coded and would like some help in improving the quality of my code.
Most of the code is styled by rules of Resharper; Resharper has helped me out a lot with my naming conventions, redundant code and much more.
It consists of 5 classes:
ModerationManager
ModerationBan
Moderatio... |
About 2 months ago I started studying python and then 3 days ago sat and began to write a program (found the dumbest & simplest thought I could: a pyglatin translator). I finally got it working 100%. Being a beginner I would love to hear some constructive criticism on my program; I know I have probably written more the... |
I wrote this code for an personal application, just to help me visualize some data related to driving. I have one JSON on my machine, this JSON contains a set of locations (lat, lngs) and every location has a category (integer number).
After I fetch this file I want to use Google's Road API, to snap the points on the r... |
This program attempts to shows the basic concepts of inheritance and polymorphism. In what ways could the code be modified to better demonstrate those concepts? The interface, abstract class and the class are all in separate files.
Greeting Interface
interface Greeting {
void sayHello(String greeting, String name)... |
I wrote the following class so that a single object can be shared across many threads. Is using the ReaderWriterLockSlim redundant in this case and only Interlocked.Funcs() can do the job and ensure thread safety?
using System.Threading;
public class SharedData<T> where T:class
{
T _data;
ReaderWriterLockSlim _lock;
... |
I've started learning C++ and still making my first program. This is a continuation of my last post.
My original aim was to make a linked list at a professional level. But have now changed it to a doubly linked list, to simplify the code. It implements a couple of public functions that should increase the usability of ... |
This program's purpose is to solve sudokus using simulated annealing. It first fills all the 3x3 blocks in the sudoku such that every block is filled with 1-9. It also builds a list of pairs of indices that may be switched, which is every pair of squares that were empty in the input, and are in the same block. So by de... |
I shuffle a deck of cards(with an equal number of red and black
cards) and start dealing them face up.
After any card you can say “stop”, at which point I pay you $1 for
every red card dealt and you pay me $1 for every black card dealt.
What is your optimal strategy, and how much would you pay to play
this g... |
I was wondering if I have any hidden bugs or traps in my code I wrote for an exercise.
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<algorithm>
using namespace std;
# define MAX 1000
int binSearch(int *arr, int arrSize, int num)
{
int leftPos = 0, rightPos = arrSize - 1;
w... |
Write a program that takes any input text and produces both a
frequency table and the corresponding Huffman code.
Take approximately 360 words from any English document as your input
text. Ignore all blanks, all punctuation marks, all special symbols.
Create an input file with this input text.
Construct the freq... |
I have posted here my working and accepted solution to the graphical editor programming challenge (detailed here) for your review.
The program recognizes the following image editing commands:
I M N: Creates a new table M × N (up to 250 × 250) with white (O) pixels.
C: Clears the table to white.
L X Y C: Colors the pix... |
I have a solution to the HackerRank Circular Array Rotation challenge. It passes 7 test cases out of 15. The rest of them are getting timed out. I think it's because of the huge data set that has been given as the input.
Input Format
The first line contains 3 space-separated integers, n (the length of the array), k (... |
I'm working on a car move problem. Suppose we have origin parking position for each car, [-1,1,2,3,7,6,4,5] (which means first position is empty, car with ID 1 parked at 2nd position, car with ID 2 parked at 3rd position), we want to find the minimal move to re-park car as specific desired positions. For example specif... |
I had to do this exercise for a further education in which I'm currently enrolled in:
Write a Java class "Air Plane".
Object-property names and types are given and compulsory.
Write the according constructor and getter-, setter-method. Check within the constructor the given values for being valid.
Moreover are the fol... |
I wrote simple compiler for Brainfuck with tcc backend (dont ask for assembler/assembly code generator!). It's output runs incredibly slow. Even Hello World program takes a LOOONG while to execute. I have added some optimizations, but it didnt help. This is code i actually made; It actually doesn't hang, but output wor... |
I read a lot about security mechanisms used in different APIs. But I'm still wondering if my own implementation is secure or not since it seems that there will ever be a risk of something you forgot ...
The scenario:
I have 2 PHP-running systems: Client and Server. There are multiple clients and one server but the comm... |
This is a task I was given for an online course. This is my solution to the problem.
Task:
Write a function called general_poly, that meets the specifications below.
For example, general_poly([1, 2, 3, 4])(10) should evaluate to 1234 because
1*10^3 + 2*10^2 + 3*10^1 + 4*10^0
So in the example the function only takes o... |
tree is described as "a recursive directory listing command that produces a depth indented listing of files" on the homepage for its Linux implementation. I don't know the full history, but it seems too have originated in MS-DOS (correct me if I'm wrong).
I've used the Homebrew port of the Linux version as a reference ... |
I've decided to learn C++, coming from Python, and this is my first program. I would love some feedback on it.
It's split up into two header files and one .cpp file:
Board.h
class Board {
public:
std::string board[7][4] = {
{ "\n\n-------------\n" },
{ "| 1 ", "| 2 ", "| 3 ", "|\n" },
{ "... |
Would this code for my Vanisher plugin for the game Minecraft, written with the Bukkit API, be optimised and conventionally right?
VanishAPI:
package com.azoraqua.vanisher.api;
import com.azoraqua.vanisher.exception.VanishException;
import org.bukkit.entity.Player;
import java.util.Collection;
import java.util.UUID;
... |
I have a 2D array like
[ [ 'B', 'O', 'C' ],
[ 'J', 'B', 'F' ],
[ 'F', 'B', 'D' ],
[ 'F', 'D', 'W' ],
[ 'N', 'F', 'X' ],
[ 'X', 'J', 'F' ],
[ 'T', 'Y', 'H' ],
[ 'R', 'Q', 'P' ] ],
And i need to group the sub-arrays such that in the resulting 3D array each group should contain only the sub-arrays with item... |
I want to create a "timetable" for some shop. It should look like, "days - hours".
I get response from the server in this way:
var array = [{
days : ["Mo", "Tu", "We", "Th", "Sa"],
dayIndexes: [1,2,3,4, 6],
time: "9am - 3pm"
}, {
days : ["Mo", "Tu", "We", "Th", "Sa"],
dayIndexes: [1,2,3,4,6],
time: "5pm - 9... |
I have been using Layered Architecture in my web application. Can anyone please advise if my data layer classes (both Linq and booking class) can be improved?
I have just started learning about solid design principles and Dependency injections. Does my object or data layer classes achieve any of the SOLID principles? ... |
What would be best way achieving this? Is it possible to use Immutable map?
import scala.collection.mutable.Map
/* Convert List of Edges to mapping Node -> List of Nodes */
def create_graph(edges: Array[Array[Int]]): Map[Int, List[Int]] = {
val graph = Map[Int, List[Int]]();
for (i <- 0 until edges.length) {
... |
Recently, I have been trying my hands on LINQ. So I've implemented the diagonal difference using Linq in Hackerrank. I know a similar question has been asked in python Diagonal Difference
Here is an excerpt of the problem Hackerrank -Diagonal Difference
Given a square matrix of size N X N , calculate the absolute di... |
How can I improve this code so I do not use so many for loops in this?
public class Hangman {
private String secretWord;
private String disguisedWord ="";
private String guessedLetters = "";
private int numberOfGuesses = 0;
private int numberOfIncorrectGuesses = 0;
Hangman(String secretWord){
th... |
My understanding is that Stack possesses LIFO property. And, based upon that I have written the following program:
// This is a sample program to demonstrate push and pop
// functionality in Stack in Java.
package collections;
public class Stack_Array {
private static final int capacity = 3;
int[] arr = new ... |
I'm wanting to step into plugin development so I can eventually push to WordPress.org so I wanted to go through and really learn how to properly develop a Plugin's settings page. I went through several pieces of documentation but I still think the WordPress Plugin Handbook is very lacking so I created a boilerplate of... |
I have created a simple Javascript game and want some second opinions on the code. How can it be done more efficiently for example?
Please see the code below, plus a link to a live working version on github.
Code to github
Thanks in advance.
(function(){
// The intro element. This element displays some introductory ... |
I wrote some code that uses Monte Carlo Integration to Approximate pi in Java and Akka. The tl;dr explanation is you can imagine throwing darts at a square with a circle inscribed inside of it. You know the area formulas for a square and a circle so you can use the ratio of darts that landed in the circle vs those that... |
I want to simplify this process of creating map, putting markers on it according to Place objects from my database, creating info windows. Using egeloen/ivory-google-map library, I've written a facade for this proccess.
class PlaceMap
{
protected $map;
protected $templating;
protected $places = [];
p... |
I wrote this piece of code to eliminate the need for multiple if then statements based on the filters from the incoming REST request.
If the request has category in it, then the query has to be filtered by category, the same for product_location. I wrote a single statement instead of having to check for the filters and... |
public String getDatePeriodtext(boolean userCanJoinAndLeave, Date startDate, Date endDate) {
String text;
if (!userCanJoinAndLeave) {
text = getText(getLocale(), "no");
} else if (startDate == null && endDate == null) {
text = getText(getLocale(), "continuous");
} else if (startDate == ... |
This is a followup to the question:
C# cache controller
Suggestions taken onboard from previous feedback, and refactoring to shorten the code in the calls to the cache controller by allowing queries to be passed as parameters.
Problem
Remove repeating cache code throughout code by creating a new cache controller class.... |
I'm trying to do some basic inheritance between the 3 classes and use some simple methods, and I'm looking to learn what should be the correct structure between them and what can be improved.
class Animal:
def __init__(self, kind, place):
self.kind = kind
self.place = place
#This class inherits kin... |
Is there a better way to write this? This is a class that displays a preferences menu. We do this when the user first installs the app during a walk-through where we only show them some of the settings with additional guidance on how to set them. We also show the entire preferences menu if the user selects our preferen... |
Is the MoveNext operation inefficient here? I really just want to increment an index. Originally, I had a mutable variable locally in ExtractTokens to accommodate this. I would have to believe that a mutable variable there would have been pretty efficient, but I'm trying hard not to have them. I can't help but feel... |
Last week I wrote a C++ program on Ultimate Tic Tac Toe. The issue was that the program was a bit lengthy (~230 lines) and it is needed to be around 150 lines.
I absolutely am not asking you to go through the whole code. Just skimming through might reveal possible contractions to code, and tips in general to write shor... |
Java allows methods to make recursive calls. This can be dangerous because an infinite recursive call will fill up the stack. It can be useful, however, for calculations that need iteration when the number of "self calls" is limited (it save a few keystrokes as well). The code below, although not very useful, does dem... |
The Julia set is the set of complex numbers z that do not diverge under the following iteration:
$$ z = z^2 + c $$
Where c is a constant complex number.
Different values of z reach infinity at different rates. A colourful fractal is produced by colouring the complex plane based on the number of iterations required to r... |
The question that sparked this question, was one on Stack Overflow in which the OP was looking for a way to find a common prefix among file names( a list of strings). While an answer was given that said to use something from the os library, I began to wonder how one might implement a common_prefix function.
I deiced to... |
I have a class that is all about doing HTTP requests, and logging (in file system & database). It's only using 3 dependencies to do these things, so I'm fine with the code so far.
Here it is for convenience :
<?php
namespace App\Services\Pivotal\Request;
use App\Core\Request\HttpRequest;
use App\Core\Request\Log\Requ... |
I've written this basic TCP socket server that uses SSL. This is my first experience with sockets in C++. The client is a Qt desktop application.
Code overview:
Receive incoming connection.
Check if connection is from an existing socket, if so reply via that socket, otherwise, create, bind and send response via new so... |
I was working on Haskell Problem 21:
Insert an element at a given position into a list.
Example:
* (insert-at 'alfa '(a b c d) 2)
(A ALFA B C D)
I have two different solutions:
--Problem 21 (also not tail recursive)
insertAt :: a -> [a] -> Int -> [a]
insertAt v [] n = [v]
insertAt v arr 1 = (v:arr)
insertAt v (x:xs)... |
I have a custom template class Array<T>, and am currently implementing the assignment operator.
However, I've come across a design decision: When assigning two arrays, must I require them to have the same size, or adjust the LHS Array size to the RHS?
Pros and Cons of Requiring Equal Size
Pro
Most of the time, the ar... |
I find that I use this pattern a lot where I have a dictionary which I would only read from and update and wouldn't add/remove keys.
In that case, using ConcurrentDictionary is not necessary and could hinder performance.
I wrote a simple class which implements such dictionary by using a wrapper class as its values:
cla... |
For a personal programming challenge, I wanted to try writing simple bubble sort and insertion sort functions in Python 3. I haven't looked at the standard pseudo-code, I just read about how they worked. Are these good implementations?
def bubble_sort(array):
"""
Sorts array using a bubble sort.
>>> bubb... |
I am still learning tikz and often have to use complicated solutions where I am sure are more simple ones. From my latest tikz files I picked one to ask for tips what I can do better, to learn about features of tikz.
The general layout should stay the same. Slight changes are fine. Suggestions should be about syntax.
I... |
Yes, I realize there are many, many, many, many, many, prime generators on the Code Review SE. However, I have been unable to find any using this method for generating primes inside a vector, so I figure it should be covered.
Here's the C++ code:
long int primeCap = 1e10;
std::vector<long int> primes;
primes.push_back(... |
I'm working on a Node.js HTTP server on my iPhone:
var fs = require("fs");
var http = require('http');
const port = 8080;
var readFile = function(name, response) {
var read = function(err, dat) {
var rv = null;
var nope = "./redirect.html";
if (err) {
if (name == nope)
... |
I've got bored, so I decided to write a code using ancient knowledge of sentinels.
Sentinel based find
Basically what we do is put value that is needed to find at the end, and then write an endless loop. Breaking from loop happens in the body of it, so one branch (which probably won't make much, since it is a loop bran... |
I have a helper function I wrote, but it feels like something _.lodash already does or could do if I knew the library better.
function changed(before:any[], after:any[]):boolean[]
{
if (before.length !== after.length)
{
throw new Error(`Length of arrays are not equivalent: ${before.length}, ${after.leng... |
This is a continuation of my LINQ stories from Pangrams-Hackerrank. Similarly, this challenge has been asked before in python Pangrams python Implementation but I have tried to accomplish this challenge using LINQ.
Here is a summary of the question
Roy wanted to increase his typing speed for programming contests. So, ... |
I'm in the process of learning Scala, and started working through a series of coding puzzles that I've done previously in other languages.
For example, this solution, coded in Erlang:
sum_multiples(Max, Max, Acc) -> io:format("The sum of all the multiples of 3 or 5 below ~p: ~p~n", [Max, Acc]);
sum_multiples(Current, ... |
I've completed a program that tests whether two words are anagrams. The program seems to work, but I was just wondering if there is anything I could be doing to make the code better. Everything is below, there is a main program and one class.
Main:
import java.util.Scanner;
public class StringTesting
{
public s... |
This is actually not something new, but I think many people wanted something useful and not incredibly complicated. So, here it is:
#pragma once
#include <utility>
#define concat_impl(x, y) x##y
#define concat(x, y) concat_impl(x, y)
#ifdef __COUNTER__
#define ANONYMOUS_VARIABLE(NAME) concat(NAME, __COUNTER__)
#else... |
I recently made this simple server in C for Linux systems and was wanting to get another set of eyes on it for a review of the design. I am new to socket programming and used a textbook from school to guide my way.
It is for GET requests from browsers and serves from a public folder (or other destination of choice). It... |
From my tests:
AABB-Sphere: 2954.8 tests per ms.
AABB-AABB: 1087.0 tests per ms.
The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number of operations (or even more in the sphere test).
My question is: why? I can't seem to figure this one out. Is there a better a... |
I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB. The production of the data 'inputv.dat' takes almost 45 minutes and it has a size of 2.6 GB. At the final step, the co... |
I am trying to improve the performance of this password cracking method:
def search_method_2(num_pass_wheels):
global totalguesses
result = False
starttime = time.time()
tests = 0
still_searching = True
print("Using method 2 and searching with "+str(num_pass_wheels)+" password wheels.")
whee... |
At now I have such code, creating or updating some entity by dto items.
public void Upsert(List<Object> items)
{
var existings = _db.Get().Where().ToList();
foreach (var item in items)
{
var existing = existings.FirstOrDefault(x => x.Id == item.SomeId);
if (existing == null)
{
... |
I have refactored the code for this game thanks to some great suggestions from woxxom
Now, once again, any suggestions still welcome. I am going to be improving the UX as a next phase (giving hints to the user etc).
I have also improved the consistency of naming IDs and using single/double quotes etc.
There was one s... |
I figured out a alternative way to make embedded videos responsive and I like to have some feedback on it.
Would this be considered a hack or just bad coding to add a extra piece of html to make this work?
.video-wrapper {
position: relative;
}
.make-video-responsive-img {
width: 100%;
height: auto;
display: ... |
Anything I can improve?
def main():
word = 'nedim'
hidden_word = list('_'*len(word))
wrong_guess, amount_of_letters, guesses, done = 0, 0, 4, False
while(wrong_guess != 5 and not done):
guess = raw_input("Guess a letter: ")
if len(guess) == 1 and guess.isalpha():
while(guess... |
if (TextArea1.gettext().length() > 0) {
String TextToChange = TextArea3.getText();
TextToChange = TextToChange.replace(TextArea1.getText(), TextArea2.getText());
TextArea3.setText(TextToChange);
} else {
JOptionPane.showMessageDialog(null, "Text to Replace field is empty", "WARNING"... |
I've been more than likely doing this entirely wrong for quite awhile and would like to correct that.
With the code review I would like to get critiqued on everything. This includes:
JQuery syntax/structuring
Additionally, if there are different/better/newer libraries let me know
HTML5 syntax/structuring
PHP struct... |
I would like to see what you think of a password generator I coded in Python.
#A password generator in Python...Coded by Mcoury(python-scripter)
#import the necessary modules:
import base64
from Crypto.Hash import SHA512
import random
import pyperclip
print('+++Pypwd is a password generator in Python...Coded by Mcoury... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.