instruction stringlengths 71 71.9k |
|---|
So my code is done it outputs exactly what it needs to I'm just wondering if it is possible to make this code a lot more simple using objects. If so could someone tell me what I would need member-wise and I will try and implement it. When I tried it got way too complex and it ended up looking easier to just write funct... |
I recently read the book clean code by Robert C. Martin and I'm trying to apply his style of writing methods to the FizzBuzz programming example.
So far I have two "public" methods called: start and parseNumber, that respectively start the FizzBuzz program or parse a single number according to the FizzBuzz principle.
c... |
It seems there are a lot of "empty containers" (I do not know the correct, technical term) with regards to multiple levels of abstract classes and functional interfaces with little or no code. Is this the case in real working situations?
Here's the class diagram:
And here's the code:
package shapeHierarchy;
public ... |
The following problem is currently taking more than 8 seconds to execute. Please help me to modify the program, so that execution time will be reduced.
var yourself = {
fibonacci : function(n) {
if (n === 0) {
return 0;
}
if (n === 1) {
return 1;
}
else {
return this.fibonacc... |
BitPat here is a wrapper around a bitset.
class BitPat
{
private:
boost::dynamic_bitset<> data;
public:
bool BitPat::operator[](size_t coord) const
{
if(coord < length)
return data[coord];
else
throw std::out_of_range(std::string("Pattern coord out of range")
... |
I wrote a short Haskell script to compress and decompress via the use of run length encoding.
The concept is simple enough, n equal items x in a row will be replaced by (n, x), decompressing is just the reverse.
For example:
> runLengthCompress "foooo barrr"
[(1,'f'),(4,'o'),(1,' '),(1,'b'),(1,'a'),(3,'r')]
As you can... |
Because I don't like writing the same useless exeption messages all the time ;-) I thought I create a better exception that would make this for me. This is what I came up with:
[Serializable]
public class SmartException : Exception
{
private const string PropertyNamePrefix = "$";
private const string InnerExcep... |
Once more, I come to you for assistance! I have written a significant bit of code that converts IP Addresses from strings to minimal byte-arrays. (So that you can store them in a binary format instead of as a wasteful string.)
It currently works with IPv4 and IPv6 addresses, saving both to a 16-element byte-array. (The... |
This program is working correctly, but I need to check if the structure is good or can be improved. Plus, if I called ra.area() immediately after declaring ra, I get 687194768. Why is that?
#include "stdafx.h"
#include "iostream"
using namespace std;
class rectangleclass
{
int w,h;
public:
void setnum(int x, int y)
{
... |
I'm trying to develop a lightweight enum for Python 2.7. This question is downstream of the SO question here; for context, a streamlined version of the bulleted addendum to that question is replicated below:
My desired feature set is:
Only having to type the enum name (or value) once in the source definition.
Valid ... |
The module adds syntactic sugar to Python 3 to allow concise specification of templates. I use it to generate a collection of static web pages from various data sources.
I wanted something relatively simple without the overhead of, say, cheetah or more recent templating systems (e.g. Mako and Jinja2). (I don't want t... |
import itertools
def permutation_lib(iterable):
return itertools.permutations(iterable)
def permutation(iterable):
if len(iterable) <= 1:
yield tuple(iterable)
else:
for sequence in permutation(iterable[:-1]):
for i in range(len(sequence)+1):
yield insert_at(se... |
After posting my first question on here, I got a lot of great feedback. I've decided to try another challenge and write it as cleanly as possible.
The rules of Odd-Even consists of the following tasks:
Given a max number a string should be returned counting up to and including that max number and adhere to the followi... |
I've written an A* search to find the optimal solution to the equation
$$ \dfrac{4}{n} = \dfrac{1}{x} + \dfrac{1}{y} + \dfrac{1}{z} $$
with \$n, x, y, z\$ positive integers, and \$n\$ given; the optimal solution being the one with smallest sum \$ x + y + z \$.
(The Erdős–Straus conjecture states that there are solution... |
I have some data under an HTML format and would like to import it in R. However, it seems that type inference is much less sophisticated than what exists with functions such as read.table. I am using the following workaround, which consists in reading the data table once, write it as a csv and re-import it.
# import r... |
Background:
I'm in the process of writing a relatively simple behavior tree driven AI system for a game that I'm working on. Basically, the behavior tree is made up of individual gameplay tasks (move, attack, etc.) as well as composite tasks that iterate over sub-tasks in a variety of ways. Each gameplay task is a leaf... |
(Offtopic note: I can't add a "networkx" tag.)
I reworked an old algorithm, this time not implementing the graph on my own, but building on the networkx module.
Script works fine for the tests and the small test file, but takes forever (estimated at around 8 hours) on the large file.
I had trouble breaking the progra... |
I'm trying to learn C++ again, trying to do all the "modern" stuff (e.g., avoid pointers in favor of references) and I found that I have some trouble understanding how references and lifetimes work. I'm using clang with -std=c++11.
I want to have a RAII-class, RoomList that basically wraps a map<int, Room>. On construc... |
This class is my attempt at creating a re-usable class that simplifies the parallel calculation of products. I would appreciate hints on all aspects especially the value of the threshold for which the best performance is obtained.
import java.math.BigInteger;
import java.util.concurrent.RecursiveTask;
import static ja... |
I have the following js code and am wondering how I can make it clean. It works fine but there are few repetitions. Is there a way to make it more clean?
$('.js-decline-button').click(function() {
$('.js-confirmation').show().stop(true).animate({ left : '0' }, 500);
});
$('.js-confirmation-yes').click(function()... |
I'm getting these errors:
error C2512: 'course' : no appropriate default constructor available
error C2374: 'co' : redefinition; multiple initialization
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
class course
{
string coursename;
int courseid;
int passinggrade;
publ... |
I ported a lz77 implementation from java to c#, and it's working fine. Now I want it to compress bytes and not strings, as I need it for another project.
This is the porting, operating on string:
public class StringLZ77
{
private char _referencePrefix;
private int _referenceIntBase;
private int _referenceIn... |
I have a date control which has a dropdown for each date, month and year.
The issue is, I can select 31st Nov. 2015 as well, and when I create date object, I get 1st Dec. 2015.
Example
var _date = 31; // value fetched from dropdown
var _month = 10;
var _year = 2015;
var date = new Date(_year, _month, _date);
docum... |
I have an application that has a form. Validation and data insertion works fine. However, it bulks out my controller. I've always been told skinny controllers.
For example:
class myController extends BaseController
{
public function store(myRequest $request)
{
$company_id = Company::insertGetId([
... |
I've been writing a python script to help me clear up some files that contain outdated code, while also serving as a way to learn python. These files have sections of code surrounded with tags on their own lines, I need it to remove both the tags and everything within. While this largely applies to XML documents I am a... |
I decided to make a Breakout game in JavaScript. Is there a way of making it cleaner? For instance, creating objects for the ball and the paddle.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Brick Game</title>
<style type="text/css">
body {
background-color: black;
}
canvas {
... |
The following should read a hex string such as "ece998a2fb" into vector 236 233 152 162 251. I was unable to find any built in method for doing this.
as.byte.vector <- function(hex.string) {
vapply(seq(to=nchar(hex.string), by=2), function(idx) {
as.numeric(paste("0x", substr(hex.string, idx, idx+1), sep=''))
}... |
I created various functions for string manipulation in Lua, where the strings are composed of tokens separated by an ASCII character (which may be the point, comma, semicolon etc.). One of these is the function puttok()
local function tokenize(C, strng)
local sInput = strng or ""
local sChar = string.format('%c... |
I would like to represent a numeric range in C#. Either open-ended, such as "up to 35" or "100 on up" or closed-ended, such as "34 to 65". I'd like to represent the open end with NULL. Further, I'd like to parse strings into the range. Strings will look like "-35", "100+", "34-65" or even "-10.5--0.5". I hate that the ... |
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace Common.Extensions
{
/// <summary>
/// Contains the logic for streaming extensions.
/// </summary>
public static class StreamExtensions
{
/// <summary>
/// Serialize an object.
///... |
I have one window service. At any given time this window service runs 5-10 threads and each thread do some logging on text file. Logging can be exception or some information related to task/job. I have to make sure all the log should be in sequence with date and time. This is so important. Log file should create every ... |
I need to call this function over a big dataset. I need it to be as efficient as possible but still be readable. Can I make it anymore efficient by using a different function for capitalize or blank check?
public static String nameFormat(String title, String firstname, String lastName) {
if (StringUtils.isBlank(fi... |
Currently, I'm writing a program that encrypts/decrypts text using Caesars cipher. The code below shifts a character.
/// <param name="originalChar"> char to shift </param>
/// <param name="shift"> amount to shift by </param>
/// <param name="letterA"> letter A in ASCII </param>
/// <param name="letter... |
So, I have a memory game written, but was wondering how I could turn these letters in the cardSet into images (I have a set of images in an images folder within the folder containing this code, called cat.png, cow.png, etc). Here's the js:
$(document).ready(function () {
var cardSet = ["A", "A", "B", "B", "C", "C",... |
This might not even warrant posting here, but I"m enjoying it and thought I would share.
//For Testing
function write_to_file($message){
$handle = fopen("/path/to/logs/a_log_file.php", "a+");
if (is_array($message)):
fwrite($handle, "\nMessage is array.\t ");
fclose($handle);
... |
This program runs in about 1.65 seconds on a 1.65GHz dual core processor.
I compile it with:
gcc -Wall -o ./program ./program.c -lm
Are there any optimizations I can use to speed this up, or is it already going about as fast as possible on this machine?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include... |
I made a genetic search algorithm in Python for the Travelling Salesman Problem for a midterm project. The grade was fine, but I was hoping to get some pointers on style and documentation. Please provie any feedback you have about how I can make my code more readable, consistent, and friendly.
"""
geneticTS.py
By Loga... |
I've implemented the classic game Rock Paper Scissors with scores, and a save file implementation. I'm looking particularly for ways to get rid of all the self.'s. Is there anything I should add, remove, or change. Are there any bugs? Anything else?
#Programmer:
import random as ran
import shelve
class Score(object):... |
I'm a new programmer, who has just finished his first small project.
It's a sort of basic imitation of the grep command from Linux. I'm learning from projects the hard way. Here is the description of the project:
The first project that we’ll try is called logfind. It’s nothing more than a simple version of grep so yo... |
I wrote a tool to send emails with data saved in excel spreadsheets (.xlsx).
It uses the openpyxl module to interact with the spreadsheets and smtplib to send the mails.
It is only tested with (and should only run for) xlsx files generated by google spreadsheets.
It should work with everything openpyxl is supporting, b... |
I have coded a database manager in C# that connects to a MySQL database and does a few things, etc.. I just wanted someone to give me a few tips on how I can improve this, and maybe make it a bit faster.
DatabaseManager.cs
using MySql.Data.MySqlClient;
namespace Kiwi.Application.Base.Core.Database
{
sealed clas... |
Problem
I want to create a simple class for storing money - I will be storing dollars/cents as just ints for this model.
Idea is to implement various operations on Money class - to be able to add/subtract/multiply/divide money by constant (division is integer for our model - so we don't support money less then a penny ... |
I'm currently learning MySQL about prepared statements and I was wondering if this code I've written is the most efficient way.
The process:
There's a query that checks a table called 'websites' for a field called websites_pagecount.
The same query then increments the field by 1. (I haven't done this is the database u... |
This is not much of a question as more of an practice/experience project and feedback request. First off, this was a project I worked on when I started getting into Java last summer and had an assignment that required us to write a simple ATM application. As I'm looking at the code a year later, and gained a bit more e... |
I am updating my gaming website's CSS and I was wondering if I am on the right track.
HTML:
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Summon The Assault - Index Page</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="skins/nos1/style.css" />
</head>
... |
Would this recursive solution's speed be comparable to a non-recursive solution?
// returns location of the target
public static int search(int[] arr, int start, int end, int target){
int midpoint = (start+end)/2;
if(target > arr[midpoint])
return search(arr, midpoint+1, end, target);
else if(target < arr[mi... |
I just learned about classes today and wanted to find a way to implement them that interested me. I whipped up this little battle simulator and would like any feedback and critiques as well as any ideas or similar projects I could pursue.
import random
import time
import decimal
rnd = 0
class Unit:
def __init__(... |
I'm working through a Sudoku solver problem that I found at UPenn (no it's not my homework ;)). I'm a beginner at Scala, and I'm trying to write good functional code (not that this particular method really demonstrates that...).
A problem that keeps occurring for me involves trying to use Lists but not using vars, as p... |
What this function does it's to return an array of remaining dates that are e.g. Mondays. Is this really the best way to do that?
function range(start, count) {
return Array.apply(0, Array(count))
.map(function (element, index) {
return index + start;
... |
On machines where I don't have C# 6 I use this named string interpolation method. I tried to make it as pretty a possible as far as good coding practices are concerned but I just can't get rid of the repeating code for braces validation and index incrementation. Somehow I don't like it.
public static string FormatFrom(... |
Is this a right way to use/implement an external library into a project? If it's not how do you do it?
class Mail {
protected $mail;
public function __construct(PHPMailer $mail) {
$this->mail = $mail;
$this->mail->isHTML(Config::read('mail.isHtml'));
$this->mail->setFrom(Config::read('m... |
I'm implementing an interface with the async method Execute. In this I need to call some synchronous code. (removing an item from a dictionary). What would be the best way to go about this?
Alternative 1.
internal class ClearClaimByClaimIdCache : IListenTo<ClaimStatusChangedEvent>
{
private readonly ICache<Guid... |
I have a common issue that I face in my applications (because I don't know any better) and I want to improve.
This is my usual structure:
Project.UI (MVC Project)
Project.BLL (Class Lib)
Project.DAL (Class Lib)
LinksConfigurationController
public class LinksConfigurationController : BaseController
{
public async ... |
What I have to do is to sort the array list and then rank them in descending order.
I have to write a method to sort and display the names according to their final scores decreasingly.
The output should be in the form:
Rank_number1 Name1 new_final_grade1 new_final_score1
e.g.
1 Winnie A 94.4351629426243
(Rank_number... |
I've created a Forum website tool for admins to add, edit, and delete users from their desktop, saving to a file, and uploading the file to the database, the program is not completed I'm posting it here for review thus far
(People I'm creating it for would prefer me not having access to database, I understand I would ... |
On my job I had the task to process multiple excel sheets, so I tried to make a generic component to make the conversion between the cell values and a java object type.
The first thing that came to mind was a generic interface that will handle the processing of a particular column:
public interface ExcelColumnProcessor... |
Conway's Game of Life is a common problem. I had to write a version of it to get my current C# job, so I thought it would be a nice way to get into Python (especially as the example in the book are a little too simple for my liking)
I've slightly abused the unit tests to print out the grids, normally I would not use a ... |
I tried this program in both Orwell DevC++ and Visual Studio 2013 (program works correctly). My astonishment is the performance of the same program in both IDEs. While the former took only 395 milliseconds, the latter took a whooping 34984 milliseconds. What's wrong with VS2013? Is it due to the compiler it uses? Or is... |
I wrote this jQuery code as I could for a dropdown menu.
But I'm sure there is a way to make this code shorter.
$(document).ready(function() {
$('#show-menu-1').on('click touch', openSubMenu);
$('#close-menu-1').on('click touch', closeSubMenu);
$(document).on('click touch', function(event) {
if (!$... |
The issue that i'm trying to fix with this code is simple
I have a huge dataset and I have to bind it (as readonly) to a DataGridView
In that dataset I have some column that are key to list and I have to display a custom property from that list
with the DataGridViewComboBoxColumn there is a big issue of unsharing row w... |
Due to an excercise, I've made a function that converts given string to spinal case just-like-this-one (all lower case).
I did it with two regular expressions. Can it be done with one, or generally better?
function spinalCase(str) {
//if string is not delimited
if(str.search(/[_\s]/) === -1){
// insert dash ... |
Context:
The following code is used to look up a setting values based on multiple layers of configuration within the application. For any given setting (ie: default printer), the application can be configured at the following levels in order of precedence.
Operation
Material
Workstation & Program Combination
Workstati... |
I'm new to C++, so I'm trying to learn the language by implementing all the type systems and languages in Pierce's Types and Programming Languages. My first attempt starts at the very beginning and implementes this very simple language "Arithmetic Expressions" on page 41 in the book (for those that want to look at it, ... |
The sole purpose of this post is to see how a production quality developer would approach this very simple problem. I am a fresh graduate and do not have a professional development experience. What are the cases and approaches that I should start considering when developing in a production environment? Please feel free... |
I'm trying to set up a contact form using phpmailer. Are there any security holes in my code? I want to be sure as I feel there might be some kinda exploit I may not be aware of.
<?php
if (isset($_POST['submit'])) {
if ($_POST['name'] != "") {
$_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_ST... |
I'm using WinForms and have a picturebox in my form. This program looks in "C:\image\" directory to find a specified image document, in my case a tif file. There is always only one picture in "C:\image\" directory.
After it locates the file, the program displays the image document in the picturebox.
When I was running ... |
Is there anything wrong with this implementation of an object pool that will be called from an ASP.NET application?
The object I want to pool has extremely expensive initialization, so currently I am storing one instance of it in a static variable and using C# lock() to avoid race conditions. I want to change to an ... |
A have a model with a dynamic field like so:
def resolveClient() {
if (prevCall && prevCall.client) {
return prevCall.client
} else {
return client
}
}
Pretty simple. However, using a dynamic field makes me unable to do queries at the database level. I can't query using HQL or Criteria. Thi... |
I made a fast and simple WPM (WriteProcessMemory) for Android. Any suggestion is welcome.
bool bChangedProtect;
cout << search_results[cur_result].size() << " found.\n" << endl;
for (int xy = 0; xy < search_results[cur_result].size(); xy++)
{
bChangedProtect = false;
if (ReadProcessMemory(phandle,(void*)search... |
For a given object that may be an instance of a class, a built-in container or type, I would like to copy that object, but replace all instances of a given class with something else. I can do this with two calls to deepcopy as shown below, but there may be a more straightforward approach.
Create some complex nested ob... |
In learning golang, I wrote a small CLI utility that will take paths as arguments and list out their md5 hash as hex strings. Included are two flags that alter functionality, --check | -c which takes an additional file, hashes both, and returns whether or not they match (and exits with the proper return code), and --te... |
Referring to my previous post, should I consider using current pointers for this code snippet for reversing a linked list using recursion?
public static List ReverseRecursion(List head){
List newHead;
List current = head;
if(current == null){
return null;
}
if(curre... |
This code correctly gathers diagnosis records for a patient to show distinct records based on the AMA ICD9 code, diagnosis description, and date of posting. The output is distinct on (ICD code, cdesc, tposted). The most recent date of usage, tposted, is assigned to each unique combination of (ICD9 code, cdesc).
Additio... |
For fun and to learn a bit, I decided to implement a bidirectional map in Ruby, relying on Ruby core libraries where possible.
Its behavior is intended to be that of a Ruby Hash, but one in which 'values' are also hashed as keys for quick reverse lookup. I've implemented nearly all the methods from Hash, except those I... |
I originally wrote this as an answer to a question on Stack Overflow, but it turned out so nicely that I decided to post it here to see if I can make it even better.
(defn char-seq
"Returns a lazy sequence of characters from rdr. rdr must implement
java.io.Reader."
[rdr]
(let [c (.read rdr)]
(if-not (neg? ... |
This is a calculator I'm working on. The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context. PSA: I'm a beginner.
def main():
hours, rate = inputData()
normal_hours, overtime_hours, overtime = computePay (hours,rate)
regular,... |
I have a folder called core with two files inside: index.js and module.js. I'm kidding a little with dependency injection and ES6, and I would like to receive feedback with improvements for my code.
index.js
module.exports = [
{
mod: require('./module'),
inj: ['bluebird']
}
];
Inside module:
module.expor... |
I have two code snippets and the following questions:
Which uses the best practice and why?
Which one is good for performance?
Code 1
jQuery( function( $ ) {
// Responsive video
var $area = $( "#sidebar" );
$area.fitVids();
// Image gallery
var $slider = $( ".owl-carousel" );
$slider.owlCaro... |
I'm working on a program that will be significantly multi-threaded. I need to respond to events between objects and threads so I've come up with the following code.
#ifndef EVENT_H
#define EVENT_H
#include <vector>
#include <mutex>
#include <algorithm>
#include <memory>
/**
* Create the definition of a dispatcher f... |
I wrote this class. I would be very interested in your feedback how much thread safe this class is. I know users of this class must still use some kind of synchronization when using this class, but I am ok with it, they will do such synchronization.
To save your time and energy, I am more interested in thread safety re... |
I am using the following to validate my user which works but i wish to incoperate roles so I used the reg iis to add the standard tables aspnet_UsersInRoles.
What I basically want is the ability to have variables canView canDelete canEdit and that I can just access them when my dal is called.
protected void btnLogin_Cl... |
I'm on a quest for making a good debug_print() method for printing out debug information in some of my private projects. When testing I aliased my debug_print() imported from a module to debug() print, and some of the intrinsic of my code stopped working.
This led to a question on Stack Overflow, which with a little nu... |
How many different ways can 200 be made using any number of coins? The possible denominations are 1, 2, 5, 10, 20, 50, 100, 200.
-module(coins).
-export([coins/2]).
coins(_, 0) -> 1;
coins([], _) -> 0;
coins(_, Goal) when Goal < 0 -> 0;
coins([H|T], Goal) ->
coins([H|T], Goal-H) + coins(T, Goal).
The call is:
1> c... |
I have the following scenario: I create a lucene document from a potentially very large text. Apart from indexing the text, I perform some analysis on the document for which I need the document's term frequency vector. The results of this analysis also need to be stored in the lucene document/index. Here is my current ... |
To display comments recursively I'm using this:
function fetch_article_comments($article_id, $parent_id) {
$app = new Connection();
if ($parent_id <= 0) {
$parent_id = NULL;
}
$sql = "SELECT * FROM recursive WHERE article_id = :article_id AND comment_parent <=> :parent_id ORDER BY comment_timestamp... |
This is a part of a project I am working on. I need advice and criticism regarding the data base design and general approach to querying the data. I am not at all experienced with relational data bases (as you should notice), and even though I have tried to invest some time in reading up I am currently forced to just m... |
This is my first piece of code to post here. I wrote this script as a
post-receive hook for a Git repository but I’m not so concerned with the Git
parts (I’d like to have the part marked with TODO working but it’s not a
priority).
It’s my first time to use either named pipes or the trap command to clean
up temporary fi... |
The code allows you to subscribe to events and publish events via an EventBus class. Events are identified by a source and subject. Events can have a single parameter or they can be 'indexed' and have two parameters (the first being an integer index - I will be using this a lot so wanted a specialization).
I don't part... |
For those who don't know, Twine is just a simple interactive fiction making tool. It lets you easily create a series of passages that are hyperlinked to each other, making a choose your own adventure style structure. It exports as HTML format, but if you wanted to just use Twine to write nodes to use elsewhere it's lac... |
I am working on a simple Rails app. For the Expense resource I use a DataTable. So, in my CoffeeScript for this resource I basically do several things:
initialize the datatabe;
since I use a custom search field (not the one, provided by DataTables), I add a search function in the table api;
initialize the Select2 plug... |
I'm completely new to Javascript and NodeJs and functional programming in general. The code below scrapes a torrent-website containing movies, gets info about the movie from the OMDb API and lets a user choose a movie to watch by streaming the torrent. Any feedback appreciated.
var scraperhelper = require('./scraperhel... |
I would like some help condensing this code down to size. I am trying to utilize Qt's container classes as efficiently as possible. I do not believe this code reflects my objective.
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QVector<int> ve... |
I'm brand new to C# and I've started to make a cipher decryption program. The code works and runs fine, apart from the odd exception. I'm just looking for ways to improve my code and make more efficient.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Ap... |
I am building a map editor to easily create 2d levels. To visualize how my level looks like I am using a canvas. On this canvas I can select which block is filled with a certain type ( like solid ). I did add click and drag but because I am live drawing on the canvas it goes very slow and if you draw at a decent speed ... |
I'm using some third-party libraries in my project. Once in a while the code in these libraries freaks out and produces infinite loops and other nasty things. My goal is to write a wrapper that allows me to abort execution of this third-party code after some timeout. Here's my current implementation:
public static clas... |
This is my 1st F# program so I'm open to any and all criticism on my syntax and the way I approached the problem.
Challenge
Project Euler 16: Power Digit Sum
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?
open System
open System.Numerics
let digitP... |
I need to vertically concatenate two disjoint ranges in VBA to be passed to an Excel function (in this case the LINEST function). I hate working with arrays in VBA but I managed to get it working using the following code:
Option Base 1
Function VERTCAT(R1 As Range, R2 As Range) As Variant
Dim ncols As Integer
... |
I'm a HPC guy so I'm all about "make it work, then make it fast." I have a little bash script which gets a Physical Source Lines Of Code (PSLOC) and Logical SLOC (currently just of Java code, but it would work for C and C++ too). It works by finding all *.java files in a directory and then goes through each file found ... |
I'm working on a page that shows groups of users. The following JavaScript function is used to show more details about a user (such as email and login) when you click on their name.
But there's a twist: clicking on one of those pieces of information will highlight it to make it easier to copy. This is accomplished by a... |
I'm just a beginner in Python. I wrote a simple code that detects the user's password strength, but I feel that it isn't very efficient. How can I improve it?
print('''# This is Password Strength Detector.\n
-----------------------------------------------------------------''')
password = input('Enter your password her... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.