instruction stringlengths 71 71.9k |
|---|
I am working with an encryption algorithm that looks like this
The key is a number stored in 4 bytes.
For each byte in the message, XOR it with the corresponding byte in the key
When you reach the end of the key, multiply the key by 13, and then continue looping
Translated, it looks like this
for (int i = 0; i < data... |
I'm developing an application that receives and manages e-mails from a server. I manage only XML files and organize, by sender, the e-mails that have XML attachments, while the others are deleted. I create a list of files and create them in the temporary folder. I have a feeling my JavaMail process is slow because i... |
This is the most basic code to join two tables in a database. For tables it uses a simple list. Solved this using brute force, sorting and using hashtable.
final class SportsMan {
private final String name;
private final int rank;
private final String sport;
public SportsMan (String name, int rank, St... |
I have an homework as follows:
Write a program where you enter from the keyboard a number n. Then n
stars are drawn onto the screen, circling around the center of your
screen. You can assume that 1 < n < 20.
The solution I came up with is below.
import turtle
window=turtle.Screen()
window.screensize(1200,1200)
... |
I'm working on a page using AJAX that will get an entire .php page when the navigation button is clicked. I have that set up and working right. But this is my first time using AJAX, so I'm not sure what the best practices are and what I can do to prevent failures and display error messages.
$(document).ready(functio... |
I'm working my way through The Java Programming Language, Fourth Edition - The Java Series. This is Exercise Exercise 20.3:
Create a pair of Filter stream classes that encrypt bytes using any
algorithm you choose—such as XORing the bytes with some value—with your
DecryptInputStream able to decrypt the bytes tha... |
Is there a better algorithm for finding the common divisors of two numbers? Can this code be shortened?
import java.util.*;
public class Testing1 {
public static void main (String args[]){
Scanner x=new Scanner(System.in);
System.out.print("Enter the 1st number(larger number) : ");
int y=x.nextInt();
... |
Testing on localhost, it takes a bit longer to get the results than I would like and gives me this PHP error:
Fatal error: Maximum execution time of 30 seconds exceeded
I am wondering if there is any way to stop that error from happening, as well as making my class faster to fetch results.
<?php
class MinecraftAPI
... |
I'm currently reading a certain pixels color from a process window like this:
[DllImport("gdi32.dll")]
private static extern int BitBlt(IntPtr srchDc, int srcX, int srcY, int srcW, int srcH,
IntPtr desthDc, int destX, int destY, int op);
public static Color GetPixel(IntPtr hwnd, int ... |
first time visiting Code Review. I figured this was a more appropriate spot than SO for this question. Here goes...
Currently, I have a php function that converts bbcode format text in to HTML (among other things). A code snippet is as follows...
function bbcode_format ($str) {
$simple_search = array(
'/\... |
While coding today, I came across the following loop in C#:
for(int x = 0; x < max_x_index; x++){
for(int y = 0; y < max_y_index; y++, count++){
some2DarrayRepresentedBy1D[count] = ...;
}
}
Would this be consider bad practice? Would the following be a better way to achieve the same result:
for(int x ... |
I've written a very basic Python 3 script to search ThePirateBay. Since the tracker doesn't have an API, I had to parse the HTML using BeautifulSoup. I'd like to get some reviews, I'm pretty sure the code is crap, so fire away. I'm also interested in projects I could read to improve my Python.
#!/usr/bin/env python3
f... |
Weekend Challenge #2 - Poker Hand Evaluation
Finding a straight with wildcards
Because of a size limit on Code Review I have to split my weekly challenge result in two, and here is a part where I think there is some room for speed optimization. I started writing this method in another approach, but after several hours ... |
Weekend Challenge #2 - Poker Hand Evaluation
Very early I decided to support the usage of wild jokers, even though I knew that this was going to lead to trouble more work. I also wanted to support big collection of cards, for example if you have 7 cards and choose the best 5-card poker hand of these. Of course, combina... |
I'm trying to teach myself Objective-C/Cocoa for eventual iPhone development but I figured I would start with a terminal app. It takes a user input, strips everything but numerics, then displays PI to the number that is left over.
Could anyone have a quick look over my code and see if there's any optimisations I could ... |
I have a small module that gets the lemma of a word and its plural form. It then searches through sentences looking for a sentence that contains both words (singular or plural) in either order. I have it working but I was wondering if there is a more elegant way to build this expression.
Note: Python2
words = ((cell,),... |
I have created the following code:
class Club(object):
def __init__(self, name, points=1000):
self.name = name
self.points = points
def __eq__(self, other):
return self.name == other.name
def __gt__(self, other):
return self.points > other.points
def compute_points(sel... |
This might be a basic question for C. I'm making a struct called check_t and I want to make an array whose elements are of type check_t. This array is called enqueued. The struct check_t contains an integer x and a lock (for multi-threading).
typedef struct _check_t{
int x;
pthread_mutex_t lock;
} check_t;
void *c... |
Question: Is having a master class bad practice? I am making a simple pong game, but I'm writing the code as if I were making for something that might be for something more complicated I want to create in the future. Also, am I not doing it in a good manner?
What I am doing: I have a class, in this case "engine", whic... |
I have started some experiments with node.js.
Any comment on style (especially the callbacks) and best practice is appreciated:
PassportControl.js
/*
* Export single function that creates the passportControl object
*
* The passport control object is supposed to be a wrapper for
* nodejs/express/passport a... |
More javascript (nodejs) to go with the passport wrapper I just posted:
UserBook.js
/*
* A wrapper for user Registration for a web site.
* This is an MYSQL version of the client to provide persistent state.
*
* Exports a single function that returns the object (UserBook) that does the work.
* UserBook exposes tw... |
This program is compiling just fine, and the variables and such seem to be passing through. However, when I open the text file there is no data. Can anyone point me in the right direction or nudge my brain into the right process thought?
package dvdlogger;
import java.util.*;
import java.io.*;
public class DVDLogge... |
I wrote a Heap, but the judge system reports "time limit exceeded" in some tests. I use a sift_down to build, so I don't know why.
Maybe I can improve the build? Or do I have a bad sift_down?
Input:
n commands
Commands:
0 xxx, where xxx is a number to add to heap
1 - extract maximum from heap
#include <iostream>... |
I am now working on a Node.js project, and on my ejs view page, I'm retrieving this array of objects, like:
[{ name: 'Andy',
age: 20,
username: 'andygoodluck'},
{name: 'Terry',
age: 21,
username: 'terrygoodnight'}]
My objective is to make use of this data to dynamically create and inject content using Ja... |
I've just created a small class to reverse date in PHP. I'd like to see whether or not it's good and can be improved.
<?php
/**
* Reverse date and hour
*/
class ReverseDate
{
var $date;
var $hour;
var $error;
/**
* Checks if the date has hours
*/
function exec($data = null, $timestamp ... |
I'm trying to use the good parts of Javascript and dont follow the classical inheritance.
I studied and created this example of compose in Javascript, https://gist.github.com/fernandoperigolo/7789866.
My question is. You think this example have a good implementations of composition? Can i go ahead with it? If not, What... |
I'm writing a SDK for a NFC device in .NET so I don't have to import the SDK from C++. Right now I'm working on the ISO14443-3 part which is just simple Halt, Request, and Anticollision commands. The communication part between the device and computer is simple enough so I'm not going to post any of that. Just know that... |
Sometimes, when you're doing something like displaying a bunch of elements, you can avoid running a function entirely if an object is hidden.
So you can either write the check from the loop:
for( Displayable * d : displayables )
if( d->isShowing() )
d->draw() ;
Or you can put an "early return" in d->draw()... |
I get the following correct results from this code, but it seems incredibly clunky to me. Is there anything I could be doing more elegantly? The results can be imprecise - as long as it's the right number of returned elements, and the selection is mostly right.
$_5elements = array(1,2,3,4,5);
$_10elements = array(1,2,3... |
As I am new to bash scripting, and want to use apt-get in my university. I know that many people have issues when trying to do so. My focus is simplicity and ease of use, but still need to be somewhat robust.
#!/bin/bash
string="install"
errormsg="\n\tInvalid input\n You should run this script with the following st... |
Example Script is located in /home/insp/public_html/deploy/
I want to return the /home/insp/ section
$path = realpath(__DIR__);
$parts = explode('/', $path);
$newPath = array(
$parts[0],
$parts[1],
$parts[2],
);
$realPath = implode('/', $newPath);
... |
I'm no pro in JavaScript. Please help me review this code. I would appreciate any suggestions!
JavaScript:
var y_offset, /*current position of window*/
distance_from_current_position, /*different between current position and target*/
body_height, /*hight of body*/
window_height, /*height of window*/
pos... |
I've been running through The Little Schemer, and have hit the example of Peano multiplication. The solution is given in TLS (reproduced below) -- however what interests me is the order of the algorithm.
(define mX
(lambda (n m)
(cond
((zero? m) 0)
(else
(+ n (mX n (1- m))))
)))
My un... |
Several of my Python 2.7 programs need to access server tasks via our server Apache instance.
The 'client' programs will run on Windows in various environments. They may be run on systems that do not use a proxy, or on systems that use a proxy with no authentication, or enterprise systems that use an authenticated pro... |
I've just stumbled upon something today that seemed "unethical" in PHP. What I originally thought as malpractice, turned out to work just fine. Basically what I was wondering is if pushing an instantiated class in an array was considered proper?
Example:
$array = array();
array_push($array, new myClass());
foreach($a... |
I have written this code which adds a querystring to a URL:
exports.addQueryString = function(url, queryString) {
var isQuestionMarkPresent = url && url.indexOf('?') !== -1,
separator = '';
if (queryString) {
separator = isQuestionMarkPresent ? '&' : '?';
url += separator + queryString;
}
return u... |
I've tried using CRTP, but the forces the class to befriend CRTP Base.
template <typename T>
class SharedConstructable
: public std::enable_shared_from_this<T>
{
typedef std::shared_ptr<T> ptr_type;
public:
struct Ptr
: ptr_type
{
template<typename... Args>
Ptr(Args&&... args)
... |
Thanks for taking the time to read this.
I submitted a code screening for a company I really wanted to work for and spent a decent amount of time on their programming assignment. Pretty bummed when they just said thanks but no thanks.
Could you guys take a look and see why that might be? I was hoping to at least talk ... |
I've been chewing through a bit of The Little Schemer and the Peano examples got me thinking about operation size and time.
I got some help on making Peano Multiplication linear -- however (time ...) didn't show much difference between a lexically scoped version and the let-loop version.
I do however find a massive d... |
In this, we are given an array of numbers, say 1 2 3 4.
We start from a given position, let's say the 1st position.
We cancel that number and move forward that many non-cancelled numbers. The number on which we stop again has the same procedure.This is repeated until only one number is left. That is the lucky number.
1... |
I have this query:
SELECT * FROM
(SELECT u.id,u.email,u.verified,u.verified_on,u.created_on,ca.html AS age,cg.html AS gender,cs.html AS state
FROM users u
LEFT JOIN combo ca ON ca.combo_group='age' AND ca.value =u.age
LEFT JOIN combo cg ON cg.combo_group='gender' AND cg.value =u.gender
LEFT JOIN combo cs ON cs.combo_gr... |
I have a pretty simple problem. A large set of unique strings that are to various degrees not clean, and in reality they in fact represent the same underlying reality. They are not person names, but they could be. So for example Dr. John Holmes and Dr. Jon Holms are more than likely the same person. From the list of un... |
I was trying to make my life easier making a class or something that would create HTML tags in a faster way. I ended up with something that I wouldn't consider the best practice. Take a look:
/**
* Add HTML to the page
*
* Add HTML to the page based on arrays with the tag names. It's gonna open and close the tags.
... |
During work, I was given this task: to group elements with similar properties in the array.
In general, the problem is as follows:
var list = [
{name: "1", lastname: "foo1", age: "16"},
{name: "2", lastname: "foo", age: "13"},
{name: "3", lastname: "foo1", age: "11"},
{name: "4", lastname: "foo", age: "... |
I need to write code for the given problem:
I'm provided with a word and I need to find all the possible combination of it that matches with a given list of words in a file.
Here's my code. Can I make it much better? I'm sure it can be done. Please offer suggestions.
dict = {} ... |
The goal of this code was to create a table from an associative array.
I need to create horizontal rows where the keys need to be used as "headers" while the values are posted below each header.
I need to be able to reuse the code with associative arrays of unknown lengths and varying number of columns allowed in t... |
Assume the server is sending data to our app at regular intervals, at least once per second. The received data is parsed and stored in memory as a POJO. A blocking queue is processing data in a worker thread.
Suppose I want to use a very simple object pool, so I don’t have to create a new POJO for each server response.... |
Being new to raw JavaScript, intervals and times this was not the easiest script to come up with, and thus, although it seems to be working as I want it too the code looks very clunky.
The timer counts down to one of 4 times of day: 8am, 2pm, 8pm or 2am depending on which is the closest. Because they are at six hour in... |
This is a copy of a posting I made on SO, it was suggested I post it here all I've changed from that post is I'm now doing the bitwise AND using a decimal number rather than using bindec("111") to create the mask. The output is identical.
I have a 32 bit number represented as a HEX string that I need to convert to a ti... |
Think of a set of text lines starting with a common string, e.g. indented code.
my $preamble = reduce {
my $len = min(length $a, length $b);
--$len while substr($a, 0, $len) ne substr($b, 0, $len);
return substr($a, 0, $len);
} @lines;
Note that after the first invocation chances are high that $a already h... |
I'm new to Java and am trying to solve a scenario. Even though I've succeeded and it works, I've just wondered if there was a more practical way of doing this task. Is there a quicker or more efficient way of solving the task, or is this fine?
Task:
Given a string, return a version without the first 2 chars. Except
... |
I wrote this program for an assignment, thus I had some requirements as far as the format of the cfg.txt file and some basic other classes that we had to use. Other than that, I am curious if there is a way to drastically simplify this code. Although the program runs fine and produces the desired output, is there a bet... |
so this is my code and I just want to improve it, I'm a beginner so I think there are some better and short ways to do what I did here. Any Ideas?
The code:
class Table:
def __init__(self,path,sep):
self.path=path
self.sep=sep
self.g=[]
self.count=0
self.headlines=[]
... |
I'm trying to write a simple game. I have an Entity object, that has a list of Sprite objects. Each Sprite has a position property where it is drawn on the screen. Sometimes, an entity can contain a lot of Sprites in which case it is much easier to set the position property on the parent Entity.
Here's a simplified exa... |
Coming from an imperative background, I have written the following code in Scala. I need to attempt to find a value in a map. If the value exists, I need to pass the value to another function and return the result, otherwise I need to return None.
def foo(index: Int): Option[FooBar] = {
val mylookup: Map[Int, Strin... |
I am trying to re-factor (improve design of existing working code) with the following principals:
Switch statements removal.
Encapsulate Field
Extract Class
Extract Interface
Extract Method
Extract Subclass
Extract Super Class
Form Template Method - Before
Move Method - Before
Introduce Null Object
Replace Error Code ... |
The context is Weekend Challenge #2 (Poker hand evaluation).
Hand.prototype.isStraight = function()
{
for( var i = 1 ; i < this.cards.length ; i++ )
if( this.cards[i].value + 1 != this.cards[i-1].value )
return false;
return true;
}
cards is an array with card objects { suit : "x" , value : "0->12" }. T... |
This is one of my Haskell solutions to a variation of the N-Queens problem, where the queens can move like knights in addition to their normal moves. It has been optimized somewhat to avoid investigating redundant combinations.
place :: Int -> [[Int]]
place 0 = [[]]
place n = go $ take n $ repeat [1..n]
where go ... |
I'm working on an open-source test framework which needs to dynamically import Python source modules from a given directory.
I can't just use importlib.import_module() or __import__(), because it's a black box and I need to do some source-code-rewriting. On the other hand, I feel the PEP 302 Import Hooks to be overkill... |
My Game class has a property of type Player, which inherits from Entity:
player = new Player( "knight.png" );
It also has a property of type World, which has a collection of Entities (Robot inherits from Entity):
world = new World( new List<Entity>
{
new Robot( "guy_1.png" ),
new Robot( "guy_2.png", new MoveBe... |
I started a Chess in Python for fun. I learned Python in my free time but I've been doing it for a while. The code works but I just want to know if there's anything non-pythonic in my code. The functions calculate all potentially possible moves (ignoring game state).
from itertools import product
from itertools import ... |
Here is some code of mine that prints out the relative date according to the current time:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (int argc, char *argv[])
{
int i = 1;
struct tm date = {0};
char relativeDays[80];
char* temp = strtok(argv[1], "/");
while(temp != 0)
{
switch(i+... |
This code is supposed to delete every node from a linked list with a given value.
Are there any logical errors with this implementation? Did I do anything wrong or is there an area of this implementation that needs significant improvement. Any suggestions?
public boolean delete(int d) {
Node tmpNode = head;
... |
I'm using PHP, MySQL, Smarty, jQuery, etc. for my website. I'm using an MVC architecture to develop the website. Now in one of the functionality I'm fetching a large amount of data and perform some processing on it. Then I'm returning the finally processed data from model to the controller and assigning it to the Smart... |
I'm new to Scala, and would appreciate any notes about a better approach, correctness, or style.
/**
* Call proc(f) for each file in the directory tree rooted at dir.
*
* proc will not be called for directories, just for files.
*/
def traverse(dir: File, proc: File => Unit): Unit = {
dir.listFiles foreach { (f... |
I have an array of 1000 numbers, randomly generated. 10 of those numbers must be between 0-9 (including 0 and 9), and 10 of those numbers must be between 991 and 1000 (including 991 and 1000). This is what I came up with:
arr = []
980.times do
arr << (11..989).to_a.sample
end
arr2 = []
10.times do
arr2 << rand(10... |
Please review the code and suggest better algorithm to efficiently extract key/value from files using multithread.
Input : FormNGFAddTab:First add Tab control inside Tabs control.परीक्षण
Output :
Key : FormNGFAddTab
Value : First add Tab control inside Tabs control.परीक्षण
Separator : ':'
DataHolder/DataStructure : An... |
I'm writing a code for my application: you can create a task, and you can choose the moment when you want to send this task (to some kind of user):
Send now
Send later
Repeat
You can select from above options. If you choose send later, you'll be prompted for a date:
And there are variety of options if you choose Re... |
I am creating a string extension to validate some input.
My scenario is when we have a string it will format it according to following guideline.
If the sample string is “One Two Three Four Five” and the length is <=20 return same. If more than 20 then “One Two Three F Five”. If still length is more than 20 the “One Tw... |
I have often encountered the following situation. I want to call a method in a Loop, but want to skip the call at the first run. It do not have to be a method, it also can be some lines of code that I want to skip. Here is one example:
I have a file which looks like that.
headline:headline1
content:lorem ipsum dolor si... |
How can I write this shorter (while keeping the same functionality and outputs to console)?
def review():
v1 = value_of_current_cards(hand_one)
v2 = value_of_current_cards(hand_two)
v3 = value_of_current_cards(hand_three)
vd = value_of_current_cards(hand_dealer)
if number_of_hands > 0:
print... |
What are the better solutions possible?
I have a character array with different strings. There is a max size for the strings. In case a string is smaller than max size remaining places are filled with '-'.
Sorting has to be done on this.
Example:
maxStringSize = 5
totalStrings = 4
InputArray: w,a,t,e,r, c,a,t,-,-, f,i... |
I'm trying to improve my javascript coding style and want to start writing my code more object-oriented. The code below is getting a JSON-stringified list of locations from a cookie and appending a li to a list for each location. I would appreciate some helpful critique and any general pointers. I have some questions t... |
I'm making a little Python script that reads a text file and puts it on a HTML page. I haven't finished that part yet, but I've been working on the GUI with tkinter. Is my code sloppy?
from Tkinter import *
import time
from datetime import datetime
#init variables
global r
r = 0
global delay
delay = 1000
#for testing... |
This was the most humerus coding I've ever done. It's for my string library in C. It detects if the user is angry to various degrees, namely str_isHeated().
Why?
Ever play a text-based game and you're swearing at the computer by typing, typing multiple !!!, and the computer responds very dumb? I think it may be useful... |
I wrote my first AJAX script that brings content from other pages without refreshing the entire page. I just want to see if improvements can be added to it, or if I'm doing something not recommended.
$(function(){
// content container content loader
$("#nav-tabs-list a").click(function() {
var page = t... |
I'm considering releasing a library as a bower module. Are there issues with code quality, missing test cases, that need to be addressed first? Perhaps it's not a good candidate for public release. If so, why not?
What level of documentation would you want for something like this? I've seen some open source modules... |
I have created a program which rolls a die according to the number of sides that the user enters:
def var():
import random
dicesides = int(input("Please enter the amount of sides you want the dice that is being thrown to have. The dice sides available are: 4, 6 and 12: "))
script(dicesides, random)
def s... |
I'm late to this weekend challenge (sorry), but since it's all in good fun, I hope that's ok. I'm no poker player, though, so I may have completely overlooked something.
The Hand class does the evaluation, and calculates (among other things) a score array which is ordered for possible comparison with another poker hand... |
I had to work in the Transport Problem and we're asked to try to make the fastest code for big matrices, so we're advised to try to avoid loops. And the only one I've got and I cannot imagine how to simplify it is this one for making an incidence matrix (with 1s, 0s and -1s) like that:
b<-diag(-1,n2)
a<-b
for (i in 1:(... |
I write a metric ton of queries for an Oracle environment every day. These are reports that often require multiple separate queries that no end of joins and sub-queries will satisfy, hence lots of separate queries.
I find myself rewriting this bit of code all too often:
try
{
using (OracleConnection conn = new Orac... |
To detect int overflow/underflow in C, I use this code. What might be a simpler and more portable way of coding this (that is, fewer conditions)?
Assume 2's complement and don't use wider integers.
int a,b,sum;
sum = a + b;
// out-of-range only possible when the signs are the same.
if ((a < 0) == (b < 0)) {
if (a < 0... |
I've got a homework that is about methods. So first part is
Write a method that prompts the customer for the car type. There are
three acceptable car types (E: Economy, M: Midsize, F: Fullsize). Your
method will return a valid car type.
But the thing that I don't understand is, should I read input from the user ... |
I have been working on this code for quite a while and just want to make sure it is up to good standards. I know many of you will have questions, so as they come up, I will edit my initial question to provide you answers. So any ways to make this code more concise would be great. Be gentle on me, I am only a beginner.
... |
//rename files
if(!empty($_FILES[$desktop_fieldname_1280x800]['name'])){
file_exists($desktop_filename_1280x800 = mb_strtolower($desktop_dir_1280x800 . 'wall_desktop_1280x800_' .
$_FILES[$desktop_fieldname_1280x800]['name']));
}
if(!empty($_FILES[$desktop_field... |
According to Donald Knuth in "The Art Of Computer Programming", the following is how to find the greatest common divisor of two positive numbers, m and n, using Euclid's Algorithm.
Divide m by n and let r be the remainder.
If r is 0, n is the answer; if r is not 0, continue to step 3.
Set m = n and n = r. Go back to ... |
I have this class for use in sorting strings such that if strings have a number in the same position it will order the numbers in increasing order.
Alphabetical gives:
file1
file10
file2
What I'm calling "number aware" string sorting should give:
file1
file2
file10
Here is what I have using a regex split from there... |
Below is a script I wrote today to use CURL to monitor the length of various HTTP server outputs and output a response if this is different than 103 characters.
This is my first bash script, so I had some reading/experimenting to do and it is quite rough.
The idea is that if there are no errors, my php script will oupu... |
I have the following code that gives me the indices of an array's largest value:
public static void main(String[] args) {
float[] elementList = new float[7];
elementList[0] = 8F;
elementList[1] = 5F;
elementList[2] = 4F;
elementList[3] = 3F;
elementList[4] = 0F;
elementList[5] = 8F;
ele... |
I wrote a simple Polynomial class:
class Polynomial
def initialize(coefficients)
@coefficients = coefficients.reverse
end
def to_s
return '0' if @coefficients.all?(&:zero?)
@coefficients.map.with_index do |k, index|
" #{Polynomial.sign(k)} #{k.abs}x^#{index}"
end.reverse.join.strip ... |
For a WPF application, I have to sort the items in ObservableCollection after Added new item.
public void UpdateSource(ObservableCollection<SomeType> source, SomeType newItem)
{
source.Add(newItem);
SortSource(source, newItem);
}
private void SortSource(ObservableCollection<SomeType> source, SomeType item)
{
... |
Please review my code and let me know of any additions or modifications that would make this even more useable.
The initial idea was to create a simple Time class that has only one function: To represent an instant in time.
I've created this mainly because I found NodaTime to be way more than I needed.
So here it is, ... |
I received this question at a C++ programming interview:
void memcpy(char* dst, const char* src, int numBytes)
{
int* wordDist = (int*)dst;
int* wordSrc = (int*)src;
int numWords = numBytes >> 2;
for (int i = 0; i < numWords; i++)
{
*wordDist++ = *wordSrc++;
}
int whatisleft = n... |
This is a console app I wrote for an end-of-chapter assignment in Jumping into C++. The parameters were for it to have a basic password system, and if you are eager, a multiple password / username system. I am going through this book completely on my own free will. It's not through a school assignment or whatnot.
It ... |
Our instructor told us to create a basic Java program using everything we've learned in class thus far (basic prints, selection structures, looping, GUI, arrays, etc) and being a Pokemon fan, I decided to make a basic GUI Pokedex that lets the user search for the details of a particular starter Pokemon.
This program al... |
Another script that is used as a token to extract information from a 3rd party application, the application does other things in the background that I don't specifically know about.
This code does work inside the parent application and produces the expected output.
Is there a nicer way to write this code?
Public Fun... |
Minecraft is a game which also has multiplayer capabilities. You need to have an account (which needs to be verified) for playing on servers. The authentication procedure looks like this:
Authenticate at the Mojang (creators of Minecraft) server with username and password
Retrieve a session id
Contact the server you w... |
The following is used to create a masonry effect with varying height rectangles. How can I simplify and make this more elegant in Unity?
private float startX = 0.0f;
private float startY = 0.0f;
private float posX = 0.0f;
private float posY = 0.0f;
private float prevWidth = 0;
private float prevHeight = 0;
private int ... |
In various projects I need to enumerate all files and folders from a specific root folder, either on a local drive or across a network. I've broken the task down into two IEnumerable implementations as follows:
static IEnumerable<string> EnumeratePaths(string root)
{
if (root == null)
throw new ArgumentNul... |
I'm building pretty big application and I wonder how should I share the code between asp.net mvc website and standalone (self running) server application.
I've got some idea how I should do this but I'm not sure if I'm doing this right.
I've got Domain Entities, Services and Repositories that will be shared between a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.