instruction
stringlengths
71
71.9k
I am building an app for android to control VLC (mediaplayer) that runs on my computer. At the moment it's just a prototype that works, but I was wondering if I am correctly managing my HandlerThread and Socket. My fear is that the thread keeps running too long or that I cause memory leaks. I have looked at a lot of e...
I am working on converting a PHP application to MVC, and have a couple questions! 1) I have a main Model object, that I require a database connection for, as well as a User object that uses a database object also. Is it a bad practice to create a new database object for each of these classes, like the following? or sho...
I have written a piece of python code in response to the following question and I need to know if it can be "tidied up" in any way. I am a beginner programmer and am starting a bachelor of computer science. Question: Write a piece of code that asks the user to input 10 integers, and then prints the largest odd number ...
if node[i] and node[i+1] are present in the neighbor[i], then store the 'i' position of node and print the 'i' value of node. this is also done by reversing the node array(only) and same type of check and print is done with the neighbor[i]. This code is written by me and works well, is there any other efficient method ...
I would like to turn the following: <div>this is a $test</div> into <div>this is a <div>$test</div></div> currently I have var regexp = new RegExp('$([^\\s]*)','g'), html = '<div>this is a $test</div>', matched = html.match(regexp)[0] if (matched){ html = html.replace(match, '<div>' + match + '</div>') }...
This is a user JavaScript for YouTube. The point is to make the thumbnail bigger on mouseover. I just want some help making it better because I don't want it to waste resources with all the extensions I have and other scrips. I also added Iframes because I have another extension that makes a preview of the video in the...
I have recently finished creating my own Deck class for my Poker game. It works the way I want it to, but I would like to know if I can make it better and/or more efficient. Deck.h #ifndef DECK_H #define DECK_H #include "Card.h" #include <iostream> #include <string> #include <ctime> using namespace std; class Deck {...
I have a class that I am using to initialize a form for editing. Once the form is submitted, data validation is done through the setters of my class. Good or bad input will be set in order to re-display them in the form (is this bad?). Everything works fine, but I am not too happy with how I am storing and displaying t...
Does this part look clean enough? Any suggestions on how to make it cleaner? if (isCheck) { if (isStuck) { return GameState.Mate; } else { return GameState.Check; } } else { if (isStuck) { return GameState.Stalemate; } else { return GameState.O...
I'm coding a 2D collision engine, and I need to merge adjacent axis-aligned bounding boxes depending on a direction (left, right, top, bottom). The four cases are very similar, except for the if condition, and the push_back argument. Is there any way I can refactor this code without compromising performance? vector<A...
I have been trying to make a simple "quiz" program in Python. What I plan to make is, say, a quiz of 3 rounds and each round having 3 questions. And at the end of the every round, the program will prompt the user to go for the "bonus" question or not. print("Mathematics Quiz") question1 = "Who is president of USA?" op...
I have written my own for practice and also some tweaks for my specific requirement. There is an insert which can copy a range (well array copy really) which I am hoping is more efficient than individual element insert. Can anyone make any comments specifically as regards efficiency and code elegance. I need to use t...
I would like to advise if the following production code is good to be unit tested. The segment of the production code gets data from a backend service and displays it on the page. It is a class: ... // Extract this code into a separate method because it is called in more than 1 place Keywords.prototype.addKeyword = fu...
Inspired by jqueryboilerplate.com, I extended their boilerplate to fit my needs. Coming from PHP development, I wanted to have a good starting point for writing jQuery plugins with a defined API/interface (more at jquib.web-sav.de). /** * JQUIB - JQUERY INTERFACEPLUGIN BOILERPLATE * * This is a solid starter templat...
I'm writing a markup for: And I've split it for these sections: <header> <div id="logo"></div> <nav id="mainNav"></nav> </header> <div id="banner"></div> <div id="content"> <section id="advantages"> <section class="advantage"></section> <section class="advantage"></section> <se...
I have just started to learn programming with Python. I have been going through several online classes for the last month or two. Please bear with me if my questions are noobish. One of the classes I am taking asked us to solve this problem. # Define a procedure, check_sudoku, # that takes as input a square list # of l...
Sadly VS2012's duration_cast is broken, and I actually need the functionality which is broken. So, I wrote my own: template<typename ToUnit, typename Rep, typename Period> ToUnit duration_cast_2(const std::chrono::duration<Rep, Period>& right) { typedef std::ratio_divide<Period, typename ToUnit::period>::type rati...
I've used EF-DB first approach and have written a simple app to retrieve the data from the database and show it in the view. The code is simple and ok for a beginner like me, but how can I implement an effective design-pattern like interface-specification pattern or generic repository pattern, and possibly dependency i...
I've written an implementation of the back-propagation algorithm in Clojure (here). This is my first attempt at Clojure where the code totals more than ten lines and so it is not very idiomatic; specifically in one of my functions I have this: ; example neural-network: {:inputs [{:weights [1] :delta -0.2 :activation 1}...
I'm creating a CRUD page. My first approach was use the same class editCategory.php for doing these actions: If this file is called via GET and categoryId parameter doesn't exist -> shall show a empty form If this file is called via GET and categoryId parameter is provided -> shall show a form with the data of this ca...
I've written a short program to find solutions to the 36 Cube puzzle. I'm trying to break away from my normal Java / imperative style, and would like some feedback on how I'm doing. Puzzle.scala package cube36 /** * An immutable class representing the state of a 36 Cube puzzle */ case class CubePuzzle(val board: Boa...
At work, we have a "pair programming ladder" where you can keep track of who is pairing with whom (based on check-ins). The idea is to promote "promiscuous pairing" where each developer eventually pairs with every other developer. In our team, this was being updated manually, so I thought of writing a script that will...
Premise Consider the following method: static String formatMyDate(Date date) { return new SimpleDateFormat("yyyy-MM-dd").format(date); } It's often desirable to memoize DateFormat objects so they can be reused rather than repeatedly instantiating new ones. This frequently leads to the following naive refactor: pri...
I'm trying to run a bit of code when my loginManager is logged in. It might be already, or I might be waiting: var loginManager = chrome.extension.getBackgroundPage().LoginManager; // If the foreground is opened before the background has had a chance to load, wait for the background. // This is easier than having eve...
Could someone please point out the error(s) in the given code? It was downvoted on Stack Overflow without any explanation, but it seems to be working fine for me: int value(char roman) { switch(roman) { case 'I':return 1; case 'V':return 5; case 'X':return 10; case 'L':return 50; ...
Could someone please help me make this code as professional as it can be? It works fine, but I feel there's a better way of doing this. I would really appreciate some guidance so I learn to code better. $(function () { $('#subForm').submit(function (e) { e.preventDefault(); ...
I have a list of elements (well, nested lists of elements, really) that the user can reorder (using jQuery sortable()). A simplified view of the structure is something like: <div class="contentList"> <div class="content" /> <div class="content"> <div class="contentListInner"> <div class="tr...
I'm trying to solve the four color theorem in Ruby. A map is like this: ccaaaa baaadc babcdc bbbcdc abcccc I have this, but it's slow. How can I make it better? #!/usr/bin/env ruby class String def visit @visited = true end def visited? @visited == true end def color @col...
Am I doing it fine?? Its only for setup not executed repeatedly CREATE TABLE #temp ( id INT IDENTITY(1, 1), name_file VARCHAR(500), depth_tree VARCHAR(10), is_folder_files VARCHAR(10) ) /* xp_dirtree selects file from specific location * dept...
I have been trying to design a good data layer that will eventually be generated. I am wondering if I have missed anything. The basic architecture contains a service class that handles connecting and eventually transactions. I wrap the IDbConnection in the service class to make sure it gets disposed properly so that th...
I'm creating a system and I'm using EF with Linq. I create my Model (.edmx) and using it, I generated my database and my classes. Like the Usuario (user in Portuguese going to keep the names in Portuguese to avoid some misleading). namespace SistemaBox.Model { public partial class Usuario { public int C...
I'm basically trying to write a helper function that reads a whole file and returns the data and the number of bytes read. Can you tell me if is correctly written and used? #include <iostream> static char * ReadAllBytes(const char * filename, int * read) { ifstream ifs(filename, ios::binary|ios::ate); ifstream...
Example that could be turned into a button to view user's public ftp where initial page is "http://user.school.edu/": javascript:(function( { var h,i,t; h=window.location.hostname;i=h.IndexOf('.school.edu');t=h.substring(0,i); window.location.assign("ftp://ftp.school.edu/public/"+t }); Help me refine this ide...
I have a simple servlet which merely serves some cached data back to the user. I also have a background thread which runs at fixed intervals to refresh the cached data. Is this a reasonable implementation? @WebServlet("/CachingServlet") public class CachingServlet extends HttpServlet { private static final long s...
I tried to refactoring someone else's code and I found that there is alot of this pattern def train(a, b, c, d, e, f, g, h, i, j, k): #Real code has longer name and around 10-20 arguments x = Dostuff() y = DoMoreStuff(b,c,d,e,f,g,h,x) z = DoMoreMoreStuff(a,b,d,e,g,h,j,y) def DoMoreStuff(b,c,d,e,f,g,h): ...
I've written a class to make async SQL calls and it appears to work like a charm! But I'm a bit concerned about what it means to send a lot of queries to the server and then aborting them by throwing an abort exception on the calling thread. Is this a problem? The code also launches a lot of threads. Is there any down...
I'm learning C from the K.N. King book and just arrived at a question to reverse the words in a sentence. Here is the output: Enter a sentence: you can cage a swallow can't you? Reversal of sentence: you can't swallow a cage can you? Though I've done this and it runs correctly, I want to make my code shorter. I'm not...
I have written a lock free MPMC FIFO in C based on a ring buffer. It uses gcc's atomic built-ins to achieve thread safety. The queue is designed to return -1 if it's full on enqueue or empty on dequeue. After some feedback, I've changed by design. I have tested this code to work, but testing multithreaded code is hard...
I'm querying a MySQL database and displaying the info in order of timestamp (DESC). Essentially, I'm grabbing the last record in the database, displaying it's date and year as the header of it's section and then going backwards from there. I've put together these if and else if statements to display the appropriate mon...
I thought about three (now four) different ways how to execute forks with PHP. What is the faster, maybe better solution and why? PHP script included foreach($tasks as $task) { $pid = pcntl_fork(); if($pid == -1) { exit("Error forking...\n"); } else if($pid == 0) { include 'worker...
I have this set of functions - it works, but I'm concerned about the use of lets. (defn- create-counts [coll] "Computes how many times did each 'next state' come from a 'previous state'. The result type is {previous_state {next_state count}}." (let [past coll present (rest coll) zipped (map v...
I'm creating a small extension to the JDBC API, with the hope of automating some common tasks and avoid boilerplate code. One of its features will be a basic support for named parameters in prepared statements (that JDBC does not support natively). Since this is a vital part of the library, I would appreciate your opin...
I had been working on a project for some time, and then it went on the way back burner after my daughter was born. I'm back to it, and now I discover that I'm best off using PDO over MySQLi. So, I'm working on the conversion, and I'd like to get some confirmation that I'm handling things well. Essentially: Does this...
Say I have this type of code I'd like to execute. There's some data encapsulated around a big Javascript object containing methods & properties that I'd like to extract based on comparing some other data in said object. The object includes associative (hash?) arrays where I don't know the array IDs at runtime so I have...
I realize that there is a surfeit of posts on SE/SO about optimizing one's R for() loops. I'm afraid, though, that I don't understand all of the guidance in the answers there, or how to apply their lessons to the loop I'm working on. First, the code: HHCovarEvals <- data.frame() for(k in 1:length(hhcovarmodels)) { q...
Here I have some simple code that worries me, look at the second to last line of code, I have to return spam in order to change spam in the global space. Also is it bad to be writing code in this space and I should create a function or class to call from that space which contains most my code? I found out very recently...
I needed short, unique, seemingly random URLs for a project I'm working on, so I put together the following after some research. I believe it's working as expected, but I want to know if there's a better or simpler way of doing this. Basically, it takes an integer and returns a string of the specified length using the ...
I'm currently working on a system using WCF to communicate between a Windows Service and one or multiple clients. Service is required to answer clients calls, as well as notify them of certain events, which is why I implemented a callback feature using simplified subscriber model. Callback interface has methods with va...
This code loads the data for Project Euler problem 18, but I feel that there must be a better way of writing it. Maybe with a double list comprehension, but I couldn't figure out how I might do that. It is a lot more difficult since the rows to split up are not uniform in length. def organizeVar(): triangle = "\ ...
In my Rails app I need to import some files from CSV and Excel files. I needed it in 2 models so I have written lib/importable.rb: module Importable def self.included(base) base.send :extend, ActAsMethods end module ActAsMethods def act_as_importable(&block) @import_block = block send :extend...
private String GetFacilityName(String facilityHexID) { if (facilityHexID.equals(FACILITY_AIRCON_HEX_ID)) { return FACILITY_AIRCON_NAME; } else if (facilityHexID.equals(FACILITY_FAN_HEX_ID)) { return FACILITY_FAN_NAME; } return facilityHexID; } Or private String GetFacilityName(String...
I have a grid as >>> data = np.zeros((3, 5)) >>> data array([[ 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0.]] i wrote a function in order to get the ID of each tile. array([[(0,0), (0,1), (0,2), (0,3), (0,4)], [(1,0), (1,1), (1,2), (1,3), (1,4)], [(2,0), (2,1)...
Is there any point in wrapping this code in the self executing function declaring window and undefined? I've read that it improves performance etc... (NOTE I will be making use of the window at some point). (function (window, undefined) { // THIS BIT HERE! var App = { init: (function () { $(document).ready(...
I wrote function to generate nearly sorted numbers: def nearly_sorted_numbers(n): if n >= 100: x = (int)(n/10) elif n >= 10: x = 9 else: x = 4 numbers = [] for i in range(1,n): if i%x==0: numbers.append(random.randint(0,n)) else: ...
I have the following jQuery click functions: $childCheckbox.click(function(){ if(!$(this).hasClass('checked') && !$parentCheckbox.hasClass('checked')){ $(this).attr('checked', 'checked').addClass('checked'); $parentCheckbox.prop('indeterminate',true); } else if($(this).hasClass('checked...
first of all sorry for this easy question. I have a class class Grid(object): __slots__= ("xMin","yMax","nx","ny","xDist","yDist","ncell","IDtiles") def __init__(self,xMin,yMax,nx,ny,xDist,yDist): self.xMin = xMin self.yMax = yMax self.nx = nx self.ny = ny self.xDist = xD...
I'm starting to learn Python and am trying to optimize this bisection search game. high = 100 low = 0 guess = (high + low)/2 print('Please think of a number between 0 and 100!') guessing = True while guessing: print('Is your secret number ' + str(guess) + '?') pointer = raw_input("Enter 'h' to indicate the...
Often I need to clean a file name using Path.GetInvalidFileNameChars(), however I do not know of a way to search for any of the invalid letters (except by using Regex) in one pass. public string LoopMethod() { StringBuilder sb = new StringBuilder(fileName); foreach(var invalidChar in Path.GetInvalidFileNameChar...
CREATE PROCEDURE dbo.foo AS BEGIN DECLARE @true BIT, @false BIT; SET @true = 1; SET @false = 0; IF (some condition) Select @true; ELSE Select @false; END SQL is not the language that I'm strongest in now, but the above stored procedure seems to be produce the desired functioning: returning the truth value...
I have developed a jQuery slider and I want to implement it in WordPress (it will be a Featured Posts slider). This is my slider logic: If there are 1 or 3 posts, show them but hide the prev and next buttons. If there are more than 3 posts but less than or equal to 6, or more than 6, show navigation. If there are more...
I wrote some Java code for Spotify's Reversed Binary Numbers puzzle and I tested it on my machine and I am almost positive that it behaves as expected. However, when I send it to puzzle AT spotify.com it kicks it back saying I have the "wrong answer", and nothing else. Frustrating as this is, I can't for the life of me...
I'm trying to become more proficient in Python and have decided to run through the Project Euler problems. In any case, the problem that I'm on (17) wants me to count all the letters in the English words for each natural number up to 1,000. In other words, one + two would have 6 letters, and so on continuing that for ...
Write a method to compute the difference between two ranges. A range is defined by an integer low and an integer high. A - B (A “minus” B) is “everything in A that is not in B”. This is an interview question and here is my code: void findDiff(int a1,int a2, int a3, int a4) { cout<<"("<<a1<<","<<a2<<") - ("<<a3<<","...
I've been learning C#/XNA in an attempt to make a game for the past few weeks so maybe this is an obvious newbie thing, but here goes: I've been making a fairly simple 2D game, so I have a list of ~1000 objects (NPC's), and I'm iterating through them extremely frequently to do distance checking on each one. The problem...
I've been working on a project where I am importing a large document of documents and tokenizing each document. I then make a hashset of the tokens I have, and for each of these unique tokens I am looking to find their frequency in each of the documents I have. There are about 130000 documents total. I've run the code ...
I have a function that needs to return the call to another function that have some parameters. Let's say, for example, the following: def some_func(): iss = do_something() example = do_something_else() return some_long_name('maybe long string', {'this': iss, 'an': example, 'dictionary': 'wich is very long'}) ...
This function takes in a number and returns all divisors for that number. list_to_number() is a function used to retrieve a list of prime numbers up to a limit, but I am not concerned over the code of that function right now, only this divisor code. I am planning on reusing it when solving various Project Euler probl...
Im using Foundation by Zurb as a front-end framework. Below is the SCSS used to generate the basic layout of the homepage using the Semantic Grid Mixins Foundation supplies (http://foundation.zurb.com/docs/sass-mixins.php). The problem I am having is that it is creating massive selectors when I view them in the inspec...
Python doesn't remove the variables once a scope is closed (if there's such a thing as scope in Python, I'm not sure). I mean, once I finish a for variable in range(1, 100), the variable is still there, with a value (99 in this case). Now I usually indent a whole block when I use the with ... as statement. But should I...
Background I like to code JavaScript in a typical style with "classes" and inheritance. My goal was to create an easy way to make inheritance available and keep classes that inherits from others clean. Also I like to use the module pattern and uses its look and feel. My solution I hope the code is self-explanatory. I'm...
My user defined comparison compare function is defined with an array: $boardkey_to_values=Array(19=>2601248,23=>2601248,39=>2603445, 43=>2256319,47=>2632006,59=>2603445,63=>2232152,67=>2260713,71=>2632006,...) so 23>19 EDIT:23=19, 39>19, 39<23,... I have an array of values $board_id, and I want to get the array of...
I have the async code that implements cancellation token. It's working but Im not pretty sure if this is the right way to do it so I just want feedback about it. Here is the actual code: /// <summary> /// /// </summary> private async void SaveData() { if (GetActiveServiceRequest() != null) { var token...
This was a homework assignment that I'm now done with - I submitted it as is. However the fact that I needed to use the same code twice bugged me... The double code is: printf("Enter a distance in inches (0 to quit): "); scanf("%f",&input); Is there a better way to do the same thing in my loop instead of the double sc...
I'm reading the awesome Head First Design Patterns book. As an exercise I converted first example (or rather a subset of it) to Python. The code I got is rather too simple, i.e. there is no abstract nor interface declarations, it's all just 'classes'. Is that the right way to do it in Python? My code is below, original...
I have a Swing application with no real design pattern. I want to start learning to design Swing or any types of application properly. Here is the main JFrame class. import java.awt.Component; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JTabbedPane; import org.text.g...
I want to know if there is a way to improve my code. It finds the two highest values in an array, and these numbers need to be distinct. I don't want to sort the values; I just want to find them. My idea is to create a new array if the length is even and compare the pair of values to find the minimum and maximum value...
This code takes text from the standard input, maps it to a struct (if possible), and creates a JSON string from that. I'm using a barcode scanner for the input, and I've attempted to use goroutines to ensure that if something goes wrong with the parsing or JSON-marshalling, the program will continue to receive and proc...
Is the subroutine test1 ugly?/uglier than the others? #!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Data::Dumper; my $ref = { one => 1, two => 2, three => 3 }; sub test1 { my ( $ref ) = @_; $ref->{three} = 4; } test1( $ref ); sub test2 { $ref->{three} = 4; } test2( $ref ); sub test3 { ...
I made this small program to demonstrate to myself an example of interface. I wanted to confirm whether it is correct and if there is anything more I should know about interfaces other than the importance of implementing polymorphism and multiple inheritance. //program.cs class Program { static void Main(string[] ...
I'm writing a function to increase a string so, for example, "aac" becomes "aad" and "aaz" becomes "aba". The result is horribly inelegant, I can't get it simple enough and I feel I'm missing something. How to improve that code? function inc_str(str){ var str = str.split("").map(function(a){ return a.charCodeAt(0);...
I'm trying to output aggregate information about a directory tree (file extension plus accumulative count and size per file type) with PowerShell. This is as far as I've got. gci -r -ea Si ` | group { if ($_.PSIsContainer) {""} else {$_.Extension} } ` | select Name, Count, @{n="Measure"; e={$_.Group | measure Length -S...
Does my main class have too much code? For some reason i have the feeling that I should put all of my thread starts and joins in a for loop just to reduce the amount of code. I dunno if that will hurt readability on this class? Also is it normal for a main class to be initialize just to call one method? I only did this...
I've written a short library for manipulating matrices for 3D drawing. I've tried to strike a balance between speed and readability. Anything to improve? %! %mat.ps %Matrix and Vector math routines /ident { 1 dict begin /n exch def [ 1 1 n { % [ i [ exch % [ [ i 1 1 n { % [ [ i j 1 ...
I'm trying to migrate from JavaScript to CoffeeScript. However I'm not sure about the best way to optimize the code generated by js2coffee. Below is the original JavaScript source : var async = require('async'); var context = {}; context.settings = require('./settings'); async.series([setupDb, setupApp, listen], rea...
I have to perform an IF statement in my Javascript code. I utilised the first method shown below: (someVar1 !== "someString") && (someVar2[i].disabled = (someVar3.find("." + someVar4).length == 0)); Is the shortening of an if like this ok to do if my code is to be viewed by other members of my team? I have been told t...
I didn't realize I am not a very good programmer at recently. I just come out from Uni, I want to become a reliable teammate. Please help me to improve my coding style/habbits. I have carefully re-written a file indexer class which I didn't do very well in my work. I come here, hope I can improve it in terms of code co...
My task was similar to my last assignment but this time I had to do it with UDP instead of TCP. This basically means I had to emulate TCP over UDP. Multithreading was an interesting problem as I had to simulate TCP's 3-way handshake. I decided to use encapsulation and break up the file I'm transferring into 512 byte s...
I'm writting a mark up for: And here is my HTML: <div id="container"> <header> <h1><img src="images/logo.png" alt="Jessica Priston - Photographer"></h1> <nav id="mainNav"> <ul> <li><a href="#">home</a></li> <li><a href="#">blog</...
I have 2 strings for example: abcabc and bcabca or aaaabb and abaaba I checked that second string is the same or not like first string but shifted. bcabca = ..abca + bc... using System; public class TOPSES { static string t1, t2; static char[] t1c; static char[] t2c; static void Main() { i...
I'm a newb at C++ and I was wondering whether I used pointers correctly and whether it was appropriate to use them in this context. Any other tips/information would be appreciated. #include <iostream> using namespace std; int euclideanAlgorithm(int *a, int *b); int main() { int x, y, a, b; cin >> a; cin ...
You can see a working example here. Be sure to click on the canvas or the key inputs will not be detected! Are there any ways I could improve upon this? Anything that should have been done differently? Any best practices I have not implemented? $(document).ready(function() { window.addEventListener('keydown', key...
I'm using Struts2 and Google App Engine. Below is my program for getting the country based on the IP of the visitor of the website. In my Struts2 action: HttpServletRequest request = ServletActionContext.getRequest(); String IP = request.getRemoteAddr(); String countryCode = Utilities.fetchUrl( "http://api.hostip.info/...
I programmed a little log engine in C I plan to use in my project and maybe some others in future. I am very novice C programmer and would like to have feedback of some experienced ones on this. It's spawned over few files but I've joined them so it's easier to compile. Thank you. #include <stdarg.h> #include <syslog.h...
I wrote a function for creating all possible translations of a source string, based on a multiple translation map. It works, but generates a lot of intermediate maps (see line marked with *). Is there a better solution? Maybe a more general solution to the "all possible combinations" problem?: /** * <p>Add to 'targets...
Please review unique_list: unique_list implements a list where all items are unique. Functionality can also be described as set with order. unique_list should behave as a python list except: Adding items the end of the list (by append, extend) will do nothing if the item is already in the list. Assigning to the midd...
I am a little new/rusty to this C++ stuff. Is this bad code? Can it be improved? #include <windows.h> #include <string> #include <iostream> #include <cstdlib> #include <ctime> bool _initialized_time = false; void Wait() { std::cout << "Prease any key to continue ..." << std::endl; std::cin.get(); } void print(char*...
So i have a super class that has a 3 child classes. Those 3 child classes have multiple classes of their own. I was having troubles saving this into XML, so I decided to parse it out and do a little bit of maths to return the correct subclass type and make an instance of it. So after a little bit of digging it appears ...
How could I make this code shorter and faster? 'Sheets("Summary(FG)") ComboBox1 items For b = 3 To Sheets("CustomerList").Cells(3, 2).SpecialCells(xlLastCell).row If Sheets("CustomerList").Cells(b, 2) <> "" Then Worksheets("Summary(FG)").ComboBox1.AddItem (Sheets("CustomerList").Cells(b, 2)) Else En...
Can I somehow make this a bit cleaner using Math.[Something], without making a method for it? int MaxSpeed = 50; if (Speed.X > MaxSpeed) Speed.X = MaxSpeed; if (Speed.X < MaxSpeed * -1) Speed.X = MaxSpeed * -1; if (Speed.Y > MaxSpeed) Speed.Y = MaxSpeed; if (Speed.Y < MaxSpeed * -1) Speed.Y = MaxSpe...
Thought I share this piece of code to the world. But be aware, I am not sure if this piece of code is safe and efficient. Feel free to improve it or give some feedback and suggestions. #pragma region DOCUMENTATION ON: STD_COPY_VECTOR_TO_ARRAY /////////////////////////////////////////////////////////////////////////////...