instruction stringlengths 71 71.9k |
|---|
I have lots of external shell commands to run.
So I gave every command a name and then run it.
tar_report_cmd = 'zip -r {0} {1} '%(report_file, _export_dir)
exec_proc(tar_report_cmd)
mv_report_cmd = "mv {0} {1}".format(report_file,report_dir)
exec_proc(mv_report_cmd)
But it looks sort of redundant and not beautiful.
... |
public static void streamReport(this Report report, Stream stream)
{
using (var streamWriter = new StreamWriter(stream))
{
//some logic that calls streamWrite.Write()
streamWriter.Flush();
}
//Should "return stream;" here ?
}
I am writing an extension method to an object in which... |
Can someone review my code which I put on exercism.io for the word-count exercise (found here)?
class Phrase:
def __init__(self, phrase):
self.phrase = phrase.strip().lower().split()
def word_count(self):
word_dict = {}
for word in self.phrase:
word_input = ''.join(e for e i... |
I have used INotifyPropertyChanged for both Model and ViewModel. Is it correct?
First of all I was trying to use INotifyPropertyChanged only with Model, but for that I had to use observable collections in UI class.
Please comment on my design.
MainPage.xaml
<phone:PhoneApplicationPage
x:Class="LocLog.MainPage"
... |
I have written a script that sits on the admin portion on my website.
Here I assume the user is valid as I have code that checks that already.
The below code is checks if the user is Admin. If they are Admin they will be flagged with a "Y" on the database (this will be a "1" for optimization later but for sanity's sak... |
I have spent the last 6 months as I am studying web development in college to build a website template that is responsive and accessible from as many devices and browsers as possible.
I would really appreciate it if someone reviewed my HTML structure, CSS and share their opinion with me, my aim is to make this site ap... |
because Arduino platforms are fairly limited in its capacities, I wrote a small process scheduler. I append a function to an array and define a tickrate. After this tickrate elapses, the function should be called. Additionally I set a small delay. If several function share the same tickrate, this delays hinders them to... |
I am new user of CodeIgniter and I am trying to build an application that there are lots of jQuery dynamical content.
Below I provide a code that I am using in order to be precise. The code below is running and I cannot see any problem. However, since I will be using pieces of code like this in several different parts ... |
I have been collecting snippets from all over the place and then put them all together creating the following .htaccess file.
I really don't understand if what I have done below is good/should work as expected, so your opinion is really appreciated.
I also don't understand the bit just after #Leverage Browser Caching. ... |
I want to parse a command line using boost.program_options. Most of my command line arguments will be intervals, which I could implement as something like --x-min=2000 and --x-max=2500.
However, I thought about adding a class that can be written to/read from streams that allows me to handle an option of that reads --x=... |
This code works. It is designed to retrieve website data directly, parse it, and open it as normal. I will develop it further later. Right now I want to know if there is any way to improve efficiency, such as not using a file etc. I would also like to know if my code could be made more pythonic (this would include PEP ... |
I would appreciate some insights / comments from Clojure regulars out there about my submission here.
(ns phrase)
(require '[clojure.string :as s])
(defn word-array
[phrase]
(-> (s/lower-case phrase)
(s/split #"\W+")))
(defn word-count
[phrase]
(-> (word-array phrase)
(frequencies)))
|
I created the following HtmlHelper extension method for my Asp.Net MVC Razor views because the ternary syntax sucks when you need to use it intermixed with markup.
Is there a better way to write this and are there any potential type safety issues with it?
public static string GetValueTernary(this HtmlHelper htmlHelper,... |
I am not a big fan of JS, but have been forced to use it in this situation for various reasons.
My task: Download a URL to a target file, and update another part of the application with the current percentage.
I've run jslint and jshint over the code, and it seems happy, but I am sure there is still plenty of suboptima... |
I have created a simple class that maintains a pool (with maximum size) of objects. It acts like a connection pool (that is where the name came from - initially it was used just to maintain a pool of SMTP connections). When an item is retrieved - if the pool is not empty, a value is retrieved from it; if it is empty, t... |
I have a JPanel (mainPanel) with CardLayout which contains 4 JPanels (childPanel).
Each childPanel contains:
a JPopupMenu with 4 JMenuItems to switch between the childPanels (First,Last,Next,Previous)
a label with the time when it got visible
a toggleButton that shows/hides the label
I created this working version bu... |
I currently have a ResourceManager class which is responsible for searching for resources with a given identifier, returning a reference counted pointer to the resource if a valid resource is found, and instantiating a new object if none has been found. Often a resource itself depends on other resources, which are requ... |
This block of code is already somewhat optimized thanks to some answers given over at Stack Overflow. In the last question I made (Improve performance of function without parallelization) the code was marginally improved but I later had to re-write a little bit of it and the changes proposed didn't apply anymore.
I'm l... |
The goals for the code below are in the class summary below. Can anyone see that the code fails at any of those goals? I'm unsure how to thoroughly test it. Is there a way to keep the Queue method thread-safe and remove the lock? Is that lock even necessary?
/// <summary>
/// The goals: only run the most recently queue... |
The function itself is just returning as void. But, the point of the posted code is not about what the function is returning. It is the code related to using T-SQL and C# to return data from a SQL database that I would like reviewed. Especially the way the using statements are structured.
public void GetOffice(int ... |
public class Office
{
private Int32 _SyncID;
private string _OfficeName;
#region Properties
public Int32 SyncID
{
get { return _SyncID; }
set { _SyncID = value; }
}
public string OfficeName
{
get { return _OfficeName; }
set { _OfficeName = value; }
}
... |
Simple post and download web app in Bottle:
server.py
import sys
import bottle
from bottle import request, response
import pymongo
import gridfs
from bson.objectid import ObjectId
import mimetypes
mimetypes.init()
# Mongo Connection
connection = pymongo.MongoClient("mongodb://localhost")
db = connection.pacman... |
An interval is a data structure that represents a range (start & end, from & to, or min & max, etc.). An Interval Tree stores these intervals in a sorted tree structure that makes searching for range intersections much faster. Interval trees help answer questions like: "find all stored intervals that at least partially... |
public class MergeSort {
public static void sort(int[] array, int lo, int hi) {
if (hi <= lo) {
return;
}
int mid = lo + (hi - lo) / 2;
sort(array, lo, mid);
sort(array, mid + 1, hi);
mergesort(array, lo, mid, hi);
}
private static void mergesor... |
I am building an Administration web site for the Office details in my database. Right now, I am just trying to display the office details.
public class OfficeRepository
{
public static Office GetOffice(int syncID)
{
List<Office> results = new List<Office>();
var sql = @"Select so.SyncID, so.tit... |
In the following contrived example, I have a collection of PropertyManagers that each contains selector and assigner delegates to read from and write to a property on the generic type. It feels clunky for lots of reasons, not least of which is that both delegates are basically there to serve the same purpose: To identi... |
I threw together a small solution for my organization today for some basic data review and approval procedures. This particular application will likely not change or add functionality at any time.
My question as I was coding the application was, does this need to be decoupled? Are there any opportunities for a Factor... |
I wrote the following simple Perl script to read lines from stdin that are the output from a psql call that returns lines of the form key1 | key2 | long text field and create a separate output file for each line, whose name is key1_key2_NNN.txt, where NNN is just a counter to ensure unique file names.
my $count = 0;
w... |
I'm writing some simple emacs tools for visual studio solutions.
I've got a function sln-process-csproj-file. This function takes the path to a project, and returns a tuple that's just a data model of the innards of the project.
Right now the return value on the last line of that function is `(,project-name ,project-p... |
I’m trying to make a simple gui app that starts a “long” process that can be started and stopped. The process generates random numbers and displays them in a JList. As numbers are being displayed (i.e. process is started), user can select a number from JList and delete.
gui and uml http://mypages.valdosta.edu/dgibson/... |
I have written a password checker using PHP, consisting of many if else statements. Is there any possible way to shorten this code?
function passtest($pass) {
if (!empty($pass)) { //check if string is empty
if (ctype_alnum($pass)) { //check if string is alphanumeric
if (7... |
I have the following code:
public EmployeeProcessOutput RetrieveEmployee(EmployeeProcessInput input)
{
var employee = input.Employee;
if (input.EmployeeId == null)
employee= CreateEmployee(employee);
return new EmployeeProcessOutput
{
Employee = employee,
State = "Stored"... |
My goal was to get my hands dirty in OOP by designing and using classes and getting started with inheritance and other OOP concepts.
I have written a very small code to play a card Game called "War". The rules are simple. Each person playing the game is given 1 card. The person with the highest card wins. I am not wor... |
I have written an HTTP client wrapped the libcurl. It should be able to do HTTP get/post with string/map param, with cookies and proxy.
Can somebody review the code? B.T.W., I'm not sure the way pass a map into HTTP header is correct, maybe I should remove these two interface
CURLcode do_http_post(std::string post_url... |
script.py:
#!/usr/bin/python
import os
srcDir = os.getcwd()
dirName = 'target_directory'
dstDir = os.path.abspath(dirName)
def ignore_list(path, files):
filesToIgnore = []
for fileName in files:
fullFileName = os.path.join(os.path.normpath(path), fileName)
if (not os.path.isdir(fullFile... |
Lately I have been trying to extract till I drop. Well not necessarily till I drop, but I've been trying to be more strict and look at some metrics of my code.
I have now come along an old class of mine which has a rather large switch case. Metrics say the method lines of code are beyond evil. It goes something like th... |
I wrote a PHP function 7 days back , which avoids (calculate spamming severity) via manual spamming . So was just a curious to know, what if I create a JS plugin (my first) which can act as an SPAM validator on client side.
So here I am with my new jQuery plugin(beta version) which validate the existence of Spams in on... |
I need to calculate the calendar week of a given date. Constraints:
It should be properly calculated based on ISO 8601 if week starts on
Monday
It should calculate based on US standards if the week starts on
Sunday
It should be compact and fast, as the routine gets called very often
It should work even if the year sta... |
I've written a program to populate a particular object from multiple data sources, however I'm not convinced I'm going about this in the right way:
I have no idea which (if any) design pattern I have used (possibly abstract factory)!
I really don't like the implementation as it doesn't feel right.
I appreciate that t... |
I've been unable to find a PHP function that will convert eol in files. This is what I have so far. It works, no errors.
Your educated opinions, thoughts, improvements, potential bugs and suggestions are welcome.
/*
$file_name - full/path/to/file.name
$eol - wanted end of line: "\n", "\r", "\r\n"
... |
This is the code I'm currently using to run a shell command on the current machine, intended for use only with GNU/Linux at the moment:
std::string getCmdOutput(const std::string& mStr)
{
std::string result, file;
FILE* pipe{popen(mStr.c_str(), "r")};
char buffer[256];
while(fgets(buffer, sizeof(buffer... |
The following code will be used for educational purposes. It is to demonstrate various way that the box-shadow property can be used. Any feedback on areas where I have not used best practices would be great.
Working example
HTML:
<!DOCTYPE HTML>
<html>
<head>
<title>Box Shadow</title>
<link rel="stylesheet" typ... |
I'm wanting to calculate exponential moving averages of a variable, distance. Is the logic (and math) correct in the below code?
time and lastTime are millisecond-precise timestamps in seconds – the former is the current time, the latter is the time of the last calculations.
lastA etc are the exponential moving average... |
I am writing a simple quiz app using Tornado and MongoDB. The user authentication is done using Facebook and each user is uniquely identified by their Facebook ID. When a user first creates an account, his score will be set to zero and he can access only questions whose ID is less than or equal to his current score. An... |
Below is a script to create and manage text snippets. It is also posted on GitHub. Most of the code is error checking and displaying help because I wanted to make a solid command line interface. The blanks function is used when copying a snippet with a blank (@) character in it. The user fills in the blanks.
I am looki... |
I was looking at the different possible threading methods that I could use in my single-threaded application. What I have written so far is a class that will lock the thread when I instantiate the object, then unlock the thread when the object becomes out of scope. Here is what the class looks like:
ProcessCritSec.h
#i... |
I am trying to develop a simple inventory system that takes JSON data gathered from a Powershell script, inputs the data into a MongoDB, and displays the info in an interesting manner for the user. It works well at the moment, but I do have a few interesting questions about how I did this, i.e. should I make the DB con... |
I'm using mongoose to seed a mongodb database based on my mongoose models.
I'm particular interested in improving the seed code.
I have two models, an article and a category.
The relationship between the models are as follows:
A category has many articles
An article has a parent category
The model schemas I'm using are... |
The following code will be used for educational purposes. It is to simply demonstrate how to apply a drop-shadow using a CSS3 filter. Any feedback on areas where I have not used best practices would be great.
JSBin
HTML:
<!DOCTYPE HTML>
<html>
<head>
<title>Drop Shadow</title>
<link rel="stylesheet" type="text/... |
I have fully functional code in class format, and as far as I am aware from my previous question, it conforms to PEP 8 and the code logic and implementation is suitably pythonic. My main concerns here is whether or not I have put self. in front of the correct variables, and some ambiguity surrounding my @staticmethod.
... |
I've got an assignment to do pure JS validation as well as submit with AJAX. Here is the code I've got so far. I'm wondering if I can do away with the whole "reason" bit. That was because it was originally meant to display a list of all the errors, but I've tweaked the code to instead display the errors right by the fi... |
I have a class Employee that contains an ArrayList of Projects.
I'm storing the Employees in one table, and the Projects in another.
I'm trying to find the best way to create an ArrayList of Employee objects based on a result set. Simply creating an ArrayList of Employees based on a result set is pretty straightforwar... |
Here is a simple function I wrote to parse record-jar data. I need it in a php5.3 application to validate bcp47 language tags. It converts the language subtag registry among other things, into a nested php array. Any suggestions on how I can improve it?
/**
* Quick script to parse any record-jar data into an array.
*... |
This is my solution for CodeEval challenge 44.
You are writing out a list of numbers.Your list contains all numbers with exactly Di digits in its decimal representation which are equal to i, for each i between 1 and 9, inclusive. You are writing them out in ascending order. For example, you might be writing every numb... |
I have written this small game for the "learn python the hard way" book. I ask for some opinions about it and how to improve it.
I know about pygame and others game engines but all the game runs in the terminal. The text file orc.txt, cyclops.txt, etc are ASCII drawings
from PIL import Image
import numpy as np
import m... |
My game uses configuration files in JSON format. One of them is used for setting up control bindings, and it looks like this:
{
"DisplaySettings": {
"IsFullScreen": false,
"PreferredBackBufferWidth": 800,
"PreferredBackBufferHeight": 600
},
"GamePadSettings": {
"Back": "Exit",
"DPadDown": "Mov... |
I'm making a Backbone-Marionette app with a file structure that matches restful verbs as much as possible. It looks something like this:
+ backbone
+ apps
+ student
+ show
+ list
+ new
+ lesson
+ show
+ new
+ edit
If, for example, the student show controller wanted to di... |
Please take a look at this code:
class error_stream: boost::noncopyable
{
public:
template<typename T>
std::ostream& operator<<(T&& arg)
{
return strm() << std::forward<T>(arg);
}
std::string str() { return strm().str(); }
bool empty() const { return !holder_.valid(); }
private:
std:... |
How can I optimize the following PHP/JS code?
It works like a charm but I think it is too long and I'm sure it could be optimized. If I have another form, I'll need to copy paste some lines from my PHP code and it'll be quickly overkill.
JavaScript:
<script>
$(document).ready(function() {
$('#createAccount').on('s... |
With iOS7, Apple introduced AVCaptureMetadataOutputObjects, which is used for scanning barcodes. If you check out the web for how to scan barcodes in iOS, almost everyone is talking about ZBarSDK. And before iOS7, this was definitely the way to go. But as of iOS7, ZBarSDK has a pretty nasty memory leak, and it's a b... |
This project has evolved a lot since I started learning Angular. I'm pretty happy with it now, and I'm wondering if there's anything I can improve upon, or have forgotten at this point...
HTML
<h1 data-fittext>FitText</h1>
<h1 data-fittext=".315" data-fittext-min="12" data-fittext-max="50">ng-FitText</h1>
Inclusion &... |
I have code which gets data from a POST request (request.form dict), compares with corresponding attribute in object accident and does some action. The code looks needlessly verbose. How can I optimize it?
if accident.status == 1:
if request.form.get('reason') \
and request.form['reason'] != accident.reaso... |
So, I am not sure if I should have Vertex extend Point, because the equals() and compareTo() functions are already parameterized with Point. I guess I don't really need compare to...
Does this structure look good? I used a Map instead of a TreeMap because as3commons and the default flex packages do not have this struct... |
char *cat_string(char *to_cat, char *destination) {
char *copy = destination;
while (*copy != '\0') {
*copy++;
}
while (*to_cat != '\0') {
*copy++ = *to_cat++;
}
*copy = '\0';
return destination;
}
I would like to know if this is an efficient and effective way of writing this function. It seems s... |
As a follow-up on my earlier question, here is the new implementation. The major change is now that the base class just deals in ICacheValue values which are implemented by the derived classes and generated through implementation of a factory method.
Unfortunately requires some casting in the derived classes but I don'... |
How can I reduce cyclomatic complexity of validation and refactor it better way?
Class Document
def initialize(opts)
@opts = opts
return ArgumentError unless valid?
end
def valid?
return false if @opts.nil?
return false if @opts[:property_1].nil?
return false if @opts[:property_2].nil?
re... |
This integration test involves database access and hence opening and closing a database connection. Does it look correct? I am concerned about ensuring the the database connection is closed should the test fail.
"use strict";
describe("MyCtorFunction", function () {
describe("myMethod", function () {
var _db = ... |
I have this assignment where I'm supposed to code an algorithm for finding the quantity of Longest Increasing Subsequences from an array of (different) integers and print them all.
I developed one which always gives me the right answer, but I have 2 issues with it:
It's a little slow
When the given array is between 1... |
I'm trying to create some easily accessible database of different skills. General idea is that every skill should do something different and be able to act on different things (ex. one skill which icreases weapon attack by 'x' [it acts on weapon] and other one which icreases chances to drop item by 'z'% [it acts on mon... |
Because the throughput of my radio and device is limited, I wanted to compress my control string. I decided to compress the command into an 8 bytes (quasi) string (throttle high, throttle low, pitch, roll, yaw plus/minus, yaw value, checksum, stop byte) and after parsing in four variables:
Pitch (between -45° and 45°)... |
I have written the following script that I'd like to have reviewed:
#!/usr/bin/python
import os
os.system('hg tags > tags.txt')
file = 'tags.txt'
path = os.path.join(os.getcwd(), file)
fp = open(path)
for i, line in enumerate(fp):
if i == 1:
latestTagLine = line
elif i == 2:
previousTagL... |
In C++, I have made a basic memset / memcpy / strcpy implementation, yet I am worried that they are slower than the STL equivalent, as they are probably made in assembly, which I do not know. Is there any way of making these quicker, still using C++?
#define BYTE unsigned char
typedef BYTE byte;
void *__memset(void *... |
I have a main menu in my application. It loads depending on the role of the user that I validate from a table in my data base, but I have to recreate this menu every time I call a new controller.
User Controller:
class User extends Ci_Controller {
function __construct(){
parent::__construct();
i... |
I have tried to implement a basic vector type in C++, yet I am not sure if I can do anything any more efficiently.
template < typename _Ty > class vector
{
public:
typedef _Ty *iterator;
typedef _Ty _Value_type;
typedef vector<_Ty> _Myt;
vector()
: __size(0), __capacity(10), __data((_Value_type... |
I am working on the largest Java program I have undertaken to date and feel uncertain in my current code practices. I think that I state and repeat things that don't need to be which can become a headache as development goes on. Specifically, in my GridBag Constraints. I have worked with GridBagLayout before and had go... |
I have the following Lua script which I use against my redis environment to perform some non-production analytics on my data.
My dataset contains hundreds of millions of records, hence I want to make sure that the approach that I am taking is optimal for query performance and best coding practices.
-- Tables to store t... |
I have asked a question on Stack Overflow and one of the guys actually managed to hack my contact form and inject a fake email into the $header of the PHP!
So after talking to him, he sent me a few articles, and I aimed to update the PHP to secure this gap and prevent the spam.
Here is my old PHP:
<?php
session_st... |
I have an application which retrieves data from a (potentially) very large XML file. A combination of XMLReader and XDocument seemed to be the only way I could manage the entire thing the way I wanted. It works, and it does so fairly quickly and efficiently. But I have a few review questions.
Is this combination ... |
I am using the GeoComplete plugin with RequireJS
It works, but please could someone confirm I've done this correctly, mainly my understanding of shim:
requirejs.config({
waitSeconds: 120,
paths: {
async: './lib/async',
jquery: './lib/jquery-1.7.2.min',
geocomplete... |
I've recently stumbled upon an interesting challenge for me:
You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, exp). Application should replace constants Pi and E with built-in values. We may have any amount of spaces between operato... |
I want to create XML messages for webservice communication. These messages should be created from a pool of reusable elements. Therefore I have created different classes. A "factory" class, that only returns a message class. An element class, that consists of the reusable parts and the message classes that are the blue... |
Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n log k) time.
For example, let us consider k is 2, an element at index 7 in the sorted array, can be at indexes 5, 6, 7, 8, 9 in the given array. I'm looking for code review, best practices... |
A couple of days ago I posted my code that models systems made up of moving parts. I got several great tips and ideas and here is my latest version. My actions are now methods annotated with @Action (instead of separate classes as in my original code). My Model class contains a HashMap of Class, ArrayList<? extends Age... |
I asked this question on Stack Overflow and in the comments someone had this to say.
In a proper design, you should almost never have to do a dynamic_cast, even if it's hidden inside some nice getter function.
Now this got me thinking a lot. I have been thinking of various ways in which I could eliminate the dynamic_... |
Does this look like a good method to hash a user password? I'm not very familiar with how this whole hashing process works and below is a bunch of stuff I've seen on many different posts.
My main concern are all of the numbers. Do they all need to match? Do they need to match something like the array.copy?
And then t... |
I'm not sure about that if else statement in function Change(). I'm guessing there is a way to eliminate this and make better use of OOP principles. Does anyone have any suggestions?
PS This code is functional and produces the desired result.
using System;
using System.Collections.Generic;
using System.Linq;
using ... |
I have several generic methods that use the typeof operator to determine the type of mapper class to create. Eventually this is going to get out of hand.
Can anyone suggest a better way to handle this? I have been reading up a bit and it seems like an abstract factory pattern or IOC would be a good pattern to use. I... |
I got a lot of good feedback on my other question. So I will take another swing at it, post my revisions, and hopefully get some more.
First, the configuration hasn't changed. Here's the JSON file:
{
"DisplaySettings": {
"IsFullScreen": false,
"PreferredBackBufferWidth": 800,
"PreferredBackBufferHeight": ... |
str, ski = int(input("text here")), int(input("text here"))
if str < 1 or str > 50 or ski < 1 or ski > 50:
print("did not enter between 1 and 50")
Is there anyway to shorten the if statement in that code? I find that it is a bit too long, but I don't really know how to shorten it.
Any suggestions?
|
Here is a SQLite Helper Class I created. Any input appreciated, including security and simplification.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
... |
For learning purposes, I made this little class which determines the Condorcet winner of a rank voting election (basically, a Condorcet winner is a candidate that would beat every other candidate in a head-to-head election).
This code does work, but I'd like to learn two-three things by posting it here:
Is this class ... |
I have an application that allows the user to place a string of text into a PDF document. I have three different ways that they can do this:
Use a Form Field. Then they have four properties to define:
Provide field name
provide instance of the field
provide an X-axis Offset
provide a Y-axis Offset
Search for a st... |
I am currently working on a problem of an online judge (not a contest). The program must calculate how many years will require for the population A (which is always less than B) to be higher than B. If the time is more than a Century then print "More than a century" in Portuguese.
Input
1
90000 120000 5.5 3.5
Where 1 ... |
I have my program working. I just need to redo it a little bit, and it could use some improvements.
I got different % rates depending on what the income and status is.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <cstdio>
//functions called
float wages_loop();
float other_loop();
float interest_... |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <thread>
#include <cmath>
#include <sstream>
#include <cstdlib>
using namespace std;
ostream* outfile = &cout;
bool testCantor(unsigned long long p, unsigned long long q){
while(q % 3 == 0){
q /= 3;
if (p/q == 1) return p==q;
... |
In my game, I need to detect whether any buttons/keys are pressed at all before I try to process any input. This is easy enough for keys since the XNA library provides a GetPressedKeys method on the KeyboardState class:
private void ProcessKeyboard()
{
keyboardState = Keyboard.GetState( PlayerIndex.One );
if (... |
Given a source and destination, in an integer matrix, find path, such
that the next position in the path has a greater than or equal to
value than the previous position. In other words monotonically
increasing. In event of multiple paths, a non-optimal solution may be
returned.
I'm looking for code review, be... |
This is my first major PHP project and I haven't gotten much feedback. I wanted to learn how to use PHP and I wanted to learn about Minecraft's status protocol, so I did what was obvious at the time.
File listing
The code is also on GitHub.
mcstat.php
Contains class MinecraftStatus and is also a stand-alone CLI tool.
... |
I came across this snippet and am wondering if I should return blank in this case.
Which is more practical to return: blank or null?
public String getInfo() {
String result = "";
String uri = clientConfiguration.getUri();
String regex = "http://(.*)/consolidate";
Pattern pattern = Pattern.compile(regex)... |
Based on this Stack Overflow question I came up with the following code. I'd like your general thoughts about it. Code style, functional, logical, disadvantages, just anything you can come up based on the code that should be mentioned about it and springs into your eyes.
This is the sandbox:
function Sandbox() {
/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.