instruction stringlengths 71 71.9k |
|---|
This is just a simple function to convert seconds to days, hours, minutes and seconds for a larger app I'm going to be building. I'm just looking for thoughts on it.
import math
def convert_seconds(x):
# Day's
days = x / 86400
fraction, whole = math.modf(days)
days = int(whole)
# Hours
hours... |
I wrote a function that adds items in a list, but my professor says to try and write it in a simpler way because he says I take too many steps. Is there any other way to write this?
def additems(self, item):
"""Add <item> to this PriorityQueue.
@type self: PriorityQueue
@type item: object
@rtype: None
... |
This is a very basic text-based operating system I've been working on. I started working with python a few weeks ago and this project only a few days ago, so there are probably better ways I can do things, but I was wondering what people think of it.
NOTE: I know that the edit function doesn't work.
import os
def user... |
So I'm writing a program that compares Bubble, Selection, Merge, and Quick Sort. All 4 methods are given a randomized array of 1000 elements and I count to see how many times it takes a method to perform to fully sort the array. My question revolves around the placement of my counts. I know I should look at the Big ... |
I need to convert a string using these rules:
Downcase the string
Replace spaces, a blacklist of "invalid" chars, and non-ascii letters (like é) with -
Replace repeated hyphens (ie --) with one hyphen (-)
For example, Is my résumé good enough? should convert to is-my-r-sum-good-enough-.
This Swift function converts t... |
I was trying to keep it SRP. I'm new into PHP OOP and I'm wondering how I can make it better.
Route.php
class Route
{
private $_url;
private $_callback;
private $_name;
public function __construct($_url, $callback)
{
$this->_url = '/^' . str_replace('/', '\\/', $_url) . '$/';
if (i... |
I just redid Rubberduck's About window in XAML:
I do not like my XAML very much. The way I place the StackPanel for the white pane over two rows, only to provide a margin to keep the copyright text out of it seems very hackish. Just as bad is the way I put the Hyperlink elements in a textbox (they are not allowed to... |
The code below is the .emacs file, which is the initial configuration file for Emacs. I use Emacs version 24.5.1 on a computer running Ubuntu 14.04 as OS. I primarily use C/C++ for coding and LaTeX for writing documents. I love to use Emacs but I feel I could do much more with it and in a refined way.
;;(server-start)
... |
Created this little config class, any room for improvements? Think I have done an alright job but would like to know if any improovements could be made?
<?php
defined("SECURE") or exit('Please define SECURE keyword to continue.');
class config
{
private $configValues;
private $configFile;
public function _... |
I have made a connection method which returns TCPMasterConnection.
public Class Connect{
String ipAddress;
int port;
TCPMasterConnection tcpCon;
public TCPMasterConnection OverTCP(String ipAddress, int port)
{
this.ipAddress = ipAddress;
this.port = port;
TCPMasterConnection tcpConnection =... |
From the array $data, I place a price for each month for one category in the first array. If no data is found for the particular category for a month, I insert 0, another category in the second array and finally place the arrays in a single array.
This code does so, but I believe there is a better and simpler way.
$dat... |
As a self-taught student of Web-Development and Web Technologies, I created a simple sign in/out form in PHP, just for practice purposes and some fun!
I read the O'reilly's book about PHP and I found one sentence there (I really don't remember where it was though):
A novice web developer will program procedurally, but... |
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;
... |
ACM ICPC Team
You are given a list of \$N\$ people who are attending ACM-ICPC World
Finals. Each of them are either well versed in a topic or they are
not. Find out the maximum number of topics a 2-person team can know.
And also find out how many teams can know that maximum number of
topics.
Note: Suppose a, ... |
In my code, there is a chain of functions call where the deepest function may throw an exception. I catch and handle it according to the business logic. The problem is that all other functions in the call chain are dependent on this function, thus, if the deepest function returns null all others function will throw the... |
I am trying to implement page objects with Page factory using TestNg and selenium. Please advice improvements in it.
Classes:
LoginPageObjects extends LoginPageLocators {
private WebDriver driver;
public LoginPageObjects(WebDriver driver)
this.driver=driver;
public HomePageObjects loginFunction(){
/... |
While implementing classes composed of various collections, I've found that it's pretty hard to completely hide the type of collection used, while still allowing C++ style operations on iterators.
For example, the following two classes allow the client to easily iterate through the collection, but require that all the ... |
Would like to ask for a code review for my DAL. I use Entity framework 6 and Autofac for dependency injection. All comments will be appreciated.
public interface IBaseEntityObject
{
public int Id {get; set;}
}
public abstract class BaseEntityObject : IBaseEntityObject
{
[Key]
... |
I have done exercise 1.7 in SICP (calculate square root precision when change in guesses is under a certain value), but I am calling the change-in-precision function twice in each iteration, which disturbs me. I wonder if there is a better way to implement this.
(define (average . ns) (/ (apply + ns) (length ns)))
(de... |
I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific functions are out. ftime seems to be deprecated but there doesn't seem to be a general-purpose alternative to using ftime.
How could this be improved?
#include ... |
I have a task to make a checkout line controller. First it receives, as input, an amount of checkouts and commands. Then commands that are C for coming and L for leaving, and after those the number of the checkout they are coming/leaving. Also, if there is someone at the checkout, they should be sent to the nearest emp... |
I am using mod and my code works. I am wondering if there is a more efficient way to write a method that returns the total number of divisors for an integer.
function getDivisorsCnt(n){
var divisors = 0;
mod = n;
while (mod > 0){
if(n % mod === 0){
divisors++;
}
mod--;
}
r... |
Rubberduck 2.0 will feature a "Search Results" dockable toolwindow that will be used for displaying the results of Find all references, Find all implementations, and whatever else we need to find. It replaces the ugly 1.x "SimpleList" view:
It all starts with a command. Here, the FindAllReferencesCommand:
/// <summary... |
One of my assignments was to create a chessboard. In this assignment I could not use an array, or a form of list or what not. Below is my code for the creation of the chessboard:
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Color;
public class Checkerboard
{
private int xPositions;
pr... |
I wanted to know how I can improve it. I mainly want to look at speed and performance, but if there are any improvements please give a suggestion.
<?php
defined("SECURE") or exit('Please define SECURE keyword to continue.');
class template
{
private $templateParams;
public function __construct()
{
... |
I have recently started writing C# from a strong JavaScript background, and found myself wanting to do something I do all the time in JavaScript: events.
Since I have a type system at my disposal, I figured I'd make use of it and make the event system type safe.
A quick note on existing options:
C#'s built-in event lib... |
I want to get the feedback this code about the best practice I should follow and if I am using the connection pooling properly.
I have classes as follows:
DAOConnectionFactory- to fetch pooled connections from the Datasource
WatcherService- the REST WS
WatcherDAO- called by WatcherService to insert data in DB
Watcher- ... |
I'm trying to set up a system where I can have an arbitrary number of parallel tasks, all of which wait for a go signal, do their work, and then stop while a manager collects the results, prepares for the next batch of work, and so on.
The easy way I know to do this is to launch a packaged_task for each job, for each i... |
I have 3 variables and each one has their own percentage to win out of 99.99...%. (The 3 percentages don't act up to 100% perfectly)
When button1 is clicked, it will go through 100,000 simulations and afterwards it will output how many times each variable "won" in a MessageBox.
I would like some help optimizing my code... |
I have refactored this. Once again, the running time can be anything between \$\Omega(n)\$ and \$\mathcal{O}(n^2)\$, yet it adapts to "smoothness" of the input array.
AdaptiveCountingSort.java:
package net.coderodde.util.sorting;
/**
* This class implements an adaptive counting sort that adapts to the input.
*
* @... |
Okay, so simple enough task - I'm using Ionic/Angular2 to develop an auditing app. Using angular I can map Objects into the DOM rather easily, so what I need to do is create an object - but I would like some suggestions or advice on how I can do this in a modular way.
The app displays a table of input fields with some ... |
I answered a question on SO today, however it did't receive any up-votes, so I want to know what's wrong with my code.
The requirement is to compare the input numbers(granted to be positive) without logical, relational or bitwise operators, and insert the corresponding comparison sign between them. For example:
input: ... |
I have this algorithm for sorting integer arrays. Basically, it's a balanced tree sort which creates a tree node for each distinct integer, and in each tree node it maintains a counter counting how many times the integer key appeared so far in the array being scanned. After the array is scanned, and the tree is complet... |
Here is my OrderBy method which includes concatenated column names.
Can this be achieved more efficiently?
public static IQueryable<T> Sort<T>(this IQueryable<T> query, List<SortationDto> sortations)
where T : BaseEntity
{
sortations.ForEach(s =>
{
Expression value = null;
ParameterExpressio... |
Design a STRING class. Provide support for:
Assigning one object for another
Two string can be concatenated using + operator
Two strings can be compared using the relational operators
Modify the String class so that assigning/initializing a string by
another will not copy it physically but will keep a reference co... |
My main interest is in how I have handled the generics and if it's idiomatic. I want the user to be able to specify what kind of integer type they would like to use for the encoding (u8, u16, u32, u64).
I want to keep the hex string -> vector of numbers
and vector of numbers -> base 64 string conversions separate.
My ... |
I want to get a second-opinion on my use of goto.
SqlCommand and SqlDataReader only read the RETURN-value of a Stored Procedure after the SqlDataReader has been closed. This is a problem if you want to interrogate the return-value to make a decision regarding how you want to read the data.
In my case, the stored proced... |
I am using a class which is taking care of minimum value so far. Please let me know of any improvements or suggestions.
class MinStack {
Stack<Node> s1 = new Stack<>();
public void push(int x) {
if(s1.isEmpty()) {
s1.push(new Node(x,x));
} else {
s1.push(new Node(x,Math... |
The task in question allows a user to re-rate a film such that only the latest rating from the user should remain in the database.
Initially I solved this problem in a very basic manor?
This was my result:
type Rating = (String, Int)
type Film = (String, String, Int, [Rating])
--Example ("Blade Runner","Ridley Scott",... |
I want to play some audio of two byte arrays. I was wondering whether it would be better to play them as two separate arrays both calling the method, or to put them into one array and play it from there.
Note: The starting from position 4 because the first 4 bytes are saved for the sequence number in the array.
All in ... |
This week I started reading "The Rust Programming Language". As I reached the chapters on enumerations and pattern matching I felt I had enough material to put together a simple representation of JSON in Rust, just to play around and get a better feeling of the language.
This is what I came up with:
use std::fmt;
pub ... |
I am developing a unit converter application for Android. The application is working correctly, but my problem is with the optimization. Is there a way to somehow optimize the code?
I have different categories - speed, weight, length and so on, and for each of them I have separate activities. Here, for example, is the ... |
I want to get some practice in writing C libraries and so started with something I can use straight away, a logging library. It is very basic and only has two levels: log everything and log only errors. Use logd (log debug) to log any low level thing and if log everything level set, that item will be logged. Use log... |
I have a list of images in a folder where num denotes the index of image and I used num to run the iterations in a "for loop". The code is supposed to segment brain part from the brain CT images. Here is the link for region growing algorithm.
How do I increase the performance of my region-growing algorithm?
% CORD_XY(1... |
Are the conditions which I have included for insertion and deletion from front and rear sufficient and necessary? Have I missed some condition check? Or have I included some redundant condition?
import java.io.*;
class Dequeue
{
int arr[];
int lim;
int front;
int rear;
public Dequeue(int l)
{
lim=l;
front=rear=... |
I have a data stored in .mat files, each .mat contains a cell array of vectors of length ~70. I'm trying to read these .mat files in to Python with h5py, but reading just 1000 cells takes about 7 seconds, and I have in total about 10^8 cells to read...
Is there any way I could simplify this process? I'm pretty sure th... |
I want to limit the request rate in a spray/akka-http route. I'm not an expert with both scala and spray/akka but learning. So I came up with the following custom directive:
trait RequestRateLimiter[T] {
def check(ctx: RequestContext, realIp: Option[RemoteAddress], proxiedIp: Option[RemoteAddress]) : RequestRateR... |
This is one of my first times writing Python. I'm most curious about style and whether while 1: x,y = socket.accept() is an acceptable way to wait for new connections.
#!/usr/bin/pythonw
import socket
import os
class Server:
def __init__(self, directory, host="", port=8123):
print("Server running on port "... |
Here is a simple Phase Locked Loop, which is a circuit used in radio communications for synchronisation between transmitter and receiver.
The loop works by calculating the (phase) difference between the input signal, and a reference oscillator, and then adjusting the reference until the phase difference is zero. In th... |
I have a few custom components, some bigger ones and some smaller ones. I'd like to know if the structure is correct. As in: Is the code to do x in the right places. For starters, I'd just like to show a very small one, take your feedback and adjust my other components accordingly.
It can be found here.
Before you clic... |
I'm a beginning C programmer. I need a function that will take a string and determine if it's a number. The data is coming from files created by different people and the number formats WILL vary. So the function needs to decide if it was Supposed to be a number and if so, I will call the right conversion function (atoi... |
In a C project I want to reuse curl easy handles. The flow of program is like:
Client --> C Application --> Call URL1, do something, Call URL2, do something, Call URL3...
In short, for each client request, the same set of URLs are called.
I initially create the curl easy handle when the program starts. The main program... |
I have just started out learning C++ and I am trying to write out a simple bills' dispenser machine as an exercise.
Upon user input, the system is to check if it can pay out the amount but only in 20 and 50 bills, and it should return with the minimum number of bills.
I need someone to point out and tell me if the foll... |
The code below is a attempt to create a persistent login cookie. I am an amateur and not professional so this is the first attempt to have secure remember me cookie. Now I want you guys to review two things:
I am trying to create a system like best way to implement remember me but I am not sure if I have done the same... |
Being new to VBA, and many years removed from college programming courses in Java, I'm seeking opinions about design, implementation, readability and general better practices using VBA to tackle complex problems. There are probably other programming languages much better suited to this problem, but I'm limited by the ... |
Working from a C# and EntityFramework background. Jimmy Bogard makes the point of modelling your domain model correctly, such that an Email Address is not a simple string but should be of type EmailAddress.
Also known as Primitive Obsession.
I've come to this part of a piece of software where a Application form is to b... |
I went from manually outputting escape codes in each string to creating a utility struct/class full of static functions and variables that needed to be initialized in source files (static private members are required to) which was a bit ugly for me. Then I was searching for something different and while playing with en... |
The following code executes asynchron on the SQL database. Is the closing of the connection implemented in the right way? Are there any missing features regarding connection handling which need to be added?
public void deleteData(Node node, User user)
{
SqlConnection connection = getConnection();
... |
I am working in Maya using PyMEL (my goal is to leverage PyMEL to create more readable, object-oriented, Pythonic code than if I'd used maya.cmds). I need to set an attribute value on an arbitrary node. The attribute may not exist or, if it does exist, may be locked. I found that setAttr with force=True did not account... |
I build/maintain an IT support self-help app and recently had the need to include some registry key manipulation when users experience certain issues.
I create the Reggie class to handle the general registry key manipulation:
using System.Windows.Forms;
using System;
using Microsoft.Win32;
namespace Reggie
{
class... |
Do I need to restructure for readability?
public HttpResponseMessage Post([FromBody]BoatProperties props)
{
// model validation
if(ModelState.IsValid)
{
// check if guid is set, else set it; don't set when user is admin
if(props.Guid == null && !User.IsInRole("Admin"... |
I have coded a very simple distributed system simulator in Python. It uses multiprocessing to assign tasks, and queues to communicate between processes.
The code is shown below.
from functions import *
import multiprocessing
import time
try:
with open("config.txt") as f:
lines = f.readlines()
max_inst... |
I have a nested hash of symbols like this:
{
a: {
b: :c,
d: {
e: :f
}
},
g: :h
}
I want to build an array that contains all symbols used in the hash, both keys and values, in any order. For the example above:
[:a, :b, :c, :d, :e, :f, :g, :h]
Is there any simple, fast and ruby-friendly way to d... |
I have to write a collection of methods for performing linear, bilinear and trilinear interpolation. I have also to write some tests to show that interpolation is exact for polynomials (which should be the case using these interpolation methods).
I ended up writing the following classes as core for my interpolation
He... |
Can someone help me optimize speed for my code? I tested it via stopwatch in milliseconds. I've implemented my own ArrayList and I would like to improve its speed without using C# built-in structures.
Mylist.cs
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
... |
I tried to collect some of my formulas inside classes so that I didn't need to browser the names of the functions anymore but only determine which Quantity I want to calculate and then check which methods are avaiable for determining it. This is based on the astropy.units module. Just to make a small example:
import as... |
I have this MSD radix sort in C++:
#ifndef RADIXSORT_H
#define RADIXSORT_H
#include <algorithm>
#include <type_traits>
static constexpr size_t BITS_PER_BYTE = 8;
static constexpr size_t BUCKET_AMOUNT = 256;
static constexpr size_t QUICKSORT_THRESHOLD = 256;
template<class T>
static size_t getBucketIndexUnsigned(T el... |
I have a bunch of custom classes for which I've implemented a method of saving files in HDF5 format using the h5py module.
A bit of background: I've accomplished this by first implementing a serialization interface that represents the data in each class as a dictionary containing specific types of data (at the moment, ... |
I did this project and I'm going back over it and trying to optimize some stuff. This is the movies_controller.rb file, which is basically a table that I need to sort based on user parameters. What I really want to know here, is there a better way to save and assign the @sort and @ratings_filter? I just need to save th... |
I'm studying functional programming, and I have the following problem to solve. It's an simplified version of Caesars Cipher:
You need to write a function, which will take string encoded with Caesar cipher as a parameter and decode it.
The one used here is ROT13 where the value of the letter is shifted by 13 places. e... |
I've just started dabbling with code, and as a learning exercise I've written a simple algorithm for solving gravitational n-body problems numerically in JavaScript.
I would be very grateful for general feedback as far as the quality of the code goes (first time I'm asking somebody to review my code; I'm very shy about... |
I have implemented the disjoint-set data structure. The purpose is to group integers together. For example, if I want to find out the groups of integers where each adjacent neighbors are same:
vector<vector<int>> test = {
{1,0,0,1},
{0,0,0,1},
{0,3,3,1}};
There are 4 groups of integers, namely:
Group 1: 1 at (0,0)
G... |
I made a class to convert the index between 2D and 1D arrays.
For example,
between
{1,3,5,7,9,11} and {{1,3},{5,7},{9,11}}
When i is 0, xy should be (0,0)
When i is 1, xy should be (0,1)
When i is 2, xy should be (1,0)
And so on...
I would be able to convert between the i-index and the xy-index to find get the equ... |
I want to do a popcount of bytes in an array.
Not a total popcount of everything, but lots of little popcounts for every individual byte to determine the neighborhood count in GoL.
The following plain x64 code does the job nicely.
function PopCountPerByte(input: int64): int64;
asm
//RCX = input
mov RAX, $55555555... |
At work we are interfacing with the Jira cloud storage for our ticket management system. I created a base class to make the process easier on the user side, and I did my best to make it re-usable and generic. I wasn't able to figure out a generic way to gain the access token authorization since I used Selenium to man... |
Many speak of using dependency injection. I do not use repository. The entity framework is uow/repository. What is wrong with using static class like the one below? My context is a new instance per request.
public class TenantManager
{
public static IEnumerable<Tenant> GetAll(AppDbContext context)
{
ret... |
I am taking a helper stack, which is used during dequeue. Kindly suggest improvement or some solution with less complexity.
import java.util.ArrayDeque;
import java.util.Deque;
public class MyQueueUsingTwoStack {
Deque<Integer> mainStack = new ArrayDeque<>();
Deque<Integer> helperStack = new ArrayDeque<>();
... |
I am working on generating sample data for my Rails application. For now we will just be using the sample data while we are designing the website. I'd like it to be as easy as possible to generate sample data each time we introduce a new model.
In our tests, we use FactoryGirl. The factories we have for testing are "ba... |
I am using two more helper stacks to sort. Kindly suggest improvements in terms of space and time.
import java.util.ArrayDeque;
import java.util.Deque;
public class SortStackAscendingOrder {
Deque<Integer> stackhelper1 = new ArrayDeque<>();
Deque<Integer> stackHelper2 = new ArrayDeque<>();
public Deque<I... |
The purpose of the following code is to measure the execution time of a simple operation (1+1) and of a call to a function who does nothing (foo).
The code compiles and seems to work properly, but the results I am getting are weird. It seems the basic operation requires about the same time as the function call, and mos... |
I'm creating a chat client and chat server after a several month programming hiatus. The goal is to make one with features I want but it's also a learning project. Although it's mostly because I'm annoyed at cough skype.
I've realised I don't know if anything I've written currently is any good (never had anyone critiqu... |
In one of my app, i m using custom navigation bar view to handle all Navigation Bar Properties.
Is it good practice to use custom navigation in given below way? Any Optimizations need to be done. It would be helpful to me, if you have any valuable suggestions.
Source Code ---->
.h
#import <UIKit/UIKit.h>
@protocol VCN... |
I wrote a Python script to download files using multiple (source) IP addresses -- kindly suggest any improvements.
import cgi
import os
import posixpath
import Queue
import threading
import urllib
import urlparse
import random
import re
import shutil
import time
import requests
import requests_toolbelt
def get_IPs():... |
I was reading this article about StringBuilder vs string.concat and couldn't figure out which one would be better in the following situation:
StringBuilder address = new StringBuilder();
address.Append(retailer.Street.Replace(",", "<br>").Replace("\n", "<br>"));
address.Append("<br>");
if (!string.IsNullOrWhiteSpace(... |
I recently had the need to loop from zero to some limit only known at runtime. Instead of writing:
for(int i = 0; i < limit; ++i)
{
// Some repetitive thing
}
I wanted to write something similar to what I often use in Python and D:
for i in range(0, limit):
# Some repetitive thing
foreach(i; 0 .. limit)
{
... |
I'm working on a scheduling table that user' can select cells (which will be gathered with jQuery using data attributes) but I'm trying to work out the best way for user' to be able to select rows and columns in a usable fashion. At the moment you can click and drag cells to select them and you can select rows.
So far ... |
Any suggestions to help refactor this method? I thought maybe some kind of factory to allocate the right type?
public static FineTime getFineTime(Object o) {
if (o == null) {
return null;
}
//FineTime
if (o instanceof FineTime) {
return (FineTime ) o;
}
//Long
if (o instanceo... |
I have got my JavaScript working as seen here:
https://jsfiddle.net/yLg1qs04/3/
But how do I condense/shorten it so that it's not repeating itself so often and taking up so many lines?
$( '#mcnumber' ).keyup(function(){ //when a user types in input box
var mcnum = this.value;
if ( mcnum.charAt( 0 ) == '1' ) {
... |
I am calculating the moving average for 5,534,446 rows in one table. I am using C# as my language and MySQL as the database. Below is the code I am using to gather and calculate an exponential moving average for different sets of days. The program is working perfectly but it is taking forever to calculate the values on... |
I was thinking about this after recently reading about the new Null Conditional Operators in C# 6.0. So here is my code that I am currently working on...
if (!string.IsNullOrWhiteSpace(question2Answer))
{
stringbuild.Append($" and ProdUsers = {Regex.Match(question2Answer, @"\d+").Value}");
}
if... |
This is my first time using C++ Templates to make a data structure. I have written a program to implement a stack of up to 5 items.
#include<iostream>
#include<iomanip>
using namespace std;
template<class T>
class Queue{
private:
T arrays[5];
int i; //empty stack
public:
Queue()
{
arrays[5] = ... |
In short - I've started with C# not so long ago (which means you find a lot of poor written code here) and now I'm aiming to create a dialogue system. Though my code is working as it supposed to, questions are:
How to make everything not this lame and improve the code
Suggestions about improving performance
Overall ad... |
Cucumber is not designed to support multi-column iterations, but it is possible to make it work. Here, I want to try each combination of path and role.
This is the Cucumber Gherkin:
Scenario: cannot access paths
When I access "path" as "role" then I should see an error
| /path1 | user1 |
| /path2 | us... |
The simplified question is:
Given a list of numbers, write a Python script that will remove the last odd number from the list.
One of the challenges is if the last odd number appears multiple times, some approaches will remove the first occurrence of that number, rather than the last.
One solution that I have is to f... |
This code is returning 'true' for any date which are later than Feb 24, 1998.
//minimumAge is number of years i.e., 18
public boolean isUser18Older (DateTime userDob, int minimumAge){
DateTime minAge = new DateTime();
Days days = Days.daysBetween(userDob, minAge.minusYears(minimumAge));
return days.getDay... |
This is my first non-trivial Haskell project, an expression parser implemented using the Pratt Parser's technique for managing precedence as a layer on top of Parsec. It simply builds an expression tree and then pretty-prints it using Text.PrettyPrint. Would welcome any comments, but am particularly interested about ... |
The function returns a list of tuples which is generated through list comprehension:
getUserRatings :: String -> [Film] -> [(String,Int)]
getUserRatings search database = [(title,rate) | (Film title _ _ ratings) <- database, (user,rate) <- ratings, search == user]
Film is defined as:
type Rating = (String, Int)
data F... |
I've taken a coding challenge as part of a job interview and the recruiting process. Sadly I didn't get through it and couldn't secure the job. I am wondering if anyone can help me out here and show me how it could've been done better.
The problem described by interviewer was:
The purpose of the class is to register a... |
I made a tumbler thingy...
Do you see possible bugs in the code or any improvements I could do?
var text = "0000 ASCII (Listeni/ˈæski/ ass-kee), abbreviated from American Standard Code for Information Interchange,[1] is a character-encoding scheme (the IANA prefers the name US-ASCII[2]). ASCII codes represent text in... |
I've followed several guides on how to implement MVC in Java, and so far I've come up with the classes shown below. From my understanding, MVC follows these guidelines.
The Model should be independent and unaware of the View and Controller.
The View should wait for interaction from the user and inform the Controller.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.