instruction stringlengths 71 71.9k |
|---|
I am new to Multi-threading. I have had a go at writing some code that loops through an ArrayList, gets a hostname and then pings the hostname. If the hostname is not pingable it adds the hostname to a list returned by the method.
I am very new to multi-threading so I was just wondering if someone could give me a hand ... |
Ok, before you ask: yes, I need to do this. Sort of.
I'm wrapping a 3rd-party API for data access, and I can't use an ORM, so I'm implementing this kind of thing:
public interface IRepository<TEntity> where TEntity : class, new()
{
/// <summary>
/// Projects all entities that match specified predicate into a <s... |
While thinking about this question it struck me that one problem of linked data structures always seems to be loss of memory locality and performance could possibly be improved if all allocated nodes are in a contiguous block of memory. So hacked together an object pool implementation in C.
The code compiles with gcc -... |
Basically I'm displaying an array of images on a page with checkboxes. The idea is when a user is editing a post and the checkbox is checked, the image will get deleted. Each image also has an order_id and description.
I'm pretty new to Ruby and programming and I'm looking for a way to simplify the following code.
Code... |
Challenge:
Given two strings, A and B. Find if there is a substring that appears
in both A and B.
Specifications:
Several test cases will be given to you in a single file. The first
line of the input will contain a single integer T, the number of test
cases.
Then there will be T descriptions of the test cases.... |
I've written a quick directive that provides two features:
Clicking on an empty area of the canvas will allow a 'drag and draw' function
Clicking on a an existing rectangle on the canvas will allow a 'drag and drop' function.
The primary thing I would like feedback on is whether my method for drawing and redrawing t... |
Purpose
This problem comes from this question on the dailyprogrammer subreddit.
Basically, the task is to write an implementation that identifies if the characters in a String are in
Alphabetical order (A to Z)
Reverse Alphabetical order (Z to A)
Neither Alphabetical nor Reverse Alphabetical order ("abba")
Both Alpha... |
Good night everyone. I spent the last week or so building this pretty cool note management program written with JavaFX. . Buttons are the method used to switch b/w open documents, and the "notes" are converted to HTML documents using a simple syntax:
Everything after HEADING on a single line is converted to a h1 eleme... |
I decided to make a random string generator for fun, and it works for the most part. Since I'm an amateur at programming, I thought I would post the code to get some feedback on it, and hopefully improve any bad habits.
#include <iostream>
#include <string>
#include <ctime>
typedef unsigned int uint;
std::string rand... |
I wrote a program to gradually lower the volume of my computer when I go to sleep so I can fall asleep with TV or music on. This was my first time using argparse and I feel like there should be a cleaner way to deal with default values of optional arguments. Any other feedback of course also welcomed.
import vol
from... |
I have a command called sprinkle. I'm not going to explain anything about it, because I want whoever that reviews the code to also tell me how much of the command documentation they understood.
Here is what I need help with:
Is the documentation good enough? Is it too verbose?
Does the constant domainName help you und... |
King Kohima problem:
King Kohima has reserved a new exclusive street for his executive class employees where they can build their homes. He has assigned you to plan that street. You have to decide on which plots along the street are new building allowed to be built. In order to this, you first want to calculate the ... |
Related: Something like a LINQ provider
I needed to work with the Sage300 View API. I had never worked with it, but my first impression has been that the API is stringly-typed, and makes you write very procedural and repetitive code.
So I decided to make my life easier, and wrap it with a familiar interface:
public in... |
I'm looking for comments on the design, correctness and performance (not so much style) of a dynamic work queue for OpenMP worker threads.
I have an algorithm that can be thought of in terms of some number of work items (how many is not known beforehand), each of which is executed and may then spawn two child work item... |
I made a command line application which uses parameters. So I try to make a system like the linux command.
So I have 4 parameters, initialized to a default value, used if wrong or none parameter are given. The user can modify those parameter by calling associate options "-options".
public static void main(String [] ... |
I'm using a dynamic pivot example. This SQL code has the purpose of perform transposing data from rows to columns, using a temporary table in SQL Server.
The data is initially presented this way:
/*
cLinID cLinDescr cColID cColDescr vValor
------ ------------ ------- ------------ -------------
1 Client 01 ... |
I have written a code to count the number of files in a folder and if there are any folder inside folder it will count the files in that folder too.
import java.io.File
class GetFileCount {
def getFilesCount(dir: String):Int = {
val file = new File(dir)
require(file.exists() && file.isDirectory)
def inDir... |
I tried my hands of Conway's Game of life. Well it works as I wanted it to but I want to improve my design and coding practice. I will be glad to get feedback and ideas to improve it and how to code it better.
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#define ALIVE true
#define DEAD false
#define T 100
... |
I'm trying to build a URL to call the SharePoint Search REST API in TypeScript. The interesting part is building the querytext, which is done by my buildQueryText method. In my case it takes two parameters: A content type to search for and a array of select properties.
buildQueryText(contentType: string, selectProperti... |
I tried this as a programming exercise. It's working as intended, but I feel like the code is a mess and I could have used the advantages of object oriented programming much more (like inheritance for fish and shark from the Cell class, and probably much more). Can someone guide me a bit through this code example and s... |
I've just completed writing a spec for a Doctrine2 repository. The repo contains only one method so far, the spec for which takes in an OAuth Identity token object (that contains an ID that matches up with a database table in my system) and returns either NULL or a UserAccount entity.
Due to the fluent nature of Doctri... |
This is my hangman game code for my GCSE computer science coursework. It has been submitted but I was wondering if there is anyway to improve it.
import random
import time
#Variables holding different words for each difficulty
EASYWORDS = open("Easy.txt","r+")
words = []
for item in EASYWORDS:
words.append(item.s... |
As part of my autodidacticism into all things Python related, I have decided to write a number of functions that I can save in a library for future use. One such function that struck me as useful to have, would be a function that could be called each time the user wished to make an amendment to an existing file.
The r... |
I have code that sorts two lists related with each other
"""
list1 reperesents customer
list2 reperesents amount of products they have brought
"""
list1=['a','c','e','i','o','u']
list2=[12,23,45,10,7,2]
list3=[]
for i in range(0,len(list1)):
list3.append([list1[i],list2[i]])
print list3
"""
[['a', ... |
I am totally new to PHP. I just wrote a PHP script for google oauth to pull the data and insert into my database. I don't know if my code is vulnerable to SQL injection. Should I have used prepared statements and should I rewrite the code?
index.php
<?php ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOT... |
With the help of SO I got my code working, but I think it still could be improved, in particular I do not like using asInstanceOf. Is there some way how to avoid it?
trait UpdatedTrait[A, K, T] {
def upd(k: K, t: T): A
}
trait UpdatedFunctor[A, K, T] {
def upd(a: A, k: K, t: T): A
}
implicit class U... |
This is my first angular application. I am sure there must be many mistakes like coding conventions, naming conventions or implementation mistakes like what goes where. Could you please review this application which converts currency from one to another.
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta cha... |
How can I make it shorter and cleaner?
using Queries.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
namespace Queries.Persistence.Repositories
{
public class Repository<TEntity> : IRepository<TEntity> where TEntity : class
... |
From SICP
Exercise 1.3: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
Square is:
(define (square x) (* x x))
I know the code could be written using language features like lambda or let, but first to remain true to the exercise, I wouldn't use ... |
I would like to create an igraph object. First, I set up the size of igraph object — n, m, then create a random matrix. As a result matrix B will be filled. Matrix B is the adjacency matrix for the igraph object. Inside for-loops I compute the distance d (scalar) and the weight matrix W. I would like to improve the per... |
I've come across a need for code like this a few times - you have an object (or objects) that may or may not have certain properties and values within those properties. Consider a program with multiple types that have a different set of "Name" type properties on each of them. Your Contact type has all of them, however... |
I'm working on wiring up a bindable Map for Xamarin Forms, and I need a fast way of dividing up the ObservableCollections (collection of map markers) as quickly as possible. Collections are a weak area for me, and I find myself doing too many foreach's when they're not necessary.
Here's what I have now.
private static ... |
I was inspired by this to write a graphic snow animation in Java/Processing. It works great, but it has some design issues.
The full project is here on github;
Main
package com.jatkin.snowday;
import processing.core.PApplet;
import processing.core.PGraphics;
/**
* Created by Jarrett on 02/04/16.
*/
public class Mai... |
Homework: Write a function to score a scrabble word.
values is a global dict formatted as values = {'a': 1, 'b': 3,...}
The docstring is supplied as part of the course, thus I'm only looking for feedback on the actual program logic.
I could have written a bunch of variables, iterated over the string word, looking up p... |
I am working on a Python project where a food processing company is trying to calculate its total sales for the year. Python has to read from a text file where its divided into for categories split by commas.
The first category is the Type of product, which can be cereal, chocolate candy etc produced by the company.
Th... |
I'm attempting to transliterate a piece of encryption/decryption code written in python into C#; the code works on save data from a particular game. I can't code in python at all, but by referring to the python documentation I was able to code up a working implementation in C#. What I'd like to know is:
Does the C# co... |
The title pretty much explains it. This is the first program I've written in assembly, so any criticism, either on programming style or saving instructions, would be appreciated.
li $t0, -1
.data
nl: .asciiz "\n"
.text
loop:beq $t0, 100, exit
add $t0, $t0, 1
add $a0, $t0, $zero
li $v0, 1
syscall
rem $t1, $t0,... |
I was helping on this question. There you have a table border to indicate countryA and countryB have a common border. And want to know what country you can reach starting from country S Sweden.
I did my recursion and works ok. But I feel I cheat a little bit. Taking advantage the number of countries are limited put a b... |
I've been coding Python for little over 6 months now. I am self taught and I would like to ask for some help for myself and also for others in my position who's been wondering if they're going about this the right way.
I am looking to see:
if my code can be cleaned up in any way
if my code is easily read by others
if ... |
Challenge:
Given three query types simulate heap operations.
Specifications:
1. "1 v" - Add an element v to the heap.
2. "2 v" - Delete the element v from the heap.
3. Print the minimum of all the elements in the
heap.
It is guaranteed that the element to be deleted will exist in the heap.
Only distinct e... |
I'm trying to improve my coding skills by going through the USACO TRAINING PROGRAM.
I would like a review of my code for solving the transform problem.
Here is the problem statement:
A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program... |
I had heard about sorting for a while, but never actually gave it a try. So I decided to make an algorithm that would sort the members of a vector from least to greatest. Though this may seem pretty simple and/or silly, I actually put a lot of thought into it and wrote out tables/diagrams.
#include <iostream>
#include ... |
This code works, but my boss told me that it's very bad code, and don't want to deploy it. It is my first time working as a programmer and I have at least 3 months of experience.
# -*- coding: utf-8 -*-
import psycopg2.extras
import time
import json
from psycopg2.extensions import AsIs
from methods_grabber import get_... |
I created a queue in which we can perform Enqueue, Dequeue and Traversing in Scala.
class Queue[+A](list:List[A]) {
def enqueue[B>:A](x:B):Queue[B]= new Queue[B](list :+ x)
def dequeue[B>:A]:Queue[B] = new Queue[B](list.tail)
def head = list.head
def tail = list.tail
}
Please review this code and make suggesti... |
There are two reasons why many people choose weak passwords over stronger, more complicated ones:
They don't know that their passwords are insecure
They don't want to change to a better password because they are generally more complicated and harder to remember
So, I came up with this program: a password trainer! It ... |
I have wrote a code to approximate the solution of a boundary value problem:
x'' = p(t)x'(t)+q(t)x(t)+r(t)
x(b) = beta in [a,b]
by using Runge-Kutta method of order N = 4.
Do you have any idea to make it short? I don't know how to call a subroutine as an argument in another subroutine. I had to copy the rk4 subro... |
I'm currently trying to get somewhat familiar with swing and so I made a little game called "Mouse LorMorR" (Mouse Left or Middle or Right). The game consists of a timer, a score display and three JPanels that display which mouse button you should click. By clicking the wrong mouse button or letting the timer run out t... |
I'm using my crawler class in the following manner and I'm beginning to think it's bad practice:
crawler.py
import requests
class Crawler():
def __init__(self, url):
self.url = url
def web_crawler(self):
requests.get(self.url)
return requests.text
main.py
for url in urls:
crawler ... |
I have implemented a Stack data structure in C and I would like to know if there is something that could be improved.
Stack using linked list:
#include "Stack.h"
#include "stdlib.h"
//Linked List based data structure.
typedef struct Stack {
int data;
int size;
struct Stack *next;
}Stack;
/**
* initStackW... |
Seeing a csv in table form is nicer then viewing it as row text, for example the csv from Calculate food company sales for the year (with headers added by me) looks much nicer in this table form than in plain-text:
<table border="1">
<tr>
<th> Kind</th>
<th> Brand</th>
<th> Sales in 2014</th>
<th> Sales in 2015</... |
I wrote an Excel VBA function that will take a string argument and return a string that is legal for naming a range. Upon looking through this, if you're wondering what I've been smoking, I should add a disclaimer that I'm new to VBA and I have not yet come across a less restrictive way to obtain this functionality. ... |
I was given this question at an interview for a position I just got rejected by, so looking to improve and see what better answers there are!
Input: List of meetings
Output: Can conference room fit all the meetings
It was an open ended problem so I was kinda flustered. My first stab at it was probably too much in t... |
I have one of my first PowerShell scripts that will query a list of users in Active Directory. While doing so it will keep a tally in a hashtable that will update for every group increasing it count so that a final total can then be displayed.
This is used so that given a group of users that are performing the same job... |
I'm in need of a solution that runs constantly incoming requests in a per-resource sequence, but parallel in general.
The use-case:
Many clients connect to a server and start issuing work. The work of a single client needs to run in sequential order, so the downward code doesn't need to cope with concurrency, but in ge... |
I want to break a larger list into $num-lists smaller lists. I thought that there might be an option for rotor that would already do it, but I haven't found one.
#!/bin/env perl6
my @a = 1 .. 13;
my @lists = fair-lists(@a, 3);
say @$_ for @lists;
sub fair-lists ( @array, $num-lists )
{
my $num-elements = @array... |
I am trying to learn Meteor, so I tried to write a basic location autocomplete.
Currently, given a string, it will request suggestions from https://photon.komoot.de/ (amazing free location autocomplete btw) and display them in an ul-li. What is not done yet is keyboard navigation.
autocomplete.html
<template name="auto... |
The goal of these files is to have some common behavior between Bash and Zsh
when starting them. As is known, when Bash starts as a login shell it will
source the first found of the following in your home director: .bash_profile,
.bash_login, or .profile. If Bash is a nonlogin interactive it will source
.bashrc. Meanwh... |
For my chunk generator for my game, it currently uses a triple nested loop, which seems very inefficient. It also seems like I could cut down a lot of code in the function somehow. Does anyone have any ideas?
void Chunk::Generate() {
const int octaves = 6;
const float heightMod = 4.0f;
const float densityMo... |
The following code was inspired from a tutorial I found online:
#include <cstdio>
#include <cstdarg>
double average_function(const int num_elements, ...)
{
va_list elements;
double sum = 0.0;
va_start(elements, num_elements);
for(int i = 0; i < num_elements; ++i) {
sum += va_arg(elements, doub... |
Here's the link to the github project.
I want to implement abstract factory instead of adding platform-dependent compilation flags in just one file and make it ugly, hence decoupled code. Moreover, I have to implement different AdNetworks on different platforms.
This is the interface:
public interface IAds
{
void... |
Before I had access to VM's, money or had any PowerShell knowledge I made this script that would do some image customizations for me. I used physical computers and would be reinstalling the OS while I was testing my image creation process. The process was long and tedious but I used this to save some of the repetition.... |
I've created a JavaScript application to highlight the syntax of HTML and PHP. I know a lot of syntax highlighter are available nowadays, I just created to extend my knowledge in JS and regular expressions. I only wanted to know if its the right way to do this. (The code below works fine.)
js/codeHighlighter.js
functio... |
Purpose
A garland word is a word
formed by chopping off the last few letters and “wrapping around” to the start.
For example: You can chop off the the trailing “on” from “onion” and still form the word by wrapping around to the starting “on”. In other words, you can write the letters “o”, “n”, “i” in a circle, in that... |
I'm quite a novice in shell scripting so far, but i'm learning and getting quite comfortable in writing shell scripts, but i have a lot to learn.
The snippet at the bottom of the page creates backups of a certain users databases.
The script checks first if there is more than 7 compressed .gz files in a folder.
Fetches ... |
I knocked this together in a few hours as I was just simply bored. I was going to add a namespace to this but decided there was no point.
This is also available on Github
All feedback is appreciated!
<?php
/**
* This class will allow you to generate goo.gl links
* @package Google
* @subpackage Googl
* @author... |
I recently created pong game using Java. This is my first time not copying any code from the internet or using any help. While it does work, my code feels well written but no streamlined or smooth (other than the fact that I made additional classes that would help create further code in this project). When playing it, ... |
I made a class that would do alpha beta pruning on a binary tree of 40 degree. However there is a time limit on a single move of 30 seconds. I am to play against my professor and his opponent class. I tried going down 6 levels but I would lose. I tried going down 7 levels and I was taking too long. Is there a way to ma... |
I have a C# file, that makes some modifications on screen (changes the text on the user interface) but I have some doubts:
How I can re-use the below methods to be more concise and reusable?
How I can separate the database methods in another file class?
private void GetDoencaNome(){
using(IDbConnection dbConnecti... |
The Sherlock and the Beast challenge from HackerRank asks to generate the following number with \$n\$ digits for \$T\$ test cases:
A Decent Number has the following properties: its digits can only be 3's and/or 5's. The number of 3's it contains is divisible by 5. The number of 5's it contains is divisible by 3. If th... |
I am relatively new to web development and I created an image gallery with pagination using the Twitter Bootstrap framework. Basically, I want to know if I approached creating an image gallery correctly and what I could do to improve. The basic idea was that each pagination <li> element linked with a different get vari... |
I have this table in my db:
table
----------
cityID
value
parameterID
The table looks like this:
cityID value parameterID
500 30 1
500 60 2
500 7 3
600 25 1
600 50 2
600 6 3
.... ... .....
where 1... |
Purpose
Validate if a number is an Armstrong Number.
An Armstrong Number is a number
such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 33 + 73 + 13 = 371.
Strategy
Calculate the remainder and quotient of the candidate value.
While the quotient i... |
I've been working on a project originally for school regarding object-oriented design, where I was supposed to write a class for a book and a bookshelf, and then have a driver class to add a couple books and print out their details. I originally started this project a while ago, adding and changing things as I've learn... |
Is there any object oriented way or design pattern I can use to make this code better? How can I avoid casting in this code? What if I add new Object like WaterTank how will it interact with fitting?
Run.java
package main;
import fittings.Fitting;
import fittings.Tap;
import bathroom.Bathroom;
import user.User;
publi... |
I ran into this challenge a couple of times today and thought I could tackle it with PowerShell. I refused to look at other peoples approaches to this hoping to complete it on my own. I'm sure the general idea is the same in either case. I have included more comments than I would normally to help people not familiar wi... |
I decided to help @Matt out a bit and ask a PowerShell question. This is a simple guess-the-number game learning how to use functions with and without parameters, and use the input and output functions. All comments are welcome.
Function GetNumber([int]$min, [int]$max) {
Return Get-Random -minimum $min -maximum (... |
The goal of this code is to read-in a stream of terminal ESC sequences, and break them down and fill a vector of parameterized sequences for processing later on.
For example ESC[5C would be filled in the vector as:
Vector[0] = C
Vector[1] = 5
Colors for example ESC[0;44;32m
Vector[0] = m
Vector[1] = 0
Vector[2]... |
I've got to delete / replace elements in an array.
For accomplishing these task one usually uses Array.splice().
Problem: Array.splice() expects the replacement items as a comma separated list. But I got the values as an array. I've made this
helper function which makes it possible to use splice with an array instead... |
I'd like to convert some integer number from a cell between 0 and 1,000,000,0000 into Hungarian text. I've found already a solution, a VBA function.
How can be improved this solution?
Function num2txthu(cellvalue As Double)
'------------------------------------------------------------------------------
'VBA-function, ... |
I just started to learn C, and for practicing, I tried to implement a simple stack data structure, and I want to know if I'm making any mistakes, or how could I improve it:
My stack.h:
#ifndef STACK_H
#define STACK_H
#define STACK_MAX_SIZE 125
typedef struct
{
int max_size;
int items[STACK_MAX_SIZE];
int ... |
I am a self-taught programmer, so please be gently. Please give as much feedback as possible for my code.
I want to make sure I am doing things the right way and efficient way.
What is the proper directory to save this info? What file type and what format?
How do I load these settings when the program loads and make su... |
My algorithm is quite simple. I simply iterate over the entire map arr and if I find the start of the combination I need to find, I begin exploring.
My combination data structure is simply the combination I need to find, column at a time.
If each column in arr matches, I return True. If at any point the value doesn't m... |
I wrote a basic command prompt Tic Tac Toe Game. I want to know what can be improved in terms of modeling and what mistakes I've made (if any).
void Main()
{
TicTacToeBoard board = new TicTacToeBoard();
while(!board.GameOver())
{
var i = int.Parse(Console.ReadLine());
board.MakeMove(i);
... |
I'm building a JSON API. I'm writing my controller tests so that they compare the response body to actual JSON I'm generating in my tests using ActiveRecord. I wrote two helper methods that make the process easier. The first simply parses the actual response body and returns it.
def json_response_body(&block)
JSON.pa... |
Often I end up with
var askName = () => {
return new Promise((resolve, reject) => {
this.waitForInput('Name:').then(name => {
this.ask('Are there more players?', ['Yes', 'No']).then(answer => {
if(answer === 'yes') {
askName().then(resolve);
}... |
I wrote a MessageBus class whose only purpose is to deliver messages from object to object without direct link between them.
I encountered a problem with duplicate code caused by requirement for same methods with and without generic types, however it does bother me and a better solution would be appreciated.
using Syst... |
I am learning Swift and object oriented programming. I am new to design patterns and protocol oriented programming.
In my test code I have several related objects:
Security: the most important object that will be contained in the other ones.
AssetClass: Contains Security objects
Portfolio: Contains Security and Asset... |
Task
Write an implementation that returns whether a String has vowels (English language) in alphabetical (A-Z) order or not.
Feedback
Is my vowels variable appropriate? Is there a better way to implement a vowel lookup?
If a candidate String has no vowels, the validator will return true - is that reasonable? From a lo... |
I made a pieChart function thanks to the main CSS properties rotate:xdeg, border-radius:100% and overflow:hidden. That helped me to make rotating quarter pies of any size.
Here is the code:
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
... |
I was asked to create a jQuery plugin that would sort homogeneous DOM elements in a given DOM container element.
I came up with the idea to attach data-priority attribute to the elements that are to be sorted, e.g.:
<div class="offer-item" data-priority="10">..</div>
, and later use that attribute in a jQuery plugin.
T... |
I'd just like to ask if there's anyway to make the functions play_Game() or is_move_valid() anymore efficient. For example, using a loop of some sort, I haven't been able to figure out how and would like any help in trying to make those functions shorter.
#TicTacToe
import sys
rows=[[0,1,2],[3,4,5],[6,7,8]]
columns =[[... |
This is a class I built to handle post/get requests to URL's, but also check for connection and provide different callbacks depending on success or failure. It is intended to work without being attached to a GameObject by using static methods.
It can set up like so:
MHSOnline.Domain = "http://yourdomain.com";
MHSOnline... |
I'm practicing my C coding and I wanted to implement my own version of the getline function in C for learning purposes. I'd like a review on coding style, correctness, improvements I can make for performance, and overall quality of the code. My main concerns are correctness and performance (in that order).
#include <st... |
Here's a bit tricky one, because AFAIK there is no existing platform, where conditionally compiled part of the code would actually get included by compiler, so it is entirely up to the human review to see if it is correct.
The purpose is to have abs function, which does not trigger undefined behavior with any user inpu... |
I'm just looking for a cleaner way. Obviously I could store a variable for some of the int parts. Personally, I think the one-liner looks better and everyone's definition of what constitutes clean readable code differs.
def gen_isbn(isbn):
for i, val in enumerate(isbn):
if len(isbn) == 9:
yield (i... |
I have code that parses through web pages finds commentaries and saves commentary info in DB. I have an array where all necessary pages are stored. I iterate through all these pages one by one and find HMTL element which contains all the info about commentary if there are multiple pages with commentaries I iterate thro... |
I wrote this program to remove comments from a C source file, accepting a file name from the command prompt. Let me know if I missed anything or if there are any improvements that can be made in the program.
#include<stdio.h>
#include<stdbool.h>
void m_cmnt( FILE *fp )
{
int prev=0 , ch ;
while ((ch=getc(fp))... |
At first, I had Database to contain std::list<Student> students, but because there are over 2000 students, searching by students should not be done in linear time. However, searching for students can be by name or by student number. To enable both searches in logarithmic time, I decided to give Database two maps that... |
The code calculates a n-bonnaci sequence to a certain number, based on the user's input. It then can print it to a file and/or print it to the console.
The calculateSequence function calculates the sequence. The first loop fills the sequence with ones (0, 1, 1, 2...). Next, it calculates the value of the current number... |
I am implementing a feature that reminds users to make a post via email if
the user has set daily reminders to true
he has not posted yet today
and if the current hour matches when he would like to receive the daily reminder in his time zone.
I am going to write a Rake task for it and then schedule it to run every ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.