instruction
stringlengths
71
71.9k
I have a Python script that takes a map of a building and then draws green or red squares on the map corresponding to the physical location of building access points, the colors represent wether or not the device responds to ping. My code currently works, however as you'll notice there is a TON of repetition, which loo...
Input: data - a matrix of size n*m*3*3 (complex values) indices - a list of coordinates (x,y), where x < n and y < m fp - a feature parameter which is a tuple of ((fp11, fp12), (fp21, fp22)), id) reference - a list of 3*3 matrices swrd - a function which computes a similarity value between two complex valued 3*3 ma...
I wrote a function to reverse a char-array (string). Since I'm beginner and didn't work with malloc and stuff before, maybe someone could take a look, if this is fine, what I'm doing here? char* reverse_string(char* string) { // getting actual length of the string size_t length = strlen(string); // allocat...
I have the following two methods which handle the liking and unliking of posts in my Rails application: def create @post = Post.find(params[:id]) if @post.present? @like = Like.new(user_id: current_user.id, post_id: @post.id) if @like.save redirect_to post_redirect(@post), :notice => 'Liked!' else...
I solved this programming challenge: Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. For example, ...
I'm learning the ropes of Java. So far everything is going good. Can you please review my code and tell me what I can do to make it cleaner - or what I need to improve on?. I'll appreciate it so much. This program: The user inputs are the gross income and number of dependents. The program calculates the income tax base...
I remembered a cwrite application that I used in the good old DOS times. Basically it took a color code as first argument and some text as the second and printed the given text in the specified color. Also it supported some escape sequences. Since Windows NT does not support ANSI Escape Codes it's not as easy to change...
Considering I'm not implementing distributed lock mechanism, is this code correct and clear? class RedisLock class NotAcquired < StandardError; end def initialize(redis) @redis = redis end def lock(key, expiration_ms) val = SecureRandom.random_number(100000000000000000).to_s if @redis.set(key, va...
Well, that's my first "program" after couple days of working with Python and programming itself. That may be stupid since everything there is so basic but I wanted to ask if there are any spaces to improve it. Idea was to give the user proper dosage of 4 supplements regarding if this is training day or not. Is there an...
I'm a novice to programming completely. I'm trying to teach myself C++. I want to write code to create two vectors and read their elements from input. vector<int> v1, v2; /*Reading vector values*/ cout << "Enter the elements of 1st vector" << endl; int ele; while (cin >> ele) v1.push_back(ele); cout << "enter the e...
This is a follow-up for here, for bug fixes and applied advice. Problem Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :( Sometimes he puts emoti...
I have a .csv file that contains student GitHub repository assignment submissions. I made a script to go to each repository and extract the YouTube video that they must have provided in their README file. The structure of the CSV file is as follows: Timestamp,Name,Student Number,Git Repo link #!/usr/bin/python3 imp...
This is the first JS/JQuery script I had written for my website, few months ago. It toggles/hide/show menus (and some sub-menus/interactions) when a user clicks on specific items from the navbar. Right now I have 6 main menus, and I believe my code is far from being optimized. $(document).ready(function(){ $(docum...
I was thinking about how I was going to use some enums I made, how I was going to make sure they had valid values and how to call the class which would contain the necessary extensions methods. And then I thought: why not wrap the enum in a struct. I wrote up a little example code and it looks like this (ignore the fac...
I was tasked with this assignment with almost no time and I cannot stand up a new environment to test this. The risk is pretty high with what is the request is for so I'm asking for as much peer and code review as I can get. I'm tasked to check all the web.configs that have a certain DB Server and change it to a new va...
I've been working on this array, and I was wondering if there was any other way to rewrite the compress and ensure capacity methods since I've been running into problems with a different application that uses this class. Array-based application: public class ListOfStrings { public static final int DEFAULT_CAPACITY = 4;...
The following code will start a timer to continue drawing real-time data (that has been pre-buffered, to be swapped in the gui as fast as it can) to the window during repositioning or inside a menu loop. // State of the application static bool running = false; static uint32_t modalmode = 0, modalcount = 0; static const...
I've written a TCP chat application for the command line that supports multithreading. I'm wondering whether I'm using best practices for socket programming, what other types of functionality would be good to add. The usage is ./chatserver port_number and ./chatclient ip_address port_number Client #include "stdio.h" #...
Toggling images in a table. The example would be a user using a checklist program. She can click on a cell next to task to toggle available status images. Like a checkmark, fail, question. Other design suggestions are welcomed <!DOCTYPE html> <html> <head> <title>Test 123</title> <style type="text/css"> ...
I recently needed to generate a series of unique random numbers (non-repeated) within a bounded range inside of the Linux kernel. The code I came up with is below. I'd appreciate any feedback -- again, please keep in mind that it's within the Linux kernel, so the standard C library is out of the question. #include <lin...
This is my finished perceptron written in python. Is there anything that I can improve/suggestions? I'm a beginner with python so anything would be helpful! import random class Train: def __init__(self): self.train = [[10,5,3,False],[3,2,16,True],[4,15,11,False]] #Initialize training set ...
Motivation This is intended to implement a C++ maybe_ptr type that can either hold a pointer to an underlying type T or a nullptr. The idea is to guarantee at compile-time the absence of null pointer dereferencing errors in code that uses raw pointers. Traditionally, these kinds of errors are prevented by the user ha...
This seems to work fine, but I'm very new to C++ and would like any suggestions for improvements. Areas I have the most trouble with are: Namespacing (honestly, it's still half looking stuff up and making an educated guess with typename blah blah blah). Is there a "cleaner" way to implement this? Various C++ idioms (c...
We had to port a program from c to python. The code works but uses a dictionary to solve the problem. This doesn't feel like the right use of a dictionary. Is there a better way? #!/usr/bin/env python3 def main(): while True: height = input("Height: ") try: height = int(height) ...
I have a project which runs from a db table - it's purpose is to run processes written in various ways. Currently it deals with python scripts, vbs scripts and console exe files. It works but I'm wondering if there any obvious refactors? private Process aProcess; public void runProcess(string aPath,string aName,string...
I wrote small app finding next prime number starting from number passed as argument: object HelloWorld extends App { println(findNextPrime(49)); def findNextPrime(n: Int) : Int = { var m = n; while(true){ m += 1; if(isPrime(m)){ return m; } ...
Being given the following code I wonder how can I make it better, without using variable valid, yet check ALL the cases and if at least one of them matches set the returned value to False def validate_ticketer_issue(self, ticketer_issue): """ Validate ticket system issue for common rules :param tick...
The Driver Code that needs to be encapsulated in interfaces is shown next: OGRDataSource *m_wfs_t; m_wfs_t = OGRSFDriverRegistrar::Open("WFS:http://192.168.139.129/cgi-bin/tinyows.exe",true); OGRSFDriver*driver = m_dataset->GetDriver(); std::cout<<driver->GetName(); OGRLayer *poLayer; poLaye...
I wrote a simple game in Java using Swing. Code is working so far but I have no certainty that "spliting" into classes is done well. I would like to know what "design" problems I have in my code. Also I have a problem with understanding exceptions, I don't really know what to do when exceptions occurs. Terminate the pr...
I'm using pylint and flake8 to control the code quality. However I am in check-mate position, where styling one does not suit the pylint or flake8: if (not re.search(regexp, summary) and not re.search(regexp2, summary)): return False Output from flake8: visually indented line with same ind...
This program is designed to interleave two strings, which are input as command line arguments. I'd appreciate any feedback as I am new to C and self-taught. Edit: Since this is an exercise in becoming more familiar with the intricacies of strings and memory allocation, the output should be stored before being printed. ...
I wanted to better understand regular expressions, however, just learning regular expressions would be extremely boring. So I created a simple little program that will verify a hash by the length and output the most likely and least likely hash type. How it works, it will grab the argv from the user containing the hash...
I wrote the following to output, at the type level, the sum, Nat, of an input HList: trait HListSum[L] { type Out } object HListSum { type Aux[L, O] = HListSum[L] { type Out = O } def apply[L <: HList](implicit ev: HListSum[L]): ev.type = ev implicit def hListSumInductive[H <: Nat, L <: HList, S <: Nat, T <:...
Here is my first try to implement merge sort using iterators - #include <algorithm> #include <iterator> #include <vector> namespace base { namespace merge { template <typename Iterator, typename Compare> void mergeBack(Iterator begin, Iterator mid, Iterator end, Compare comp) { typedef typename st...
This is my first attempt at building a full project. I've recently learned using prototypical inheritance in JS. Please tell me how I can improve the quality of this code. The game is available here: http://tic-tac-toe-realtime.herokuapp.com index.js file for the server: var express = require('express'); var bodyParse...
This is matrix multiplication. Big matrix split on the submatrix and multiplication in parallel, result matrices merge to result. How i can make this code better? public class MatrixMultiplication implements Callable<int[][]> { private static int LENGTH_OF_SIDE = 1000; private int taskCount = 4; private int[][] matrixA...
I have two arrays as follows: public $headers = [ 'user_id', 'timestamp', 'value', ]; protected $args = array('user_id' => array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array('regexp' => '/^[a-zA-Z0-9_]*$/'), ), 'timesta...
I have the following method which creates a like for a post: def create post.likes.create(user: current_user) respond_to do |format| format.html { redirect_to post_redirect(post) } format.js end end We don't really care whether the create was successful or not and either redirect the user to the post (th...
I have written a powershell script that will scan a directory for any *mkv, *.mp4, *.avi files, and will parse the filename to get Name, Season Number, Episode number. Then will check against destination directory to determine If Name exists (if not create it) If season number exists (if not create it) Once both these...
I am new to Django and added a vote duplicate check to the tutorial application. I set a cookie in the vote view: cookie_name = 'voted' cookie_pattern = '^(\d-?)+$' # ... def vote(request, question_id): question = get_object_or_404(Question, pk=question_id) # ... # Set duplicate vote cookie. half_year =...
I have one application with two views. One to sign in and one to sign up. Each view has an Email entry as main identifier. I want to add some itemTemplates to my application, because for now I repeat all UI properties twice. In the code, a block is a listItem. Some blocks have the same name, but icons is different, and...
I need to query the table below and list the distinct items at the top of my result set and the duplicates will follow, the order of the duplicates does not matter. I am working with Sql Server 2016 if that offers any nice tricks for improvement. Table design create table Items(Id INT,Item VARCHAR(5)) insert into Item...
I have a string that contains a random order of parenthesis {[()]}. I want to check if for any given parenthesis is there a matching closing one. Example: }}}{{{ //true {[] //false {[()]} //true private static bool checkIfWellFormatted(string inputString) { if (string.IsNullOrEmpty(inputString)) t...
Given a sorted array and a number x, find a pair in array whose sum is closest to x. Here's my solution: import Data.List (minimumBy) import Data.Ord (comparing) closestPairSum :: (Num a, Ord a) => [a] -> a -> (a, a) closestPairSum xs n = snd $ minimumBy (comparing fst) pairs where pairs = sums xs (reverse xs...
For my game I have a function that resolves FireOrders between units. The function is being called a ton of times and it's only being extended from various classes. I have this: doDamage() for a Particle-Parent, a Matter-Parent and so on (5 in total). The functions are the same, except for a very little if/else part th...
I present to you... my battleship location picker! This will be part of a larger battleship program. The coordinates that are important are finalcoords. from operator import itemgetter import getch import skilstak.colors as c #colors BOARDLENGTH = 10 BOARDHEIGHT = 10 board = [['_'] * BOARDLENGTH for _ in range(BOARDHEI...
Is this a satisfactory implementation of event sourcing using functional programming? module Account (*Types*) type EventAggregate<'Aggregate> = { Event:Event; Aggregate:'Aggregate } and Command = | Login of EventAggregate<Account> | Deposit of EventAggregate<Account> | Withdrawal of EventAggrega...
The following script makes an image pulse in Unity by fluctuating its alpha channel. However, I feel like there is a lot of duplicate code in the update method. How can I clean up that code to have it not repeat itself with +-, true false, etc.? using UnityEngine; using UnityEngine.UI; [RequireComponent(typeof(Image...
I have JSON which is coming by executing a URL. I want to store all the value of id field in a List<String> by parsing through GSON. Also, if the next field is true, then that means there is another URL at the bottom of the JSON which I need to use to get the second page which will also look like this JSON response whi...
I was doing some reading on the Wagner Fischer algorithm algorithm for computing the edit distance on strings. None of the examples in the literature I have read showed how to recover the edit sequences from the final populated matrix. The examples only showed total number of edits. The logic I am using is simply calli...
This is a follow-up for here, for bug fixes and applied advice. Problem Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :( Sometimes he puts emoti...
I'm currently working on solving the SmartWordToy TopCoder problem: The toy company "I Can't Believe It Works!" has hired you to help develop educational toys. The current project is a word toy that displays four letters at all times. Below each letter are two buttons that cause the letter above to change to the...
Here is my code to use range minimal query to resolve the LCA problem. I applied comments from here. Any advice on code bugs, performance improvement in terms of algorithm time complexity, code style are appreciated. Major ideas of my idea are: Build depth array of each node by in-order traverse Build MRQ index for de...
I wrote a script which is supposed to be making requests to an API to gather a lot of data. There is a limit on requests that I can make: about 30 000 in 8 hours otherwise, I will get banned for a significant time. Each object I get from the API can be identified uniquely with a hash. Each API call returns me some data...
I'm new to Firebase and am a recovering SQL developer, so I haven't quite wrapped my mind around all aspects of firebase querying. I have an app that has basic functionality in place, but some aspects run quite slowly. For example, I have a function that gets cities for a dropdown based off two other dropdowns (country...
Here is my code to implement authentication in a Node/Express/Sequelize project. This is my first time using JWT and I would appreciate any help! // Load required packages const jwt = require('jsonwebtoken'); const expressJwt = require('express-jwt'); const config = require('../config'); const User = require('../models...
I have data returned from an API coming back in a response: response.data [ {"amount":"45342", "comment":"random text", "currency":"USD"}, {"city":"LA", "amount":"54366", "lane_id":{"$oid":"5645999965a5b0"}} ] I need to take only the amount and create a new set of objects like this: [{amount: "...
I'm working on this problem, and any advice on performance improvement, bugs or code style issues are appreciated. Problem Description There are N gas stations on a straight, M kilo-meters long highway. The i-th gas station is Ai kilometers away from the beginning of the highway. (It is guaranteed that there is on...
Here is little snippet from my types.h code: /** * tick_t: is used to store and manipulate with time (tick count) * Unsigned, at least 32bits * 32bit number gives us 71 minutes resolution * 64bit number gives us 584'942 years resolution * Use OMFW_TIME_ISELAPSED(targetTime, currentTime) for time comparing */ type...
I have some sensor data that contains timestamps from when a machine is turned on and an indicator variable showing whether or not the machine is actively running. The data is mostly recorded every two minutes, but they there could be more or less time between two sensor readings due to issues with the sensor. I wan...
The challenge description is as follows: You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array. Example: longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2) --> "abigailth...
Working on below cross river problem, and post my code in Python 2.7 using dynamic programming. Any advice on performance improvement in terms of algorithm time complexity, code bugs or code style advice is appreciated. More specifically, my idea is, build a DP array to represent if we can reach a location by a certai...
I am writing a code to search Product database and return result to user. user can select various options like product attributes that varies from product to product, also there may be case like for single attribute there can be multiple value. For Example user can select brand as filter and can select from given brand...
I'm trying to learn python and am still a bit foggy on classes. Am i using them right in this tic-tac-toe game? Everything function like i want it too but not sure if i am really getting how to use classes. Any other suggestion for improvement are welcome as well. import random import time class TicTacToe(object): ...
This is my first game made using canvas, currently it works well but I know my JavaScript could be better as I am still learning. What improvements can I make on the structure of my JavaScript? document.addEventListener("DOMContentLoaded", function() { var c = document.getElementById("board"); var ctx = c.getCon...
This is one of my first competitive programming solutions. The problem it solves is described here; basically, you get a series of grids ("fields"), where . means "no mine" and * means "mine"; you have to compute how many mines are adjacent (8 adjacent squares) to each non-mine square. My solution is correct, but seems...
Using the standard C library, I want to repeatedly concatenate onto a fixed size string. Despite its promising name, the semantics of strncat do not appear suited to doing this, and the return value provides no new information. strncpy also requires a strlen to update the position. The reason I used snprintf (C99) in t...
I am dong a competitive programming problem I have passed all the tests. but my program times out. I need help optimizing my code so it can run faster. Task: Finish method: BingoCaller.GetNumber() Return all numbers in the range of 1 until 75 once and in random order If there are no numbers left, return an empt...
I'm the newbie in Java (and programming) and I've tried to make a simple calculator. Code is barbaric, I know, so I would like to make it more beatiful. Main.java: import java.util.Scanner; import java.util.Vector; public class Main { static Main mainobject = new Main(); ActionsToDo act = new ActionsToDo(); ...
I'm developing a Social Engineering Awareness Training Application. This is the focus of my thesis for my undergraduate degree. This will be a multi-part review request, however, if you want to see the entire application, it can be found on GitHub. For this request, I'm looking to see how my revised AuthController (ini...
I want to implement a service that fetches eyetracking events and publishes them to all subscribers of the stream. The whole thing is supposed to run asynchronously, so it doesn't block the UI thread. This is how the service is supposed to be used: ETStreamService service = new ETStreamService(); service.getObservable(...
Motivation In this question, a user asked whether it is possible to inline the following function: -- simplified version {-# INLINE nTimes #-} nTimes :: Int -> (a -> a) -> a -> a nTimes 0 f x = x nTimes n f x = nTimes (n-1) f (f x) Unfortunately, the answer seems no, since GHC sees a recursive function and gives u...
This is a school project submitted last year, and I've been looking over it and trying to figure out what I could improve on. I know I used celsiusInput and fahrenheitOutput the wrong way around in Fahrenheit conversion, that was just laziness at that point and not wanting to break something before handing it in. I wou...
https://projecteuler.net/problem=11 Any thoughts? Also, when measuring with chrono it takes supposedly 4 ms to compute, is this reliable value? Previous problems took little longer to compute so I'm suspicious, and I'm still a beginner so I'm not sure how long it "should" take or if chrono is good for measuring comput...
I try to learn (flat-, FASM-) Assembly currently. For to become more familiar with the concept of branching I made a tiny program. Inspired by an exercise I had to do once in school when learning PHP. "Write a program which takes an integer given by the user. The program then calculates and prints the square numbers f...
I have written a short Python program which does the following: loads a large data file (\$10^9+\$ rows) where each row is a point on a sphere. The code then loads a pre-determined triangular grid on the sphere, and counts the number of points in each triangle. I have optimised it as best as I could, however, I'd like ...
i just had a problem converting the JSON from Phillips Hue Lights (Response) to a Model. Since it may contain several "unknown" keys in success and/or may contain just a String for success i had to write/use a TypeAdapter and a deserializer aswell. This works but im pretty sure there is a better way to solve this. Dumm...
This is my first game, and looking for some help to improve current code because I've identified a lot that I think could be written more efficiently, particularly the segment that checks which key has been pressed but I'm not sure how to improve it. import pygame from pygame.locals import * import random import sys ...
I'm trying to learn exception handling in C++. I wanted to read two integers and divide them and print them. The code should throw an exception when the second integer is zero, ask the user to re-enter the second integer, and then complete the divide operation. I coded something like this: #include <iostream> #include ...
Since the FizzBuzz challenge is about developing ideas, I've added a third test case for which I chose divisibility by 7 and its accompanying tag "Go". This tag was purposely given a length other than 4 to resist writing an optimization that would otherwise impair adaptability. outputting in a redirection friendly ma...
I'm learning Java concurrency by a TDD approach. Therefore I wrote a basic test case in JUnit to test the behaviour / expected results of 2 threads. I'm looking for feedback for this code. In particular, the feedback for using CountDownLatch. I'm not sure if it is used correctly. package io.mincongh.concurrency; impor...
I wrote a multithreaded p2p chat application with Qt, and I'm hoping for some feedback. I know there's some deficiencies with error handling, but I'd like to know what else I'm missing. Thanks! import sys from PyQt4 import QtGui, QtCore import threading import socket import time import Queue class initWindow(QtGui.Q...
I came across a question where I had to find the floor by using given room no. And given no data structure to hold the data. What we know is distribution of the rooms across the floors. I have given below solution for it but, I think it may break as number of floors increases. int queryRoom = 37; int totalFloor = 6; ...
I wrote a piece of code to benchmark the detection of perfect numbers up to 10000. The original code is here, in C: #include <stdio.h> int isPerfectNumber(int num) { if (num == 1) { return 0; } int i, c = num - 1; for (i = 2; i <= num / 2; ++i) { if (num % i == 0) { c -= i; } } return c...
I created an example (for me) of how I must get the comments and replies from the database. Here is the result for example: //I am ONLY thinking a query like this $q = "SELECT * FROM comments_table WHERE post = 'url_code' ORDER BY date DESC"; //An example result (Not used the query above) $comment = array( ...
I'm new to programming, but want to build up a good habit of code review so that I can develop best practice. It's been couple of weeks I'm coding in C and my knowledge, so far, is data types, conditions, arrays, loop and, very minimal, pointers. I'm creating multiple search and sorting algorithms - not only to underst...
I'm working on the cross river problem (previous post here). Any advice on performance improvement in terms of algorithm time complexity, code bugs or code style advice is appreciated. More specifically, my idea is: build a DP set to represent if we can reach a location by a certain speed; when checking whether we are...
I am making a game for Android using Java and libGdx. I have an ArrayList of enemies that are updated each frame. The update method for the enemy looks like this: public void update(float delta){ if (waypointIndex < waypointCount){ waypoint = path.getPoints().get(waypointIndex); distanceToWaypoint...
I have written a piece of code (in Py3) that graphs out the controller value of PID controller. This is so that by changing the various sub controllers (P/I/D) I can visualise how the graph changes. I've written the following code, but having difficulty in the PID algorithm, and obtaining a correct controller value. Yo...
I am learning design patterns from Head First Design Patterns and a principle I came across is to "code to interface". Now I want to apply this principle in my Android app, which includes lots of API calls. I am using Retrofit for network calls. I have applied this principle considering some scenario something like thi...
I am writing a computer opponent in java to play the dice game pig. I am trying to code it to be optimized based off of this paper. @Override public boolean decideIfShouldRoll(int turnNumber, int rollNumber, int poolSize, int myScore, int opponentsScore) { if (myScore < 30 && opponentsScore < 30) { ...
I have a method that checks if a date is correct or not, which returns a boolean if it is or not. In the method, I first check the format, then the date by using the function checkdate, then I check that time is of the format His. /** * Function that checks the format, date, and time of a given timestamp. * @author...
// NODE implementation template <typename T> class forward_list_node{ public: using value_type = T; using pointer_type = T*; using reference_type = T&; forward_list_node(value_type value = 0) : data(value), next(nullptr) { } forward_list_node<value_type> * get_next() const{ return th...
Is there any way for optimizing the below query without further addition of any INDEX, if possible? CREATE VIEW [dbo].[VFUN_Late_Evnt_By_Acct_Doc_Id] AS SELECT L.Doc_Id ,L.Evnt_Id as Latest_Event_Id ,E.Evnt_Name as Latest_Event_Name ,L.Crtd_Dt ,L.Evnt_Xml_Doc as Latest_Event_xml ,L.IsMailSent ...
I have a function that accepts false as a default value but can be passed an array. protected function sendMessages ($recipients = false) { //cast to an array $recipients = is_array($recipients) ? $recipients : [$recipients]; // if no recipients are passed get email from current object (default) if (i...
I am reviewing the following code: $creationDate = $order->getOrderCreationDate(); $dir = Mage::helper('moduleX/order')->getPathOfTheDay($creationDate); The $creationDate variable is only used once in the aforementioned code. I was suggesting to my coworker that it could be simplified to: $dir = Mage::helper('moduleX...
A fast paced shooter which counts and displays your kills. If you are to copy and paste this code also copy the images and save them as png files with names in the code import pygame import time import random import timeit pygame.init() display_width = 1600 display_height = 850 speed = [1, -1] black = (0,0,0) wh...
I want to implement simplest mutex without built-in functions or the <pthread.h> module. #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h> // strcpy #include <unistd.h> // usleep #define MICROS (1) #define THREADS (300) #define ACCESSES (1000000) char * names[] = {"alpha", "bravo", ...
This is my first big project that I've made in Python. I've noticed as I was writing it that it's extremely repetitive and I just don't know how to make it less so. # This is a basic calculator that also has area/volume calculations for certain shapes. import math import sys # Main menu def main(): choice = inpu...
This simple JavaScript code styles all file inputs to match with Bootstrap's style. Simply, it turns this: Into this input: (function(window){ window.jQuery(function($){ $('input[type="file"]').each(function(){ var $this = $(this); var $parent = $this.parent(); $this.d...