instruction stringlengths 71 71.9k |
|---|
I have the following code working here on JSFIDDLE:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<label for="opt1"><input class="radio-button-selector" type="radio" name="a... |
I was wondering if you could provide some feedback on this Router class I built. Worth noting that it relies on an Apache rewrite rule that always redirects to this file, but passes the path into $_GET['url'] as a string (e.g. A request to http://foo.com/foo/bar) goes into $_GET['url] => 'foo/bar'.
You can then define ... |
I'm working one of the recommended tutorials -- actually, the UPenn online course CS194 -- for learning Haskell, and I have a working solution to the final "challenge exercise" for HW 2. But it seems to be a very brute-force way of doing things, so I'm wondering if this is really the idiomatic Haskell way, or if I'm br... |
This is function for reversing a string in C using recursive calls:
#include <stdio.h>
#include <string.h>
void revert(char* left, char* right) { // Should I pass char* like I'm doing now or are char** a better idea?
if(left == right) return;
char *ll = left; char* rr = right;
char tmp = right[0];
ri... |
I have been playing with Java for around a year and I started writing this API for storing data in files. I wrote this method which will save the parameters in a "key: value" format in a file.
The method is getting fairly long and I am just wondering if there is a better/shorter/more efficient way to do this.
public vo... |
I've got a text I don't want to be copied by users.
To avoid that, I'm using this code:
index.php
<?php
session_start();
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < 100; $i++) {
$randomString .= $characters[rand(0, strlen($charact... |
I'm trying to essentially replace an element and make it transition smoothly to the new size... I started off trying to work with the appended element itself, but the padding and margins made that difficult, so I switched to using a container.
var template = "<p>I've replaced the button<br>and in a very smooth<br>fashi... |
My client needs their Google AdWords destination URL query parsed and the values spell checked to eliminate any typos ("use" instead of "us", etc).
I'm pulling the data using the AdWords API and putting it into a dateframe for manipulation. Everything works, but there are over 100,000 records every pull and sometimes ... |
I have a 2-dimensional grid defined by a known point gridCenter and distance between points gridStep and need to find all points on this grid that are inside or on the radius of a circle defined by center and radius.
My solution is to use a brute-force approach like so:
public static IEnumerable<Vector2> GetPointsInCir... |
I am trying to more or less perfect a movement script that activates when "triggered" by another object. Below I have the code for both the triggering object as well as the object being triggered.
I tried to provide summary data to make it obvious what I'm doing, but what can I improve here? And please don't tell me "e... |
This function creates a series of links at a desired destination by the usage of a premade tag system.
Usage:
createMyTAGS_DATA passes in a single line of all the links as: LinkText;LinkAddress;;
createMyTAGS_LOCATION passes the destination to a div,span,... to render the result
Result would be:
<a href="LindAddress... |
Feeder is in charge of returning an array of items rated by users (feed). If there is a watching user (current_user), the Ratings should be from all users being influencers except for a watching user.
Scroll is given by a gem. It gives a cursor for each rating so that infinite scrolls will work.
I see this pattern quit... |
I'm using a simple octree in my program and wanted to know if my implementation could be faster. It is part of this program.
Octree.H:
#ifndef OCTREE_H
#define OCTREE_H
#include "Rendera.H"
class Octree
{
public:
struct node_t
{
float value;
struct node_t *child[8];
};
Octree();
virtual ~Octree();
... |
So far I have Java code that will:
take in two .csv files
store each line as a string in a string array
split it into a 2D string array where a comma would act as the separator
sum the number found in a column with all the other numbers that share the same number in the column next to it, and count how many times it d... |
For an assignment at Uni we had to code a program that takes numbers as input and determines the coefficient if they form a geometric progression once you declare EOF (ctrl+z). If the user inputs a number that doesn't belong to an already established progression the program breaks, telling us there's no geometric progr... |
Was just wondering if I was using nested if statements to much. I've been looking around and it seems that people try to not use them. Also does the code look messy in any way? Anyways here it is:
CheckScores.java
import java.util.Arrays;
public class CheckScores {
private int maxScore = 6;
private int sum;
public v... |
I've been working on a COM Add-in for the VBA IDE with a friend. The idea is to search the active VBA Project for "magic" comments and create a task list much like any sane IDE would have.
This is my first "real" project in C#, so I'm feeling like this code could be better. The code below is all in the code behind of ... |
Is the use of _pn in __init__ pythonic? It seems that most examples change the actual attribute to self._pn to indicate it's private, but I would like to be able to call self.pn but have the advantage of checks with setters.
The following code will cause a recursive loop:
class part:
'Holds various attributes of intere... |
I have a table structured like this:
UnitScanDB = {
["profiles"] = {
["Goblin"] = {
["Bars"] = {
{
{
["track"] = "Cloak of Shadows#Anti-Magic Shell#Hand of Freedom#Spell Reflection",
}, -- [1]
{
... |
I have found Tic-Tac-Toe source code: Tic Tac Toe in C++
I have rewritten the source code in C++11 as shown below. How can I minimize hardcoding in the game logic?
#include <iostream>
#include <cctype>
#include <algorithm>
#include <functional>
#include <array>
class TicTacToe
{
public:
bool isFull() const;
vo... |
I just wrote this function and I was curious if anyone could find any flaws in it.
It look pretty secure to me but I just want to make sure since I'm no cryptography expert.
function urandom_rand($min, $max) {
if ($max <= $min) {
trigger_error('Minimum value must be greater than maximum value.');
}
... |
I'm trying out new things (on class Inproc), specifically using std::unique_ptr and std::move, and I'm wondering if I'm doing it right. The code compiles so that gives me hope. Still, what do you think?
Note: I'm working without exceptions for reasons I won't go into. That means the factory functions are required to ha... |
I had recently completed one programming challenge where I've had to design a deck of cards. The time was limited but I tried my best. I designed the basic operations and am wondering if I can improve the current structure of class and objects. I'm also looking for pros and cons of my design.
import java.util.Random;
... |
I do not use JavaScript often, so I will be thankful if you could improve my code. It is my implementation of the game 2048.
Here is a part of the Angular controller:
$scope.grid = new Grid(4);
$scope.key_pressed = function(e) {
if (e.keyCode == 37) {
$scope.grid.moveLeft();
} else if (e.keyCode == 38... |
I have two functions that replace letters. In one function, I'm replacing a regular Hebrew letter with its final form, and the other function undoes this operation. (Consider it like lowercase/uppercase, except only a few letters have both forms.)
I created an object where the keys are the regular forms and the values ... |
I have been trying to learn the various aspects of the languages I know so far to do the Daily Challenges in reddit (/r/DailyProgrammer). The one which I am working on just now asks for an alphabetised count of the occurrences of letters in a string e.g: "Hello World" -> "d:1 e:1 h:1 l:3 o:2 r:1 w:1".
I have tried to ... |
Removing Duplicates:
/**
* Remove duplicates without using a buffer.
*
* @param head
*/
public static void removeUnsortedDuplicatesWithoutBuffer(final LinkedListNode head) {
//if the linked list is empty
if(head == null) {
throw new RuntimeException("linked list is empty");
//return;
}... |
I've coded a small command line helper tool for this library I'm working on. The library provides tools for the use of Virtual Texturing on iOS devices (mainly games).
This little command line helper is still pretty much a prototype that I coded as quick as I could, for testing a new file format. Some feedback would be... |
The point of the application is to create a school, create courses for that school, create students and register them to the school, assigning them courses based off the courses they prefer.
There are quite a few things I find messy, and hope to get some seasoned advice on it. I put comments where I found they were nee... |
I made this because I need to make a program that creates and destroys huge trees in gigabytes for hours or time. The default malloc/free in MinGW/GCC is too slow.
I wrote two equivalent test programs, in C and in Java, which does a large amount of small frequent dynamic memory allocation. The C program using the basic... |
I've started looking at Heroku for application hosting and deployment and it appears that my configuration constants need to be stored in environment variables. I can do this in Heroku, but my application might also be deployed to shared servers and it may not be secure according to this question.
Basically I want the ... |
How idiomatic is my code? Since Lua does not have classical inheritance such as in OO languages. Feedback on the test and implementation are both appreciated/welcomed.
The rules are:
If the phone number is less than 10 digits assume that it is bad number
If the phone number is 10 digits assume that it is good
If the p... |
I've recently picked up OOP in Java and I'm trying to use it for my PHP user system.
I've come up with the following generic.class. On my main site, I'll simply put include('generic.class.php'); at the top of the file before my content.
<?php
include_once('connect.class.php');
class User {
private $id;
privat... |
It is a common task for me to need to run many nearly identical child processes. Not often but sometimes I need those child processes to communicate their results back to the parent process. I have created the following implementation to avoid boiler plate pcntl_fork() calls, and standardize the client code.
I will in... |
What's a more concise way to do this? It's way too verbose for my taste.
@Override
protected void onResume() {
super.onResume();
Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1);
TinyDB tinydb = new TinyDB(this);
Log.v(TAG + "BaseStartup.onResume", "onResume");
IntentFilter intent... |
This is based on my first Tic-Tac-Toe game:
Tic-Tac-Toe in C++11
I have come up with different game logic for my game. I would like to know which one is more reliable and effective and how I can improve the whole game.
#include <iostream>
#include <cctype>
#include <algorithm>
#include <functional>
#include <array>
#in... |
Base64 is a widely used encoding mechanism to allow arbitrary binary content to be transferred as printable text. This program is designed to take binary file as input and produce a Base64-encoded binary file as output.
#include <stdlib.h>
#include <stdio.h>
void enblock( int len, char *in, char *base64, FILE *output... |
My code convert text to Base64. I used the algorithm without bit operations. What do you think about my code?
#include <stdio.h>
#include <stdlib.h>
#define CRT_SECURE_NO_WARNINGS
#define BIN 2
#define MEMORYSIZE 10
void FromSixBitNumbToDec(char *number1, FILE *result){
char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZa... |
It works fine, however it's a little messy. I understand it would be better for performance to use JOIN and have been advised before to use sprintf. However, it's pretty confusing and I cannot understand the PHP tutorials on it.
<?php
$exerciseID = get_the_ID();
$blogUrl = get_site_url();
global $wpdb;
$getImageIdQu... |
I have a small project in which I get the URL, username, password, and driver from a text file and I have to fire a query on the database by dynamically reading the jar file in a predefined directory, register the jar, get a connection object and possibly de-register it. Each query may talk to a different database sche... |
I have a tokenizer, where one of the token types happens to be a C# string type. It takes a TextReader as its input, which is created from a StringReader, and it needs to support the basic stuff C# strings supports, such as "jo dude", "joe \"dudes\"", "this is a backslash \\ token" and of course "this is carriage retur... |
Okay, so I just started learning Haskell around a week ago and this is my first real program that I worked on all of yesterday with a lot of help from IRC. I know that using indicies and arrays is not very "Haskellish" but I found constantly manipulating lists and traversing them was extremely slow and sometimes the pr... |
This code draws two sets of 9 boxes on the screen to display the contents of two arrays.
How can I speed up, shorten and make the code more efficient?
for (int x=0;x<3;x++){
for (int y=0;y<3;y++){
if (pattern[x][y]==1){
g.setColor(colorrange.colb());
g.fillRect(ac... |
I read around for a while and surprisingly didn't find a fitting solution. I need a .NET Stream that internally issues HTTP Range requests when it seeks. There are huge files server-side for which I only need small amounts of data in a very random-access way. The consumer of the custom stream (beyond my control) issues... |
Project Euler problem #1:
If we list all the natural numbers below 10 that are multiples of 3 or
5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below N.
My code is correct, but I don't know how I can optimize and make that faster.
N = gets.to_i
N.times do
a... |
Please review my Sieve of Eratosthenes implementation.
std::vector<int> generate(const int& n) {
std::vector<bool> input(n+1, true);
for (int i = 2; i * i<= n; ++i) {
for (int j = i; i*j <= n ; ++j) {
input[i*j] = false;
}
}
std::vector<int> primes{};
for (auto i = 1; ... |
This is a problem from a Coursera class:
Write a data type to represent a set of points in the unit square (all points have x- and y-coordinates between 0 and 1) using a 2D tree to support efficient nearest neighbor search (find a closest point to a query point).
I implemented the class with pre-setup API. The proble... |
Below I present to you an IQueryable LINQ to SQL query (used with NHibernate).
I have tried to simplify this query but I could not do it.
I want to run a query for searching information.
Options:
search on source or target
search with match case or not
search match exact or not
The query it seems to work but there is... |
As a follow up to a previous question, linked here, I have revised the code and developed what I believe to be a better solution.
In summary, the script should backup all files in a particular directory, and assign them to a particular zip file based on their modification dates. This should only occur for files modifie... |
I took a test at Codility called TapeEquilibrium. The task description that I received can be seen here.
I came up with a solution that worked, and I was pretty happy with. However, the performance was apparently awful. The expected time complexity is apparently supposed to be \$O(N)\$, but I got \$O(N * N)\$. I'm not ... |
What do you think of my code? I know it is a little rough around the edges but as of two days ago I had no idea how to use jQuery or JavaScript.
$(document).ready(function () {
var json = {
"205100": {
"success": true,
"data": {
"type": "game",
"name": "MasterKin... |
I have ChannelWrapper and Channel Value Object. I want to convert each and every field of ChannelWrapper to Channel Value Object.
public class ChannelWrapper extends BaseWrapper implements APIWrapper<Channel>,
APIUnwrapper<Channel> {
@XmlElement
private Long id;
@XmlElement
private User user;
... |
I have a CouchDB view with the following view/reduce function. After working over 2 hours on it, I have a result I am happy with, but I believe there is a lot of room for improvement. Basically, I would like the code a bit more slim.
map: function (doc) {
if (doc.type == 'ticket') {
emit([doc._id, doc.appli... |
I have been slowly evolving some code for Git and VSS interop based on a quest I started a while ago
And the code is now working, some parts have been updated without test (such as the init) and I am not 100% sure everything is doing what it should/is the best way and some parts seem really round the houses!
Its certai... |
Input
The input begins with the number \$t\$ of test cases in a single line
(\$t \le 10\$). In each of the next \$t\$ lines there are two numbers \$m\$ and \$n\$ (\$1 \le m \le n \le 1000000000\$, \$n-m \le 100000\$) separated by a space.
Output
For every test case print all prime numbers \$p\$ such that \$m \le p... |
This is my current code:
def search(word,source):
places = []
for x in range(0,len(source)):
if source[x] == word[0]:
if source[x:x+len(word)] == word:
places.append(x)
return places
How would I optimize this without using regular expressions?
|
I use this node.js script to migrate MongoDB collection to a schema to another. It does work if the collection is <20k documents, but slows down to a crawl and sometime throw a
FATAL ERROR: JS Allocation failed - process out of memory
Is it because of a memory leak? Or the intensive call to process.nextTick() (once p... |
A practice interview question:
How would you design a stack which, in addition to push and pop, also has a function getMin which returns the minimum element? Push, pop and min should all operate in O(1) time.
class stackWithMin
{
private:
std::vector<int> stack;
std::vector<int> minLoc;
int min, current, ... |
After a couple of small programs in Python we are now asked to do some basic stuff in Java. I don't really know where to start to improve this and whether it's even necessary.
This is an exercise, so the resulting message for when the denominator is zero should not be taken too seriously.
import java.io.*;
/**
* Cla... |
A while back I had to do a project for school in Python, creating a game or something interesting. I decided to make a memory game. The code isn't really nice and neither are the variable names. It's not supposed to look good, and all that matters is the functionality. I had done a lot of movements with the Turtle so g... |
I need to generate a T-SQL script for loading data into this table:
create table dwd.FiscalCalendars (
_Id int not null identity(1,1)
,_DateInserted datetime not null
,_DateUpdated datetime null
,CalendarDate date not null
,CalendarDayOfWeek int not null
,CalendarDayOfMonth int not null
,Ca... |
My main concern with this code is this problem - given that this program could generate a prompt string from Bash, Zsh, Fish, etc., I would like to make this code easily extendable so people can add support for a new shell simply by declaring a new Module (or through some similarly easy tactic). The difficulty is that... |
Can I make this more efficient?
#include <stdio.h>
#include <string.h>
#include <math.h>
void setvalue(int array_copy[], int i, int n)
{
int j,p;
for(j = i*i ; j <= n ; j +=(i*2) )
{
array_copy[j] = 1;
}
}
int main()
{
int n,i,l=0,sq;
scanf("%i",&n);
sq = sqrt(n);
int pr... |
Please review the implementation of Dijkstra algorithms. Points on which I have doubt:
My Graph doesn't have any ID for nodes. Nodes are accessed based on their data. Is there any general approach in that? Should nodes be referenced by an ID as that will also make these algo somewhat easier to implement by using id a... |
I learn BASH scripting occasionally from time to time, now I am working on a simple bash script that serves to maintain Dovecot user database. The general purpose of the script is able to list, add or delete user entries in the specified file. Please add some comments about the code - common mistake and etc. I want to ... |
I've written a method that takes an object whose keys are arrays and converts it to an array of objects.
I feel like the code is fairly complex, after waiting a week or so and revisiting it, I don't think anyone would be able to really understand what is going on, especially if they aren't used to this style of coding.... |
I am collecting tweets using a Python script and I want to store them in a MongoDB database.
I want to find out the lowest tweet id and for each tweet, I want to change the id field to an _id field.
Is it possible not having to iterate over all the tweets with a for loop in order to do these 2 things.
search_result = ... |
I have the ToHtml() Extension Method
public static class StringMethodExtensions
{
private static string _paraBreak = "\r\n\r\n";
private static string _link = "<a href=\"{0}\">{1}</a>";
private static string _linkNoFollow = "<a href=\"{0}\" rel=\"nofollow\">{1}</a>";
/// <summary>
/// Returns a cop... |
I am trying to follow the template provided here to create a doubly linked list in java. This homework is based on this lecture. Can someone please review my implementation?
No change to this part of the code
/* DListNode.java */
/**
* A DListNode is a node in a DList (doubly-linked list).
*/
public class DListN... |
Based on this question on math.SE regarding probabilities in variations on the Monty Hall problem, I cobbled up a simulator in Ruby to give myself an introduction to the language.
Since this is my first Ruby program, I'm especially looking for feedback regarding Ruby style, but I would love any general code improvement... |
I wonder if there is a "correct" way to display different content, based on the the state of responsive webdesign. Different in this case is meant as an abbreviated text to display instead of the full one.
I have created this example table with a couple columns, containing either the full name of a state, or, when resi... |
Please review the implementation of Kruskal algorithm. Points on which I have doubt:
My Graph doesn't have any ID for nodes. Nodes are accessed based on their data. Is there any general approach in that? Should nodes be referenced by an ID as that will also make these algo somewhat easier to implement by using id as ... |
Please review the implementation of Prim algorithm. Points on which I have doubt:
My Graph doesn't have any ID for nodes. Nodes are accessed based on their data. Is there any general approach in that? Should nodes be referenced by an ID as that will also make these algo somewhat easier to implement by using id as ind... |
I am using a checkbox to filter some components on my ListView by changing the variable's content which is bound to this ListView:
C#
#region Constructor
void CreateAllParts()
{
// GetParts() returns List<Part>. Now we can pour it's results
// using the following select in List<EditPartViewModel> on the
... |
I've coded my own proxy class in python. The aim is to have a different type() but otherwise behave as identical to the underlying object as possible. I'm wondering if there's any problems with it or any use cases where it won't work.
Something strange I've noticed is that Proxy(1).__class__ is int, which isn't very de... |
This is the batch file i have created which copy the specific folders which I want. I use the specific server folder name of which I want to copy. Please suggest any improvements.
@echo off
:: variables
echo This script takes the backup of file SwiftALM Important folders
set /P source=Enter source folder Example D:\jbo... |
Background
Unsatisfied with existing implementations of Miller Columns (used to edit hierarchical data), I decided to re-invent the wheel.
Problem
Most of the existing implementations are too complex, offer extraneous functionality, reliance on complex (or unavailable) frameworks, have numerous dependencies, are riddle... |
I'm not a beginner to programming, but I am to programming in OOP (effectively at least). So to learn better I wrote an object oriented game of Snakes and Ladders. For background, see this question.
I wrote four classes: Board, Cell, Portal, and Player. All are self explanatory except for Portal. A Portal object repres... |
I have this code working for submitting a form using PHP and HTML (Bootstrap). I did not post the CSS, so I hope this is not an issue.
I am interested if this code is clean, following good practices, secure etc.
Are the headers needed?
Do I need to declare and initialise all those variables?
Do I need <?php if (!empty... |
I have a simple static class that it's purpose is given an RDD of Point to find the median of each dimension and return that as a new Point using Spark's reduce functions.
This is the class:
public class MedianPointFinder {
public static Point findMedianPoint(JavaRDD<Point> points) {
Point biggestPointByXD... |
I have a data set with close to 6 million rows of user input. Specifically, users were supposed to type in their email addresses, but because there was not pattern validation put in place we have a few months worth of interesting input.
I've come up with a script that counts every character, then combines it that so I ... |
I have a situation where I am receiving data from a web service and the data is in all caps. I have to convert to HTML and format for display. In this case, we need the string to be normalized. The XML we receive has the possibility, and most of the time is, large, sometimes being over a MB in size. Performance is ... |
I have a huge class taking care of companies informations in my app. Arrived at 4000 lines of code (!), I finally decided to break it up. However I am not too sure if the way I am doing this is the best. For example I had shareholders functions in the company class taking care of returning one or all, editing, adding, ... |
I decided to subclass SKSpriteNode for a game test in Swift today and soon realised that it was not as simple as my Objective-C background suggested. After a little hunting around and a bit of testing in Playgrounds I have come up with the following (See below). I have not tested this in a project as I am just starting... |
The following responsive navigation on JSfiddle works well, however I am just wondering whether there is any way to improve what I have done. I am new at JQuery so all help appreciated: JSFiddle here
$(document).ready(function () {
$(".menu").click(function () {
$('#menu').animate({
'left': '0p... |
Here is code that will output maven coordinates from given pom.xml file. How can I remove boilerplate (possibly convert it to xml picklers)?
import Control.Lens ((&))
import Text.XML.HXT.Core
import System.Environment (getArgs)
import Text.XML.HXT.Arrow.XmlArrow
import Control.Monad (liftM)
import Data.Maybe
import Con... |
Some definitions:
#define _count(total) for (int count = 0; count < total; count++)
#define _xyCount(x,y) \
for (int xCount = 0; xCount < x; xCount++) \
{for (int yCount = 0; yCount < y; yCount++){
#define _xy }}
I just use these to save time. The _xy is used cause if I don't, VS will act weird. Now fo... |
This takes over 60 minutes to execute. The program is small in size, about 16kb. I am thinking that the repeated calls to printf slows it down significantly, rather than the nested for loops.
I used:
gcc -Wall -o charsprint charsprint.c ./charsprint
Without removing the printf call: How could this source code be sm... |
Using the table data gateway (TDG) pattern, I created a class QuestionGateway for retrieving, adding, updating, deleting, and sorting multiple-choice questions.
class QuestionGateway
{
private $dbh;
public function __construct(PDO $dbh)
{
$this->dbh = $dbh;
}
/**
* Find all test quest... |
Of course the when this select is comes with less options it will be better to leave it like this, and when it comes more then this it better to make it via loop.
The question is that if I should make it loop or leave it as it is ?
which way is the best and why ?
var htmlTemplate =
"<select class='action cycle' a... |
I wrote (several months ago) a program that will take an input file, with a provided std::string, and append that to each individual line in the file. Looking at the code again, I am wondering about the performance of this program, possibly if the file is very large or any of the lines/input string is long.
#include <f... |
I need a function I can put on a form which does:
Calculates number of working days until a given date
Excludes weekends
Excludes any dates in a "holiday" table
This is replacing something which looks like:
=DateDiff("d",Now(),[DateEstimatedDesignStartBy])
with
=getWorkingDaysUntilDate([DateEstimatedDesignStartBy]... |
I have a long-running task. My goal is to create a method that will allow me to:
Asynchronously wait for this task to complete
While waiting on a task, do some async action once in a while. This
'action' basically tells some remote service that task is not dead
and still executing.
I've written the following code to ... |
#include <iostream>
using namespace std;
class Math
{
private:
int answer;
public:
/*void getAn()
{
cout << answer;
}*/
int add(int x, int y)
{
cout << "Add two numbers:\n";
cin >> x;
cin >> y;
answer = x + y;
return answer;
}
int sub(int x, int y)
{
cout << "Su... |
This is a script I made while having trouble with xautolock and dimming of the screen right before locking it. I would like some tips for making it a bit more robust and to know of any disadvantages of it. I don't know how it works with multiple screens but I suspect it does not.
#!/bin/bash
# Lock screen in:
minutes=... |
As it currently stands the code works fine. Is there a way to optimize the code in the class Neighbours? What I have done was to copy the code for each of the adjacent 8 neighbours of the cell and implemented a try catch ArrayIndexOutOfBoundsException. Is there a way to optimize it by use of arrays or a different metho... |
I have made an AVL tree. It works and does what it needs to do. I only need it to insert and search. I am comparing how long it takes to load and search a dictionary file in relation to other various data structures. My AVL tree takes 25 seconds to load the file.
This is in comparison to hash tables that took only thr... |
Here is a class I made that is able to ask a teacher what percentage their student has in a class and gives them back a grade. The code is very repetitive and I am wondering what I can do to simplify the class below before inputting any more grades.
import java.util.Scanner;
public class Grades{
public static void... |
I need some help with my register and log in functions. I'm not sure if I have understood bcrypt correctly either. I'm doubting the security of it, what do you think?
Is this good, or are there any changes I should make? Have I missed anything?
For the database table users, I created (ID, username and password[char:60]... |
I'm currently in the process of refactoring a Django app to use Django REST Framework. Within the existing code there are 15 models for lookup tables. The structure of each model is as follows (using gender as an example - there are valid reasons in the context of the application for including a gender model rather tha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.