« first day (1269 days earlier)      last day (1145 days later) » 

12:00 AM
RELOAD! There are 2900 unanswered questions (92.4865% answered)
12:51 AM
Q: Detect if string contains more than 1 period

AnonymousThis function returns true if the string contains zero or one periods, and returns false if the string contains more than one period. bool isStringValid(std::string str){ std::size_t pos = str.find('.', 0); if(pos != std::string::npos){ pos = str.find('.', pos + 1); if(po...

1:07 AM
This is getting downvoted because it is off-topic for Stack Overflow. If you have working code but want to know how to improve it, use Code Review. — juanpa.arrivillaga 8 secs ago
Q: I recently got criticized for this at work ("Overdoing OOP?")

needcodehelpAlright so first let me set some sort of context, the application I'm working on is a middle-man type application that feeds data from server to a user acting as a middle-man to easily display data to the user without having to find it all throughout a website, it also does a bunch of other funct...

@DanPantry JetBrains just announced a couple of days ago that it now support React Native: blog.jetbrains.com/webstorm/2016/10/…
1:32 AM
> Unfortunately, Apple only lets you develop for iOS on a Mac.
1:56 AM
Vulgar IDE
it tokenizes that "hello world" and @SimonForsberg's , and executes the fizzbuzz but somehow the hello world test is failing
actually it outputs the alphabet, not hello world
2:38 AM
Q: Objective C - function declaration

SunnyWhat would be the best way to add the flexibility of querying different HKQuantityType to this function, which is slightly modified from Katzian's work? - (void)fetchCalorie:(void (^)(double, NSError *))completionHandler { NSDate *const now = [NSDate date]; NSDate *const lastWeek = [no...

Q: 2 Player TicTacToe Game

jzbakosI am a beginner Java programmer and I have just finished creating a simple 2 player TicTacToe game and would appreciate some feedback/advice on how to make it better. import javax.swing.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class TicTacToe implements...

2:50 AM
@smac89 In that case they should try Code Review. — techydesigner 51 secs ago
3:11 AM
@CaptainObvious off topic I think
Q: A box for comments

PhrancisI made this as a practice application to learn React. It is simply a box where someone can enter their name and a comment and submit it, and display other comments. This animated GIF illustrates what it looks like: Note: Please don't be too critical of the looks, I haven't spent a lot of time...

@CaptainObvious @DanPantry ^^
3:31 AM
Test method BrainFuck.Tests.ExecutionContextTests.ExecutesCodeReviewPost57382 threw exception:
BrainFuck.Syntax.InfiniteLoopException: Exception of type 'BrainFuck.Syntax.InfiniteLoopException' was thrown.
I run hello world and alphabet output, but choke on fizzbuzz for some reason.
must be nested loops, but my brain hurts
Q: MIPS multiplying floating point by user input

tasuminagorashiI'm pretty new to MIPS and ran into a problem. How do I multiply a floating point by the user input? I've tried using mfcl and mlcl, but neither are working. Here is what I am supposed to do: Write a program that repeatedly prompts for an amount in US dollar and then displays the equivalent amo...

Q: Calculate parking fee

Rushabh ShahAn underground parking garage requires a program that allows clerks to calculate and display a bill for customer parking charges. A customer is charged when they leave the garage, and the amount charged is based on a few different factors. Some customers own a special membership card if they work...

@Mat'sMug BrainOverflowException
I picked a bad time of the day to post a good question :\
Took me like an hour to write it lol
3:51 AM
nice work
I'm going to put up my BF interpreter now :)
Since not that many people know React well I went out of my way to really explain how the code works
4:38 AM
Q: A completely overkill BrainFuck lexer/parser

Mat's MugLexer The lexer reads the code as a string or stream input, and yields tokens - a trivia token can span multiple characters, instruction tokens are all single-character: using BrainFuck.Tokens; namespace BrainFuck { /// <summary> /// An object responsible for tokenizing an input stream...

4:57 AM
This is what you get when you let your feet get cold: chat.stackexchange.com/transcript/message/33093487#33093487
Been getting that the last couple years, but didn't realize what it was from until this year.
Solution: wear socks and shoes when it is in the 40s/50s.
@Hosch250 Frostbite?
5:30 AM
@CaptainObvious Answered some of it.
@EBrown nice answer
Q: How can I fix CSS issues in Safari?

user121063 .bs-content{ width:530px; height:300px; margin:0px auto; text-align:center; margin-top:20px;; } .bs-content .inputs { position: relative; margin-top:15px; } .bs-content .inputs input[type=radio] { position: absolute; top:50%; height: 32px; margin-top:-20px; } .bs-content label{ te...

Q: Looking inside a file and printing a line

Miguel ValdezHey guys so I have an assignment where eventually after saving a command line argument string, I look for the string in certain files (also defined in the args) and look through all the files and print the line where that string appears, could someone help me trying to implement that? This is wha...

5:46 AM
@Heslacher Monking
@CaptainObvious You have to actually go out of your way and fight the IDE to get HTML this badly formatted
C# 6.0 does look quite cool, it addresses one of the things I dislike about C# and Java: It just takes a lot of code to make them do stuff :)
(Java more so than C#)
4G in my neighbourhood is over 2x faster than my home internet connection...
6:01 AM
Good grief
Who's your ISP again?
A company called MetaLink Technologies.
Sound like a pretty small company...
It is.
The top test in that link above is on 4G/LTE, the bottom one is Wifi.
6:05 AM
I think Time Warner Cable just upgraded the service last week, I used to only get about 20-30 mbps
2.95 mpbs man that really sounds like there's something wrong with the services, unless everyone on that node gets that slow of speeds
We're on a Wireless connection, that's standard service around here.
Oh, like satellite internet instead of fiber?
Antenna, but yeah.
6:09 AM
Sounds terrible, but I guess they probably have a monopoly don't they?
You should move down to Kentucky, we got better internet (and better bourbon too)
Lmao Can't move right now.
Q: Pronounceable binary-to-text encoding

alvaroceballos1This is a binary-to-text encoder that is based on Base64, but it works by converting data into an almost pronounceable string (consonant-vowel-consonant-vowel for each 3 bytes). Code: bitspeak.hpp #ifndef BITSPEAK_HPP #define BITSPEAK_HPP /* Encoding: ******** ******** ******** CCCC...

Did you see the JS question I just posted?
6:14 AM
No, it's a JS question...lol
You should at least look at it, you might be surprised that you can write JS like this :P
I need to shave...grah.
Try Code Review for info on how to improve the code — techydesigner 38 secs ago
Jeez, +40 on that answer I just wrote.
6:22 AM
The longest pattern in cccc is not c, it is cccc - even with repetition defined as more than one occurrence, it might have been cc - shortest pattern dividing/covering a string? Then, there is ccc occurring at two different positions… See also: Find the shortest whole repetitive substring. — greybeard 46 secs ago
Q: K-Complementary Pairs

SiddPBelow is the program that I have executed import java.util.HashMap; import java.util.Map; public class ComplementaryPairs { public int noOfComplementaryPairs(int arr[],int k){ Map<String,Integer> result = new HashMap<String,Integer>(); result.put("result",0); for(i...

Q: how to get display from mysqldb using pyqt4

p.arun prasath# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'C:\Users\user\Desktop\ar\PYQT\viewtable.ui' # # Created by: PyQt4 UI code generator 4.11.4 # # WARNING! All changes made in this file will be lost! import MySQLdb import sys from PyQt4 import QtCore, QtGui try: ...

Q: Chunking a list into separate lists of 5, and then iterating through each

alaskanloopsI'm writing a service that receives a list of Latitude/Longitude objects, prepares them for transaction, and then calls a web service to write them to the organization's Mainframe. According to the existing application that I'm replacing, the Mainframe can only accept "chunks" of up to 5 Lat/Lon...

6:54 AM
@Jude Monking!
@Phrancis are you familiar with Optional<T> in Java 8?
I'm not
Haven't done that much Java TBH
Finally beat 7k rep on CR.
But I think you are familiar with Optional classes, aren't you?
7:07 AM
Gosh this is so easy.
Q: K-Complementary Pairs

SiddPBelow is the program to find k-complementary pairs. K = A[i] + A[j]; package org.test; import java.util.HashMap; import java.util.Map; public class ComplementaryPairs { public int noOfComplementaryPairs(int arr[],int k){ Map<String,Integer> result = new HashMap<String,Integer>(); ...

7:40 AM
Q: X86 Legacy boot loader error trapping

Shift_LeftThe boot loader that I'm designing is just simply going to setup (A) Stack, (B) Segment registers (C) Load remainder of track for specified device. Conventionally, this could have been up to 4 floppy and/or fixed disk devices, but now, it may be an FDC, but most likely USB or fixed disk. As my bo...

8:02 AM
@Mat'sMug Oh, it's this one?
Q: ASCII table in Brainfuck

TyiloI made my first Brainfuck program today, which prints the numbers 0-255 and the corresponding character. I was wondering if I could improve my program, as I'm repeating myself a lot (e.g. 3 x copy & paste "comparer" function): max == 255 LF == 10 space == 32 '0' == 48 '9' == 57 ':' =...

@SimonForsberg hey!
@Mat'sMug And then there's this one:
Q: Hello, Brainfuck

MastIt has been bugging me for a while that while I understand how the basics of Brainfuck works, I can't get a firm grasp on the advanced features of the language. So I started to re-evaluate what I know about the language from the ground up. Brainfuck's memory consists of a tape of cells. Every ce...

and if you want to give your tokenizer another challenge you could give it this: github.com/Zomis/Brainduck-BF/blob/master/fibonnaci.bf
(I'll probably post a CR question about that one later on)
Naruto answer; accepted non-selfie answer with 0 score: Unit testing a prism event
First, when you create a snippet, there is a button Tidy. Use it. Second, if the object of this question is to reduce the code and your current code is working fine, please post it to CodeReviewsRajesh 38 secs ago
8:19 AM
Q: iOS Saving images in Realm or in Disk, which is fastest?

WYSI need to save some images on a temporary location until the user takes an action where the images are either moved or uploaded somewhere. The reason for this is to reload the photos if the app quits. Is it faster to save to the disk using Realm or just using FileManager?

Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Angular template for a dropdown menu
I'm voting to close this question as off-topic because it belongs on CodeReview — Fraser 37 secs ago
I guess. Note that, if your code works, your question is eligible for Code Review, which is suitable for questions with a lot of code. But that's an aside. Note that your example isn't what I would call "minimal", by the way. But it's probably hard to come up with something that shows your problem in a short way. — Zeta 11 secs ago
9:11 AM
Q: Javascript survey to optimize

Coman PaulI am creating a survey for an event but i need some help in creating an optimized code because it's redundant. First time i used that code $('body').on('click','.step1',function(){ //starting survey $('.Survey_Event_Customizer').html('<img src="img/loader.gif" class="loading" />'); $.ajax(...

Q: Python MySQL/CUPS PDF printer for STAR TSP100 ECO

NicholasCThis is my very first attempt at Python and whilst the script works perfectly, I'd like to see if I'm missing anything obvious or doing anything particularly stupid. I think this runs on Python 2.7, but I'm not 100% sure. please review and advise! Goal: The goal here is to grab a task and its...

9:31 AM
Q: Simplify definition of a dictionary with default return value

misteriossI need a constant (dictionary with values and default return value if there are no defined value for a key). Searching any ways to simplify the code. Without a default value I can simply define a dictionary like this: REDUCE_VALUE = { "honda": 0.95, "suzuki": 0.85, "suzuki": 0.87 } ...

Q: Given a blob of text (that is a complete html page) return all email(s) present

DarrenOkay so this is NOT my code, I just inherited it. Seems it has an obvious bug that it will only return the first email despite being called "GetEmails". My main concern is actually that it takes forever on some pages. The regex looks over complicated, but regex are something I have never really '...

Q: Reducing the redundancy of my repository/persistence-service implementation

maguesteI have the following situation: I have... Models like ServerRoom and ServerCabinet Repositories of the Model instances (in-memory collection) PersistenceServices which are interfacing the persistence-method I chose (mssql db) The problem I am facing is repetition. Basically, the implementatio...

Also: omg captain
Q: How should we deal with askers fixing off-topic questions when an answer has been posted

Joe WallisI done a quick search to see if this has been asked, but it didn't seem to be. The intent behind this question is from how this question was handled, but is not limited to it. The situation is an asker posts broken code. It gets an answer. (Question may get closed as 'off-topic broken code'). ...

@Phrancis yeah its true afaik you need xcode or something to develop ios applications, which you can only get on mac
I bet my colleague that someone on the forums would beat him to Gold in League
and that I would eat a raw broccoli stalk if he won
This was my desk this morning
9:46 AM
Gratz :^)
10:00 AM
Q: Follow the name change of "Programmers" to "Software Engineering"

Daniel JourIn "our" help center there are links to programmers.stackexchange.com. I guess this should be changed to reflect the recent renaming of that site to "Software Engineering".

Q: An unbeatable TicTacToe game

Daniel JourI wrote an answer to another question about the same subject and a new implementation, but instead of just posting my code there I think it's a good chance to see what can be improved on my own code. #include <algorithm> #include <array> #include <iostream> #include <iterator> #include <map> #in...

Q: Music Downloader

R.CampbellThis is a music downloader based on Youtube-Dl and VLC. It is written in python 3. The PAFY python module is required in addition to VLC (http://www.videolan.org/vlc/download-windows.html). Currently the cancel button is not functional and there is still a pop up command prompt. import urllib.re...

Too broad for SO. Have you tried on code review? — Diego Martinoia 8 secs ago
10:39 AM
Q: How do i apply the code i have, to multiple checkboxes?

Steve101Private Sub SetCompletionStatus(ByVal isCompleted As Boolean, ByVal section As Object) Const CompletedColor As Long = VBA.ColorConstants.vbGreen Const OutstandingColor As Long = VBA.ColorConstants.vbRed section.Caption = IIf(isCompleted, "Complete", "Outstanding") section.BackColor = IIf(isCompl...

Q: How to implement in python?

rajaHow to implement rainbow table for certain Hash functions, and to crack the hash codes of users' passwords, i.e., to recover the pre-image of a hash code. We are free to choose the approach to generate our rainbow table, the password length, the character space and the Hash functions

Q: Creating a Credit Card class with a Builder

curtisLoewAs someone who rarely uses C++, I need guidance deciding which approach is more idiomatic and/or developer friendly. I’m developing a library which requires a credit card class. Let's assume that besides the card number, cvc and expiry date, I also provide means to store the billing address, whi...

@CaptainObvious Asking for code.
10:55 AM
@JoeWallis thanks for the edit. Somehow my keyboard starts swalloing keystrokes (again)
@Heslacher No problem, :) I hope the grammar change is ok, it threw me when I was reading it.
You/Everybody can always fix my grammar mistakes. I know that english isn't my strength ;-)
I'm not very good at English either, so I don't like editing grammar.
11:24 AM
12:02 PM
Am I imagining things, or is this someone asking us to do their homework?
Q: Looking inside a file and printing a line

user5666676Hey guys so I have an assignment where eventually after saving a command line argument string, I look for the string in certain files (also defined in the args) and look through all the files and print the line where that string appears, could someone help me trying to implement that? This is wha...

12:15 PM
@pacmaninbw I have put the last close vote on it.
and you were right
@Heslacher Thank you!
no problem
Morning MCP.
Greetings, Programs.
Greetings, User
in the last 90 days we closed a third of all questions asked ...
of that third, two thirds were closed as broken ...
wtf is wrong with people that they don't understand that is off-topic ...
12:23 PM
@Vogel612 They either haven't found stackoverflow yet, confuse us with stackoverflow or think we won't be as mean as stackoverflow.
well at least we got a decent-ish amount of questions migrated to SO with a not too terrible rejection rate
ah wait ... other way round ..
SO -> CR: 53 questions, 16% rejected
How many CR -> SO?
10. 1 rejected
as I see it, we got higher quality standards for migration.
most "SO-style" questions just get closed instead of migrated
assuming that half of the borken code questions would be migrated to SO that's a different number...
12:26 PM
Yeah, I try to suggest migration in my comments, not always followed.
and FWIW it wouldn't even give SO quality anything like a hit ...
I've asked a few questions on SO, I feel like I'm searching for landmines by stomping on the ground.
unrelated-ish. Could someone tell me what part about this question is broken?
Sorry, Python is not my strong point.
@Vogel612 I don't see a close vote on that question
12:36 PM
I saw it in the review queue
strange. Maybe the voter did retract the vote
Just checked it myself in the queue. Its in the queue without a vote, so I guess retracted
or just flagged by user with not enough rep to VTC
12:52 PM
You really shouldn't use your own salts on password hashes and you really should use PHP's built-in functions to handle password security. Make sure you don't escape passwords or use any other cleansing mechanism on them before hashing. Doing so changes the password and causes unnecessary additional coding. — Jay Blanchard 7 secs ago
Q: Reading log file of subprocess

abstrusI run subprocesses with lot of output (compilation of Unity 3D projects). I use log parsers to find known issues. class LogParser(object): def __init__(self): self.report = [] def __call__(self, output: bytes): for decoded_line in output.decode().splitlines(): ...

@Vogel612 Huh, where do you find that?
10k tools
10k users can access codereview.stackexchange.com/tools
mods can additionally access /admin
Oh, that's cool... I should really read what you get at the different privilege levels.
1:07 PM
especially since you got there just recently, right ;)
in VBA Rubberducking, 25 mins ago, by Duga
[Vogel612/TranslationHelper]‌​ Vogel612 pushed commit 3c79b5ad to TranslationProjects: Moved some things around ... broke a few things. nothing serious
I had 15k rights before, ); #IMissBetaPermissions
oh right... 15k was question protection ...
1:58 PM
Q: Display a list of editable properties

Morgan ThrappI'm trying to create a grid of settings for the user to edit. I'm using a PropertyGrid at the moment, but I'm open to alternative solutions. My two big issues are that I don't love the look of the property grid. It looks overly complex for the small number of properties that can be edited. Also...

possible answer invalidation by Da Spotz on question by Da Spotz: codereview.stackexchange.com/posts/143811/revisions
2:26 PM
Q: SQL Prepared Statement Factory

Jack WilsdonI have written a simple prepared statement factory in Java and would like some feedback on how "secure" it is. By "secure" I mean that I can pass any old garbage in as a string and it should not allow any form of SQL injection or modification of the query in an undesirable way. Here is the code ...

2:48 PM
Q: VBA Macro - Speed decreasing with every loop iteration - substituting word bookmarks from excel

Da SpotzI previously asked this question but have since improved my code. The original question is here: Substituting bookmarks in a Word document with data combined from an Excel sheet What happens in the code: Information about a list of suppliers needs to be consolidated into a word document that m...

@Mat'sMug Someone gave me a DV on that answer...lol
However it really doesn't matter with the 15 up votes.
3:07 PM
Q: Is explicit input sanitization overkill if I'm using a whitelist?

Kimberly WI am adding functionality to a public REST API for my site, in that it takes a new parameter and does some database lookup with the parameter value. Since it is user supplied, I can't trust it straightaway. Initially I just had a sanitizing function on the user input. It applied a regex replacem...

3:19 PM
Q: Avoid repeated code with object orientation?

Robert BraxHere is a caching code of a nodejs / typescript app using lru Cache module. For various reason i need to setup separate caches: one for homeCache another one for detailThreadCache... but this is just the beginning I may need to set up more. This code is working, but how would you refactor it to ...

@EBrown someone gave me a DV on the question too. nice answer, I learned stuff :)
@Mat'sMug What did you learn? I figured you would already know it all...lol
the new dictionary initializer syntax was foreign to me
Ah, I think it makes things a bit more readable.
I'm a bit torn on expression-bodied overrides. it does make the code ridiculously short though.
and you did find a possible NRE here: context?.Increment
(although it's debatable whether context would ever be null)
3:25 PM
@Mat'sMug There's a few other possible NRE's, I just focused on that one to show how simple the method could be written while still having maximum feature support. :P
I may or me not end up writing a BF IDE
I like how the syntax trees simplify reading the code. IncrementInstructionSyntax (x10) is so much clearer than ++++++++++
almost takes the F out of BF
ASP.NET MVC is so handy
I was building this site in ASP.NET Web Forms...but why?
Note to self: if you find yourself creating a folder in an ASP.NET Web Forms application for each object, with Add, Edit, etc pages, it's probably more suitable as an MVC application.
17 rep and I cap
Q: Backbone View Effiiciecy

DaveyJakeI'm currently using Backbone to generate a carousel slider. In my View, I have an initialize function that looks like this: initialize: function(){ this.listenTo(this.collection, 'update', this.render); this.listenTo(this.collection, 'update', this.afterRender); this.listenTo(this.c...

Q: Pythonic way to convert dict value to float, or else get None

PhrogzMy Python code is converting XML attributes in an ElementTree to appropriate values. How do I best convert a value in this dict to a float() if it exists, or else get None? Best I have now is: attr = etree_elem.attrib self.radius = float(attr['radius']) if 'radius' in attr else None ... if self...

3:41 PM
Clearly off-topic:
Q: Creating a Credit Card class with a Builder

curtisLoewAs someone who rarely uses C++, I need guidance deciding which approach is more idiomatic and/or developer friendly. I’m developing a library which requires a credit card class. Let's assume that besides the card number, cvc and expiry date, I also provide means to store the billing address, whi...

Q: Tokenizer building blocks: tokens and spans

Mat's MugIn a completely overkill BrainFuck lexer/parser I've presented the lexer, parser, interpreter and syntax tree classes. With this post I'd like to go over the lower-level Token and Span mechanics. Each token has a Type property that returns a TokenType enum value: namespace BrainFuck.Tokens { ...

@Donald.McLean thanks! :)
@Mat'sMug you had a weird comment issue in there, hope I didn't overstep by editing that newline in there
3:57 PM
@Malachi ha, thanks for that!
@Mat'sMug you're welcome
interesting code... which I had some time to play with the code a little bit!
Q: Converting ActiveRecord array to JSON

DobzI have two tables, devices and device_properties. The devices table columns are as follows: id, ip, mac, device_property_id, created_at, updated_at The device_properties table columns are as follows: id, property_name, cli_enabled, created_at, updated_at At the moment I have the following co...

My ISP just asked me to...
> Unfortunately, your direct debit details have not been processed for this order as the name on the online order does not correspond to that on the direct debit details provided to us.
Please complete this Direct Debit Mandate and return it, signed by both parties
Why? Because I signed up to the ISP with the name Dan Pantry, but my bank account has my full name, Daniel Pantry, on it.
They think I am two people.
@CaptainObvious Maybe it's just me, but that question seems off-topic...
Also, it has some of the worst formatted JS I've seen
@Phrancis Possibly related. My family says it is a chill blain.
4:20 PM
Q: bucket sort in rust

emma sculateurFirst of all, the code: struct Bucket<H, V> where H: Ord { hash: H, values: Vec<V> } impl<H, V> Bucket<H, V> where H: Ord { fn new(hash: H) -> Bucket<H, V> { Bucket { hash: hash, values: vec![], } } } pub fn bucket_sort<T, F, H>(values: Vec<

4:38 PM
As a side note: If your code works as intended and want to make it better, try posting it here: codereview.stackexchange.com — MooingRawr 39 secs ago
This might be better suited for Code Review. — devlin carnate 10 secs ago
Kaitlin Pike on October 24, 2016
Welcome to The Stack Overflow Podcast #92, brought to you by the The Facsimile Association of America. Since the late 1800s, faxes have solved the infuriating problem how to get a message to someone quicker than physical mail, and since the late 1900s, slower than just sending an email. The Facsimile Association of America: When Was the Last Time You Needed to Fax?
If your code is working and you are looking fro help with optimization, try posting to http://codereview.stackexchange.com/CAB 26 secs ago
4:57 PM
Q: Creating a Concurrent/Parallel ForEachAsync that can fail immediately or wait until enumeration complete

TerryI needed an asynchronous parallel ForEach mechanism so I could enumerate an enumerable by N degrees of concurrency and process an action for each item. Searching around, my code was modeled/merged from a few posts I found. First, http://stackoverflow.com/a/25877042/166231 points to a Stephen To...

We are no code review service. — Olaf 18 secs ago
@Olaf I want to know how to stop running the r.out file - this isn't a code review. OP is asking (in his own words) essentially how to kill/stop the r.out file. Code Review is when you want feedback on any/all aspects of your working code. — Mat's Mug 22 secs ago
5:16 PM
today I've learnt very good lesson: don't name nested folders in the project with the same name as project (it won't be possible to output executable, because it's a folder name currently)
so now, not only can I be drunk-dialed, but I can be drunk-DDoSed
"switching is easy: just swap the bottle" - aka solving a problem that didn't exist in the first place????
5:33 PM
Q: Optimization for an array structure changing algorithm

Sam YeI wrote some code, and would like to know if there're other ways to optimize it. The code: <?php $arr = [ 'name' => ['a', 'b', 'c'], 'age' => [ 2 , 1 , 3 ] ]; $result = []; $keys = array_keys($arr); foreach($arr[$keys[0]] as $index => $temp) { $data = []; foreach($keys as ...

Q: Naive implementation of Naive Bayes in haskell

dimidA simple implementation of Naive Bayes, as I'm a Haskell beginner I've tried to put an emphasis on clarity and documentation. I've tried to incorporate the feedback form a similar question. This is the main class, the full code can be found here. module NB where import qualified Data.Map.Lazy as...

Q: Multi-way Tree organized alphabetically and search in preorder trasversal order

Mario GrullónIn attempt to create a k-ary or multiway binary tree sorted alphabetically at every deep i created below class in ruby to handle the order & search in a recursive way by the preorderTrasversal method: try it here: https://repl.it/EEBt/2 class MultiwayTree def initialize @list = Hash.new{|h,...

I need 2 rep...lol
it's still on HNQ
Q: how to get zero if one element is missing from the list using python

user121129with open("gpcr3.fasta") as gpcr: from collections import defaultdict counts = defaultdict(int) for line in gpcr: if line.startswith(">"): continue for char in line: if char in {"A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "...

5:49 PM
@pacmaninbw, hi! Have you written or seen memory allocators? I'm currently writing allocator library, but am struggling with the interface a lot
A piece if iron at 20 degrees and 200degrees look exactly the same
I have but not in a really long time, and it was in C, not C++.
@pacmaninbw, do you have any classification of them? Currently I classified them in terms of their abstraction from raw memory. I've tried to implement interface mentioned in this talk but then found that it is flawed
@Kaz But it really doesn't feel the same when you pick it up.
@Kaz but a person touching a piece of iron at 20 degrees and 200 degrees doesn't
5:53 PM
@DanLyons they don't sound the same either
How does a piece of iron at 200 degrees sound?
I meant the person touching it
In that case you are absolutely correct.
Bonus lesson: A piece of iron can be at 30 degrees where you're holding it, and 300 degrees just 8" further down
if in doubt, use a water dropper and listen for the sizzle
5:56 PM
In other news, I spent today in a forge making a wrought iron dragon. It was fun. And occasionally painful.
from your account of what happened, you should name it trogdor
possible answer invalidation by Terry on question by Terry: codereview.stackexchange.com/posts/145116/revisions
@Olzhas Are you writing a container class?
@Duga rolled back.
@pacmaninbw, I tried to write one, but then found that it's going to be terribly slow without specific allocator. Then I've got carried away and started to write my own allocator library. Failed attempt.
at least I figured out how to not write allocators. The problem with the failed attempt is that some allocators support some interfaces and some not. Basically, chaos.
now I'm writing a paper first. First attempt failed solely because I was thinking that I'm almighty
6:11 PM
Been there, done that, won't try to start a business again.
Did you find this in your search en.cppreference.com/w/cpp/memory/allocator?
std::allocator is complete failure. It is not designed to allocate things, it is a factory
So you're trying to re-write new and delete?
@pacmaninbw, no. I'm trying to create whole hierarchy. new and delete are kinda factories. What I want to write first is raw memory allocator. Then provide a facade for typed allocator. Currently it will just control the memory allocation strategy, it doesn't care about types at all
my stack_allocator got ~30-50% faster on average than std::malloc(). This is what I want: to not repeat failures of the people of the past., because they were just mandated to do so.
You're getting into system calls here. Basically what you're saying is that you want to write malloc() and then you want to write new over malloc?
@pacmaninbw, close. I want memory source, which just "supplies memory", and facades that doesn't really care from where the memory came from. Facades are strategies, for example a freelist allocator. Then seggregators, bucketizers, and all of that stuff
6:20 PM
possible answer invalidation by Terry on question by Terry: codereview.stackexchange.com/posts/145116/revisions
Well, lost 18 rep to mortar so far.
@EBrown, how did you get 9 downvotes?
@Olzhas No, I mean I missed out on it because of capping.
@pacmaninbw, if you're interested I can send you a paper that I'm writing (though it is now rather a fairy tale written by kid).
@Olzhas The safest way to do what you are trying to do is to malloc() a huge block of memory and create you allocator on top of that, otherwise you need to look at malloc source code and utilize the system calls it makes. Keep in mind that you're going to need to handle thread safety here.
The paper would be interesting.
If I was writing embedded code I might do what I'm suggesting to you. malloc() as much memory as I can safely use and then track all allocations from that block.
6:28 PM
@pacmaninbw, I'm doing exactly what you said on mallocator (it's just malloc wrapped in a class). Send me something to my email, I'll reply you with the next version of the paper (I need to fix some bugs in the paper, too). The email is on my about page ^^
I'll reply with the paper when I'll assure that it doesn't contain bugs. I'll also try to define interface for the first 2 layers of abstraction
possible answer invalidation by alvaroceballos1 on question by alvaroceballos1: codereview.stackexchange.com/posts/145065/revisions
@Duga, it's fine
@Olzhas I want you to test out something that used to work on SunOS and Solaris. Allocate a huge block of memory, then free it, then try your performance tests using malloc(). Because you've already allocated the huge block once, your process still owns the huge block. Your mallocs should be much faster at this point. This is what we did 30 years ago to get around the malloc() performance issues.
Think of mallocing at least a Gigabyte in this test.
@pacmaninbw, I've thrashed the heap with filling it with random numbers on each run, since it would be unfair to compare with stackallocator then
otherwise, std::malloc() is slightly faster than stack allocator
Q: A working stack allocator

user1095108Here's an absolutely essential piece of C++ lore, a stack allocator, that will allow you to, say, allocate strings and vectors on the stack. There are 2 stack allocators I know of, here and here. The trouble was, neither of them were working with gcc-4.8, and both needed fixing. Here's a fixed v...

6:41 PM
@pacmaninbw, stack store is good, but stack allocator is definitely a step back
no composability. I would like it to be unaware of which memory it holds now: stack, static or heap. Strategies are abstract enough to deal with that
stack allocator is nothing more than placement new in that post
btw, @pacmaninbw, are you that old? :D
I'm 19 :D
Live long and prosper.
@pacmaninbw, I'll do :) can't even imagine how much experience you might have
@Olzhas About 60 years worth. /endbadjoke
6:47 PM
If you don't need to keep both the arrays with all values and unique values, then just re-use the same variables for the unique. And if you wanted to just not worry about the unique, depending on the content of the original array, you can make an associative array so that when there is a duplicate you end up overwriting the value instead of adding a duplicate. Without more code, it is hard to tell what you are doing. But either way, this is likely off topic for SO. SO is for fixing code, but however ugly, this code works. There is a codereview.stackexchange.com that might be better. — Jonathan Kuhn 34 secs ago
Very old picture, it's mostly grey now linkedin.com/in/paul-chernick-63b566a
60 years :o Not that it's very old per se, but feels weird to talk online to people that are of my dads age :P
you look familiar, as if I've seen you somewhere
I always imagine what I'd be in 40 years, all 60+ retired people playing MMO's together?
@skiwi, in gw2 probably every 5th player is older than 30
6:49 PM
I'm looking for a job, I'm too young to retire and would get too bored.
It's not the years that count, it's the attitude.
Would be interesting if you add up all the years of experience you qualify for
Q: Open a text file and remove any blank lines

cssGEEKI have the following functions which help me to open a text file and remove any blank (empty) lines: def fileExists(file): try: f = open(file,'r') f.close() except FileNotFoundError: return False return True def isLineEmpty(line): return len(line.strip()) <...

@pacmaninbw I would have no trouble amusing myself. Long hikes, working on open source projects...
Hi @Hosch250
I'm looking forward to being financially independent, but I am going to miss my afternoon walks something awful.
@pacmaninbw Hi.
6:52 PM
@Hosch250 It's not ruled out when you have a job though, depending on the workplace
@EBrown Didn't start programming until I was 10.
@pacmaninbw I didn't start until I was 18.
@pacmaninbw Very nice.
I didn't know that computers existed at that time, lol
Gosh, 50 years ago. You started around the time they put people on the moon.
6:53 PM
Assembly :(
@Hosch250 2 years before that actually.
Nowadays people torture themselves for fun with Brainfuck
Close enough for a wild guess.
Pretty good, yeah
So, which languages do you know?
@skiwi Brainfuck isn't hard to programme in, if you think about it correctly. It's just very unreadable.
6:55 PM
@Olzhas Computers actually predate my birth by a few years.
@EBrown Kind of like your Br-En words?
BTW, do you spell "jail" as "gaol"?
Pascal, Basic, Cobal, Fortran 66, Snobol, C, C++, PHP, JavaScript, CSS, HTML. You won't find some of those on my resume.
@Hosch250 It's en-GB, IIRC.
Oh, OK.
@pacmaninbw I can believe that.
2 or 3 different assemblers.
Really I didn't think they still used it.
I guess I'd say I'm an advanced user of C# (not advanced programmer, just know the language pretty well), can figured out things pretty well with VB.NET, JAVA, JS, HTML, and CSS, and I can read most C/C++ (except understanding everything that goes on with pointers) and Python.
Cobol is probably the best Data Definion language around.
Pointers are fairly easy if you can grasp the underlying principles.
@Hosch250, no templates, no C++.
I'm sure I could if I tried, but I never use them.
So, every time I learn the syntax, I just go and forget it again.
7:01 PM
It is really easy to screw up pointers.
I understand the underlying principles, sort of, like passing around a pointer to an actual memory location instead of relying on the system to understand where it is.
Yes, and always keep in mind that pointers aren't the same between processes, that's part of why threads became important, along with less overhead than a process has.
@Hosch250, actually it is not about an address, but about interpretation of it (e.g. casts). This is where the funny things start, like aligned memory, undefined behavior if it's not POD, and so on.
By George I think he's got it.
Machine word size is very important with raw pointers, that's what made new and delete a joy to work with, you didn't need to calculate the size.
7:04 PM
All I know is that you have an "address" that can be stored in an int, and you can get a value from it by loading it into a variable of a certain type.
@pacmaninbw Like IntPtr in C#.
In C just cast the pointer, but don't depend on the size.
@Hosch250, it's very dangerous to assume that it's int. it's std::inptptr_t or std::uintptr_t, in cstdint, or stdint.h in C
OK, I've talked enough about the glory days. See ya all later.
see you
7:06 PM
See you.
Q: FIFO Queue Implementation

jacksonecacMy Implementation of a FIFO queue. I am mainly curious about my initialization of empty generic arrays. public class Queue<T> { T queue[]; public Queue() { queue = (T[])new Object[0]; } public T pop() { T queue2[] = (T[])new Object[queue.length-1]; ...

7:20 PM
Q: Bytecode for a custom programming language

MidnightasSorry for the tags, there wasn't a bytecode tag, and this technically has to do something with a compiler and interpreter :P. I am working on a programming language that compiles into my custom bytecode. As you do not know the "elegenat desein" of my bytecode here is an explanation for a simple...

posted on October 24, 2016 by CommitStrip

@CommitStrip "pouf" lol
@CaptainObvious wouldn't that be "high-level design"? opinion-based?
7:39 PM
hmm, any c++ human around ?
monking !
class Student {
	int id, nr_note, *note;
	char isomething, *name;
Welcome to CR! I think the code for your custom language's grammar, lexer, parser, compiler and/or interpreter would be a perfect fit for a peer review on this site. But it seems you're asking for opinions on the design of the compiled byte code... I think it would be better to ask for a peer review of the compiler code that generates this byte code instead; you'd potentially get the same design/optimization feedback you're asking for (i.e. feedback on any/all aspects of the code), while also opening answers to a much broader audience. — Mat's Mug ♦ 6 secs ago
I have this, and I want to read *name
as a string of chars
so *name is a char pointer?
it's a bit unusual honestly
8:02 PM
Q: Cannot find symbol

Noel Liberatus[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/GPfTh.png Connectivity.createConnection(); PreparedStatement stm = Connectivity.con.prepareStatement("insert into doctor values (?,?,?)");

Naruto answer; accepted non-selfie answer with 0 score: Tasks organizer app
Q: Calculating a snowballing investment

UcennaI'm currently taking a JavaScript class. I was fairly familiar with JavaScript and coding in general, so I decided to teach myself functional programming on the side. It's been great, my teacher's fine with it. However he doesn't really know much about functional programming, so it's difficult fo...

Q: Console colorizer

t3chb0tTo be able to apply various colors to the console I created a ConosoleColorizer. It's really simple. It just takes an XML and renders it to the console with the colors specified. internal class ConsoleColorizer { public static void Render(string xml) { Render(XElement.Parse(xml)....

8:20 PM
Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Using promise all with push array
8:41 PM
Welcome to Stack overflow. See "How to Ask" including the linked pages, and "Minimal, Complete, and Verifiable example". We need the minimal code in the question itself, not as a link. Links rot then break and at that point your question will be worthless to others in the future. If your code works correctly and you want ideas on how to improve the code itself then Code Review would probably be a better site. — the Tin Man 16 secs ago
8:58 PM
> Here there be monsters.
~ Mr. Ugly beard.
@Mat'sMug The * gives away it's a pointer.
@Mast I know as much
Q: Formatting/indentation for nested list comprehensions

PhrogzI have a non-trivial list comprehension in Python. What's the accepted way to format such a beast? self.types = frozenset( v for v in ( getattr(objects_module,enum_name,None) for enum_name in element.attrib.get('object-types', '').split()) if v) s...

9:34 PM
Q: Checking if a bag has enough coins in program

ohdearohnoThe objective of the program is to check that the weight of the bag that the user inputs and then calculate how many coins are needed to the added/removed to ensure the bag has the right amount of coins in. It needs to display the difference in weight and the number of coins to be added/removed a...

Q: Prevent Variable Overflow from InputBox user error

Jacob BischoffI was writing some code that required the user to input a number, which was then stored in a variable. While testing the code I input a number larger than the variable type would allow and I got an variable overflow error. So I wrote this code to prevent that from happening. It works, but I was...

10:08 PM
Q: Python Ascii-Art Generator

Uriel EliAs a part of a console utilities module that I'm building, the central function (after which the module is named) is a function that generates asciiart representation of given text. The format of the configuration file is: First line: the height of every character in the configuration file. ...

10:50 PM
Q: Java Console Version Conway's game of life

Jim FergusonI did a super simple version of Conway's Game of Life and would like a review public class Conway { String [][] grid; int [][] neighbors; int [][] directions = {{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}}; Conway (int gridSize) { this.neighbors = new int [g...

11:04 PM
Q: Reading keyboard strokes using multiple input threads

max pleanerI have a command line program which reads input one character at a time. The following code is working, and if I press three keys at once they will all be printed. There are four questions here: why does 3 simultaneous keys seem to be the limit is there any way to preserve gets.chomp on the ma...

11:27 PM
Q: The Trip Programming challenge Uva10137

Teererai MarangeI have the following solution for the Trip problem from Skiena's and Revilla's Programming Challenges (full problem description here). //#include "stdafx.h" #include <iostream> #include <string> //Always import <string> if piping std input to a string in .net #include<algorithm> #include<math.h>...

@cwschmidt - that wasn't the op's question. But, I'll revise the answer, because that's apparently what we're doing now... answering questions and performing free code review. — Hill 31 secs ago
This is not part of a code review. It is strictly a problem with the code. If you want to perform a code review, you'd have to move x and counter into their respective scopes. — IInspectable 15 secs ago
11:50 PM
possible answer invalidation by Darren on question by Darren: codereview.stackexchange.com/posts/145081/revisions
Q: IPC using pipes

In78I have simulated the conversation between a caller and receiver using fork and pipe. The parent process is the receiver and the child process is the caller. Each message is terminated by a newline. The program seems to be running correctly. Should I take care of any other condition? #include <st...


« first day (1269 days earlier)      last day (1145 days later) »