instruction stringlengths 71 71.9k |
|---|
I am working on the following script for python2.7 which "works" on small files.
I ran a sample on an input file of 188kB and it took approx. 1.15 min to complete. However, I need to process a 5GB file using this script and I did the math, it will take 11.48 years to finish it the way it is now.
sample input1
aba_tra... |
I find myself using subject blocks in my tests to setup example because it is succinct. However is this considered bad form and can it have undesired consequences?
require 'spec_helper'
describe "stations/index" do
before(:each) do
stub_user_for_view_test
assign(:stations, [
stub_model(Station),
... |
Just wondering what I did bad/could have done better. It's a simple script for pulling information from Leafly about cannabis strains. I've also added in a function to search. I am fairly new to Python. Anything is greatly appreciated. I also realize nothing is commented. I will quickly answer any questions, but it'... |
I like to create tools for memoization since it can sometimes be useful. I recently created a generic tool for memoizing the results of pure functions.
Here is an example of how it works:
// Dummy function
auto func(int a, bool b)
-> std::string
{
// Some heavy computations
}
int main()
{
auto memof_f = me... |
I have these lines of code in my view:
<?php
$count = count($product->getTags());
$tagsStr = '';
foreach($product->getTags() as $key => $tag){
$tagsStr.= " " . $tag->getTag();
if(($key == 0 && $count < 1) || ($key == 0 && $count >1 && $key != $count)){
$tagsStr .= ',';
}
... |
I would like to refactor this code a bit further and make it better and more generic.
As of right now, it is doing what I want it to do (reading a list of URL's, splitting the query and the ampersand and writing the split into appropriately named files). However, I would like to take the hash list out and make it as ge... |
I am fairly new to Python coding, although I have been coding on and off for 30ish years. I am sure I am writing Python with too much influence from the other languages, such as REXX, VB, and some Powershell.
Maybe I should use more functions? Please let me know where the following the code is straying from being Pyth... |
I am new to database design but am fairly familiar with SQL and its syntax. I want to create a database for an e-commerce website that will sell a single product type such as a shirt. They could be different sizes, colors, and design. I formulated list of information I thought would be necessary to collect from a visit... |
The task is to add data or values to members of a given enum class. The compiler should check if a value for each enum member is available, and not just the default constructor empty values. It is a tool to verify that no values are forgotten during a change.
The interface is modeled after the array of enumeration type... |
This program takes blank spaces before some chars like > < />, and if there is more than one blank space in the line, it will reduce to one.
return source.replaceAll("\\s{2,}", " ").replaceAll("[[\\>][\\s]][[\\s][\\>]]", ">").replaceAll("[[\\<][\\s]][[\\s][\\<]]", "<").replaceAll("[\\s][/>]", "/>");
How can I improve ... |
There are some blocks in my code.
To make it easier to read, I often append comment after the end
such as
end # end upto
end # fileopen
Because sometimes the indentation still not easy for read.
Is there any better practice?
And my indentation is 2 spaces, is it OK for most Rubier ?
require "faker"
real_sn = 2124... |
I need to concatenate a bunch of delimited text files. In the process, I need to add a new column to the data based on part of the name of one of the directories containing each file. The script works, but I have a feeling that it is inelegant in the extreme.
In particular, I'm wondering whether I should be reading the... |
I was referred here from StackOverflow, so here is what I posted over there:
So, for an assignment, I have to construct a binary search tree, plus an assortment of related functions. I have them all working, but I'm looking for a way to optimize my way of finding in-order predecessors and successors. Here's my code for... |
I'm building a hash table for this problem:
Implement a class for storing a set of integers:
class FixedSet {
public:
FixedSet();
void Initialize(const vector<int>& numbers);
bool Contains(int number) const;
};
After the call of the Initialize() function, FixedSet contains integers from the input vector. ... |
I have written a common class for finding display sizes in pre-honeycomb and for the latest versions of Android. Could anyone review my code and suggest possible modifications for this code?
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
impo... |
This is one of the first RSpec tests I've written, and I'm not really sure what the best practices are etc.
My question basically is: what would you do differently? What is good? What is bad?
The complete code can be found here.
Here is the class to be tested:
class WeeklyFlexCalculator
attr_reader :params
def i... |
My question is for validation of my code (any loop holes / bugs) and guidance the best methodology to implement for my requirement.
I am developing a Python application that will have many classes. We need to communicate in between each class - pass data. It would be very clumsy if across all classes I create a setter... |
I'm adding a function to my test library to assist in testing if two IDictionary objects contain the same keys/values.
I need the method to be generic and support a dictionary that has collections as values. So I thought I'd try to do it without using class types.
It appears to be working, but I would like to clarify t... |
I'm currently working on a BMI calculator and just wondered if there was a shorter or more condensed version of doing the if validating statement.
I have currently done it this way for both Height and Weight, but I find it to be a mess and it seems to cluttered. There must be a way of shortening this down or condensing... |
I'm wondering what people think about Dependency Injection vs Service Locator patterns. Specifically I'm using Prism with MEF. I'm also using the MVVM pattern.
So I have a service which I export. I also have a class which doesn't export its class type as I don't need that to be registered with MEF. This class is actual... |
I'm kind of new to C++ and was just wondering if anyone could give me tips on how I could make my code more efficient (I added some comments to the code to help you understand it better).
Is it a good idea to use switch cases? Is there a way I can use more functions/arrays/pointers?
Source code
Here is some of the code... |
I did most of my PHP coding back with PHP 4, and among the projects I did was a popular pagination class. I've been meaning to bring it up to date with PHP 5 and OOP practices. I've also been working on updating my database code, using PDO over the deprecated mysql* functions. What I'd like from you is your input and f... |
This copies the level graphics but uses a scale parameter. If the scale is 1, it copies a screen size segment. If it's 2, it copies a half-screen size piece and scales it to the screen size, etc.
How can I optimise this game level code or achieve the same outcome but simpler?
public void render(Graphics g){
int t... |
I recently wrote a code for a encoder and decoder that works off of a key and the only way to decode the message is with this program and the case-sensitive key. I have yet to incorporate punctuation but that will come soon. I am currently designing a GUI using the Tkinter module. I would love any feedback.
from rando... |
I recently wrote a small demo that allows users to send and receive files from an HTML5 Javascript application. It's all client-side. I thought this would be a good place to get feedback about what I've done.
It's hosted here: http://danielsadventure.info/HTML5FileDemo/
<!DOCTYPE html>
<html xmlns="http://www.w3.org/... |
I am an artist and a total beginner in C++.
I would like to find a better method of importing my variables from a values.txt file, which may contain 18 values in one column:
63.64474122
5.214728341
0.405110193
0.261556475
-2.00743E-09
2.76001E-10
34.45902482
15.62249852
0.220861685
2.88127E-09
0.445804979
2.76001E-10
8... |
I wrote a python function that writes a integer to a file in binary form. But are there any ways that I can reduce the number of steps, is there a more efficient way to write a integer to a file?
def IntWrite(FileName, Integer):
#convert to hexadecimal
data = str('{0:0x}'.format(Integer))
#pad number if odd... |
I'm looking for bugs. I tried to test all functionality in a variety of ways.
#by JB0x2D1
from decimal import Decimal
import math
import numbers
import operator
from fractions import Fraction
class Mixed(Fraction):
"""This class implements Fraction, which implements rational numbers."""
# We're immutable... |
This code works 100%, but I am trying to see if I can use a for-statement to make my second method less-cumbersome and more efficient instead of making so many variables.
I have to show the differences between each quarter for every department.
My array has 6 Departments and 4 Quarters.
import java.util.*;
public voi... |
Please review this JavaScript text editing webapp. Review the code quality. Give me suggestions to simplify the code.
var textarea = document.getElementById("textarea"),
statusBar = document.getElementById("status-bar"),
inputFile = document.getElementById("input-file"),
appname = "Notepad",
isModified = false,... |
I have the following set. a = [1,2,3,4,5] and i want to find all of the following sequences of consecutive elements:
1,
1,2
1,2,3
1,2,3,4
1,2,3,4,5
2,
2,3,
2,3,4,
2,3,4,5
3,
3,4
3,4,5
4
4,5
5
This is the following code that I use and works correctly. My only problem is with the complexity of the algorithm O(n2). Is th... |
Last week I posted a piece of code to apply Dijkastra algorithm to calculate the shortest path between to nodes in a graph. Now, I've made some improvements, but I am still having difficulties.
I have a class Graph that is going to be constructed by two other classes. A vector of elements are instances of a class Edg... |
Which of the following is better coding style and why?
print("We have x = %i" %x)
print("We have x = "+str(x))
|
How can I write a better database query wrapper?
//code for connection
exports.connect = function(callback) {
client.connect(function(err, conInfo){
if (err) callback(err);
conInfo = "Connection at " + client.host + ":" + client.port + "/"
+ client.database + " used by " + client.user;
... |
I am writing non-blocking code as it should be in Node.JS. If I want run function A after B I do it using callback.
But I find this style guide:
Use closures, but don't nest them. Otherwise your code will become a
mess.
Right:
setTimeout(function() {
client.connect(afterConnect);
}, 1000);
function afterConnect()... |
I have an application which currently uses AJAX for CRUD operations on a simple Person object. The following script works fine, but I'm looking for some pointers on how to structure my code. Currently, I have four methods for CRUD operations, and I'll extend my person module as needed, but I was hoping to get an idea... |
I must implement a simple Caesar cipher class. Initializer takes two parameters - number of positions to shift the alphabet (integer) and the alphabet used (as string, not necessarily the standard English alphabet). The class must have two instance methods encrypt and decrypt, which take a string and do the respective ... |
The question is:
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four
million, find the sum of the e... |
You will prompt a user for a month, a day and a year. You will then
tell the user how many days since January 1 of that year the input
date is. For example if the user inputs a 3 for the month, a 2 for the
date, and 2000 for the year the program outputs the number of days as
being 62. Note 2000 is a leap year.... |
I've just posted this solution in my review of @adrienlucca's question, which is to read three rows of six tab-separated doubles.
#include <fstream>
#include <iostream>
#include <string.h>
#include <vector>
struct Sexdoublet {
double x, y, d, m, c, t;
friend std::istream &operator>>(std::istream &in, Sexdoubl... |
I am a total novice to web development, but I am trying to be a WordPress developer and have been actively at it for some weeks now. All self-taught with the world's best tool as my aid: the internet. Anyway, I was hoping that you guys could look at my (no doubt: shoddy) code and tell me what you think I could do to ma... |
I recently worked with an architect who structured his base class like this:
public abstract class Base<T>
{
public abstract T Get(int id);
internal T InternalGet(int id, IRepository<T> repository)
{
// Do more magic
return repository.Get(id);
}
}
And then in the derived class, if you ju... |
Trying to return the below values from an RSS feed. I have sorted out the RSS feed side of things but I am not sure if what I am doing is the best way to extract the data that I need. I have looked at beautifulsoup and regex's, re.search but not sure what is the best way to do this.
Values that I need; (both of these... |
Is there a shorter or maybe a cleaner way of doing:
Using your is_prime? method, write a new method, primes that takes a (non-negative, integer) number max and returns an array of all prime numbers less than max.
def is_prime?(max)
i = 2
while i < max
is_divisible = ((max % i) == 0)
if is_divisible
... |
Let a,b,c be a boolean value. I need to print all values of expression a && b && c. I'm writing the class
public class BooleanTriple{
private boolean a,b,c;
public BooleanTriple(boolean a, boolean b, boolean c){ this.a =a; this.b=b; this.c=c;}
/**
*Increments the value of triple with lexicographical or... |
I am having a slight issue here, i am trying to think of a faster way of finding two elements from 2 different lists that match. The problem is that if i have lists which both have 1000 elements ( rules ) and the very last one [index.1000] matches then in order to find it i have to loop through booth lists from top to ... |
The overall question is: I need feedback on the security of the idea and the script. Do I need to do more in raw code, or is this ok, taking into account my other information?
Let's assume these following first:
All images are stored on a subdomain (e.g. images.example.com)
The subdomain images.example.com does not... |
Using ARC, I'm calling the following function in an iOS app every time the app gets opened in the applicationDidBecomeActive function.
My concern is that it could create a memory leak because it's creating new instances of UIViewControllers every time the app gets opened from the background.
- (void)showMainWindow{
N... |
I've implemented the following code which allows me to bolt modules of code on to my core library via the prototype chain. It's quite prescriptive so any user creating a module has to create an init method and also has to define a queue method:
(working fiddle: http://jsfiddle.net/wG9Pv/)
//Constructor
test = function(... |
As an exercise, I have implemented a linked queue whose enqueue and dequeue methods are synchronized. There is a Producer thread which keeps inserting elements into the queue as long as there are less than 10 items in it. When the queue is full, the thread waits. The second thread Consumer keep removing elements from ... |
This is the CalculatorAdvanced Kata from the Kata gem. I've just finished it and would love some feedback on my solution.
CalculatorAdvanced Kata
Add Method
Allow the expression to handle new lines between numbers
- example: "1\n2\n3" computes to 6
- example: "2,3\n4" computes to 9
... |
I'm a mediocre programmer at best and am pretty terrible at JavaScript. But I have been tasked with creating a Google Maps application. This application is driven by a dynamic report with a Java layer on top of it. This Java layer spits out generated Google API JavaScript.
The problem I am running into is that I am a... |
I have a “featured projects” view that requires its subviews conform to a non-uniform grid: one narrow column with 3 items, then one wide column with 2 items, followed by another narrow column with 3 items. The width that is used for each subview is determined by the model’s display attribute. If there are any extra it... |
I'm trying to convert an std::string to an int with a default value if the conversion fails. C's atoi() is way too forgiving and I've found that boost::lexical_cast is quite slow in the case where the cast fails. I imagine it's because an exception is raised. I don't have C++11, so stoi() is out.
The Delphi function S... |
How can I make this program run faster? On enter, I have a string from the console. For example:
1 1 7 3 2 0 0 4 5 5 6 2 1
On exit, it will be
6 20
Could you recommend a way to make this run faster?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayLi... |
I wrote a chatbot in Ruby for turntable.fm, a chatroom where users can listen to music together. It interacts with users in a room, who can type in specific keywords and get responses from it. It also enforces some rules. For example, if people playing music go AFK for too long, it will force them to stop playing music... |
Please review my strstr implementation. This is an interview question that does not allow the use of strlen(). Is there a better way than using a boolean below?
#include <iostream>
#include <cstring>
char* my_strstr(char * s1, const char *s2)
{
if ( s1 == NULL || s2 == NULL )
return NULL;
size_t s2Size = 0;
... |
Please review my answer for this interview question:
#include <iostream>
#include <vector>
std::vector<int> merge2Sorted ( std::vector<int> left, std::vector<int> right )
{
//finger matching algo
auto itLeft = left.begin();
auto itRight = right.begin();
auto itLeftEnd = left.end();
auto itRightEnd = right.... |
I'm learning backbone.js in parallel with unit testing. I've just made a simple model and wanted to unit test it. Do I have the right idea? I am simply making a model with some default values.
Person = Backbone.Model.extend({
defaults: {
name: "fetus",
age: 0,
child: ''
},
initialize: function() {
... |
Case 1_a:
zip_file = file.sub(directory, '').sub!(/^\//, '')
zipfile.add( zip_file, file)
Case 1_b:
zipfile.add(
file.sub(directory, '').sub!(/^\//, ''),
file)
Case 2 : If the String contains lots of parameters , I prefer write in an array.But I'm not sure to have a line break behind [ is better, or no... |
I have tried to comment my code as much as I can. If you have any questions about it, please feel free to ask. The code itself should have a lot of details and the comments mostly explain what is going on. The task description is in the code.
#pragma config(Sensor, dgtl1, allowButton, sensorTouch)
#pragma config(S... |
I wrote some very basic R code.
This has at least two problems.
It uses a very basic imperative-programming style instead of good R style.
It draws the result as an ellipse, not a circle. This effect is barely visible on RGui on Windows, but extremely visible in RStudio on Linux. [Edit: rcs has mentioned that the asp... |
Here is the code that I am using on a website's contact form:
HTML file:
<form name="ajax-form" id="ajax-form" action="php-file.php" method="post">
<label for="name">Name: *
<span class="error" id="err-name">please enter name</span>
</label>
<input name="name" id="name" type="te... |
I have a Lua project that uses some syntax sugar described in DecoratorsAndDocstrings, near the bottom of the page. It looks like this:
random =
docstring[[Compute random number.]] ..
function(n)
return math.random(n)
end
Notice how the function definition is concatenated to the result of the function previo... |
I am making a filter to get posts by status that are saved by post metavalue in a Wordpress plugin. It is a question and answer system, where the question and answer are post objects.
// Filter post where
function posts_where( $where ) {
global $wpdb, $dwqa_general_settings;
switch ( $this->filter['filter... |
I have a script, which updates my table's column and writes an id to it.
I need to check whether the column is empty or not. If it is not, I add a ,.
$subs = mysql_fetch_array(mysql_query("SELECT subscribed_user_id FROM users WHERE user_id=".(int)$_GET['user']));
$subs_array = array();
$subs_array=explode(',', $subs... |
I have thisPoint Class:
public class Point
{
private final int CONSTANT_VALUE = 0;
private int _x;
private int _y;
public Point(int x, int y)
{
_x = x;
_y = y;
}
public Point(Point other)
{
_x = other._x;
_y = other._y;
}
public int getX()... |
I would like to know if my chosen layout is HTML5 standards compliant, or if I'm using the heading tags incorrectly (or any other tag for that matter)?
Main Header
<h1> for website name
<h2> for webpage name
<h3> for website slogan, or should this be <span> with styling?
Main Content/Sidebar Content
<h2> for every f... |
I am working on a Windows project using C++03 (C++11 is not an option), and without using Boost. I have several resources that are accessed by multiple threads at various times - a queue, for example, with data added by one thread and removed by another. Individual methods of the involved classes generally perform loc... |
Let's say I have a collection of expensive-to-generate objects stored in an IEnumerable:
IEnumerable<Expensive> expensiveObjects = CreateExpensiveIEnumerable();
Now I will iterate over everything in expensiveObjects and afterwards, I want to know if it was empty.
Here is how I am doing that currently.
var count =... |
I want you to look the following code for validating dictionary schemas. There are some libraries out there that do the same thing, but I just wanted to write my own for fun and not to overload my current project with a big third party library.
Feel free to comment regarding code optimization, duplication, API design a... |
I'm experimenting with std::future, but haven't found any materials that deal with the usecase I have in mind and was hoping someone could either confirm or deny the validity of the approach excerpted below:
class Thing {
private:
std::string mValue;
public:
Thing() : mValue( "" ) {}
void set(const std::... |
This is a program for converting Roman numerals to their decimal equivalents. There must be a better way of distinguishing between, for example, 'IV' and 'VI', than what I have currently written.
#include <iostream>
#include <string>
using namespace std;
class romanType{
public:
romanType();
romanType(string ... |
I'm writing yet another MVC framework just for learning purposes and I would like you to review my code. Whenever I'm coding, I have that feeling that my code is horrible and is not the most efficient way to achieve something.
Right now the request class takes a URL path from ORIG_PATH_INFO or from PATH_INFO and explod... |
I need to add logging functionality for an existing code, based on a result of an operation. I was thinking of creating a class that, when constructed, receives a condition function and a function for execution. Based on the result of the condition, the code will be executed.
Example:
class auto_logger{
public:
auto... |
I wrote a simple utility script to process source code files, extract and pretty print braces. It could be very useful for spotting the ugliest files in a code repository. So, I tidied it up a little bit and open-sourced it here.
I would very like to have your suggestions and comments on how to make this Python code be... |
So I have this simple code in Java. It enqueue (adds) and element to the end of the queue (implemented by an ArrayList) without changing the original queue.
public class MyQueue<T>{
private List<T> body;
// some constructors and helper functions.
//copy constructor
public MyQueue(List<T> list){
... |
I have a library that's parsing some expressions, part of which is a CSS selector. More accurately, it's a jQuery-compatible selector. The selector itself is opaque to my library - I don't need to pick it apart, and I don't need to verify that tag and attribute names are valid HTML, or that its pseudo-selectors exist... |
This is my first foray into the wild world of jQuery plugin development. The plugin "ajaxifies" forms, which isn't particularly spectacular:
It gets the basics (action, method) from the form itself, serializes the form's fields, and sends the request.
Users can provide (via its options) callback functions for the lo... |
I've answered this question on Stack Overflow. The problem is - there are 30 columns in an Excel sheet and I need to validate each of the fields with different validation logic. The code should avoid a lot of if-else blocks. I have used strategy pattern to solve this. I would like to get a review of this code.
interfa... |
I have implemented a solution to Project Euler problem 5:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
My solution uses Python 2.7, and consists of a module... |
Can you please take a look at the following x86-64 C++ code which should implement a multi consumer/produce lockfree stack? Do you think I have missed anything?
namespace lockfree {
// NOTE: this lock-free stack uses the highest 2 bytes
// of each pointer to store a 'counter' (an "id") to
// ensure that the... |
I have written a slideshow application and I am looking for some reviews:
import sys
import os
import utils
from PyQt4 import QtGui,QtCore
class SlideShowPics(QtGui.QMainWindow):
""" SlideShowPics class defines the methods for UI and
working logic
"""
def __init__(self, imgLst, parent=None):
... |
I've written C# code for solving a maze problem. It works, but I want to optimize it so that it could give me all paths. To solve the maze, I walk on the zeros and assumed that the final is reaching -3.
const int MAZE_SIZE = 6;
static int[] allowed_move_row = { 0, -1, 0, 1 };
static int[] allowed_move_col = { 1,... |
I made this nice bit of code that I can insert into any of my projects requiring user input. It seems quite long for what it does and I would love some incite as to how I can do this more efficiently i.e. fewer lines of code.
I love to make my code elegant, but I don't see how to do it any better.
String x = (JOpti... |
I've just finished reading Learn You a Haskell and I've started to experiment on my own. I just wanted to create a very simple game system where player A can attack player B.
Now I have 2 questions:
My autoAttack function was very daunting to write. How could I improve it?
How would I format my autoAttack function cor... |
I was implementing a rolling median solution and was not sure why my Python implementation was around 40 times slower than my C++ implementation.
Here are the complete implementations:
C++
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
int tree[17][65536];
void insert(int x) { for (int... |
i'm wondering is there any way to optimize this code?
It must be able to work with big files, for example, formatting raw 140kb .txt file (12.5k words) takes 2 seconds (measured with Stopwatch class).
Text example http://pastebin.com/2p88v8EN
Maybe i used here some bad techniques or there is some part to simplify? May... |
I've got a page on a website that shows a table, and upon clicking on a row in the table, it can dynamically load in more results. I am new to jQuery though.
index.php page:
<!DOCTYPE html>
<html>
<head>
<title>Knife kills</title>
<script src="jquery-2.0.3.min.js"></script>
<script type="tex... |
I was given the task of batch process a single-level control break program to produce a lecturer information report by lecturer from a university course file.
I have attempted to create a solution using a OO design in Java. I have run into some problems as I don't think the the modules are cohesive as they are not very... |
I am very new to python (probably too new to consider efficiency etc.). But I am bit confused about which method to use while reading a file for post-processing.
Here I am reading it line-by-line. There is other methods also for reading the file(e.g infile.read()), one of them is to load the complete file in memory.
Ca... |
I am designing a basic in-memory cache storage with a thin CRUD (actually CRD) interface. The design is inspired by backend solutions such as Parse and StackMob.
Main characteristics:
Cache consists of tables(schemas) storing hashes.
The keys(fields) in a table are fixed(enforced).
Maximum memory efficiency for storin... |
My goal is to provide a function with the following functionality:
// Will throw iff a != 42.
check(a == 42) << a << " is not equal to 42!";
I have the following:
class check
{
public:
check(bool everything_OK = false)
: should_throw{!everything_OK}
{ }
check(const check&) = delete;
~check(... |
I've created a simple NAT library, with four essential functions:
Find the UNPN device (the router in my case).
Get the external IP address.
Add a port forwarding entry.
Delete a port forwarding entry.
Currently, updating an entry in the NAT table will change only the internal client ip address or the internal port... |
I've learned PHP following only tutorials on the web and I'm quite sure my style is not at top.
I'd like to understand how this code could be written in a more elegant way:
<?
$posts = // array with informations about posts fetched with PHP PDO from DB
$html = "<ul>";
foreach($posts as $post) {
$html .= "<li><h2>"... |
The whole question is Simplified regular expression engine.
I have solved the question, and in turn felt the need to get it reviewed. Any suggestions for clean up and optimization would help.
Also please verify my complexity:
Complexity: O (n), where n is the length of the longer or regex or string.
public final class ... |
I am writing an API which gets results from a DynamoDB table and puts the JSON back into the browser.
The code below works and returns the desired results. However, after reading about async and callbacks, it's becoming important for me to know if I should be writing this in another way. Does the following scale well... |
I've made this simple function for reading N bits from an unsigned char* (with a possible offset) and I'm willing to share it here, get a review, suggestions for improving it, etc...
typedef struct bits_t {
unsigned char *data;
unsigned int len;
} bits_t;
bits_t *read_bits(unsigned char *src, int bits_offset,... |
I've just finished a program for a 2-way carousel. Meaning, if I click left or right, you are able to go up and down, depending on where you are. This is suppose to work for iPad or tablet only.
I would like to know how to make the code better or if there are any suggestions. I would appreciate it. I am new at this, ... |
As mentioned in @rolfl comment. What this program does is that it "resequences the cards using a fixed system and count the number of times the resequencing happens before the output is the same as the input."
I was wondering how I could make this program faster or perhaps use less memory. I thought about using dictio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.