instruction stringlengths 71 71.9k |
|---|
I am extremely new at scheme and I am doing this problem from here:
Write a procedure switch that takes a sentence as its argument and
returns a sentence in which every instance of the words I or me is
replaced by you, while every instance of you is replaced by me except
at the beginning of the sentence, where ... |
I recently ran into some issues with a plugin and outlined the issue in this post and wanted to know if the modifications I've made below cover the scenarios that the with scope blocks would have covered.
I've modified some code to remove the with operator and I'm wondering if I've replicated everything properly in doi... |
I am writing a database manager that reads and writes to a local SQLite database on a mobile device. It works pretty well for the most part, but read access is somewhat slow - it takes about 2-5 seconds to load 250 to 500 records. I've already gone and made some improvements where I can, but I'm hoping that there is mo... |
I have an async method which calls my Task class while my Task class does all the work:
private ExecutorService executor = Executors.newFixedThreadPool(10);
@Override
public Future<DataResponse> executeAsync(DataKey key) {
Future<DataResponse> future = null;
try {
Task task = n... |
This code reads a .cs source file in the \bin folder and parses the C# code in it. The program outputs keywords, identifiers, separators and numerical constants.
How could it be improved?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tema3... |
I've written this code that connects to a .xml file at a given url, parses it and outputs the values of some specific elements to the console.
I want to write reusable and appropriate code accordingly to OOP standards, but I'm not sure where to start. How to improve this code?
public class XmlControl {
public s... |
Algorithm to find pair with max sum from two arrays
A[0 ... n] and B[0 ... n]
A[i] + B[j] = max (A[i] + B[j], with i < j)
i,j < 99999; n < 99999
My best result is this:
int[] testArrayA = { 7, 1, 4, 5, 1};
int[] testArrayB = { 3, 2, 1, 5, 3};
String res = "";
int maxSum = 0;
for (int i = 0; i < testArrayA.length; i++... |
As many people will undoubtedly recognise, this is a question in a well known series of problems that I won't name ;)
It's been a long time since I've written any F# and I'm not sure I've ever come across any canonical style guidelines so I'd like feedback on all aspects of the code.
let largestPrimeFactor (number:int6... |
All the calculator programs I have seen so far seem long, complicated and they can only operate on two numbers. I am trying to write one that is simple, short, and it can operate on as many numbers as you want. After implementing suggestions from my previous question regarding use of operator.XXX and functools.reduce I... |
As a part of my (future) MVVM framework, I need to be able to detect changes on an object. To do this, I used the RealProxy, a C# object that implements Aspect Oriented Programming to "intercept" calls to an object's method.
In my scenario, I'll use the proxy to intercept calls to a _target's setter to launch an event,... |
I have a function for parsing data, that goes to the database, (it's more validation, the sanitization process is taken care of by the framework). Here's my handmade script, based on a jQuery library, forgot its name. The comments are in Spanish.
/**
* Procesar Información.
*
* Compara la información proporcionada con ... |
This method should check whether a number is a palindrome or not:
typedef enum { false, true } Bool;
Bool is_pal(int n) {
Bool is_pal_helper(const char *arr, size_t size);
char temp[12]; // INT_MIN == '-' + 10 digits (+ null-Terminator)
sprintf(temp, "%d", n);
return is_pal_helper(temp... |
I'm working on a new prototype that is a simple drag and shoot arcade basketball game. For this project I am working with LibGDX and the Box2d physics library.
You can play the game here: Play arcade basketball!
This here is the custom collision listener for the game. One quirk that I have not been able to resolve is... |
I find it pretty annoying that c++11 atomics can't be copied. The reasons for this have been discussed e.g. here and I don't want to argue about them now. However, I find myself repeatedly in situations, where I want to copy data structures around that contain atomics. Usually BEFORE they are actually used in a multith... |
I have a class in my application which manages storage of OAuth2 tokens. There are unauthenticated tokens (in my code, called "application access tokens") which can be used for API calls that do not require a user account, but when a user signs into the app, I receive an authentication code from which I retrieve an aut... |
Isn't it annoying when you can't find a file you recently created? Especially when you either have a very disorganized drive or a directory with lots of files.
Even if you don't care, isn't it nice to have a program be able to locate a file for you?
I did this because I have files that I can't seem to locate, but I kno... |
Is this an effective way for merging two lists? It seemed too long.
struct Node {
int item;
Node *next;
};
Method:
Node* mergeTwo(Node* headA, Node* headB)
{
Node* currentA = headA;
Node* currentB = headB;
Node* headC = NULL;
Node* currentC = NULL;
while (currentA != NULL && currentB != NULL)
{
if (curre... |
My goal is to continually update an object and record any changes and the times they were made at. The input has to be JSON but the output/storage format doesn't.
This function will check a JSON object/dictionary against a reference object and return a list containing the updated object and another object containing ju... |
In my ASP.NET form I have a file upload control where I am letting users upload image files, converting it into base64String to store it in the database.
I am using following code to do so,
if (FileUploadControl.HasFile)
{
var img = new Bitmap(FileUploadControl.FileContent);
... |
Two days ago I started reading about SignalR and today I started writing a simple application. I have written the code below so far, but I was wondering if you have some tips to improve my code.
Program
Desktop client will automatically create a random group (random) and displays the random generated code to the user.... |
I'm learning the mvc pattern and today I finished my first mvc routing class.
Hope you can give me some tipps and improvements.
Router.php
<?php
namespace System\Libraries;
class Router
{
/**
* Store the given parameters
*
* @var array
*/
private $_param = [];
/**
* Default actio... |
I have function that builds different types of boxes.
namespace TestSome.ViewModel
{
public class OneBoxViewModel : ViewModelBase
{
private ObservableCollection<BaseBox> boxes;
public ObservableCollection<BaseBox> Boxes
{
get
{
return this.boxe... |
I put together a jQuery plugin that displays a month of dates using underscore templates. When the template has been populated and displayed in the UI, a user can click on a date which sends a request to the api(with the selected date parameter) to give a list of available deals on that date. I then display these deals... |
We are always told to call GPIO.cleanup() before we exit our Pi programs. I've seen people using try ... catch ... finally to achieve this. But hey, we are doing python here, an elegant programming language. Do you guys think this is a more elegant solution?
# SafeGPIO.py
from RPi import GPIO
class SafeGPIO(object):
... |
As part of a larger project I wanted to write my own size once RAII C array wrapper. Now I could have just used std::vector, which I'm sure is the first thing almost everyone will want to point out. However, I'm doing this for learning purposes. Aside from wanting to learn more, Simple_Array is not exactly designed to ... |
I love the badger's song (YouTube), so I wrote a FizzBuzz about it.
The thing is, I've been writing Javascript for years but I'm still not sure about the best practices. So FizzBuzz seemed a simple trial for me to write some code and make it reviewed!
function FizzBuzz(limit){
var _limit = limit;
var fizzBuzzC... |
I am using Selenium Webdriver via Java. My method clicks on a filter check box (eg. make, model, etc.), that is passed in, from a modal.
When running my method in my test class, via ChromeDriver, it seems to go pretty slow and rightfully so since I am making a lot of tiny network calls for getText(). How can I optimize... |
After searching around and reading through articles and answers I came up with this implementation for extending the cookie for Forms Authentication. I am not sure that I did not introduce any vulnerabilities and now I provide it here for review.
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
... |
I am new to programming. I have written a solution in two different ways, but would like to know what is considered a better solution, and why.
Additionally, in terms of performance, why would one be considered better?
Solution 1:
function titleCase(str) {
str = str.toLowerCase();
str = str.split("");
str[0] = s... |
Still hooked on Windows, I refactored the hook into a number of interfaces, and I wanted to support 2-step hotkeys, so I started with defining an IHook that can be attached, detached, exposes a property that tells whether a hook is attached or not, and raises an event when the hook receives a message:
public interface ... |
I'm a novice to Scala and Akka-Http and am experimenting with Akka-Http for writing rest services. I have to return JSON or protobuf based on the Accept-Header.
optionalHeaderValueByName("Accept"){ contentType =>
if(contentType == Some(protoEncode)) {
complete {
NewsService.getNewsList().map {
case ... |
For my first Python project, I decided to create a script that would automatically collate MP3 files into a music countdown. I wanted to 'learn by doing', so I dived straight in and used the Python docs and Stack Overflow as my primary learning resource.
The idea is as follows:
Python script resides in base directory.... |
I have this method which returns the number, but Rubocop said:
Assignment Branch Condition size for rating is too high. [15.84/15]
def rating
response = response_quality
if response == 1 && @typos.zero?
5
elsif response == 2 && @typos.zero?
4
elsif response == 3 && @typos.zero?
3... |
I'd like some feedback on the readability, style, and potential problems or issues.
foursquare.py
import time
from api_keys import CLIENT_ID
from api_keys import CLIENT_SECRET
from api_keys import CATEGORY_ID
from business import Business
from business import make_request
def search(lat, lng, distance):
"""
... |
I was thinking of building a really flexible fluent API for my persistence layer. One of my goals is to achieve somehow the following result:
IEnumerable<User> users = _userRepo.Use(users => users.Create(new User("MattDamon"),
new User("GeorgeClooney"),
... |
My code returns the correct answer for the example (highest prime of 13195 is 29), but when I test against the number in the question my code basically is too slow for my liking.
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?
Is there anything obviously w... |
I've created a program for work that checks the status of all our servers quickly. What we use to have to do is ssh into each server manually.
I'm looking for some critique on what I've created here. Any input on it would be greatly appreciated, such as better syntax I can use, better variables, easier ways to perform ... |
I've been tinkering around with making a fancy clock on a Raspberry Pi B. This little application will sync the Pi's time with an NTP server, then display it using toilet so it's nice n' big & centered on a monitor. This was made for a GUI-less Pi, and I'm looking to hopefully make it more efficient. Right now the seco... |
I have this web site I inherited as part of my job and it has some old code. I'd like to optimize it, but I don't really have the time to do it right, so I'm looking for some "low hanging fruit" to optimize. Basically I want minimal change with the greatest performance improvement.
One of the things I've come across i... |
I'm trying to write a function that produces an infinite list containing strings of the form \$a^nb^nc^n\$.
My first idea was to do it using comprehensions.
f = [replicate n 'a' ++ replicate n 'b' ++ replicate n 'c' | n <-[0..]]
But this does a lot of duplicate work. I then decided it would be better to do the followin... |
I have a function that returns rows from my database, and it works fine, but I was told that it was poorly written, and there is a lot of unnecessary code in it. I'm wondering if there is a simpler, easier way to rewrite this function.
function gd($query) {
global $connect;
$fetch = mysqli_query($connect, $que... |
My algorithm for finding an Euler tour of a digraph, G⃗, if such a tour exists, starting from some vertex, v.
'use strict';
var graph = {
1: [{val: 2}],
2: [{val: 3}],
3: [{val: 5}, {val: 4}],
4: [{val: 1}],
5: [{val: 6}],
6: [{val: 3}]
};
var EulerCyle = (function(G, source) {
var Cycle... |
I'm working to make a thread that monitors a web API to get the latest announcement via JSON. I cannot test this currently, so I'm unsure if anything needs to be changed with this. I've read through other questions but everyone else doesn't seem to be using a loop to keep getting a response.
public void run(){
try ... |
As an attempt to learn multithreading better, I wrote a program to crack the password of a ZIP file. It is sort of slow, processing a three-digit password of the 95 printable ASCII characters in about 1:45 minutes. This is my class that actually handles the cracking:
class DecryptPassword
{
private readonly List<... |
I've been just getting started with Agda. I tried to prove, as exercise, evenness.
even : ℕ → Bool
even 0 = true
even 1 = false
even (suc (suc x)) = even x
x : even 12 ≡ true
x = refl
But asserting truth using _≡_ seems like a really bad way. What would be the best way of doing the same thing?... |
I have this project about using OOP in python. How to fully make use of OOP and use __init__(self)?
class Parent:
name = "Player"
lives = 3
#display player running
def run(self, name):
self.name = name
print "%s is running." %self.name
#player will start to jump against enemy
de... |
Background
I am working on a WebGIS application using JavaScript and ArcGIS JS API. I am new with js, so please bear with me.
While learning and developing with js, I am trying to follow some rules, such as Asynchronous Module Definition (which ArcGIS JS API encourages), Revealing Module Pattern, and the Standard Style... |
On my quest to learn Ruby I figured exploring the proper usage of different data-structures would be invaluable, including strings, arrays and hashes.
I decided to build a hash containing the numbers 1 till 100 inclusive. These hashes would contain:
Whether the number is prime
What it's FizzBuzz output would be
The n-... |
I'm tutor for a university operating systems course, and part of my work is creating exercises for them. Those exercises are mostly about concurrency and synchronization issues. For the next exercise I intend to show them the finished implementation of an unfair counting semaphore, and their job is to make a fair one. ... |
I have a working useless todo app created with ReactJS.
I'm just wondering if my code can be improved.
This app can add a todo item and it can display editable list of todo items.
This is my ReactJS code.
var TodoApp = React.createClass({
getInitialState: function() {
return {items: []};
},
addItem:... |
I've been looking at some code done in C# ASP .NET WebForms and for some reason I really don't like the below code. What is the best alternative for creating a document and downloading it in Webforms, on the click of a button? Should the developer be messing with the Response at all, in this way?
Response.ClearContent(... |
I recently had the need to detect how long a button is pressed and perform different actions based on that. I found some examples on Stack Overflow, but the ones I looked at showed how to use timeout().
I came up with this. There are probably other ways to solve this. While searching, I found an example using IIFE in J... |
I got tired of starting timer every time I need to do something simple as running some function 5 seconds after something in my code happens. So I tried to write a function (actually, 3 of them: setTimeout, setInterval and clearInterval) to write one line of code when I need it instead of, say, five.
It is working, at ... |
I've written a jQuery Plugin which searches text and replaces it with other text or HTML.
Now everything works quite well, but recently I came across this SO question where the OP could have use of my plugin. That's why I linked to the GitHub repo and asked him for critiques and/or contribution.
Soon after, he said tha... |
(See also the Algorithms part.)
Post details
The program I am putting for being reviewed does not fit entirely in a single post, so I have to resort to the equation by Niklaus Wirth:
Algorithms + Data Structures = Programs
This part is about data structures: a set of classes that do not do anything fancy. Of course, ... |
Yesterday, I've come up with the idea of using python context manager to ensure cleanup available here. This time I am using that context manager to make a decorator.
The context manager
# SafeGPIO.py
# updated, warning silenced
from RPi import GPIO
from exceptions import RuntimeWarning
import warnings
class SafeGP... |
Update: Version 3 is here.
My first version was an answer I provided to EBrown for his original post titled "Multithreaded Mandelbrot Generator". My answer had many good things in it, but I felt some of parts of the code were weak, particular around my efforts to apply some flexible scaling rather than using a constan... |
Note
This post is a continuation of Discrete event simulation of a prioritized lunch queue in Java (Data structures). Please refer to it for problem description.
This part about "algorithms": all classes that are more about doing rather than representing information.
PrioritizedQueue.java:
package net.coderodde.simula... |
I made a library that adds undo/redo functionality to EditText widgets in Android. It came from problem I had building text-editing apps that deal with large (1,000words plus) volumes of text, and the performance problems I came across using some pre-existing solutions. Calling setText() with large amounts of text on s... |
I have a list of boxes and need to list only the outdated ones.
For example, input will look something like this:
maier/alpine-3.1.3-x86_64 (virtualbox, 1.2.0)
maier/alpine-3.1.3-x86_64 (virtualbox, 1.3.0)
ubuntu/precise64 (virtualbox, 20151202.0.0)
ubuntu/vivid64 (virtualbox, 20150821.0.0)
ubuntu/... |
Inspired by this answer and previous a commentator of code review use:
Given a complex Perl data structure, traverse/jigger/modify as follows:
If ORACLE_SID is 'key' in any hash then keep only ORACLE_SID section matching of $ENV{ORACLE_SID}
Eliminate any single level arrays, if after step 1, we're left with s_level ar... |
A while back I asked a question about my Simon Says game and did well on my assignment! But now we need to go back in a make some modifications to the game to be more advanced. I've done that as well, but I need some tips to make it more pristine and little cleaner, some things I'm still working on, but any help here w... |
I have implemented a simple client-server solution using Java sockets and useful classes from java.util.concurrent.
The communication protocol is rather simple:
Client sends a string with the appended request_info#.
A server responds to a client with the message that provides a description on how to use a server.
If... |
This is a program I wrote to grab restaurants/bars from Google, Yelp, and Foursquare. It then ranks them more effectively based on the rating, the number of ratings, and the number of data sources using a Bayesian average. My guess is that the main method could be broken into more functions. I'm also guessing I'm missi... |
In my OpenCL kernel, I have the following logic:
size_t id = get_global_id(0);
uchar index0 = (id / 32760) % 16;
uchar index1 = (id / 2184) % 15;
uchar index2 = (id / 156) % 14;
uchar index3 = (id / 12) % 13;
uchar index4 = (id / 1) % 12;
if (index1 >= index0)
++index1;
if(index2 >= index0 ||
index2 >= in... |
I have four fields a, b, c, and d. All of them must be populated if any of them have a value.
So what I want to do is validate that they are all populated, if any of them have a value. I'm trying to determine the best way to do this. I think I could do this:
class User < ActiveRecord::Base
validates_presence_o... |
I have this great C program I'd like to embed into an iOS app. One passes command line arguments to it and the results are printed to stdout via printf and fputs - like with all the good old Unix programs.
Now I'd like to just edit main and the print functions to use my own printf function which collects all the output... |
Rock Paper and Scissors is a pretty basic program.
The reason I wrote this program is because I wanted to see what a small script that used all of the main programming paradigms looked like.
My code contains:
OOP: A Player object.
FP: First class functions : player.intelligence is a function is stored in a variables a... |
I use the following script to download the result of a SEDE query and scrape a specific column from it using BeautifulSoup:
import json
def extract_column(soup, colname):
"""
Returns a generator of cell values in selected column.
For simple columns like timestamp, a cell value can be simple,
for exam... |
I had to recently implement a code to count the union of all intervals (if there are overlapping intervals) for an interview. I was provided with the following function stub:
public int solution(int[] A, int[] B) {
}
A[0] and B[0] form one interval, A[1] and B[1] the next one...and so on.
I tried two approaches.
Co... |
Recently I was asked to implement a stack specifically for storing 'int' type data and find memory leaks. Isn't the garbage collector responsible for releasing all the memory? What are the possible memory leaks and how do I handle them?
import java.util.NoSuchElementException;
public class MyStack {
private int st... |
Given a String, if the String begins with "red" or "blue" return that color String, otherwise return the empty String
public String seeColor(String str) {
if(str.length() <= 3){
if(str.equals("red")){
return "red";
}
return "";
}
else if(str.substring(0, 3).equals("red")){
return "red";
}
... |
How can I change my two functions to be more readable functions (i.e. in steps), because I am using pycharm.
import collections
def compute_word_importance(fpath1,fpath2):
mylist1 = []
mylist2 = []
with open(fpath1, 'rt', encoding='UTF-8') as f:
for line1 in f:
for word in line1.split(... |
I'm using node-ftp to download some files from an FTP server; due to nodeback difficulty and nested calls I'm promisified some of the calls, hoping that this will help get me out of pyramid code hell, but I think I'm still mis-applying something.
Before I get to my code pasted below, conceptually the pseudo-code of wha... |
I have a method which will merger two sorted list together. The function works, but I saw some duplicated code.
Any ideas to make the code more elegant?
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
def MergeLists(headA, headB):
head = ... |
I need to be able to store results of a game in a file with names and high scores where I will eventually want to review the file and sort it alphabetically, etc. I'm unsure if I have the correct way of storing the results to be able to do this.
class_number = input('Please enter your class number: ')
from datetime i... |
I wrote a Cordova plugin for an app that I'm working on, and now I'm trying to write an Angular definition to wrap my plugin. So far, I've followed the model in ng-cordova.js:
angular.module('ngCordova.plugins.audioPlugin', [])
.factory('$audioPlugin', ['$q', function($q) {
return {
init: function(session... |
If you came here because of the title, chances are your server isn't down. But if by some miraculous reason it is:
A while ago, I posted a program that would ssh and ping all the servers at work. I got some very good feedback and went ahead and rolled with it.
Here's what I came up with:
It now is much more readable, ... |
The idea of the game is that the player and the computer take turns entering either 1, 2, or 3, and that number is added to a running total. Whoever goes over 21 loses. I need to develop a strategy that lets the computer always win.
I have a strategy worked out, but I was wondering if there is a more efficient way to d... |
I am wondering if this is a safe and/or sensible way of going about doing the following task:
My problem is that I have a folder with loads of directories with names of form YYYY-MM-DD. They are from my camera. Each directory contains picture files. The problem is that the picture files are designated by just 4 digits ... |
It is a simple program which allows you to input a username an password. If the username/password is equal to the String it launches a JOptionPane that says "Correct". If it doesn't it launches a JOptionPane that says "Incorrect".
import java.awt.event.*;
import javax.swing.*;
public class Main {
//The Strin... |
This is an adaption of a single player Battleship game. I made it two player, and I also tried to implement OOP and DRY principles. I would like my code to be reviewed for OOP, DRY, PEP8, and overall best practices. I am new to development (about 1 month strong), so any constructive feedback would be greatly appreciate... |
I'm trying to improve my understanding of inheritance and template classes in C++ so I coded a hash table (see compilable source code below).
I would be greatly appreciative of any comments on how to improve this code.
Description: The LinkedList template class inherits from the template class Stack. The Stack class co... |
When I finished this problem, I thought about how I initialized my loop iterator variables i and j. Originally I had i = 0 and j = 0, but then I had to initialize count to 1, instead of 0. And that just seemed a bit odd to me. A similar conundrum came to me when I was incrementing/decrementing count, and deciding if I ... |
I am working on Problem 2.30 from Structure and Interpretation of Computer Programs. I book is in scheme, but I am doing the exercises in Clojure.
The problem is to write code that takes a tree of numbers and return a new tree with the numbers squared. I have done it in two ways:
Without higher-order functions:
(defn ... |
How can I refactor these switch cases?
void selectOption(Shape** shapes, int size, int selection) {
int obj1;
int obj2;
bool init2 = false;
bool init = false;
int option = 0;
do {
cout << "\n (1) Rectangle #1"
<< "\n (2) Rectangle #2"
<< "\n (3) Circle #1"
... |
I'd say currently my understanding of C# is within the range of (1Beginner-10Intermediate) a solid 4-5. Thus I am seeking to broaden my understanding of C#; I've started coding an IRC bot to improve. This is the code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
... |
My problem is this: Given two strings, append them together and return the result. However, if the strings are different lengths, omit chars from the longer String so it is the same length as the shorter String. So "Hello" and "Hi" yield "loHi". The strings may be any length.
Is there a way to do it without using of S... |
I will first explain the context. I want to read serie subtitles contained in .srt files. I have already done the part of extracting the words from the files (and how many times the word appears for a serie) but when it comes to inserting the data in my SQL Server database, it takes more and more time to do the updates... |
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... |
Does someone want to review my solution to part 1 of Day 7 Advent of Code in Scala?
The assignment is here: http://adventofcode.com/day/7
Without repeating the whole text, in short:
Given a text file of the following form (simplified):
x AND y -> a
x -> 1
y -> 0
calculate the value of a. Here is an example of a full i... |
I've written a program that encrypts files (or stdin) with a user-specified key from 1 to 255. This "encryption" is very insecure, but still a bit better than ROT13 (at least for people trying to crack it using pencils and paper). How can I improve this program?
#include <stdio.h>
#include <stdlib.h>
#include <string.h... |
I have wrote some service in AngularJS that use defer, can you check my code and tell me if I getting it right?
Service (I dont really like name: WatchableTeaser, have you got another?):
.factory('Teaser', function ($resource, DateUtils) {
return $resource('api/teasers/:id', {}, {
'query': {method: 'GET', i... |
I have recently written a jQuery plugin called Pageee.
Pageee is a jQuery plugin to scroll through full pages automatically, by arrow buttons, or by dragging the page.
I have now come to Code Review to ask you if you have any suggestions to the code appearance (readability), the browser support (should only support ... |
I have working code with original design, and now I had a slight design change so trying to code review that as well. I already had code review on my original design here.
Original Design:
I am using RestTemplate as my HttpClient to execute a URL and then my server will return a JSON string as the response. The custome... |
I have made a mental Maths game but it seems quite long, is there anyway in which I can simplify it? And can you also help me with my other Maths game, Ten quick questions ?
correctq=0
actualanswer = 0
print("Welcome to Mental Maths")
print("If you chose Division rpund down to the nearest whole number")
mode = input("(... |
Like my previous question about my Mental Maths game , I have written a script for a ten questions Maths game and again it seems like there is a more simple method, can anyone take me out of the dark on this one?
def tenquestions():
mode=input("(E)asy, (M)edium, (H)ard")
questions=0
rightqs=0
while ques... |
This code takes the position of your mouse cursor, and it creates circles where the cursor is.
strokeWeight(3);
stroke(24, 0, 0);
fill(245, 0, 0);
background(255, 255, 255);
draw = function() {
ellipse(mouseX, mouseY, 30, 30)
};
I would like to know:
If there is a way to shorten this code, but sti... |
I'm trying to check in my meteor app for a defined timeout (idle user) to show a modal. But the way I did it seems a bit too complicated to me.
I'm doing a setInterval for 1 minute. Then a counter - which is stored in a Session var (maybe a local reactive var would be smarter?) - will be incremented by one. If there is... |
I have this monstrosity
@nation_biopsy =
User.all.where(country: @nation).group_by{ |u| [u.institute_type, u.biopsy] }
.map{ |i, o| ["name" => i[0], "y" => User.where(id: o.map(&:id))
.sum("biopsy")]}.flatten.to_json
What it is doing is finding all the users in my database that belong to a cou... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.