instruction stringlengths 71 71.9k |
|---|
I'm just looking for advice on how I can get my code to operate faster. It's pretty quick right now with searching through 30 3-page PDFs, but I imagine once there gets to be thousands of files to search that it will take longer than I'd like. I can change SearchOption.AllDirectories to TopDirectoryOnly. I've done some... |
This is based on my first review and the suggested points in "Multiple dispatch decorator in Python":
import inspect
from functools import wraps, update_wrapper, partial
class multi_dispatch(object):
"""
Returns a multiple dispatch version of the function, that has a "register"
method with which new vers... |
I have a lot of data in separate files generated from a simulation program. All data is clear and formatted via a single space to read in 4 columns. I can open and store data from each file one at a time, but that will get so impossible once I hit more than, say, 10 files of data with the same simulation data columns.
... |
I have decided to create a dashboard view of a number of running processes/programs/applications, because it became tedious to monitor a bunch of applications, which I had to boot up manually.
Please keep in mind that the .fxml files have been autogenerated using JavaFX SceneBuilder 2.0 and hence may not have proper fo... |
I just created 2 model class for my iOS app:
HALUserDefaults represents the persisted data in my app. It has the ability to both retrieve persisted data and store new data.
HALParseConnection represents the connection to my Backend service Parse.com
These 2 models were made to work with each other.
HALUserDefaults.h:... |
When using MVC 4 Razor (I am new to web development), I get concerned about my understanding of interactions between the database and the client. Much like all appilications these days, there is a lot of data that is presented to the user and in different fashions. I have looked around, and I can't find a concrete C# e... |
I have a somewhat unwieldy IF statement and am wondering if anyone has any suggestions on how to make it more readable.
One one line it was all but impossible to understand, so I broke it up into multiple lines:
if (
empty($row) // IF the row doesn't ex... |
This question is a partial followup from my previous question, however the requirements have changed: I now need to be able to store multiple data entries for some fields.
I also have added two hooks into the OrganizationBuilder, one that validates the given input, and one that formats the given input, mainly used to a... |
So I was playing with writing FizzBuzz in Elixir; this is my first, naive implementation:
defmodule FizzBuzz do
def getFB(n) do
cond do
rem(n,15) == 0 ->
IO.puts "FizzBuzz"
rem(n,3) == 0 ->
IO.puts "Fizz"
rem(n,5) == 0 ->
IO.puts "Buzz"
true ->
IO.puts "... |
This is a Python 2 script to take in a file in one of two formats (unknown), and standardize it.
The data are coordinates in the xy-plane. They represent airfoils in the first and fourth quadrants: x should always be positive, and y may be positive or negative. The magnitude of each coordinate of any given point should... |
I wrote a little code sample which:
load images
manipulate DOM (replace images)
store/retrieve related data using
localStorage
$(document).on('ready', function(){
$('#chooseFile').on('click', function (e) {
url = $('#image-url').val();
// check if it's empty
if (url === "")
alert('Ple... |
This is a wrapper for an API. For now all it does is get a certain document or search for relevant documents from a document store -- although I plan to build out more features later. I'm new to PHP and want to both improve my PHP skills and develop "idiomatic" PHP style. It depends on HTTPFUL, which, for now, is being... |
I have a large number of plain text files (north of 20 GB), and I wish to find all "matching" "bigrams" between any two texts in this collection. More specifically, my workflow looks like this: for each text, for each sentence in that text, for each possible combination of two non-stop-words ("bigram") in that sentence... |
My goals are to make this code:
faster
more idiomatic C++
What the code does:
take an integer command-line argument N
make a vector of N random floating point values
make a matrix of N*N random floating point values
do inner product of vector * matrix
write the resulting vector to a file
Currently compiled with: g+... |
I am writing a TCP client app using netty
NettyConnectionManager.scala:
class NettyConnectionManager(val config : NettyConfig) extends ConnectionManager {
@volatile private var connection: Option[Connected] = None
def get() = {
if(isConnected) {
connection.get
} else {
synchronized {
if... |
You're running a jeans company. Your system is collecting detailed orders' data, but it's a bit archaic and it's storing the number of units ordered per size in a delimited string with 20 "fields", each taking up 4 characters. You want to normalize this data to make it easier to eventually analyze orders at size level... |
I've been playing around with porting a simple strategy game over to Javascript, the idea being to run it in a browser for testing. I've done some simple Javascript code in the past, but this is my first model/view setup. I'd love to get feedback on following Javascript best practices and avoiding pitfalls. I know t... |
I made this code to change the background color for a div in a set of divs while disabling the rest of the divs in the background. It works fine, but I wanted the code reviewed for more improvements since I am new to jQuery and JavaScript.
<div id="singleProjectTitle">
<div class="ProjectMainLink" id="aboutProject... |
I have UserGroups for Users to be assigned to in a ListBox in HTML form. Items from listbox can be multi-selected or completely unselected.
In summary currently, I am getting a int[] of GroupId from client into my action and I am pulling existing assigned usergroups for the user into the action as well. Then I am compa... |
In a header I have something like:
#define OPENGL_TARGET_VERSION_MAJOR 4
#define OPENGL_TARGET_VERSION_MINOR 0
#define OPENGL_TARGET_VERSION ( OPENGL_TARGET_VERSION_MAJOR * 10 \
+ OPENGL_TARGET_VERSION_MINOR * 1 )
And then a lot of checks like:
#if OPENGL_TARGET_VERSION < 44
#ifdef G... |
I wrote a custom decorator to check whether user is in particular group of not. Please provide the feedback on optimizing code. I currently moved from Java to Django-Python so I wasn't able to optimize the logic.
Check whether student is in labsheet_collector, assignment_collector or fund_collector.
def labsheet_collec... |
I have written an interface system for iOS that allows interface elements to be moved around on the screen as actors move around on stage. It can operate within a ViewController environment. It relies on messaging through the Notification Centre (obviously not LocalNotification).
The central object is the ARKView objec... |
I currently have an MGF file containing MS2 spectral data (QE_2706_229_sequest_high_conf.mgf). The file template is here, as well as a snippet of example:
BEGIN IONS
TITLE=File3249 Spectrum10594 scans: 11084
PEPMASS=499.59366 927079.3
CHARGE=3+
RTINSECONDS=1710
SCANS=11084
104.053180 3866.360000
110.071530 178805.0000... |
I have a HashMap<Token, Integer>, which counts occurrences of Token. Each time Token is found, the value in the map should be incremented.
Map<Token, Integer> occurrences = new HashMap<Token, Integer>();
// ...
public void tokenFound(Token token) {
Integer numberOfOccurs = occurrences.get(token);
Integer newN... |
I have a small open source library called Equ that I've been using already on several projects. After a rework of the internals I thought I'd ask here for opinions on improvement possibilities.
At the core of my library is a class that generates equality functions, i.e. bool Equals<T>(T a, T b) and int GetHashCode<T>(T... |
I was looking for long time around to have a portable robust solution for multiprocessing synchronization. Who touche this things know that good solution are boost::iterprocess named sync objects.
When your process have a named_mutex locked and your process die (there are many normal situations when process die, not ju... |
Basically is a script to export a table from Google Sheets and send it via email. But it's not a clean script, although it works.
If there is any way of making it more simple, or instead of get all the values get the complete table and then export, that would be much more clean.
function sendFuelcount() {
var sheet =... |
I am using a combination of the following two classes to achieve a quite simple task. I have Users in my application. These Users can be assigned Roles. And these Roles need to be assigned Rights.
Currently I do this with a primefaces selectCheckboxMenu. This menu requires the entries to be Strings. In itself this is n... |
I was wondering if my code is safe for sql injection.
This code just checks if the username exists in my db or not.
$username = $_POST['username'];
$stmt = mysqli_stmt_init($con);
$query = "SELECT username FROM users WHERE username = ?" ;
mysqli_stmt_prepare($stmt, $query);
mysqli_stmt_bind_param($stmt, "s", $username)... |
I've created a function that uses binary search to insert an element into an array (similar to this question). I haven't benchmarked it, but based on my knowledge it should get \$O(1)\$ in the best case (i.e., appending an item to the end of the list) and \$O(nlogn)\$ in the average/worst case (I have no numbers to ba... |
I am currently creating a game engine for educational purposes.
ECS Design Pattern
The first design pattern I've included is the Entity/Component/System pattern. Therefore I've got a base singleton class called cEngine, which contains all systems (PhysicsSystem, GraphicsSystem, etc.) so it can update them on each frame... |
I'm little frustrated because I don't know how well I can refactor this script. I wrote the authentication function but it's too complicated, maybe too large in one function, and seems like spaghetti code. How will I be able to make this a little better?
I'm using Restify framework for NodeJS. There are a function tha... |
I've been making an interpreter for my own programming language that I've been working on as a hobby. I made an expression evaluator that can evaluate simple mathematical expressions.
It understands +, -, /, *, brackets and the order of operations. I haven't put a modulus operator in the evaluator because I'm going to ... |
I'm using XML to store data and I need to store a string array in it. The best way (that I can think of) to store a string array is by converting it to a single string. In order to do that, I'm using string.Join to join the strings with \0 and then use Base64 so that the \0 (and any other special character) can be retr... |
Is this example of an escape - unescape function correct?
ESCAPE = '/'
def escape(s):
rv = s
rv = rv.replace(ESCAPE, ESCAPE + ESCAPE)
rv = rv.replace('+', ESCAPE + 'PLUS')
rv = rv.replace('-', ESCAPE + 'MINUS')
return rv
def unescape(s):
rv = s
rv = rv.replace(ESCAPE + 'MINUS', '-')
rv... |
I am implementing generic repository and unit of work for the first time. I would be glad if someone can correct me if I am doing something wrong here.
This is how I communicate with my DAL from controller:
public class HomeController : Controller
{
private UnitOfWork unitOfWork = new UnitOfWork();
... |
I am trying to get over my fear of multithreading programming and teaching myself to code using POSIX. I wrote a small version of the consumer producer problem. I am hoping I can get some feedback if it works (I think it does, as I traced the threads when my for loop was at 20 and it made sense) and what I should do to... |
I have a simple calculator program that needs some reviewing. Is this as efficient as it can get, or is there a better way?
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Welcome to the Calculator!");
do {
System.out.println("\nType a calculation:")... |
I am trying to create a webpage that will read RSS feeds from the TED talk website and display it on a page. I am using Google's Feed API for this.
Here is the link to view the code online.
Could someone please tell me if there is a better way to display the data coming from the feed?
HTML
<!DOCTYPE html>
<!-- To chan... |
I have written a simple GUI Tic Tac Toe Application and since this is my first shot, I think it can be improved a lot.
Please tell me what you think about it and what you see I made wrong so I can avoid those mistakes the next time.
Is there code redundancy I don't see? Is everything declared and implemented at its rig... |
My application needs to read a file, which includes a list of cars from different factories, and calculate the prices (by this I mean mean add up their prices).
I suppose my solution is efficient. Is there any better approach to it?
Company Price other details
Benz 10000 x ...
BMW 3000 y ...
Benz 1000 ... |
This query performs a FizzBuzz in SQLite 2.8.17 without creating any tables or sprocs.
First attempt:
select case when fb <> '' then fb else n end from (
select g + f * 2 + e * 4 + d * 8
+ c * 16 + b * 32 + a * 64 as n,
coalesce(fizz, '') || coalesce(buzz, '') as fb
from
(select 0 union select... |
My application needs to read a file, which includes a list of cars from different factories, and calculate the prices (by this I mean mean add up their prices).
I suppose my solution is efficient. Is there any better approach to it?
String factories = "Benz,10000,BMW,3000,Benz,5,Toyota,500,BMW,50000,RR,100000,BMW,100... |
The function asks the user for a value to search for, then deletes all matching values in the list.
The program runs flawlessly, but I can't figure out a simple/elegant way of separating cases for 'first node', 'last node', and 'intermediate node'.
Please help me make it more elegant and readable.
I'll post the relevan... |
This is a JavaScript function that returns ALL the possible combinations of whatever word the user enters. I am looking to clean this code up a bit...any and all suggestions are welcome!
function allAnagrams (word) {
if (word.length < 2) {
return [word];
} else {
var allAnswers = [];
for (var i = ... |
I'm building this as part of a larger class to rapidly search for smaller images inside larger images. This is my first serious F# project so comments especially concerning style and organization are appreciated.
module imagesearch =
type BitmapSearchClass() =
// Largely inspired by this article
/... |
I am slowly moving through Project Euler, and have reached problem #10:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
I did a naive implementation first, which was very slow (15+ minutes runtime). But since I know the last number in the series, the Sieve of E... |
I have an abstract PersonDao class, extended by several other DAO classes, for example EmployeeDao, StaffDao.
The non-abstract DAOs correspond to different tables. The tables have some common fields, and also some unique fields. Operations on the common fields are implemented in the abstract parent PersonDao class, op... |
Here is a small C++11 utility collection to store any object that satisfies a given interface. Only the basic concepts are provided, I did not try to create a full collection:
#include <memory>
#include <utility>
#include <vector>
#include <boost/iterator/indirect_iterator.hpp>
template <typename Interface, template <... |
I have these two methods on a class that differ only in one method call. Obviously, this is very un-DRY, especially as both use the same formula. Could anyone give me advice on how to tidy this up?
public class PlayerCharacter {
int level;
public int getAttack() {
int attack = 1 + level;
for(Equ... |
I often write something like this in my code:
try {
obj.doSomething();
} catch (Throwable exception) {
// there is no need to interrupt application
String exceptionMessage = String.valueOf(exception.getMessage());
Log.e("Name of my app", exceptionMessage, exception);
// and may be something else
}
... |
I wrote a method that closes 3 closeable types:
java.sql.Connection
java.sql.PreparedStatement
java.sql.ResultSet
public static void closeAll(final Connection connection,
final PreparedStatement statement,
final ResultSet rs)
throws SQLException
... |
My goal has been to learn Polymer so I started developing a complex combo-box element.
I did my development on Plunker. Here is link to my plunk.
I'm happy with my .scss file, but I wouldn't be opposed to some constructive criticism there. That being said what I'm mainly looking for though is your thoughts on the follo... |
Why this thing :
I work on a project where I need to call many asynchronous functions to get data, chain them, execute them if conditions are met,.. and I ended up having unreadable code.
At some point, I looked at promises library like Q.js but even with such tools my code was complicated, so I decided to write so... |
Use Case
Creating a generic and reusable predicate with closures that supports Float, Double, Integer, float, double, and integer.
Problem
Extending "Number" doesn't allow for the modulo operator.
Code
Below is the form I'd like the code to be. However, Number doesn't support the modulo function.
public <T extends Num... |
I am new to oriented object paradigm and I work on Android using Java project for an internship.
I must be able to locate the user and some around buildings I read stuff about how to setup LocationListener and all, and decided that I better write a class that manage everything for me.
public class NetCampusLocation {... |
I have created a custom web server control that will have a bool property 'RenderAsLabel' so that I can convert TextBoxes to Labels, for read-only forms. I was wondering if there is any reason why this code should not be safe, or work as intended. Upon initial testing it seems fine, but I just want to make sure I'm not... |
I wrote this class to perform simple template-set operations on boost::unordered_set. These operations are part of a larger code base. Calling them will be explicit with SetUtilities::set_intersection(setA, setB).
The main reason I wanted this was to optimize intersection operations (using constant time find in the lar... |
I have an bit array var data = []; ... and I have the following function:
jsPerf
function getBit(n) {
return (data[~~(n / 32)] >> (n % 32)) & 1;
}
Because this is a bottleneck, I need the fastest cross-browser solution in my code, can anybody help make it any faster?
Also, ~~(n / 32) === Math.floor(n / 32)
It can ... |
This is a follow up question to: Admin page select function
Here, index.php does the following:
Checks for a login status using sessions and a cookie
If logged in, allow the use of the ?page= query
Check that the value of ?page= is in the $pagearray and that the file exists
If the user is not logged in, include login.... |
This is a follow up question to: Login system, PDO and me
Is this considered secure for a login script?
if (filter_input(INPUT_POST, "login", FILTER_UNSAFE_RAW)) {
$usercookie = 'Admin-'.uniqid(mt_rand(), true);
$lastlogin = date('d / m / y - H:ia');
$session = uniqid(mt_rand(), true);
$active = 1;
... |
I have a URL that is hardcoded via a config which I extract into a config:
$url = 'http://www.example.com/api/v1/all/limit/{limit}/offset/{offset}'
// this is stored as a string inside a config file
then $limit = 10; $offset = 0;
I currently use the following preg_replace to replace the given URL and transform into a... |
I've been developing a page that is designed like this:
______________
| | |
| | |
| | |
--------------
Everything is wrapped in a wrapper, then there are 2 divs inside it, menu and content. They're both floated to the left so that way I don't have to fiddle with CSS and give myself a head... |
I have two types of event labels. The HTML markup is:
<article>
<time class="reg-day">Mo</time>
<time class="reg-time">13:00-14:30 Uhr</time>
<p class="reg-location">Regent Street</p>
</article>
<article>
<time class="work-month">Feb</time>
<time class="work-day">24</time>
<p class="work-type"... |
My Java app converts its modal object to JSON (using the GSON Library).
This is just fine, but I have to get it back into a modal in PHP. Now I've created a modal (in my case it's, for example, GeoLocation) which has several getters and setters.
Example:
class GeoLocation {
private $cellTowerId;
private $dateC... |
I've written my first OOP program (194 lines including docstring and comments) in Python that uses Tkinter as GUI and Threads. The program shows a window and displays a scrolling stock exchange ticker in a line.
I've created the following classes:
A class that draws the GUI layout with Tkinter library.
A class for th... |
I have the following code, it takes a list of maps representing bands and transforms the band properties via the pipeline_each method.
As you can see in the code, I am dealing with a lot of Options being returned when I modify the band data in the map - I am using an immutable map object and therefore need to return a... |
This simple program uses Scanner to obtain a radius from the user, then calculates and outputs the circumference and area.
Questions:
Is it customary in Java to place a function call inside of a println(), or is it better to put the returned value into a separate variable and then display that?
Should I consider imple... |
I have just finished a simple GUI stopwatch, but some of its code looks like it needs replacing. This is the code:
Clock class (extends Thread):
static int hr = 0;
static int min = 0;
static int sec = 0;
static double milisec = 0;
static int rotation = 0;
static long l = 0;
static long m = 0;
public void run() {
w... |
I'm doing some practice problems on Khan Academy. The current one is Prime factorization. I came up with this:
require 'prime'
def prime_factorization(n, primes = nil)
return [n] if Prime.prime? n
primes ||= Prime.take_while { |p| p < n/2 }
factorization = []
prime = primes.detect { |p| n % p == 0 }
factor ... |
This takes a string input like 1,2,3,4,5, splits it using , delimiter, converts each char to int and output it in a single line like this : 12345
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int* createIntArray(char* numbersInString, int* array_size);
int* createIntArray(char* numbersInString, int* arra... |
I am trying to solve this problem:
Given an array of integers, find two numbers such that they add up to a specific target number.
and this is my strategy:
For each i in array num, do a binary search in numfor target - i in num.
class Solution:
# @return a tuple, (index1, index2)
def binary_search(self, a... |
Python has by far the best slice implementation I've ever used. As a quick evening project I felt like trying to implement Python's slice construct in a JavaScript function (thinking about sending a pr to a certain library with Python's slice semantics). I came up with the code below, and I'm trying to improve my code.... |
I know that my let configFilePath = Prelude.head args is unsafe and was wondering how I could handle it better. My deployment almost always has a file at ~/config.cfg so I suppose I could have used mayHead then later maybe to safely default the filepath to ~/config.cfg.
This was all done a little rushed, so I'd like t... |
I wrote a program to calculate Collatz sequences for initial numbers between 1 and a given integer i, then find the one with the largest cycle length. My code is pretty fast, but I want to increase the speed more. Please have a look at my code and if there are any changes to made in my code to make it faster.
import ... |
Given a binary tree, return a list of each level.
I'm looking for a general review and a mention on best-practices, optimization, and verification of my complexities.
Time complexity: \$O(n)\$
Space complexity: \$O(2^{height})\$
public class PrintEachLevel<T> {
private TreeNode<T> root;
public PrintEachLev... |
The idea is to show how many times a user (by EmployeeID) is in the TblTableList and then update the TblTableStatusCount
I have been learning Fetch this week so wanted to ensure I have gone down the right path and this is a small database, can/should I use this for any size?
Code:
USE [database]
GO
SE... |
I have the following query. I know there's an easier way to do this without the sub queries, or at least optimizing how they're used. I've read about cross joins and using HAVING but cannot figure out how to make this better as I know it's pretty bad.
Basically what I'm trying to do is get the top 10 stores within a ca... |
Say I have the following code. What are your thoughts on questions 1-4 below?
I think it's way too long when I have to list out most of the fields. Is there any better way of doing this?
I build up the DB column name so it can be used later in my select and insert statement.
This is where and how I use the string I bu... |
I'm new to JavaScript, and in Java I probably would do this as a singleton. I need something that I can call from anywhere and instantiate only once.
This is what I have done, but I need some advice to write it in the right way in this new prototype based and functional JavaScript.
var winston = require('winston');
va... |
I have a 2D list like this:
>>> a = [[8,2,3,4,1,2,1,1,3,1,0,1],
... [1,2,3,4,1,1,5,1,3,1,1,1],
... [9,2,3,4,2,1,1,1,3,1,0,1],
... [1,2,3,4,1,1,1,5,3,1,1,1],
... [1,2,3,4,1,1,6,1,3,0,1,1]]
I want to convert it to:
result = {0: {0: [10],
1: [4, 6, 7, 9, 11],
2: [1, 5],... |
I made a Rock, Paper, Scissors game and would like the code to be reviewed.
Main class:
public class Main {
public static void main(String args[]){
Game game = new Game();
game.gameLoop();
}
}
Game class:
import java.util.Scanner;
public class Game {
String yesOrNo;
Input inputClass = n... |
I ran into this question on Stack Overflow. It looked like a really cool thing to try myself, being that I haven't done any recursion for ages (read at least 2 years).
var keypadPossibilities = (function()
{
var keypad_mapping = [
[],
['a','b','c'],
['d','e','f'],
['g','h','i'],
... |
I've been tasked with updating our current error logging system to prevent the logging of similar errors (from a single client program) that were probably caused by the same event. The code here is what I have added in order to accomplish this. Are there any obvious issues I am missing or is there a simpler way to acco... |
I just programmed a quiz and the code is given below. Is there a better way to program to do what I have done? Also I tried to do transition effect while the question is changing, but it isn't working.
<!DOCTYPE html>
<html>
<head>
<title>Quiz</title>
<link rel="stylesheet" type="text/css" href="reset.css">
... |
I've written the following code ages ago (10+ years) which is part of a simple chat server. I'm going to refactor it a bit in Java and then for fun I'm going to convert it to Scala and use Akka actors instead of threading.
Do you see any thread issues that can arise from the method of synchronization?
If a thread appen... |
This works, but do I have to make a new array, result, or is there a way to just insert the field I need into each $key of the received parameter $data?
Won't this way take up more memory needlessly?
function add_tax($data){
$result = [];
foreach($data as $product => $details) {
... |
I have a Python 2.7.6 script parsing large files (~60MB to ~2GB) containing lines of the following format:
componentA componentB < floating point value >
My goal is to sum the floating point values for duplicate pairs of components and reflected pairs, reducing each pair to a single entry in the output file. For exam... |
I am using this code to write more than 170,000 rows to an Excel document. All in all, the file generation process takes about 3 minutes total. (I've already shaved off about ten minutes by shaving off overhead in the form of Apache POI and an unnecessary ArrayList) I'd like to shave off some more time, but I'm current... |
This is my revised code of Stopwatch:
package com.zm0617;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.*;
public class MultiThreadedStopwatchController implements StopwatchController,
StopwatchState {
private volatile static boolean isStarted;
... |
This is my revised code of the Calculator:
import java.math.*;
import java.util.*;
public class Calculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Welcome to the Calculator!");
do {
System.out.println("\nType a calcula... |
Garrett Openshaw had an okay answer to Codingbat maxMirror challenge
But there were a couple of issues with the code he gave, so I decided to review it and make it a little bit better.
I don't have access to Java here at work so I instead changed the code in C# which wasn't too much trouble.
I added a List<int[]> to ke... |
I'm trying to hover over over the img then use Greensock Tweenmax on hover to control the speed and opacity of the text within the span. The opacity will change on mouseover and mouseout.
The problem is that I'm having to repeat the same exact same effect on several div's and it's becoming repetitive. Each one will b... |
This algorithm seeks to find all of the possible permutations of a word:
-(void)permute:(NSMutableArray*)word position:(int)p length:(int)l{
if(p==l){
[self.allPermutations addObject:[word componentsJoinedByString:@""]];
}
else {
for(int i = p;i<l;i++){
NSString* t;
t= word[p];
... |
The Codility's TapeEquilibrium problem asks:
Given an array \$A\$ with length \$N\$, indexed starting from 0, find an equilibrium index \$P\$, such that
$$\left| \sum_{i=0}^{P-1} a_i - \sum_{i=P}^{N-1} a_i \right|$$
is minimized. Assume that \$2 \le N \le 100000\$ and that \$-1000 \le a_i \le 1000\$. Elements of inp... |
This is a much simplified version of the real code focusing just on the handling of Futures from Requests Futures.
I have a few questions:
I had to implement my own version of as_completed because the data handlers may add more Futures to _pending. Is this a decent way to handle the problem, or is there another approa... |
This code is intended to be used with an image manipulation library that I'm working on, and the goal is to take the raw byte[] data from an image, and transform it into a 2D array where each position on the array has a value corresponding to the pixel coordinates of the image.
Comments concerning how to do this faste... |
I'm new in LINQ and Lambda expression. I'm not sure is there a way to shorten the result on this o.z.cust.cust.cust.bintAccountNo. As you can see below, the more table needed to join the longer the resultselector cust.cust.cust. Is there better way to shorten this Lambda expression's result selector?
POCO
public clas... |
This question is attributed to GeeksForGeeks:
Given two numbers represented by two linked lists, write a function
that returns sum list. The sum list is linked list representation of
addition of two input numbers. It is not allowed to modify the lists.
Also, not allowed to use explicit extra space.
Example
Input... |
I have written an adapter class that allows iteration over the rows of a Mat object from OpenCV. For those interested, here is the Mat documentation, but the salient points are as follows:
Mat is a reference-counted header to a shared data buffer.
Mat::row() returns another Mat, which provides a view of a single row o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.