instruction stringlengths 71 71.9k |
|---|
I have two similar libraries for use in an embedded system (Teensy, sort of like Arduino). One is for debouncing a digital pin, the other is for reading a capacitive pin as if it is a debounced digital pin.
They have similar APIs:
constructor (with pin number as parameter)
void update() hides reading the pin and inte... |
The following code is my attempt to create an interactive bodeplot. I used JavaScript using d3.js, jQuery Mobile and math.js. The bode plot shows a lead lag filter in continuous time and several discrete time equivalents using a certain discretization technique.
I would like to have some comments on:
How I created the... |
I came across this problem by accident and gave it a go. I think my solution works as it has passed all the unit tests I wrote. Given I just started learning F# a couple of weeks I would love to have some feedback on the code regarding both its accuracy and its quality.
To be clear about the problem, given an integer ... |
I wrote some code to implement a way to filter the arguments of a variadic template based on their type.
My current solution requires many helper meta-functions and I'm sure that there must be a better way. How would you improve this?
#include <type_traits>
#include <tuple>
//Type for storing a variadic template
templ... |
I was playing around with ES6 arrow functions, currying and partial application and I decided to try a functional implementation of the FizzBuzz problem:
function* range(start, stop) {
for (var i = start; i < stop; i++)
yield i
}
var map = fn => res => x => fn(x) ? res : null
var isDividedBy = dividend => diviso... |
I have the following 'interface' to the C++ std::list and I was wondering how I could make it go faster. In particular, it needs to be able to evaluate up to two million operations in a matter of a couple seconds. Right now it's at around 8 seconds.
#include <iostream>
#include <list>
int main()
{
int n, m;
s... |
I built a small app that gets data from a remote json file and displays it in a list of users. In each list item, an image of the user, their name, and their points tallies are shown.
The list is displayed in two possible ways - 'all time' and 'recent' - depending on the user's choice.
I would specifically like feedbac... |
As an interesting sub-part of an interpreter -- just the Read part of the REPL -- I present my raw-mode line-oriented editor that I intend to use for my APL interpreter. (The Eval part has been posted for review in comp.lang.c.) It defines a large character-translation table to coordinate the input-form/internal-rep/ou... |
I'm learning C and one of the questions I've been asked is converting a string to an integer. The code I've written supports converting from a string in any base up to 16/hex to an integer. There is no over/underflow checking and it does not support lowercase hex.
int ASCIIToInteger(char *x, int base)
{
//Each el... |
Heres the idea
Write a program that takes two integers, N and M, and find the largest integer composed of N-digits that is evenly divisible by M. N will always be 1 or greater, with M being 2 or greater. Note that some combinations of N and M will not have a solution.
Example: if you are given an N of 3 and M of 2, the... |
I wrote a function that basically works like sprintf, but instead returns the formatted string (std::string). I haven't worked on this long, and I'm aware there are tons of improvements that could be made (alloc/realloc perhaps?). I was just looking for some advice before taking the next step.
GLOBAL string format(cons... |
As a follow up to my previous question I've improved the code + algorithm. The compression now works the following way:
Each character is followed by a length byte. The top 3 bits of that byte denote the number of additional length bytes which encode the count. The count is stored in "little endian order" (least signif... |
I recently solved this leetcode problem:
Given n nodes labeled from 0 to n - 1 and a list of undirected edges
(each edge is a pair of nodes), write a function to check whether
these edges make up a valid tree.
For example:
Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true.
Given n = 5 and edg... |
Explanation
For this Christmas, I got this puzzle as a present, with the aim being to try and fill 25 "Z" shaped pieces into a 5x5x5 box. Once I saw this gift, I thought I would challenge myself into trying to make a program to solve this for me.
Picture of piece
All pieces are exactly the same, which are 5 units in s... |
I'm using a method to make initialize the attributes of my objects, and this method is called from both constructor.
What it does is, if no correct currency has been passed, choose € by default.
I'm just wondering if what I've done below is correct in terms of design.
class Prix
{
double valeur;
string monnaie;... |
I'm learning Clojure and I'm interested in areas that could be more idiomatic. The main function is below. If you're interested in the whole lib, check out this.
The function operates on a grid, which contains a finite number of cells. A cell is a single point in a grid. neighbours-of will get information about moving... |
I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed.
Situation
We have one message queue. We would like to process messages in parallel and limit the number of simultaneously processed messages.
Our solution
Based on answers g... |
I'm making a Battleship game using python 2.7. However, how to make it is not currently my issue. The main aspect that I'm asking about is the style and method of making the code. Am I following best (or even good) practice? Are the comments too much, too little, unclear? If someone could give me some pointers based... |
I have a list T of objects (of class Element, this class stores attribute values (strings) of elements from an HTML page) in C# - Visual Studio.
I am interested in finding the maxPageWidth. To do that, I want to check the whole list of objects for the Left value and the Width value. The highest of these values put tog... |
Here is what I've written for a program to print upper half triangle of a matrix. Now I need a way to do it without using goto:
#include <iostream>
using namespace std;
int main()
{
int a[10][10], r, c, i, j;
cout << "Enter the number of rows and columns";
cin >> r >> c ;
cout << "Enter the matrix... |
Based on suggestions and some thoughts I made some refactorings of my classes to hold EAN13 codes, I created a contract interface which now is extended by BarCode classes, since there will be other types of BarCodes, like DUN-14, UPC-A...
public interface BarCode {}
I decide to move all the validations to factory clas... |
import java.util.Scanner;
public class ticTacToe {
public static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
char p1 = ' ';
char p2 = ' ';
boolean gameOver = false;
char[][] board = new char[3][3];
int pos1 = 0, pos... |
I have written this little function to convert UK weight drams (dr) to ounces (oz) and pounds (lbs). As far as my research goes, 1 lbs = 16 oz and 1 oz = 16 dr. I need the function to return an array of lbs, oz and dr.
Am I doing it right? Or is there a better way to do it? Has my method got any flaws?
function fromDra... |
Here is my Haskell program designed to list all of my GitHub repos along with their descriptions and languages via the GitHub JSON APIs:
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad
import Data.Aeson
import qualified Data.ByteString as BS
import qualified Da... |
Is there anyway to improve with how this code is structured into functions? Is the coding style compliant, and what can be improved beyond this?
def add_lower_intuitive_relation(gurobi_model, Leg1, Leg2, lower_bound, eval_func, name=""):
for first_departure in xrange(Leg1.latest_departure_time - Leg1.earliest_depar... |
I built this as part of completing the Codecademy JavaScript lesson. I wanted to perfect it, make it readable and functional, and as efficient as possible. As far as I can tell it can't be any more efficient than this. But maybe I can't tell. What do you think? I know there are little things, maybe the victory variable... |
What I'm trying to do here is first set the first eight variables to the proper default values. That's the first area I'm thinking there might be a way to optimize. Is there anyway to set both variables at once for example I know in PHP I could do $title=$d_title="value"; Is there any way to consolidate that section? (... |
I created the following code to better understand CIDR notation. Also to learn some of the Stream features in Java8. I posted my unit tests too.
I'm interested in ways it might be improved especially by using Java8 features. I reviewed the InetAddr class and realized it uses at array of bytes instead of ints. I did... |
I wrote a simple synchronization primitive that I can use with async operations on an external REST service so that I don't call it twice from different threads and have one call fail due to not having the latest state. Despite obvious limitations of that design decision I think this should solve my problem...
struct ... |
I need to read Databases which contain 44-50 Tables, with around 5 Million entries in Total (~ 100k entries per Table).
The Data consists of Positional Tracking Data in Sports (Players,Refs and the Ball) and Match-Events (Shots, Plays,Tackles,...):
Match-Events are negligible regarding performance.
Table: PlayerXYZ or ... |
I have written the below code which loads the dictionary and checks if the given word is present or not.
The implementation is using a hash table with a chained linked list.
In regards to the hash function, I have kept it simple as I was not very concerned about collisions.
Can someone please review it and let me know ... |
I made this small and easy function that returns the largest common multiple of the elements of ms that is equal to or lower than max:
LCMLthan = function(ms,max) {
ms = sort(ms, decreasing =TRUE)
max2 = c()
for (m in ms)
{
max2=append(max2,m*floor(max/m))
}
max2=min(max2)
while (T)
... |
This is code for performing a calculation that should be repeated with different levels and temperatures. I am concerned about the organization of this code as I feel it may contain too many helper functions and seems a little unnecessarily complicated. Only the getCharge() method needs to be exposed to the browser.
Th... |
For a leetcode problem to generate the valid parentheses of length 2n, I have written this solution. It is working for smaller inputs but not for larger inputs. Please suggest a way to optimise my code.
I have read the Stack Overflow questions but was unable to implement the same concept in my code.
//I have writte a ... |
I've got a simple JavaScript function that takes multiple types of arguments. Inside the function I'm doing a check on the arguments to determine which way the user called the function:
var build = function() {
var args = Array.prototype.slice.call(arguments)
var options = {
to: {},
from: {},
... |
I got bored and decided to create a lua announcement system with the ROBLOX API.
One part is the display code, and the other part is the announcement code.
DISPLAY CODE
while true do
wait(0.2)
if script.Parent.Parent.An.Value == 0 then
script.Parent.An1.Text = "This bus terminates here"
script.P... |
Sorry, if you were looking for fresh baked pies, I only have a web client to help you sell them.
I've recently picked up server-side JavaScript and have added it to my toolbox, and while I've had a great time learning so far, I've got some code which needs another pair of eyes to review it.
A quick objective summary: ... |
import csv
import logging
import itertools
from random import choice
from string import ascii_lowercase
from collections import namedtuple
from tempfile import NamedTemporaryFile
DELIMITER = '\t'
ENCODING = 'utf-8'
def get_random_cursor_name(length=7):
return ''.join(choice(ascii_lowercase) for i in range(lengt... |
I'm seeking a code review for the following C++ implementation of Dijkstra's algorithm. I'm trying emphasize code reusability and extensibility but performance is also potentially important.
Documentation
Heap.h
This class implements the priority queue for use in Dijkstra method of Graph class.
The insertion into the... |
So this a exercise from the book COMPUTERS SYSTEMS A PROGRAMMERS PERSPECTIVE
I need to add two signed numbers and in case it overflows or underflows return TMAX (011..1b) or TMIN (100..0b) respectively. In this case we can assumed two's complement representation.
The book imposes a set of rules that the solution m... |
Recently, I ventured into the realm of C++ programming. I have extensive knowledge in C and C#, but very basic knowledge of C++. I decided to build a brief TicTacToe example to test my knowledge.
It works by typing any comma-separated value (i.e. 2,1) and decides whose turn it is by odds and evens. X always goes first.... |
I'm trying to categorize file names of anime episodes (for now) into appropriate title based categories. The Show-titles are parsed from an XML file (I got from Anime News Network).
EDIT: The passed on backgroundWorker object type variable is just to facilitate GUI update as this algorithm runs on a secondary thread.
D... |
The code is actually a TemplateBuilder.
We have 2 different templates, French and Dutch.
We need to change the template and then convert it to PDF so it can be stored in the DB later.
The main method is createBulletins().
What am I looking for?
I don't like the constantly reading the template from the byte[] for each ... |
Here are some stripped down versions of the two different programs I am deciding between.
In version one, my state machine is called within the interrupt:
void TimerInterrupt(void)
{
int battery_voltage;
StartADC();
while(ADCrunning){}
battery_voltage = ADC_value * scale_factor;
BatteryStateMach... |
I have implemented a phonebook in C using a singly linked list sorted data structure. This is my first average-major project.
I need some reviews so that I can improve my coding standards. The program consists of 3 files:
header.h: custom header
/*
* File : header.h
* Custom Header Definition
*/
#include<stdio.h>... |
Consider the following string in javascript:
var string="border-radius:90px 20px 30px 40px";
I want to extract the 4 numbers from that string and store them in an array called numbers.To do that I developed the following code:
var numbers=string.split("border-radius:");
numbers=numbers[1].split("px");
This code is wo... |
I've made a small js/css/html module which purpose is to fill a pie chart up to a given percentage. Basically it could be used for instance as a filling pie chart that keep tracks of the amount of donations for a non-profit organization.
Let's sum up briefly what it does. Basically I have two svg circles, the base col... |
I am trying to write an SQL Procedure that will calculate the Last Price paid for a certain Part.
DECLARE @ItemId int;
SET @ItemId = 1;
SELECT
SD.Price
FROM SalesOrderHeaders AS SH
INNER JOIN SalesOrderDetails AS SD
ON SH.Id = SD.HeaderId
WHERE (SD.LineItemId = @ItemId)
AND (SH.OrderDate = (SELECT
MAX(SH.OrderDat... |
This is actually a question that bugged me for 8 years or so, but just swept it under the rug.
I have a project (big, old, zend 1, etc.) that contains a decent (not high but large enough) amount of logic in views. This implies existence of conditionals there. It does not have any template system (like smarty/twig) so p... |
I'm a coder who's relatively new to Python and I wanted to spice up my console applications a bit by making animations. The code I've written works perfectly, but I just wanted to know if it was good in a pythonic way and if it follows the OO standards. If not please tell me what could be improved and why.
import subpr... |
My code is meant to update the positions and velocities of planets. There are a few methods in this class, but updatePosition and updateVelocity are the most important, as they implement the velocity verlet algorithm. Could it be shorter/more efficient?
public class Particle{
private double mass;
private PhysicsVector... |
From SICP
Exercise 2.27: Modify your deep-reverse procedure of Exercise 2.18 to produce a deep-deep-reverse procedure that takes a list as argument and returns as its value the list with its elements deep-reversed and with all sublists deep-deep-reversed as well. For example,
(define x (list (list 1 2) (list 3 4)))
... |
I am caching an image locally..That same image will be used in few screens. Steps for doing this is as follows:
Get image from cache
If not present in NSCache, get image from Cache directory
If not present in Cache Directory, download from Internet
Save downloaded image to dir
Insert the image in cache
//Helper clas... |
Here's my solution to checking if a Sudoku board is valid. The algorithm checks the following,
Rows add up to 45
Columns add up to 45
Rows have no duplicates
Cols have no duplicates
Every 3X3 sub-grid has no duplicate
Invite comments.
public class Checker {
private int size;
private int[][] board;
public... |
I wrote this Python code that plots the movement of an object under the effect of a given force function in 2D by solving the Newton's movement equation numerically. One can add other force functions, or even parameters to the draw_path function. I tried to make it as readable as I could.
I would really appreciate if ... |
I have a blog that I occasionally post to, but it's a PITA because of the fact that it has it's own WYSIWYG editor and doesn't support Markdown. So I have to switch the WYSIWYG editor to the HTML editor, and of course the HTML is garbled from the WYSIWYG editor.
So, I wrote a programme that I can feed Markdown into, an... |
I'm writing a query to get the number of sessions created each day for the past 90 days. I'm currently using a prepared statement to do this - looks something like this:
for($n = 0; $n < 90; ++$n){
$days[] = $n;
}
$st = $this->db->prepare("
SELECT *
FROM `sessions`
WHERE DATE(sessionStart) = DATE_SUB... |
I'm using RxJS 5.0.0-alpha.12 to perform some data transformations, and some of those transformations use Promises.
return observable
.flatMap(item => {
return Observable.zip(
Observable.fromPromise(fs.readFile('./config.json')),
Observable.of(item),
(s1, s2) => {
return {
config: JSON.pa... |
Since it was getting boring to always do OOP Languages I decided to dabble in the functional realm of programming.
For that I chose the narrowly missed community-challenge by Edward: Resistor Mania, since it really is a quick-to solve using recursive and functional style.
Challenge description:
In electronics, two re... |
I'm just learning how dependency injection and mocking work, but I'd like some feedback on how I'm setting up a couple of tests. I can get them to pass, but I'm not sure this is all I need.
This is an MVC application that makes Web API calls to return data. For this example I'm running queries in the Web APIs that po... |
A third follow up to the simple compression implementation.
Adopted most of @holroy's suggestions. Main changes:
Compression now uses high-bit to indicate that additional length bytes are still following
Added decompression support
Should no longer depend on CHAR_BITS == 8 which increases portability
Use of unsigned l... |
How can I make this code shorter? The code I am using is so long. Just making one simple level is taking about 100 lines of code.
public class Sister_age_guesser {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Sherlock holmes - The game");... |
A utility method StringUtils.replace to replace multiple search strings simultaneously.
I'm looking for a review of any and all aspects, but especially:
Is there's a better way to do this? (short of external libraries)
Is the parameter validation OK the way I did?
Is the way I test adequate and up to good practices in... |
Problem: Given a arbitrary string, split by a given regex and format into an R vector expression. E.g. Convert "a..,b..,c,d" into 'c("a","b","c","d")', when the given regex is "[.,]+".
Solution in haskell:
module Lib
( toRVec
) where
import Data.List (intersperse)
import Data.Maybe (from... |
My team and I have ended up creating this class, which is called directly from ASP.NET Identity as a custom password hasher. I'd like to know whether this would be "overkill"/use a lot of CPU, specially because the site is going to be hosted in Azure.
To take into account:
HashPassword is called when a new user is b... |
I'm teaching myself programming, using Python as my initial weapon of choice.
I have learnt a few basics and decided to set myself the challenge of asking the user for a list of names, adding the names to a list and then finally writing the names to a .csv file.
What would you do differently, i.e. how could this code b... |
I made this simple code which makes easy HTML tag generation. It is open-source and right now only makes tag names and replaces tags... :/
#include <iostream>
#include <fstream>
std::string makeHtmlTags(std::string tagname, std::string tagcontent) {
return "<" + tagname + ">" + tagcontent + "</" + tagname + ">";
}... |
I am working to design an object which would abstract away the use of a WebAPI. I want the developer to be able to use these objects as if they are using a traditional API.
My core problem is how to abstract the interactions with the WebAPI. I currently use an Interface which is initialized in each element to provide ... |
Here is an implementation of Dijkstra
As an rags-to-riches version of this Object oriented approach to Dijkstra's algorithm
#include <set>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <iterator>
#include <iostream>
/*
A very simple Graph object:
The graph type here ... |
I'm trying to update my skillset by learning how to write isomorphic JavaScript applications. For my stack, I've chosen React and Express - no database yet.
The problem many people seem to face when it comes to writing these kinds of applications is getting data from the server to the client so the view can be rendere... |
I have coded for the problem Code Kata 18. Provided the input dependencies, I need to come up with all the transitive dependencies. While working, I encountered various problems like Data Structure Solution, ConcurrentModificationExceptions and others.
Used HashMap of String,HashSet to represent a class along with dep... |
I've made a Pomodoro Timer application. All it does is countdown from a time in minutes given by the user to 0:00. It does this first for a session time, and then switches to a break timer and continuously loops like this until the application is paused or closed.
The time can be adjusted by clicking on a '+' or '-' be... |
I have implemented mergesort in C. Any advice on making it more compact? My merge function seems less than fully optimal.
//mergeSort in C
#include <stdio.h>
#include <stdlib.h>
void merge(int [], int[], int[], int, int);
void mergesort(int[], int);
int main()
{
int unsorted[] = {4, 1, 3, 0, 10, 2, 5, 5};
i... |
Background
Emacs on OS X by default binds several keys with the super modifier. I do not want these bindings as I switch between OS X and Windows frequently, and want a clean slate on both platforms to bind super keys for my own purposes.
Code
global-unset-all-super-key.el
(defun global-unset-all-super-key ()
"Will u... |
Please review my Parser class. Should I declare map outside of convToPosfixQueue method?
class Parser {
private final Stack<String> tempStack = new Stack<>();
private final Queue<String> postfixQueue = new LinkedList<>();
public Parser(Queue<String> infixQueue) {
convToPosfixQueue(infixQueue);
... |
I would like to receive input from more experience coders regarding the potential improvements this piece of code might have. I am new to PHP development and I am sure this code looks horrible behind the eyes of someone more competent. It works, but I think there's plenty of room for improvement.
I have an images folde... |
The below script will compare a set of arrays according to similarities between their key's values. For example, if the first 4 keys values of an array are equal to another array's first 4 keys values, they are equal and consists a cluster. Here is my code:
<?php
$arrays = [
array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4),
array... |
I have created a test login page that, as most do, takes in two values from the user (username and password) and the processes it.
For this I have opted to use jQuery and AJAX to pass the results to a separate page to be processed, checked and validated before allowing access.
My main front end uses Twitter Bootstrap v... |
I'm absolutely terrible with .bat files, but sometimes they are just needed. Right now I'm working on a project with quite some submodules, which have quite some submodules, and sometimes even those have submodules. Now, being a lazy programmer I figured I'd automate the task of committing the submodule-update in every... |
This function is part of our company's project code.
The following function updates six members of struct CpGSMTimeDelayQuery -- t14_cp, T14_au, Tdl_fib_f, Tul_fib_f, Tdl_cp_f, Tul_cp_f -- in the database.
It contains six similar blocks. These blocks do the same thing: read a specific register, calculate the member va... |
I am trying to prevent CSRF for my login page (linked from here), and for this I am going to use a random token generator to create a UUID for the session.
The function that I have so far is as such:
function UUID()
{
mt_srand((double)microtime()*10000);
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyp... |
From an exercise in Kochan's Programming in C, following a chapter on C's null-terminated strings:
Write a function called removeString to remove a specified number of
characters from a character string. The function should take three
arguments: the source string, the starting index number in the source
string, ... |
I made a small application that makes async calls to an api (local in this case). The target application will make a million of calls per day.
With maxSockets set to 1 I had a time of 45 seconds. With maxSockets = 10, the execution time has dropped to 40 seconds.
How can I make this code go faster please?
var request ... |
I know, there are a few implementations of immutable strings out there, but my focus seems to be a little different.
My goal was to have a type that provided value semantics, but didn't incur the cost of dynamic memory allocation when constructed from a string literal which is already guaranteed to exist during the w... |
I'm rebuilding a basic webpage using AngularJS, and want to implement changing languages when clicking an icon. So far I've made a service called 'langService', that has functions to set and get language. I then pass the service a value (say 'eng' or 'slo') with the set language function when clicking an icon on the pa... |
Following on from this question I have added some more functionality to Markdown Markup, and made it more WPF idiomatic.
It now supports saving data from any of the four boxes, and loading Markdown or CSS files.
Everything seems to work, so as always, any tips/pointers/critique is/are welcome.
So, first, the new MainWi... |
As a follow-up to my code's v0.1 revision, we now introduce V0.3, with capability for storage of attributes and a struct for each HTML tag. Just start the struct, call its functions, change its variables then use <fstream> to make the complete HTML file using generateHTML()!
#include <iostream>
#include <fstream>
#incl... |
I have the following class:
class MultiArray
{
private $array = array();
public function add()
{
$keys = func_get_args();
$value = array_pop($keys);
$array =& $this->array;
foreach ($keys as $key) {
if (!isset($array[$key])) {
$array[$key] = arr... |
I tried to implement Dijkstra algorithm in C++ 11. Is this a good implementation of Dijkstra algorithm in C++ or not? I have overloaded -= and += operators to make the code more easier to read. These operators are used to add and remove nodes from the object of MyList class which is inherited by vector for vector like ... |
I'm especially interested in ways to further optimize a constraint algorithm. So far I've switched to SIMD sse4 vector operations which nearly doubled the performance. I'm hoping there is more performance to squeeze out that I simply don't see.
Here is the algorithm:
FVector4 rest(REST_DISTANCE); // Set the constant si... |
This snippet is about detecting whether the carry flag is set or cleared. I work on Mac OSX, so my snippet supports Mac only.
First, we need a routine that does the job:
func.s:
global _read_carry_flag
_read_carry_flag:
mov al, 0
jnc end
mov al, 1
end:
ret
(Try nasm2 -f macho64 func.s for compiling ... |
I've created a program that will list all hung print jobs on a specified server, from there it will load them and strip the jobs down to their Job ID then cancel the jobs on that server only.
I would like a critique of my work please.
How does this look as an OOP script?
Is there anything I can do differently?
Is call... |
This is an analyzer and code fix for VSDiagnostics that detects when a doc comment on a method does not have all parameters listed. When the user tells it to provide the fix, it adds a /// <param name="{paramName}"></param> line for all missing parameter nodes.
Here is the analyzer:
private void AnalyzeNode(SyntaxNode... |
I am developing a CUDA program and I want to enhance my performance. I have a kernel function which is consuming more than 70% of execution time. The kernel calculates the distance between several spatial points and based on whether they are neighbors or not, it fills a boolean vector.
Any ideas on how to get more spee... |
Can anyone suggest a better way to implement my template code?
var $teams = $('#info');
var template = "{{#data}}<tr><td>{{teamName}} </td><td>{{playedGames}}</td><td>{{wins}}</td><td>{{draws}}</td><td>{{losses}}</td><td>{{goalDifference}}</td><td>{{points}}</td></tr>{{/data}}";
$.ajax({
headers: {
'X-Auth-To... |
I've developed the following multi-threaded code and would like a review. It is supposed to be implementing the Producer-consumer problem as defined here.
I have multiple consumers and one producer. I would like to know whether there are any problems with my use of concurrency and also if you have any suggestions on h... |
I have written my own one time pad algorithm for encryption and decryption, but I would like to listen to your opinions about its correctness and eventually how could I improve it. My idea was to keep it readable, but not so bad in terms of performance. I have also written some tests.
Here's the code:
from random impor... |
I need to pull an rss feed with links, headlines, and descriptions onto the front page of a website, and while I would like to think the source is trustworthy, you can never rule out malicious actors. I also would like to avoid iframes, since a sufficiently secure iframe sandbox would impact the browsing experience, an... |
I've written the following function on Python (3.3) to take a list of 6 integers and return the maximum score for a game of Farkle. While the results are correct I don't feel it's a very Pythonic implementation. I'd like to hear from the community on how I could make it better and more Pythonic. Any and all tips are mo... |
I would like to know if this function is correct (I know that it works, but I have not got enough knowledge so as to demonstrate that it is correct).
Indication: a colleccio is defined as a vector< int > always of size 12, so I can represent the number of banknotes and/or coins of value 50, 20, 10, 5, 2, 1, 0.50, 0.20... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.