instruction stringlengths 71 71.9k |
|---|
I've done some code so you can obtain Object of any Class from Pool, take a look at it, is it safe? At least it works.
MultiPool class has method obtain with Class param, so can know from which inner-pool obtain Object.
import com.badlogic.gdx.utils.Pool;
import java.lang.reflect.Modifier;
import java.util.HashMap;
p... |
So there's a known bug in excel where applying named ranges via ribbon doesn't work properly (for 2010 and 2013 and possibly 2016). There was a question about it on superuser - Apply names in excel bugged?. I took a shot at it.
This code will find all of the named ranges in the book and then search a specified range f... |
This script converts the numbers to be at least 13 characters long (for UNIX_MS strings). For use with timestamps, I'm having issues with it being very slow. I wanted an alternative to grepping for one specific UNIX_MS timestamp and not finding it and then having to grep multiple more times.
For the output I wanted the... |
I wrote yet another optimized single-threaded Eratosthenes Sieve implementation in C:
erato.c
// #include <stdio.h>
#include <stdlib.h>
#define N 1000000000
#define num_t unsigned long
int main() {
register char *b = malloc(N * sizeof(char));
for(num_t i = 0; i ^ N; ++i)
b[i] = !(i & 1);
// print... |
I have complex objects containing nested objects. I need to check if a key exists anywhere in the nested object. I wrote this code as a makeshift solution. Is there any other way to search for the key?
function checkKey(obj, key) {
if(key in obj){
return obj[key];
}
else{
for (k in obj){
... |
I have this working code and was wondering how I can optimize it. Is there anything I can declare globally so it does not need to be be created over and over? This function is called around 30 times a second.
bmScreenBuffer is a global Bitmap.
Contents of drawScreen():
// Buffer - Get the main window handle to create 2... |
In the beginning, everything is defined to be of value 10, but I have to change them to suit them for different possible values, hence those are changing. I'm a (Im)mature C coder, hence there might be trivial mistakes. I would like to get feedback on how to improve it.
#include <stdio.h>
#include <stdlib.h>
#define... |
While I was writing this I had some thoughts and questions going through my head about if I was doing this in a good manner. For instance, is it good to use a StringTokenizer to loop through the words in the line I copied from the Scanner's input?
Write a method named coinFlip that accepts as its parameter a Scanner f... |
I am trying to read lines from a text file in Java, but there is a lot going on. Is this the best way to do this? I am especially concerned with resource leaks.
import java.io.*;
public class Filing {
public static void main(String[] args) throws FileNotFoundException, IOException {
FileReader fr = new Fil... |
I'm trying to learn a bit about Golang and decided to try out building an SSH address book command-line app. I used a YAML library to serialize and store data in a configuration file. The app has a few command-line options to view, delete, make, and run SSH address entries. It also runs the ssh command given an entry n... |
My goal is to make web page loading faster by bundling all the CSS files together. The web browser will then only have to load only CSS files. This will only run when the application is starting.
void function setupApplication() {
application.initialized = now();
...
var renderCSSFile = application.GWASSE... |
So I made a quick programme in F# to do FizzBuzz, I'm trying to learn more languages, so I figured I'd do something functional for a change. (Haskell is also on the list.)
FizzBuzz is pretty self-explanatory: every third value print Fizz, every fifth print Buzz (possible both if it's a multiple of 3 and 5).
[<EntryPoin... |
I am relatively new to programming and would love to get some feedback on the following section of my code.
class Gene:
def __init__(self, gene_symbol, gene_id):
# gene_symbol represents the abbreviated name of the gene (string)
# Example: 'RHO' (short for 'Rhodopsin')
self.gene_symbol = gen... |
Is there a better way to do this? That switch_status method seems like it could be made a lot more compact.
class Taxi
def initialize
@status = :available
end
def switch_status
if @status == :available
@status = :busy
else
@status = :available
end
end
end
t = Taxi.new
t.switch_st... |
I'm making a simple connect four game that I will eventually extend by creating an AI that the player can play against. Given that AI algorithms are reasonably complex, I find myself wanting to reduce the algorithmic complexity of my win-checker in order to maximize performance once the entire thing is built.
Currentl... |
I have a program that searches for prime numbers in an array specified by the user. The program starts by asking how big the user wants the array to be, then asks how many threads to split the computations.
I tested 1000 numbers, 10,0000, 100,000 and 1 million, and they all yielded results in a fairly reasonably time.... |
I am trying to work on writing readable code and reducing the amount of redundant code I write. I find this hard to do especially when it comes to algorithms. So, I wrote a quicksort program to practice.
Is there any way I can improve this? I know in terms of efficiency it could be better (instead of taking the leftmos... |
I have written a program which closely resembles the way contacts are added and dynamically sorted in ascending order in your phone or other device. Though I have used Integers instead of String, I was just wondering if this has any real world use and how I can improve it.
import java.util.*;
public class Ascending
{
... |
I just started to learn programming, going through a lot of different tutorials, trying out different programming languages and I stumble in the same sort of questions all over the place.
I give you an simple egg timer in bash I use for cooking.
#!/bin/bash
### varibales
min=$1
sec=$2
message=$3
### run
timer=$(($mi... |
I'm currently playing with D3.js.
While doing so I use this JSON-file as a data source: http://codepen.io/chriscoyier/pen/taqCe
Example of the structure:
{
"fathers" : [
{
"id" : 0,
"married" : false,
"name" : "Robert Wilson",
"sons" : null,
"daughters" : [
{
"age"... |
This code produces HTML from the results of a database query.
Self-taught, I have concerns about developing bad habits and I wrestle with the principles of OOP and MVC.
I would be grateful for your opinion on a number of issues:
The use of global. My HTML page is generated from a template which requires a config file ... |
I have a model that works, as far as I know, but it's so messy! I am very new to Java, so I'd really appreciate some help tidying up. In particular, a lot of my constructors are empty which is probably not good, and I'm not sure if I've made the right choices in terms of public, static, void etc for my methods. It prob... |
I'm writing an s-expression tokenizer in Rust.
I have the following code written, but it is not idiomatic Rust - it is quite ugly. TokenizerI is simply an interface with a body that is really of no import here other than to note that _s is unused (hence the underscore).
extern crate regex;
use regex::Regex;
use std::c... |
I have a mathematical function as shown below
$$ (h+1) * U(k,h) = \sum_{r=0}^k \sum_{s=0}^h (r + 1) * (k - r + 1) *
U(r + 1, h - s) * U(k - r + 1, s)\ + \sum_{r=0}^k \sum_{s=0}^h (k - r
+ 1) * (k - r + 2) * U(r, h - s) * U(k - r + 2, s)\,. $$
Base condition for U(k,h) is
$$ U(k,0) = (-1)^k/k! $$
I am using the f... |
I have adapted a VBA code to import all the XML files I have on a folder into Excel. I have tried to run the code with only two files and it takes about 30 seconds. Several minutes to import less than 20 files.
I need to import more than 200,000 files. Can you please help me on how to improve my code?
Sub ListFiles()
... |
In my application i keep repeating writing this pattern. I just cant figure out how to write it better. Coming to you for suggestions:
if ($_POST['x'] = 1) {add_remove($one, array($two,$three,$four,$five));}
if ($_POST['x'] = 2) {add_remove($two, array($one,$three,$four,$five));}
if ($_POST['x']... |
I'm trying to build an xliff for localization from 3 specific files: one contains a list of IDs, the other a list of source strings and the last, a list of translated strings.
Basically, each file contains 200,000 strings, and the process is taking so much time. How can I speed up this loop?
I use sed to replace < with... |
Is it considered bad practice to pass string literals as char*, when an array and not a c-string is expected by the function? From my code:
char ConsoleIO::GetNextChar(string prompt, char* choices, int numChoices) {
// Loop until valid input, or 10 times.
for (int i = 0; i < 10; i++) {
Write(prompt);
... |
I am building a GUI to display a digital clock face (four seven-segment displays), and I have a selector to switch between 12/24-hour formats. I have working code to show both formats, but it is messy. I am looking for a better solution for this section.
The obvious repetition is the section that displays the AM/PM ind... |
Here is a plunker of my working demo.
I have the following code which I have created for a subscription service for data through a webworker. I was wondering if I was following functional-reactive programming best practices and patterns on the webworker. I am new to RxJS and none of our team at work has ever used it, b... |
As detailed in this SO question, I'm using custom logic in a BTreeSet to automatically sort a foreign data type as elements are added to the container. Note that the Data type is used from another module in the actual implementation, so I can't just implement Ord for it, necessitating this approach.
I'm concerned that... |
There were a few recent questions which had a challenge like this:
The subway shop provides catering for meetings and other events. All
sandwich platters are $40 each. Cookie platters are $20 each.
Beverages are not included in catering service. Write a program that
prompts the user for the number of sandwich p... |
The problem is to find all divisors of a given integer n.
(It may be better to implement a true prime generator, rather than a fixed set, as discussed with examples here, but that was not my immediate concern. Also, I am aware that there are much faster algorithms to generate fixed number of prime numbers—I am avoiding... |
I want to condense down some of this, is there anything I can change to make it better or shorter?
It works now but I don't know what else I can change, are any of my if statements changeable to be shorter?
def main():
#displays company name and report
print("Helena Hockey Haven")
print("sales report")
... |
I am creating a miniature bulk email sender. I am using Postfix on Ubuntu with JavaMail. Here is the key part of the code:
public static void main(final String[] args){
final Connection selectConnection = DriverManager.getConnection(prop.getProperty("select_connection"));
final Statement stmt = selectConnection... |
I have written code to implement the nearest neighbour algorithm to produce a solution for the TSP problem
On my machine, the code takes roughly 10 seconds. Since this is so short, a lot of the profilers I have tried don't get a chance to record it properly. How do I profile this code effectively?
When I define the dis... |
I am trying to remove a key from a hash table, which is built using linear probing. Removing a key works fine but I know I need to rehash a portion of the table after the removal but my method down below is not quite efficient. It basically rehashes the whole table that is unnecessary. Is there anyway that I could impr... |
For an interview question, I was asked to do the following:
Given a dot separated domain name, reverse the domain elements.
Here are a few input/output examples:
codereview.stackexchange.com -> com.stackexchange.codereview
foo.bar -> bar.foo
a.. -> ..a
This was my proposed solution. I really feel like there's probab... |
Given a dot separated domain name, reverse the domain elements.
Example:
codereview.stackexchange.com -> com.stackexchange.codereview
google.com -> com.google
I just wanted some suggestions to improve my code. Or if you can suggest a better way, please do so.
package practice;
import java.util.Scanner;
import java.... |
Introduction
I am still learning both swift and ReactiveCocoa, and instead of directly applying it to one of my projects, I have instead worked a few hours on implementing a silly form with it.
My form has these elements:
Email
Password
Confirmation
Reset button
Submit button (not implemented)
There are three validat... |
I have re-coded my entire path-finding class, it used to follow Dijkstra's Algorithm, while also being super inefficient, using Lists and a lot of other bad things that I had/have no idea about.
However, I've spent the last 2 days re-writing the entire thing, this time following A*, finally delving deeper into the subj... |
I need a revision for this code... it's a working code, but i'm pretty sure that can be simplified or even improved. This is for converting a normal xliff file (localization file) into a csv, having this content "ID","SOURCE","TARGET" aligned on the same line.
This is an example of the file i'm trying to convert:
...
... |
I have a column where, pretty much, each entry has numbers (specifically #1-4) and spaces (' '). I wanted to make a query that could avoid having to know these numbers and spaces.
$results = $db->query( "SELECT CHS, PIN, DEF FROM MAIN WHERE CHS LIKE '%".$q."%' OR REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(PIN, '1',''),'2'... |
I was just wondering what every one thinks about my Blackjack game. If there are some things I could change to simple the code down, or if I put some repetitive things I don't need. This is my first real extensive coding project.
One thing I was wondering was, when I ask for a bet (numerical input) from the user, how d... |
I've just done my first Angular.js project and can't help but feel I have too much code outside of the framework.
jsFiddle
This is a QA form scoring page that will eventually store it's results in a CRM system, the scoring has a bug but please ignore that.
I'm really after peer review and what the Angular framework can... |
Building a form where values can be entered in either pounds or kilos.
Script is...
function onlyNumber(fld) {
if(fld.value.match(/[^0-9.]/)) {
fld.value=fld.value.replace(/[^0-9.]/g,'');
}
}
function convertUnit(sense, value) {
retValue = 0;
if (isNaN (value)) { alert ('Non-numeric value'); ret... |
I'm working on a project where i am using VueJS as front-end framework.
I've so much data in JSON format to work with for that i've written a helper function to retrieve data from JSON. much like we query SQL for table rows.
here is what i wrote
function getWhere(field, value) {
var result = [];
$vm.services.f... |
Usage (all parameters are optional):
declare @options int = ( -- SQL "enum"
select a.ExcludeUserDatabases | a.ExcludeOfflineDatabases
from dbo.ForEachDatabaseOptions() as a
);
execute dbo.usp_ForEachDatabase
@Command = N'print Db_Name();'
, @Options = @options;
execute dbo.usp_ForEachDatabase; -- print... |
Recently I created a class that would manager errors, log them, and write details about them to files when the function logError was called. It would be done by having an error code and error message and then displaying the error to the console and writing it to the file if the user wanted to.
I just posted this here t... |
I've recently been writing simple data structures, even though they exist in the library it helps me understand them a lot better.
public class Stack<E>
{
private int capacity;
private E[] data;
private int top;
/**
* Default Constructor where the stack size is initially
* set to 1000 element... |
Is there a way to shorten the conditional statement below? As you can see, there's a lot of repetition. Is the if-statement the best approach here? Bearing in mind that there will likely be more numbers to check for (not, just 2 and 3):
var searchArea = function() {
// Search the area around the current position ... |
This is just like std::array<T, N>. I wrote this for practice. The class is in a different namespace, so the name array stands!!
There is only one bug (that I'm aware of) and that's the base() function for the reverse iterators. Works fine with const_reverse_iterator, but if I do the following:
auto i = arr.rbegin(); ... |
The specifications are:
The first 36 hours worked are paid at a rate of 15.0, then the next 5 hours are paid at a rate of 15 * 1.5. Hours after that up to a max of 48 are paid at a rate of 15 * 2.
It works, but I'm new and might've gone about this in a complicated fashion.
import java.util.*;
class Task3
{
public stat... |
I created a guestbook that on one page displays both the form for a new entry and all of the entries that have been created so far.
I am trying to use Kaminari for pagination for the entries.
Right now this code is working on my local machine, but I just have that feeling that it could be improved/refactored, so I wan... |
Here is a little encryptor I wrote, I'm just asking for people to tell me what is good practice and what's not. Also, I mean the code, not the actual encryption (because it's just a dumb thing).
#include "stdafx.h"
#include <iostream>
#include <stdexcept>
using namespace std;
int encrypter(int input);
int decrypter(i... |
The below method is meant to work similar to the way an ArrayList would work with the add method: The given double is added to the end of the array. Obviously since you can't add to arrays, a new array is returned with the number added to the end.
I'm worried about using this in loops due to performance, because if I a... |
The following C# methods take n bits and operates on them all in one pass.
// Sets n bits to zero at index i.
uint zerobits(uint x, int n, int i) {
return x & ~((uint.MaxValue >> (sizeof(uint) * 8 - n)) << i);
}
// Sets n bits to one at index i.
uint setbits(uint x, int n, int i) {
return x | ((uint.MaxValue >... |
Since I've been playing with F#, I decided to try my hand at implementing some of the Project Euler problems, and I've been having a blast doing it. (f#-is-fun)
So, I'm going to list all the Project Euler problems I solved to make things pretty clear:
Project Euler Problem 1: Multiples of 3 and 5
If we list all the na... |
I am calling a service outside of my control. My application must include a time out, so that if the call to the service takes too long, an appropriate time-out message is returned.
// Client connected to remote service
RemoteClient Client = new RemoteClient();
private async Task<MyResult> CheckItAsync(CheckRequest rq... |
I want to have a thin wrapper (low overhead) around c-style string. Also, with some additional features like == and < operators for map indexing. I have come up with the following class.
Can somebody comment on it? From what I've gathered this class would take only as much memory as a pointer, so much less than std::st... |
The idea of my program is to use pthreads, semaphores, posix shared
memory, and sockets to create an environment where N processes
(that we will refer to as the children) can connect to a single
process (that we will refer to as the parent) in order to send it
data.
Requirements
Common Code
The parent and child proce... |
I'm currently working on my final project of my first semester of C++ (and programming in general). What my professor wants us to do is to make a mock social media program that has some basic functions such as:
Sign up
Sign in
Follow user
Write a post
View Activity – (Activity from friends)
View Profile – (Username, f... |
Below function takes an array, an element to be deleted and returns a new array minus the indicated element. Can this be optimized some how? How good is it generally?
public static int[] sbSample(int a[],int i){
int size=0;
int b[]=new int[a.length]; // provide length of new array
for(int k=0;k<a.length;k... |
The following code ingests 10k-20k records per second and I want to improve the performance of it. I'm reading json and ingesting it into the database using Kafka. I'm running it on the cluster of five nodes with zookeeper and Kafka installed on it.
Can you give me some tips to improve?
import os
import json
from multi... |
<?php
// From adventofcode.com
// Question 1:
// An opening parenthesis, (, means he should go up one floor, and a closing parenthesis,
// ), means he should go down one floor.
// To what floor do the instructions take Santa?
// Question 2:
// Now, given the same instructions, find the position of the first characte... |
I need someone review my google map class , here is my situation I am working in medical project , I created one class to show hospital items in map with data object , here is my fragment class , I create helper class as I don't like to put all methods in long class.
import android.location.Location;
import android.os.... |
I am using Play Framework and Slick. In userController.scala I am handling HTTP post requests and sending to personRepository.scala. Is this controller and method written in the correct way?
userController.scala
def register = Action.async { request =>
var user = new UserInsert("", "", "", "", "", "")
request... |
This is a follow-up from: Reversing a domain name string in Java
There are a number of ways of splitting a String using a delimiter in Java, especially now with Java 8:
StringTokenizer (not recommended)
String.split (recommended replacement)
Scanner with delimiter
Scanner with Pattern
Pattern.splitAsStream
With the m... |
As first steps in C, I'm trying to write a program that reads from stdin into an array allocated on the free store, until an exclamation mark ! is entered. The array should be extended to prevent overflow.
Here is what I've written:
#include <stdio.h>
#include <stdlib.h>
char* increase_buffer_size(char *buff_ptr, size... |
I need to handle concurrent requests by waiting for the result of an already running operation. Is this code safe or does it contain bugs?
private readonly object _gettingDataTaskLock = new object();
private Task<Data> _gettingDataTask;
public virtual Data GetData()
{
Task<Data> inProgressDataTask = null;
loc... |
I'm using Cache::remember to cache 3 results in my action, 2 in the same call to Cache::remember. It works, but I have 2 questions about how I can join this Cache::remember call:
Could I use two Cache::remembers in the same method?
Could I join these two Cache::remembers (I need change the first param)?
Is it possible... |
I'm willing to have a way to calculate a quality score of an object; in this case an addressbook contact.
I believe there are way better approaches to do this and I'd like to hear your references.
How can I calculate a quality scoring of an object based on its properties?
/**
*
* get Quality
*
* @return float Conta... |
I have a case in which I need to determine whether a for loop yielded at least one element:
@property
def source_customers(self):
"""Yields source customers"""
for config in RealEstatesCustomization.select().where(
RealEstatesCustomization.customer == self.cid):
yield config.source_customer
... |
I just want some opinions/tips on how to improve.
#import
import string
import random
import time
import pickle
#create grid
def create_grid(size,lastcell,numberofmines):
grid = []
for i in range(size):
row = ['0']*size
grid.append(row)
mines = create_mines(grid,lastcell,numberofmines,siz... |
I'm a junior who wants to refactor a big method in my code, which has been tested and works:
def self.authorized_status plugin_id, store_id, application_id, version, locale=nil
if plugin_id.match /^(\w|-)+$/
I18n.locale = locale || :en # I think I can move it to a concern
# for this I thought about a... |
I am trying to solve following problem in Haskell using recursion:
Define a recursive function funkyMap :: (a -> b) -> (a -> b) -> [a] -> [b] that takes as arguments two functions f and g and a list xs, and applies f to all elements at even positions [0, 2..] in xs and g to all elements at odd positions [1, 3..] in xs... |
I've been messing around with a RationalInt type, using a simple
int-based structure for the time being. I've created code to convert
strings to the RationalInt type, but I'm not happy with it; it is too
convoluted for comfort (though this second rewrite isn't as bad as the
first rewrite, and the initial revision trea... |
I am writing an Express middleware component that'll run on Node 4, which has limited ES2015 support.
The fundamental purpose of this component is to verify JSON web tokens, using the jsonwebtoken module. Here is said component:
const jwt = require("jsonwebtoken");
module.exports = {
ensureAuthenticated: function(r... |
I'm fairly new to jQuery and have decided to make a jQuery audio player for a website.
There are two versions of the way it selects the audio:
Here
Here
I removed some basic, not connected with the player functions. What do you think of it?
$(document).ready(function() {
function secondsTimeSpanToHMS(s) {
... |
I've written (and tested) a simple least mean square adaptive filter . The steps of the algorithm are:
$$ For n = 0, 1, 2, \ldots: $$
$$ x = [u(n), u(n+1), \ldots, n(n-p+1)]^T $$
$$ e(n) = d(n) - w(n)^Tx(n) $$
$$ w(n+1) = w(n) + \mu*e(n)^Tx(n) $$
Where \$u\$ is the input signal, \$w\$ are the weights of th... |
The text file containing cars' arrival and departure time will upload stuff from the parking lot.
Text will be like this:
10:10, 11:10
10:30, 12:40
10:25, 11:10
11:10, 12:20
I created a ParkedCar class:
public class ParkerCar
{
public DateTime ArrivalTime { get; set; }
public DateTime DepartureTime { get; set... |
Is there a cleaner way to write this code? It's the start of a hexeditor I'm creating.
I'm aware that the variables aren't descriptive, this is just a test run for when I imbed it into a File Converter program.
def hexeditor
file = File.read('TESTFILE.txt')
file2 = File.read("TESTFILE2.txt")
a = 1
b = ... |
I have a bash script that is meant to start a google search from the command line. I am also looking to implement a way of getting source code for the search page possibly through a subscript. This is what I have so far:
if [[ $1 == "-n" ]]; then
if [[ $# -lt 2 ]]; then
echo "Usage: google [-n] term [, term... |
I wanted to code a small ASCII art minesweeper clone, to see what it looked like and how much code it needed.
The result is not so bad, under 80 new lines of code in total. It looks kinda readable to me, but I wrote it just know, so I'm biased.
Input checking...
I feel like I got pretty much obsessed with input checkin... |
I have a Tiva TM4C ARM processor connected to a GSM modem (SIM900). When the GSM modem receives a new text message it sends a UART string to the MCU, where an interrupt routine increments a new message counter.
Then my program takes over to parse the message. Below is the code. This code currently functions correctly. ... |
I've made this some time ago for an assignment and I was wondering how it could be improved both in terms of performance and best practices for C code.
#include <stdio.h>
#include <string.h>
#define NR_ROTORS 3 /* Number of rotors */
#define ROTORSIZE 26 /* Rotor charset size */
#define INIT_CHAR 'A' /* initial c... |
I have the working code but it is pretty dirty. The goal is to input a number in an application. If it satisfies the min/max logic then jump to the authorization part. Afterwards we can confirm it or reenter it or cancel it. If fails then re-input it. So totally we can only input twice.
public virtual CallerAuthoriza... |
Description
My program checks the sum of 2 numbers to determine if it is divisible by a certain number (5 in this case). Divisible numbers are deemed usable (for another program I am running). Next it checks the individual integers to see if those are divisible/usable as well.
Problem
I want to use this same code for d... |
I have a report on SSRS (that's SQL Server Reporting Services) that I need to be able to parameterize so that it can run for..
Yesterday (scheduled every morning)
The week that just elapsed (scheduled on Sunday mornings)
The month that just finished (scheduled on the first Sunday of the month)
Now, in order to be abl... |
I've created a (very) simple solution for Project Euler problem 6:
Project Euler Problem 6: Sum square difference
The sum of the squares of the first ten natural numbers is,
$$ 1^2 + 2^2 + ... + 10^2 = 385 $$
The square of the sum of the first ten natural numbers is,
$$ (1 + 2 + ... + 10)^2 = 55^2 = 3025 $$
Hence the ... |
In my single-work.php I have some code with slight variations that I feel could be more DRY. When there are only slight variations like this is it ok to repeat part of the code? Or is there another way to write parts of this?
// Advanced Custom Fields
// Grid images or videos
$grid_image_1 = get_field('image_1')... |
This is a small program I wrote for GCSE computing, it operates using Vectors and that's pretty much it, wondering if you could tell me if there is anything I could do better.
BlackJackv2.cpp
#include "BlackJack v2.h"
int main() {
// Create Vector with the players, using vec because of an undiefined amount of pl... |
I wrote this page with the goal in mind of having a footer that runs along the bottom of the page that can be closed, and has a floating info box that appears when the footer is hovered over. I'm just learning JS, HTML and CSS now, so I'd appreciate any critiques on style.
Am I doing anything the long way? Is any of th... |
The following code sorts the current users bid model items based on a param condition :bid_status. It starts to get messy when checking if the project space (:real_property_sale_project) :failed_date is .present? or .nil? to exclude certain items from the returned results. How can I improve this?
def index
@bids = cu... |
I have written a pager in C that is supposed to be used in systems where curses is not installed (or broken). It can also be used as a system-wide pager, it works with man pages (only on BSD, though). I want to spot any portability or output problems, as there may be some due to the dependence on buffered input:
#inclu... |
Validate that the following bracket pairs [], {}, () open and close successfully in a candidate String.
Valid String Example: "[{()}]" should be evaluated as true because no "outer" open bracket is closed before an "inner" open bracket.
Invalid String Example: "[f{o]o}"
I would appreciate feedback on my implementation:... |
In this revision (follow-up of this post) I've fixed reading from stdin, and also tried to minimise the damage caused by typing additional characters. You might want to see my original post on this.
#include <stdio.h>
#include <stdlib.h>
/*
* A very SIMPLE pager that does not require curses. If your curses library
*... |
I'm trying to implement an algorithm able to search for multiple keys through ten huge files in Python (16 million of rows each one). I've got a sorted file with 62 million of keys, and I'm trying to scan each ten file in dataset to look for a key and its value.
Sorted file key:
a
b
c
d
...
Each dataset file appears ... |
It takes a long time to execute and the CPU usage for the executable is about 25% while it is executing. Any ideas on how to make this faster?
primes.c:
#include <stdio.h>
#include "primes.h"
/* COUNT will be how many numbers to
* check and see if they are prime */
#define COUNT 1000000
int main(void)
{
FILE *ftp;... |
I wanted to revisit this site to post some recent work I put into this small project. I was able to add a console as suggested; but I thought I would ask here how my coding stying is before I work on it more to hopefully avoid getting too frustrated with modifying what may be bad coding style. How has this improved? Ho... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.