instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
So I started learning how to code about 6 days ago and suddenly realized that I've really only been referencing my book and myself without any outside input. I'm learning python and the most complex thing I've done on my own so far is a simple class that handles 'user' info with a bunch of tests to make sure it works.
... | stackexchange/codereview |
I'm fairly new to real world Java so I tried to rewrite an old app I wrote in vanilla java. I've made this one a lot more OO and used a dependency/build manager (Gradle). Now I just want to see what more experienced devs have to say about the project.
This is the main code snippet that does most of the work. Any com... | stackexchange/codereview |
I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is \$\mathcal{O}(n)\$ but I'm not too sure about that:
Challenge: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn ev... | stackexchange/codereview |
I've made an iteration of the text game Hunt The Wumpus. The specification came from the text Programming Principles and Practice Using C++ by Bjarne Stroustrup.
Implement a version of the game "Hunt the Wumpus". Hunt the Wumpus" (or just "Wump") is a simple (non-graphically) computer game originally invented by Grego... | stackexchange/codereview |
Was trying to implement and example code to smart pointer from link.
Is it a good practice? To go with all unique pointers or should we use shared pointers in this case? How can i improve this ?
#include <iostream>
#include <string>
#include<memory>
void LOG(std::string strText)
{
std::cout << strText << std::endl... | stackexchange/codereview |
Playing around with the google API.
I have written demo applications to use the google gmail API. But what I am actually looking for is a review of the C++ wrappers for Authentication (OAuth2) and an initial GMail wrapper. Want input before I start going any further.
Please take your time to point out all even the slig... | stackexchange/codereview |
An application I've been working on for a while needs a manner to find a missing element from a sorted array, the problem with the application is that these values aren't numeric. They have a formula, but they aren't inherently numbers.
This means that using a basic binary search is out of the question, and it's also n... | stackexchange/codereview |
I have the following first-letter only alphabetical sorting algorithm:
Note: FileManager is just a file I/O class that reads in the unsorted words from a textfile then writes the sorted ones back out).
public class Sorter {
static String list[];
public static void main(String args[]) {
FileManager fm... | stackexchange/codereview |
My goal is to implement a method, which finds a list of Windows Services that match given set of criteria:
SearchString: A search string
SearchServiceBy: Could be ServiceName or DisplayName
SearchOption: Could be Equals, Contains, StartsWith, EndsWith or Regex
SearchServiceType: Could be SingleService or GroupOfServic... | stackexchange/codereview |
I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the efficiency of the Fibonacci generator, but all scrutiny is welcomed.
Here is a link to the entire project, but below are the part... | stackexchange/codereview |
I have a piece of code that takes a couple of integers and check if performing an addition on the inputs would result in an overflow.
I was wondering if this code is SOLID:
public static boolean CanAdd(int me, int... args) {
int total = me;
for (int arg : args) {
if (total >= 0) {
if (java.... | stackexchange/codereview |
From the README.md
Introduction:
The purpose of data-in is to read all the lines from a text file and return the file's contents as a Clojure value in a standardized manner.
Specification:
Takes:
Filename
Assumes:
a space delimited text file
Returns:
Vector [L1,L2,...Ln] where Li:
represents a line in Filename
is... | stackexchange/codereview |
This function updates the user last login date on the user collection. I guess there are too many brackets and much spaghetti. How can I shorten this code?
(function () {
'use strict';
var database = require('mongodb');
var util = require('util');
var constants = require('../constants');
var dbh... | stackexchange/codereview |
I am making an inventory application and I must create a function that allows me to perform different operations with the arrays that I have created, the application consumes data from an api and processes this data to modify some things, I found a way to do it but I don't consider it the most suitable because I have s... | stackexchange/codereview |
I recently found out that a class library I have been building, xofz.Core, could mostly be salvaged and back-ported to .NET Framework 2.0. This enables it to be used to build applications for Windows 98! How cool is that?
Here is a link to the repository: https://github.com/spearson/xofz.Core98
And the class I would ... | stackexchange/codereview |
I wrote this simple program that tests how long it takes for a loop to iterate through a vector<unique_ptr<>>. I'm wondering if this a good way to perform such a speed test? Are there better methods to this?
Also, I can't seem to use myVector.max_size()(which is 1073741823) to allocate the maximum amount of entries for... | stackexchange/codereview |
I wonder if the following 301 redirect is the best way for my situation. I used this post on SO to give me the following 301 redirect:
RewriteRule locations\.php$ compare-biomass.php [R=301]
What we've done is changed a filename from locations.php to compare-biomass.php.
The new URL should be:
www.mydomain.com/compar... | stackexchange/codereview |
I want to change the background color of each section of the page when the user scrolls. The code works but I feel like it's too inefficient
var colors = ['blue','yellow','green','purple','brown'];
var myScope;
var sections = [$('#section1'),$('#section2'),$('#section3'),$('#section4'),$('#section5')];
var sectionTop =... | stackexchange/codereview |
I just watched the video from "Think Like a Programmer, Episode 2: Puzzles & Problems".
The problem is:
Assign number 1-7 to three departments in a city: Fire, Police,
Sanitation.
Requirement:
Each department should have a unique number
Police should be an even number
Fire + Police + Sanitation = 12
Generate a li... | stackexchange/codereview |
I've been studying C on my own using K&R 2nd Edition, and started exploring GTK+ to practice some of the concepts I've learned by making GUI applications. This is the first GUI application I've built, designed in Glade and coded in C.
I've also included my Makefile with compile options and the Glade XML file code gener... | stackexchange/codereview |
How can I refactor this code? I know it's repetitive but I'm not sure how to fix it.
$(function() {
$('#category-1-button a').bind('click', function() {
$(this).css({opacity:'1'});
$('#category-2-button a,#category-3-button a').css({opacity:'0.4'});
$('#blog-headers').css({backgroundPosition... | stackexchange/codereview |
I did a working CRUD abstracted class, and I am not sure that this is a good way for it, so I would like to hear your opinion.
protected function properties(){
$properties = array();
foreach (self::$table_fields as $db_field){
if(property_exists($this, $db_field)){
$properties[$db_field] = $... | stackexchange/codereview |
Before I begin showing code, I have two main questions which I feel could help me.
What is a service or factory, I've heard of them but why use them?
Should I use one shared instance of ILogger throughout my whole application, I only plan on persisting errors and I can get the reporter from the stacktrace.
So,
I deci... | stackexchange/codereview |
I have following ViewController class with a tableView.
final class ListViewController: UIViewController {
let tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.separatorStyle = .none... | stackexchange/codereview |
I've got a rather long function that will take the size of a triangle print it with stars and give the user the option of whether or not they want stars printed inside the triangle, and the orientation (point up or down). I was hoping for some general refactoring methodologies I could apply.
Every permutation is possi... | stackexchange/codereview |
I just started coding a simulation-like application. It's about our solar system. Right now, I'm working on rotating the moon. I have this constructor
function Mass(elm) {
if (typeof elm == "string") {
this.elm = document.getElementById(elm);
} else {
this.elm = elm;
}
this.width = ... | stackexchange/codereview |
My __main__.py file has a function's flow, based on methods of each class instance, which each one has its own methods and attributes, like this:
from xlrd import open_workbook
from pprint import pprint
from rubrica_manager import RubricaManager
... | stackexchange/codereview |
I've got dictionary of lists of tuples. Each tuple has timestamp as first element and values in others. Timestamps could be different for other keys:
dict = {
'p2': [(1355150022, 3.82), (1355150088, 4.24), (1355150154, 3.94), (1355150216, 3.87), (1355150287, 6.66)],
'p1': [(1355150040, 7.9), (13... | stackexchange/codereview |
I'd like to get some feedback/criticism on my attempt to write a simple client/server application that reports back the (client's) global IP address.
It would be nice if you could comment on the UDP socket setup, general security or any other drawbacks you were able to spot. Since this is my first attempt in writing Py... | stackexchange/codereview |
This is a follow up question on this post
This is what I changed on my previous code:
I use Exchanger and PairCurrency class instead of Bank
I renamed addRate and addCommission to setRate and setCommission respectively
Exchanger object contains multiple PairCurrency objects which can be added to Exchanger by addPair... | stackexchange/codereview |
While upgrading our code base to take advantage of new features in .Net 4.5, I'm trying to refactor our take of the classic Producer/Consumer algorithm, but I'm concerned my refactoring is going to increase the CPU usage.
Each instance of my WorkItemConsumer class is basically a System.Threading.Thread that is able to ... | stackexchange/codereview |
I have currently implemented this simple example of a database to output for a REST API to show the way information is being parsed, mapped and serialized starting from database data converting it to JSON. This solution currently works fine, but the problem comes from the fact that it makes use of PHP tricks (like call... | stackexchange/codereview |
I am writing a conditional that checks two values, for several different scenarios.
What I am modifying is a series of objects, some of these objects are in arrays, and some are just arrays. I need to check these values and then check a file, and then check my values (the series of objects, array objects, and arrays) a... | stackexchange/codereview |
Here is some of the code in my library. If there any inefficient things in my code, let me know.
UPDATE: The following code is deprecated. All of your fixes have been incorporated. The project now lives at InitializeSahib/Inverse
InverseAPI.cpp:
// InverseAPI (Cobalt)
// Developed by Sahibdeep Nann (@SahibdeepNann)
// ... | stackexchange/codereview |
I have a GiftCard class where I have method can_deliver? and deliver! that I think can be refactored to better looking code :
def can_deliver?
(self.sent_at.nil? && self.scheduled_at.nil?) || (self.sent_at.nil? && self.scheduled_at && self.scheduled_at < Time.now)
end
def deliver!
return unless self.can_... | stackexchange/codereview |
As a Java programmer, I'm new to the OOP-Approach of JavaScript and it's hard for me to find the best way to write code based on objects. I read a lot MDN and across the web to find a good way to code with JavaScript.
Just to see how can it look like, I realized the following functions: Add two INPUT-Elements to a vide... | stackexchange/codereview |
I wrote this method which I think is not effective as it doesn't respond to the missing method when I use the PORO Class.
BalanceService
class BalanceService
INITIAL_MULTIPLIER = 1
HUMUS_EFFECT = 1.3
instance_methods.each do |m|
undef_method m unless m.to_s =~ /^__|method_missing|respond_to?/
end
def in... | stackexchange/codereview |
I've no idea what to call this, so I called it Classify since that's how I use it.
Basically, the idea is to pass a Dictionary<TResult, Func<TValue, bool>> which is evaluated for an input, and the first Func<TValue, bool> returning true will return the TResult key.
The intention is to make this a generic extension meth... | stackexchange/codereview |
CellStyleCSS class creates css based of Excel Workbook CellStyles. This class is used in conjunction with TagBuilder class, which is, posted here: Creating HTML using a Builder Pattern
My main objective is to simulate a DataGridView and my focus is on generating HTML Tables using this class.
Please let me know if th... | stackexchange/codereview |
Currently, I have been digging up my old codes. One of the applications I worked on was an Image editing phone app that displays a collection of random pictures from a user's picture, which I limited to less than 80 pictures because of performance. These random pictures are chosen from different folders in the pictures... | stackexchange/codereview |
The code retrieves the data from PBI API - it's my first one and I would like to learn how to make it pro.
Here is the list of my questions:
Can you please analyze 2 functions: GetReports and GetReportsUsers in accordance with the best practices? Should a table with metadata be added? Should a function responsible fo... | stackexchange/codereview |
I am studying the book Realm of Racket.
On chapter 5, there is a challenge:
Find an image of a locomotive. Create an animation that runs the locomotive
from just past the left margin to just past the right margin of the screen. Next, modify your program so the locomotive wraps around to the left side of the screen afte... | stackexchange/codereview |
I made a small stack-oriented language in Rust. It tries to run anything it is given. To elaborate: Division by zero gives zero. If there is nothing on the stack and a request is made that involves popping off the stack, instead of just throwing an error, it acts as if 0.0 is always available on the stack. Currently it... | stackexchange/codereview |
I wrote an n-dimensional convolutional neural network from scratch in Julia (check out the GitLab repo or the GitHub repo). It implements the following layer types:
Conv: convolutional layer
Pool: mean pooling, combine neuron clusters
Flatten: flatten output of Conv to vector
Dense: dense/fully connected layer
Even t... | stackexchange/codereview |
I have written Python code that generates a plot. In the code below, when I set maxtime = 0.1, the program takes ~50s and when I set maxtime = 1, it takes ~420s. I need to run it for maxtime = 1000.
I am familiar with Python syntax and writing "Matlabic" code, but am lost in writing natively "Pythonic" code. As a resul... | stackexchange/codereview |
I have implemented a class which encapsulates a thread of execution and provides an interface to send messages to it. It is based largely on an article written by Herb Sutter in 2010. It also uses the pImpl idiom as described by Scott Meyers in Effective Modern C++.
A comment on Stack Overflow from a guy with a high re... | stackexchange/codereview |
I had some issues with the behavior of the iterator in my prime generator:
#include <vector>
#include <set>
#include <iostream>
using namespace std;
int main() {
int a,b;
int nbr;
vector<int> t;
set<int> s;
// prime generated to b
b = 10;
// set 2 -> b.
for (int i = 2; i != b; i++)
... | stackexchange/codereview |
I made a simple password vault in Java and I was wondering if anyone had any input on it. The code works fine, I just wanted to know if there are any improvements that could be made.
import javax.swing.*;
import javax.swing.table.*;
import java.awt.event.*;
public class PasswordVault implements ActionListener
{
s... | stackexchange/codereview |
I'm learning Haskell, and there was quicksort implementation, so I thought that I could implement it in a similar way in JavaScript. The result:
const quicksort = ([x, ...xs], compareFn = (a, b) => a - b) => {
// If x is undefined, the array is empty
if (x === undefined) return [];
const smallerSorted = quickso... | stackexchange/codereview |
I put together this simple query which calculates the total percentage of answered questions and unanswered questions. The formulas used to calculate these are shown below:
$$
\text{Answered Percentage} = 100 - \left(\frac{\text{Unanswered}}{\text{Answered}} \times 100\right) \\
\text{Unanswered Percentage} = \frac{\te... | stackexchange/codereview |
I'm developing a mediator for an MVVM application. This application lets employees file tickets with IT support to ask for help.
The mediator communicates messages and triggers callbacks between ViewModels. Here's a description of it's architecture :
The messages between the ViewModels
The messages are stored in an en... | stackexchange/codereview |
Just a disclaimer this code was one of the last homework submission for my CSCI intro to C++ class and from my guess very rough around the edges. If any of you are bored during the quarantine and want to look at around 450 lines of a novices code, please, by all means, be brutally honest I can take it and I would actua... | stackexchange/codereview |
A quick description on the problem I solved on codewars.com but remember I just want a small part of my solution refactored (just the for-loop):
Description
Vasya wants to climb up a stair of certain amount of steps (Input
parameter 1). There are 2 simple rules that he has to stick to.
Vasya can climb 1 or 2 steps a... | stackexchange/codereview |
I tried to write my own variant class, that is fully move-semantics enabled. WRT to implemented visitors, they don't require any policy and like to be derived from boost::static_visitor or to contain typedefed result_type. The result type of the visitor deduced by means of std::result_of and also can be prvalue, rref,... | stackexchange/codereview |
This code works but is there a simple / better way to do this?
It starts from a particular point (starthere) in the array, looks for first stop value to the left of start point, and the first stop to the right side.
Basically returns the closest values' positions to a start point both sides. (I'll make this a function.... | stackexchange/codereview |
I have a has_many through relationship between my cities and travels that looks like this:
class Travel < ActiveRecord::Base
has_many :cities, through: :destinations
end
class City < ActiveRecord::Base
has_many :travels, through: :destinations
end
And on my Travel controller I have a method to join all its cities ... | stackexchange/codereview |
I sped through the 5hr F# pluralsight course this week-end and thought I'd sement my learning by going through as many Advent of Code puzzles I could with this new learning. However, already on day 2 I'm starting to question whether I'm too biased from C syntax and imperative coding to do it "right".
I really really mi... | stackexchange/codereview |
Here is code I wrote to concatenate data files into master file. Once the data to be pasted into the master sheet exceeds the number of rows left in the master sheet, the program will create a new master document and continue the process. Help me clean it up and make it faster if you can.
Option Explicit
Public NewMast... | stackexchange/codereview |
I want to insert about 10000 new rows into an existing table which already contains 10000 rows. I need to get the insertid for the query and to use that id in another function inside the loop.
foreach($values as $val){
$sql = "INSERT INTO wp_posts (`post_author`, `post_date`, `post_content`, `post_title`, `post_exce... | stackexchange/codereview |
What could be a better implementation, following the Scala way of doing it?
class Node(itemValue: Object, nextItem:Node){
val value = itemValue
val next = nextItem
}
class MyList() {
var start: Node =null
def add(value:Object){
val cache = start
this.start = new Node(value,cache)
}
def print:Unit... | stackexchange/codereview |
This is my code to check if a string C is an interleaving of Strings A and B. Please suggests optimizations, and where I can improve.
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#includ... | stackexchange/codereview |
To learn some PowerShell I made a tool, I've made before in bash. It pings the subnet for arp values and checks if there is no weird behaviour.
function IPv4toBin ($i){
$b = $i -split '\.' | ForEach-Object {[System.Convert]::ToString($_,2).PadLeft(8,'0')}
return $b -join ""
}
function Get-IPs($subnet)
{ ... | stackexchange/codereview |
I would appreciate some feedback on the below code I wrote for a Project Euler problem. The answer comes out correct but I'd like feedback on the design of the function and implementation of docstrings. It seems to me that it may be overly complicated but I'm not sure how to simplify.
"""
Number letter counts
Problem... | stackexchange/codereview |
I was tasked to write process that initially seemed like a straight forward thing. "Fetch data from database, create a cache object, and assign this data to it. Use existing class to model this after." That's it in a nutshell. The 'existing' class did not do any caching, just an async call across layers to the database... | stackexchange/codereview |
I've been a fan of coroutines and asynchronous programming for a while, and I recently took a trip down memory lane to when I was using Python's tkinter module for a GUI. I wanted to combine the two worlds, one of smooth coroutines and one of callbacks.
My hope is to find a better solution for the basic event loop, imp... | stackexchange/codereview |
From "The C Programming Language" (K&R):
Exercise 1-13. Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging.
I wrote a program to generate a vertically-oriented histogram. It doesn't accurately... | stackexchange/codereview |
I have the following code which I am running through fortify. Why it gets marked for poor error handling, throw inside finally?
private String getResourceContent(String fileName) throws IOException {
try (InputStream resource = ErrorResource.classLoader.getResourceAsStream(fileName)) {
return new String(r... | stackexchange/codereview |
I'm new to Python and I came to the following excercise:
Write a function named printTable() that takes a list of lists of
strings and displays it in a well-organized table with each column
right-justified. Assume that all the inner lists will contain the same
number of strings. For example, the value could look... | stackexchange/codereview |
Which is best?
I have a bunch of components in my projects. It's related to Ashley (a java entity system) to libgdx (a game engine).
this components are like that:
public class SpriteComponent extends Component {
private Sprite sprite;
private SpriteComponent(Sprite sprite) {
this.sprite = sprite;
... | stackexchange/codereview |
I'm new to Haskell, the part of my code I'm concerned with is the isSumAbundant function. Surely there must be a better way, in an imperative language I might use a for loop and break out of the loop if i got greater than n, but it seems like having to filter the list for every single function call is not optimal.
The ... | stackexchange/codereview |
I made a python analog clock program with turtle. The problem is, it takes about 1.4 seconds to loop, so it only moves the second hand every 1.4 seconds. Its probably cuz my computer is slow...
from turtle import *
import time
from datetime import datetime
screen = Screen()
screen.title("Clock")
screen.setup(425, 425)... | stackexchange/codereview |
Please can you suggest a better / Optimized logic or code for the question. It has been asked that when you find a zero value in a matrix, make that element the sum of its upper, lower ,left, right value and make the upper, lower ,left, right elements zero. I assume to the matrix provided has at least 2 rows and 2 colu... | stackexchange/codereview |
I'm creating a small simple scripting language for fun and as a learning exercise. For the first iteration I want it to be very simple:
C-style syntax
Functions are defined globally as in C, no passing functions around (yet)
The interpreter calls the "main" function (if it finds one)
String and number datatypes, no o... | stackexchange/codereview |
Source: careercup.com
You are given an array of integers(with all valid input) You have to
write a function which will produce another array, where the value in
each index of the array will be the product of all values in the given
array exccept that index.
Example
Array 1: 1 2 3 4 5
Array 2: 120 60 40 30 24
Co... | stackexchange/codereview |
I've made my first-ever program in Go, which sorts a given input of integers. There are 2 options: The list of unsorted integers and the algorithm to use.
Since it's my first go project I'm a bit unsure of a few things. For example, the "floating" variable declarations.
I think that the algorithms itself are okay, th... | stackexchange/codereview |
Over the weekend I built a fairly simple allocator:
struct FreeOnes { //data structure holding the pointers to free blocks
int len;
void** array;
int capacity;
};
void append(struct FreeOnes* f, void* what){ //add a free block to FreeOnes
if (f->len < f->capacity){
f->array[f->len++] = what;
... | stackexchange/codereview |
This code gives me info of a movie and the movies directed/acted by corresponding director and actors. It is working as the way I expected but I included lots of try and except statements and as a result my code is slow. Is there anyway to speed this up?
from imdb import IMDb
def rating(name):
p1 = ia.get_movie(i... | stackexchange/codereview |
The code below has many Lists<> but I'm not sure how to modify it. The only thing here that is an algorithm is the Fisher Yates shuffle algorithm. I am trying to put in good use an algorithm or just code better said to do this. It seems a bunch of code just used in repetition.
My question is, is there a way to make thi... | stackexchange/codereview |
Update
I've posted a follow up question to this code. Find it here:
Not a very interesting implementation of a Simple Substitution Cipher in Python.
I implemented a second encryption algorithm: the well known caesar-cipher. This turned out to be longer than I expected. The "main" code is very concise, but the interfac... | stackexchange/codereview |
How can I improve the following working SQL statement for better performance and consistency?
SELECT if(roll is null,0,roll) as roll,
if(cpapername is null,0,cpapername) as compulsory,
if(corepapername is null,0,corepapername) as Core,
if(e1papername is null,0,e1papername) as Elective1,
if... | stackexchange/codereview |
Say you have two strings: exp->aaccbb comp-> aa2bb
This example will return true as there are 2 chars between aa and bb. I have written this code snippet and am wondering if there is a better way do solve this problem and if I am missing any edge cases.
Also, what would be the fastest way to solve this problem with res... | stackexchange/codereview |
I'm new to programming. I wrote this following weather app in python. This app can provide simple weather forecast for three days. If the user provides the location in the correct format then it should be able to give weather information. I hope someone could point me if there is any mistake in the code or make it bett... | stackexchange/codereview |
I need to calculate the calendar week of a given date. Constraints:
It should be properly calculated based on ISO 8601 if week starts on
Monday
It should calculate based on US standards if the week starts on
Sunday
It should be compact and fast, as the routine gets called very often
It should work even if the year sta... | stackexchange/codereview |
I want to check if a string contains only a single occurrence of the given substring (so the result of containsOnce("foo-and-boo", "oo") should be false). In Java, a simple and straightforward implementation would be either
boolean containsOnce(final String s, final CharSequence substring) {
final String substring0... | stackexchange/codereview |
In the last few day, I wanted to sharpen my C skills a bit, so I wrote a math expression interpreter that can handle + - * / ( ) and only integers.
I just want to know how good this code is, if anyone has any comments on any part of the code and if writing such code guarantees that I understand every aspect of the C la... | stackexchange/codereview |
I've built an image/content slider using JavaScript and as I've added to it and built in new functionality I've found myself writing several if statements in order to achieve the required response.
I'm now going over it again and I want to refactor it to make it shorter (if possible) and to increase performance (again ... | stackexchange/codereview |
So I've started getting familiar with Batch for the last year off and on, all self taught, and I've made a few little dinky projects here and there but I'm wanting to find out the best way to go about expanding my code. Using other programs for inspiration I've learned just the tip of the icebergs for "FOR loops" and u... | stackexchange/codereview |
Here is the script:
function opening(){
setTimeout(function () {
var opening = $('#stage');
opening.find('h1').fadeIn('slow', function(){
setTimeout(function () {
opening.find('.logo').fadeIn('slow', function(){
setTimeout(function () {
... | stackexchange/codereview |
I am working on a product-related app where the data model for a product attribute feels too heavy. But I can't split it into several small data models because they are all about goods.
At present, my approach is to parse network data directly into a data model. The properties of the data model are readwrite. For exam... | stackexchange/codereview |
Given a map of items to their attributes:
OPTIONS = {
paper: %w[A4_paper countable universal],
pencil: %w[trackable universal trackable],
chalk: %w[stationery countable trackable A4_paper],
}.freeze
I need to return the items that have a particular attribute. For example, fetch_type_values('... | stackexchange/codereview |
I need my string-to-int converter to handle all exceptions without throwing any errors. I also have a use case where I need the default value to be less than zero if the TryParse is false.
Is there a built-in way of doing this?
Should I make any changes to the method?
public int ToInt32OrDefault(string value, int d... | stackexchange/codereview |
Part of my job is to maintain an old application written in Silverlight talking to a WCF service which in turn fetch/persist data into a SQL Server database and in a BI cube.
Most of the security is specified at database level using database roles, users are authenticated using Windows Authentication (integrated secur... | stackexchange/codereview |
This is a much more basic implementation of Regular Expressions (Python docs). Do note that core functionality is missing and the functions aren't completely fool-proof, but it does a good job of matching basic patterns. Also, filtering 'symmetric' patterns (like quotation marks "" or markdown bold **) is not possible.... | stackexchange/codereview |
This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template Function with Execution Policy. Based on the previous questions, I am trying to consider execution policy parameter for recursive_transform function here.
The exp... | stackexchange/codereview |
Re - designing c-style input output [ btw I use printf() and scanf() in the core ]
Reasons for redesigning it :-
Needs 2 functions for input output [ namely printf() and scanf() ]
Can't customize the format specifiers
Can't print float/double point precisely / dynamically [ i.e printing 3.5 makes 3.500000 from printf(... | stackexchange/codereview |
Sum of Pairs
Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum.
sum_pairs([11, 3, 7, 5], 10)
# ^--^ 3 + 7 = 10
== [3, 7]
sum_pairs([4, 3, 2, 3, 4], 6)
# ^-----^ ... | stackexchange/codereview |
I want to make a Ruby nested hash table class to avoid repeating ugly code and to keep my programs as true to the OOP paradigm as I can. Are there any ways to make this class definition smaller and/or simpler?
To clarify, the class essentially creates an arbitrarily-deep hash table. For example, if you had a NestedHa... | stackexchange/codereview |
I am new to Python and I am writing my first utility as a way to learn about strings, files, etc. I am writing a simple utility using string replacement to batch output HTML files. The program takes as inputs a CSV file and an HTML template file and will output an HTML file for each data row in the CSV file.
CSV Inp... | stackexchange/codereview |
I have the following two methods that write to file various data line by line. Both methods differ from each other only by few lines what would be the best way to refactor them that when in future I want to add another method (for example, CreateXYZLegacyInFile) it would be least time consuming.
public string CreateCVT... | stackexchange/codereview |
My goal is to create a URL query params from std::map<std::string, std::string>. For example, we call to_query_params( {{"one","1"},{"two","2"}} ) and we get ?one=1&two=2.
Is this a good way of doing it?
std::string to_query_params(std::map<std::string, std::string> map)
{
if (map.empty()){
return "";
}... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.