instruction stringlengths 71 71.9k |
|---|
Consider, please, my code of the finalizer template:
#include <functional>
template<typename F, typename... Args>
class finally
{
public:
finally(F action, const Args&... args) :
_action(std::bind(action, args...))
{}
~finally()
{
if(enabled)
_action();
}
bool enabled = true;
private:
... |
Im making a Python program. It is basically a questionnaire and I was just wondering if there is a shorter way of doing this as at the moment I'm writing out all of the questions in separate functions. I was wondering if there is an alternative way of doing this in almost a single function where the function just repea... |
The following code I am using to lookup the description based on a "Partition Type" in either a string, an integer or hex value. By calling parttype(parttype) in the below code.
Is there a more pythonic way for this?
__PARTTYPE_TO_DESCRIPTION__ = {
"00": "Empty",
"01": "DOS 12-bit FAT",
"02": "XENIX root",
... |
Trying to get https://github.com/github/fetch working with an API that almost always returns a json payload, even when the response is an error:
{
"message": "User not logged in",
"code": 401
}
So I came up with this, adopting their status check example
function checkStatus(response) {
if (response.status >= 20... |
sentence = input("What is your sentence?")
sentence=sentence.capitalize()
counta = sentence.count("a")
counte = sentence.count("e")
counti = sentence.count("i")
counto= sentence.count ("o")
countu= sentence.count ("u")
countA2 = sentence.count("A")
countE2 = sentence.count("E")
countI2 = sentence.count("I")
countO2 = s... |
I have a static list of descriptions in a resource and I am filtering down the list based on the index positions of the text in the array
Here is my multi converter:
using OCLMEditor.Data.StudentInfo.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
namespace... |
I am new to perl and want some help in tuning this script if possible cause it takes time if I increased my array. also if I use warnings I get a lot of warnings which I'm unable to handle. I'm using perl (v5.24.0) built for darwin-thread-multi-2level.
Here is an example of what I want to achieve:
The number 886 is lik... |
I am interested in implementing advanced data structures. One of them that tickled my fancy is the SkipList.
I wanted to know if there is anything to improve in my code.
The SkipList node:
/**
* SKNode.java
*/
import java.io.Serializable;
class SKNode<T extends Comparable<? super T>> implements Serializable{
pr... |
My application is really easy. It's going to add 500 records at a time to AWS Kinesis and if there's an error occur I'll just add that back to the queue and it's going to be retry. It's going well but I feel like there's a bug somewhere that I don't see.
'use strict';
const _ = require('lodash');
const moment = requi... |
I wanted to write a c++ program to solve a 3x3 rubik's cube, but failed at it. So I picked up a 2x2 rubik's cube and wrote a program using Blindfold cubing algorithm. Can anyone help me write a more efficient program ?
This is the program I wrote
#include<iostream>
#include<string>
using namespace std;
class Solver
{
... |
I am making a little single-player game and to help with scoring I have created a Player class. Can you review my implementation?
I know that for a multiplayer game this isn't good. For multiplayer I would need to call functions and have all players in one instance.
File player.h
namespace SDLGamecore {
namespace playe... |
I'm implementing a "live analytics" feature and I need to always keep track of the last N items that were added to a collection so I figured I'd make a circular buffer since I couldn't find one.
I tried to figure out to use Interlocked but couldn't find out how to use Increment or CompareExchange in an obviously corre... |
I recently wrote the livejson module as a way to make working with JSON in Python easier. The idea of the module is that you initialize a livejson.File, and then you can interact with your JSON file with the same interface as a Python dict, except your changes are reflected in the file in realtime.
I'd like to know how... |
I've written some code to scan large files and search for long strings that you can write without repeating a letter. I'm self-taught in python and I'm wondering what I've missed.
import sys
letters ={} #letters is a dictionary
currentResult=""
ideas=[]
with open(sys.argv[1]) as f:
while True:
c = f.read(1)
... |
I have two matrices a and b that have, on each line, some values (null or not) and then a bunch of zeros at the end.
I want to construct a matrix c that for each line has the corresponding line of a from the first element till to the last not-null element, concatenated with the corresponding line of b from the first el... |
I'm looking for a general review of this AVL tree implementation:
#pragma once
#include <cmath>
#include <algorithm>
namespace mds {
template<
typename T,
typename Func = std::less<T>
>
class avl_tree {
struct Node {
T key;
int h;
Node *le... |
I am working on a user login using Flask and the following extensions: Flask-Login, Flask-WTF, WTForms and Flask-SocketIO
Client-Side
Rendering of Forms and pre-filling with data is done with Flask-WTF / WTForms just like this:
<form class="form-horizontal" role="form" id="username-password-form" method="post" action="... |
Currently all this does is retrieve data from specific columns, the final result will be that I will check the data to make sure that it passes the test cases, but I want to look at this foreach right now and see if I can't make it a little simpler.
A lot of what I have coded I have come back and turned into Linq sta... |
The application I'm working on needs to occasionally take pictures, and then send them to either an ftp server or a network drive (user configurable). To try to abstract away the differences between a ftp server and a network drive I made this class.
The idea is, the code that takes a picture with the camera and saves ... |
To generate a password, I generate a key using RNGCryptoServiceProvider. The key is 9 alphanumeric characters long into which I insert a single non-alphanumeric character for a full length of 10 characters.
Having a mix of Uppercase, lowercase, numbers and symbols and being 10 characters long, as a plain text password ... |
This is code that gets a list of polygon vertices, non-ordered, and finds the order in which they should be arranged in order to create the polygon with the largest area.
There are two key elements in the approach:
Testing the area of the polygon is done by Monte Carlo calculation. Random points are dropped on the pla... |
I have switch statement that is switching on an enum to build a ContextMenu depending on what the selected enum value is. While the various enum values require different operations in their cases of the switch, some of them require some of the same operations.
All of the MenuItems are declared as readonly and initializ... |
This is a toy version of the code I really want to write:
#include <stdio.h>
#include <stdlib.h>
typedef struct node_s {
char val;
struct node_s *next;
} node;
int n;
char obtain_next_char(){
if (n<100) {
return 'a';
} else {
return 0;
}
}
int main() {
char c;
node *start, *curr;
... |
The program can be used to hide an image within another image and later extract the hidden image. This is done by concealing the secret image within the lowest bits of the apparent image. Example of a cat hidden within a tree.
I split it into 2 programs to make commandline args parsing easier, Crypt and Decrypt.
Info.h... |
earlier I coded a quick console worker that runs a timer every 1 second and updates the consoles timer with how long the app has been open, how can I improve this?
using Faze.Other.App;
using log4net;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using S... |
I got this as part of some interview assignment. After some head scratching I think I have done quite well as the result can be seen here:
After transformation(10x10 tile):
More crisp picture with smaller tile size:
So, the requirement were:
Not to use any external library.
Only front end code.
Should be a producti... |
I am quite new to using python for machine learning. I come from a background of programming in Fortran, so as you may imagine, python is quite a leap. I work in chemistry and have become involved in chemiformatics (applying data science techniques to chemistry). As such, the application of pythons extensive machine le... |
I created this as a template for our email marketing team to use when creating emails. For fluid/responsive behavior, I am using max-width and conditionals for clients that do not support it (e.g., Microsoft Outlook).
If anyone could give some suggestions for improvement, that would be appreciated!
<!doctype html>
<htm... |
A few hours ago I posted a similar question but this is a follow-up, I have revised the code and added and removed certain lines of code and hopefully improved it a bit, I just brought it here for a final cleaning, can anyone notice anything than can be improved even more? Some of the code has been totally changed such... |
Decided to get a little JDK 8 practice in today, so I built two methods to print out the golden ratio, one uses the Stream API the other does not. Wanted to request general feedback on how well I implemented these methods (mainly the stream generator,) considering the given task and if there is anything I could have do... |
Basically, what I mean by splice is to take an array of Enumerables, take the 1st element from the first one, then the 1st element from the second one, and so forth, until we come back to the 1st enumerable, and we then take the next element from it and each of the others.
Sort of like this:
[A A] [B B] [C C] [D D] [E ... |
Inspired by Swift's @autoclosure feature, I tried writing a brief C++-14 header that permits "optionally" lazy parameters (by "lazy" I mean @autoclosure-like; I chose the word "lazy" in emulation of lazy evaluation in languages such as Haskell). From this post on interesting Swift features:
The @autoclosure attribute ... |
If you are unfamiliar with the logic puzzle game Takuzu, I learned how to play it and was inspired to make the project from this challenge posted on reddit. The short version of the game is it's a logic puzzle that uses 0s and 1s on an n×n grid that does not allow three repeating numbers in a row nor two rows or column... |
I have 7 variables controlling 7 widgets showing or hiding from the frontend. I want to put them together and control all of them using one function. Here is what I have. However, I feel like even though this way works, the code is really ugly and should have space for improvements.
$scope.showWidget = function(showA, ... |
The objective is to find all primes between two given numbers. It is specified that the two numbers are \$\le\$ 1 billion and the difference between the two numbers is ~100,000. We are to repeat the whole process for a \$t\$number of times, where \$t\$ is given \$\le\$ 10.
Detail of the problem: PRIME1
The following co... |
Works for any 2D matrix represented by a 1D array. Comments and criticism welcome. Also wondering whether the code can be made shorter. It's really messy right now.
#include <stdio.h>
typedef float fpoint_t;
void print(fpoint_t* m, int row_size, int col_size)
{
int i, j;
printf(" array([");
if(row_... |
class LinearEquationSolver
{
List<LinearEquation> rows = new List<LinearEquation>();
decimal[] solution;
public void AddLinearEquation(decimal result, params decimal[] coefficients)
{
rows.Add(new LinearEquation(result, coefficients));
}
public IList<decimal> Solve() //Returns a ... |
I previously posted a thread asking for a general review of one of my first projects related to programming (C++ Prime Number Library) and received very good help and new perspectives. After this, I decided to incorporate my newly acquired knowledge of templates into the same project. I want to know if this implementat... |
I've recently given a coding interview on a Java concurrency task and unfortunately didn't get the job. The worst part is I've given my best but now I'm not even sure where went wrong. Can anyone help give me some ideas about things I can improve on below code?
The question is pretty vague. Given 4 generic interface... |
Introduction
I'm fairly new to programming (and Java) and I've actually never implemented Insertion Sort.
I know that there's pseudo-code defined in the wikipedia article (linked above), but the goal was to implement the algorithm without looking at the pseudo-code and only using the wiki article's graphic for referen... |
I have 4 cases of time string as follow:
s = "July 5, 2016, 12:04 a.m."
s = "July 5, 2016, 7 a.m."
s = "July 5, 2016, midnight."
s = "July 5, 2016, noon."
I want to convert string to timestamps. Based on this question, I need to declare 4 cases of pattern. I am looking forward to improve my solution.
The following... |
I have a tree view with a list of cars and a webservice to get the details for each car.
On page load, there are no cars selected so the details footer is loaded with all cars.
$.ajax({
type: 'POST',
url: '@Url.Content("/GTracker/Cars/CarTreeDetails")',
data: { "id": [] }, // not cars filter
... |
One of the projects that have been on my to-do list since years involves controlling a number of Inter-Integrated Circuit (\$I^2C\$) peripherals. Lately I've been turning everything into it's own library and I'm wondering if I'm doing it right.
While the libraries are usually called by a server-like script, they all ha... |
I am trying to write an Angular service that will wrap the regular Http service and automatically make authentication calls if Bearer token is not available or invalid.
Here's an illustration of a regular GET call made via the service:
this.httpWithAutomagicAuth
.get("http://localhost:5001/books")
.map(res => r... |
I would like to a review of my database design.
There are 3 tables + ASP.NET Identity tables.
The Users could have many postcards.
Here's my tables without Identity.
I attached also my scripts of creating tables.
CREATE TABLE [dbo].[Country](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
... |
I often use a similar scheme work with an API project. Can it be made easier, or is there a standard approach?
This class creates an API request:
public class ApiRequestCreator {
private static String TEST_API_REQUEST = "http://jsonplaceholder.typicode.com/posts";
public static Request createTestApiRequest(... |
// names are unique within a function, any valid variable name
// a jump table try, allowing return values to determine the exception thrown(index in a jump table, -1 being success for example)
// you only need to put in what you need, not all exceptions, or total exception count
#define GTRY(name, exc) void* __jt_##na... |
I have to compose an email where I have to list a list of difference between old and new value of a list of addresses. Only a subset of properties have to be listed, so the first thing that pops into my mind is doing something like this:
private static List<Difference> RetrieveDifferences(IEnumerable<AddressPoco> newVa... |
Part 2 here.
I wrote this class for packing data.
Would it benefit from being named BitPacker rather than BitStream (and change write/read to pack/unpack), or it works as is?
How can I improve it? Any way to make it more efficient? How can I reduce the amount of code? I have a lot of copy/pasted code with minor things ... |
I recently implemented a dictionary class in TypeScript. I'm still new to JavaScript so I'm curious what people think about it.
class Dictionary {
public constructor ();
public constructor (object: Object);
public constructor (object?) {
if (object != null) {
for (let property in object)... |
I came along these two ciphers in my cryptography book and though I'd implement them just for fun. After that I went on developing a cipher based on these two that minimize the weakness of each cipher alone.
I would appreciate your expert opinions on it and if it would be possible to crypt-analyse.
import java.util.*;
... |
I made a little application (for windows, but easily compatible with linux by just changing some lines) for displaying a little network graph using Tkinter and Python. I basically draw lines higher and higher while the ping is still running, and when the soft receive the ping response I reset the line height.
My issue ... |
I am trying to use Two Step View pattern in WPF. The problem is about keeping things in sync – I need a way to data-bind models to view models. Are there any good existing solutions? My approach is to introduce Property<T> to be used this way:
public abstract class TextField : ObservableObject
{
public Property<boo... |
My code needs to take two ints and then check those ints to see if their binary representations have any differences. The function convertBits returns the number of differences between the two binary forms of the ints.
For example, you can change 31 to 14 by flipping the 4th and 0th bit:
31: 0 0 0 1 1 1 1 1
14: 0 0 ... |
I'm still new to Java and learning programming, so my main goal is to learn to making good code, so I don't want to do anything complex until I fix all of my bad coding habits on smaller programs.
So, this is my third version of this program, you can find last one here and here is where I started. I wanted to expand th... |
I have made an attempt to make a chat script and its working as required but the problem is that it is slow on slower connections and sometimes even on fast connections. Sometimes while loading the site it gives "RESOURCE LIMIT EXCEEDED". I made a page speed insight and the result is here.
I would like to know how to i... |
I need to transpose the following file output1.csv, which is is a result from a quantum chemistry calculation into a single colum efficiently:
Frequencies -- 18.8210 44.7624 46.9673
Frequencies -- 66.6706 102.0432 112.4930
Frequencies -- 124.4601 ... |
I am supposed to write a small java program. The program must contain 3 different kind of dogs. The dogs can bark and move, these methods can be represented just by System.out.println();. Some dogs can have common way for moving or barking. Here is what I wrote so far but I am not really sure that its satisfies the req... |
Say I'm creating a simple CLI. I want to use native node readline module to take in some input from user at prompt. I thought of this:
var prompt = chalk.bold.magenta;
var info = {};
rl.question(prompt('Thing One : '), function(args) {
info.one = args;
rl.question(prompt('Thing Two : '), function(args) {
... |
Purpose:
Given a Worksheet Table (ListObject) that may, or may not, have a filter currently applied to it, return a range consisting only of the filtered data.
Method:
Loop through each row in the table.
If row is visible, add it to a filteredRange via Union().
Return filteredRange.
Specific Areas of Interest:
Is the... |
After learning more about memory alignment and how it can impact processor data access, I tried to find something in the standard that offers proper memory alignment inside blocks of raw memory that will be used to hold heterogeneous types. With no luck, I had to come up with a solution.
The problem
Assuming we have so... |
I have to modify the number of points in this XML in order to test the performance of another program of mine. Here is an example of the XML I have to modify.
performance.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ICCP Local Control Center Configuration -->
<!DOCTYPE LocalControlCenter SYSTEM "C:\Program Files\... |
Using base R, I've conducted a simple profit sensitivity analysis, i.e. measuring the impact on profit if there is a change in price, variable cost per sale, unit sales or fixed costs assuming that there are no interaction effects between the dependent variables, e.g. a change in price does not change unit sales.
I'd l... |
I started with VBA yesterday. Could this code be improved?
Private Sub Worksheet_Change(ByVal target As Range)
If target.Column = 3 Then
Call Modul1.AutoFill(target)
End If
End Sub
Option Explicit
Sub AutoFill(activeCell As Range)
Dim storedData As Range: Set storedData = GrabStoredData(activeCel... |
(See the next iteration.)
I have this template function for computing standard deviation in one pass over the data. The underlying math is here.
coderodde_sd.h:
#ifndef CODERODDE_SD_H
#define CODERODDE_SD_H
#include <cmath>
#include <iterator>
#include <sstream>
#include <stdexcept>
namespace net {
namespace cod... |
I have incorporated all the cool points made by ChrisWue in the initial iteration of this post.
Now, I am not reinventing the wheel for my concurrent queue, but use internally std::deque. Also, I modified the API of the concurrent forp construct: now it takes any range specified by means of iterators as the input list.... |
This is my first time ever having code peer reviewed! This is just the main function I'm concerned about.
Edit
Apologies for the initial vagueness of my question, this is the "login" part of my login script the classes is initial instantiated on the index.php which handles a $_POST request from login.php I wont paste ... |
We all know that std::regex class doesn't allow access to the original string which was used as the source expression. (In fact, GCC even keeps the original string as _M_original_str, but won't allow external access. Still, I have not used this member because it is implementation detail.)
So I derived a lightweight cla... |
I have finished and launched my first website and would love some feedback/ideas for improvement. This is a single page website for the purpose of displaying my finished projects. I know that I have used a lot of !important declarations to make things work properly. I have also used many media queries to have things be... |
This is a tally calculator for the Saudi card game Baloot. As in, they're a set of functions so that the user would provide their winnings at the end of a round (card captured, projects declared, etc) and the functions would give them the score for themselves and their opponent.
Domain Model
(I listed most of these ... |
This program goes through 7 common logical functions (AND, OR, NOT, NOR, XOR, XNOR, and NAND) and generates and prints truth tables for them all.
#!/usr/bin/env python2
# coding:utf-8
import operator
import itertools
table = list(itertools.product([False, True], repeat=2))
ops={'AND': ('∧', (lambda a,b:bool(operato... |
For a raytracer I’ve been writing with a classmate, we use a custom scene definition format that allows specifying shapes, composite shapes, materials, lights, cameras and transform and render commands.
The assets of a scene (i.e. shapes, composite shapes, materials, lights and cameras) are stored in the data transfer ... |
I am just learning swift and tried to make a queue class with enqueue and dequeue.
The node holds the data for each element
The enqueue adds an element to the "queue"
The dequeue deletes the first element in the queue and returns the data
Head and Tail are references to node elements, which also tells if the queue is ... |
The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter.
Start: gain
End: fire
Output:
gain
gait
wait
wart
ware
wire
fire
I created a linked list of linked lists and a hash map that uses the word length as a key so that it checks only ... |
I am creating a webpage for my newsletter archives. The archives are divided by year (currently there is only 1, but there could be many), then by topic, before listing each newsletter. There will always be exactly five topics, but the number of newsletters in each topic will vary.
I add the name of the newest newsle... |
I'm trying to implement point, velocity and acceleration types.
They should be connected by some derive function which:
takes time and velocity and returns a point increment;
takes time and acceleration and returns a velocity increment.
In pseudocode, it should look like this:
derive :: Time -> Velocity -> Point
deri... |
I have an html button that when the user clicks the button it will change color from blue to red and back. Is there a better way to do this in jQuery?
HTML/jQuery
<html>
<head>
<title>Button Fun</title>
<script src = 'bower_components/jquery/dist/jquery.js'></script>
<script type="home.js"></script>
... |
Drafted this up today out of the need for a very simple php based login form to protect an html page.
The app is simply included the top of index.html like this:
<?php require_once('./login.php'); ?>
Usernames are stored in a flat csv file 3 levels up (just above docroot). For this particular application I am not con... |
How can I make my code for Project Euler #4 more efficient and cleaner?
Project Euler #4: Largest palindrome product:
A palindromic number reads the same both ways. The largest palindrome
made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit
... |
I wrote a script to compute / interpolate the nodes of a Polyline at a given latitude, input_lat. It works for my purpose but I am wondering if there is a better, more optimized way of doing this.
The idea is to first check if there is any exact match, i.e. if there are nodes at the exact given latitude so I subtract... |
Basically, what I mean by illumination is having a method create an object where the caller supplies all the dependencies. This allows us to hide our new keyword behind a dependency on an Illuminator, allowing us to much more easily test our code.
Yes, a little bit of reflection is involved, but not too much (IMO).
Pl... |
I finished an output stream-based pseudorandom number generator, that works based on the current time and output data.
Here is the header's code (entrostream.hpp):
#ifndef ENTROSTREAM_HPP
#define ENTROSTREAM_HPP
#include <iostream>
#include <cstdlib>
#include <climits>
#include <sys/time.h>
#include <queue>
#include <... |
This is one of my first projects, just a quick hobby thing for fun.
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
using namespace std::chrono;
using namespace std::this_thread;
using std::chrono::system_clock;
int random();
int main()
{
cout << "Choose a JonTron episode!" << endl;
... |
I have 2 <label>s being used for displaying the votes, which is up votes and down votes. There is no problem for the adding or removing votes, but the switching of votes is the issue (not really an issue).
The structure of the votes in the HTML is:
<label id="up_vote"></label>
<label id="down_vote"></label>
The va... |
I'm fairly new to front end web development, but finally felt confident enough to create my own jQuery slider. I wish to receive constructive criticism about my code, how I can optimize any line of code, or ideas on how I can make this a bit more interesting.
$(document).ready(function(){
/*
=================... |
The following piece of code generates the vertices of the rectified hypercube in arbitrary dimensions. The 3D case of the rectified hypercube is a cuboctahedron with 12 vertices (±1,±1,0), (±1,0,±1), (0,±1,±1).
The code below works perfectly, I only want to know what optimizations should I consider and/or if faster app... |
I was thinking about how to handle AJAX requests in a MVC environment in PHP in a easy way.
What I've come up is (without showing you the backend code):
$.ajax({
// url is empty so the request goes to the current route and controller
// each controller (extended from base controller) checks every request to
... |
First of all, my code does work as expected at least to some extent. The intention of the program is to extract data from a DBMS in order to create a CSV dump and transfer it to an FTP server.
My two issues:
The functions of the class seem to be bloated with self.-references. How can that be optimized? Or is that the ... |
Is there a better way to code this specific algorithm using successively division through 2 which converts decimal numbers into binary numbers without calling a built-in function?
print "Please enter a decimal number."
prompt = '>> '
dec_number = input(prompt)
dec_new = dec_number
binstr = ''
'''dec2bin'''
while dec_... |
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
//This declares the input and output files.
ifstream input;
ofstream output;
string filename;
int value, total = 0;
cout << "Enter the file name: " << e... |
I wrote a small simulator to understand the Elo rating system. I can create players, matches and tournaments, and I want to be able to predict the match ending depending on the rating of each player and some randomness. At the beginning the ratings are all around the same values (say 600) and it appears to stay between... |
I'm learning F# from Tomas Petricek's "Real-World Functional Programming" book. As suggested at one point in the book, I started implementing a zip function using a recursive sequence expression. I'm not very happy with my implementation and I would like to know how F# devs would refactor my implementation. I know that... |
Coming back for another look at my project after I've reworked a few of the key points made in my previous post here.
So far, I've rewritten most of my code to address SQL Injection. I've created a class called DBManager to connect to my database and then create prepared statements and execute them.
Right now there is ... |
As I've mentioned in previous questions, I am writing MySQL statements to update overlapping database entries and insert new data into various tables. My database design looks something like this, where there's one parent table (hash is the primary key and id is indexed):
+---------------+
| hashes |
+----------... |
I have an assignment to code a method that will print values in a diamond pattern. For example, if the method is called like printNumberDiamond(2), then the results should look like:
" 0 "
" 010 "
"01210"
" 010 "
" 0 "
I have spent a ton of time on writing the code that does this, but I am sure that it's not the m... |
Someone on SO asked how to fill in the NA's with row means. His example code was:
cancer1 <- read.table("cancer.txt", stringsAsFactors = FALSE, quote='', header=TRUE,sep='\t')
Since he didn't provide the data I think we can simulate it with:
cancer1 <- data.frame(a=rep(c(1,2,3,NA),10),b=rep(c(1,2,3,4),10), c=seq(1,... |
So I have a method that does a lookup in an existing List<T>, populated elsewhere by grabbing the records from a SQL table holding configuration data for each state where we do business. This method just looks up in the list by state abbreviation and then returns the value of a Boolean field in the record.
public bool ... |
The following code reads a CSV file for image links and checks the links for 200 or 404. The CSV file contains a sku,image url per line. I believe the code works fine however it appears that it may be returning false positives when dealing with a larger CSV file (Ex: 500k+ rows), how can I improve my code? I am more wo... |
Yesterday, I came up with a simple method to predict the next value in a sequence.
The method works like this:
Start with a sequence, say 1,4,9,16,25,36, call it Δ0.
Now, Δ1 is the difference between every adjacent element in Δ0. (The first element is left unchanged). For our chosen sequence, this is 1,3,5,7,9,11.
In ... |
Moving on to the next steps! Previous review was here. The idea here was to implement suggestions made by @hd/@Pimgd and then implement an effective way of tracking and logging results when an exception is thrown. With that said, my focus is still on security of my application, but now I also really want feedback on th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.