instruction stringlengths 71 71.9k |
|---|
I've never used a framework before, so I wanted to see if this fairly simple scenario was done correctly or could be improved:
public function actionCreate($id) {
// Is request Ajax
if(Yii::app()->request->getIsAjaxRequest()) {
$userID = Yii::app()->user->id;
try {
$cmd = Yii::app()->db-... |
I'm writing a function called unzip that turns:
[(1,2);(3,4);(5,6)]
to
([1;3;5],[2;4;6])
I've got a working implementation right here:
let unzip (data:(int*int) list) : int list * int list =
match data with
|(x,y)::tl->(x::traverse (tl,true),y::traverse (tl,false))
|[]->([],[])
let rec traverse tree =
... |
I am trying to implement a vector-like container of my own (just to gain a better understanding of how std::vector works under the hood). I've been using this as a reference.
Although I've succeeded in implementing most of the interface (only the parts I use the most), I'm still uncertain whether:
There are no me... |
I'm trying to write a message queue implementation
so my threads can exchange data.
To keep things simple, the queue is only responsible for
sending pointers to memory. Only one thread may send messages,
and only one thread may read messages.
The struct mq_t represents a message queue.
mq_t.messages is a circular buff... |
I'm trying to create small PHP framework for my own needs (and likes). However there are questions for which I may need advice of more wise and experienced people before things became too complicated - so I moved it to github from private repo.
Currently I'm curious about organizing imports of modules better. I use the... |
I'm just getting to know the whole prototype world, and now I'm trying to do in JS what is normally done in OO languages, namely classes and DAO classes.
I'd be grateful for any comments on whether the code is written in accordance to JS best practices and whatnot. More specifically, I didn't implement getters or sette... |
As this new approach differs from my previous revisions, it shouldn't need references to them.
After receiving much guidance from CR chat, I ended up utilizing these things:
enums for the Rank and Suit instead of arrays
a namespace for the enums and Card class
to_string()s for representing the Ranks and Suits as std::... |
I need a copy_if_max() function, i.e. copy all the elements in an input range that are equal to the max in that range. The most obvious implementation does two passes over the data:
template<class InputIt, class OutputIt>
OutputIt copy_if_max2(InputIt first, InputIt last, OutputIt dst)
{
using T = typename InputIt:... |
Currently, in my games, I'm using new and delete to create entities and components. It works fine, but there are slowdowns when creating/deleting many (5000+) entities or components at once.
After asking for advice on StackOverflow, I decided to create my own memory pre-allocator.
It allocates a specific amount of mem... |
I've hacked together what feels like a mess for an authorize attribute to secure web api methods. The code appears to be functionally correct; passing the unit tests in place. The code has me worried because it will be executing with every call to any web api method and there is a lot going on, including string allocat... |
I try to implement a (restricted version of) step function in Haskell. A step functions is a function that is constant on a finite number of half intervals, and mempty everywhere else. (equivalently, one can fill those "everywhere else" by half intervals)
This can be modeled as a StepData a b, which stores a list of th... |
I think many know the problem of working with multiple projects: private projects, company projects, probably even projects for multiple companies.
From day-one, I've always searched for better ways to handle all those projects on the file system level. I think I figured out a nice basic directory structure that works... |
I'm trying to do a one-way directory sync. Given a list of existing files in a dir, I'd like to make the files in the dir equal a new list of files. There will be subdirs under the dir. Because operating system calls are expensive, I'd rather minimize the number needed.
It's easy to just delete each file in the existin... |
I wrote a program to proxy MDNS requests in a local network to the DNS server. This is useful because in some private networks, host names ending in ".local" are configured in the DNS server. But ".local" is actually reversed for MDNS. Some systems have problems resolving these host names because they only try to resol... |
There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job (maybe apart from the disconnect part, but it allows to trace whether database is connected via $database->isConnected). Can ... |
Some background: I work mostly in Python (specifically numpy), doing Bioinformatics type work. I am interested in moving towards Haskell. Initially, I hope it will be possible to replace some of the simple exploratory scripting I've been doing with Haskell. The following is not something that would actually be particul... |
I am capturing a window of my own choice, and taking a screenshot of it constantly in a loop. Latency and speed is everything.
It's very capable, but I hope it can be improved.
var proc = Process.GetProcessesByName(prcname)[0];
IntPtr hwnd = proc.MainWindowHandle;
RECT rc;
NativeMethods.GetWindowRect(hwnd, out rc);
B... |
Please criticize the classes GameJudgeImpl and GameInfo so that I could make them clearer.
public interface GameJudge {
public GameInfo gameInfo();
}
public enum GameResult {
UNKNOWN, DRAW, PLAYER_WINS, OPPONENT_WINS
}
public enum Cell {
EMPTY, PLAYER, OPPONENT
}
↓
public class GameInfo {
private fin... |
The PHP Mess Detector of my IDE warns about a Cyclomatic Complexity of 14 (threshold is 10). To me this code doesn't seem to hard to follow. Would you refactor it in some way to lower the metric?
Exit if $payload isn't an array or has a number of elements not equal to 1
If $payload is array or ArrayAccess build a prop... |
I am building a PHP framework and would like to get some feedback on a few different section of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing this different task in an efficient and or correct way.
This section is of the Template parser. I wish to cre... |
After 4+ months since I started learning web design I created my very first website. It's far from perfect but I learned a lot since then. I would appreciate it if someone would be so kind to review my work and suggest fixes to make it more functional and run more smoothly.
Please, don't pay attention to background ph... |
def dfs(graph, node):
"""Run DFS through the graph from the starting
node and return the nodes in order of finishing time.
"""
stack = [[node, True]]
while True in [x[1] for x in stack]:
i = 0
for x in xrange(len(stack)):
if stack[x][1] == True:
i = x
break
stack[i][1] = Fal... |
I'm new to Haskell and I've made a very short KenKen solver. Any input is welcome.
import Data.List
import Control.Monad
set :: [Int] -> Bool
set x = x == nub x
mats :: Int -> [[[Int]]]
mats x = filter (all set . transpose) . replicateM x $ permutations [1 .. x]
doIt :: Int -> [([(Int, Int)], [Int] -> Int, Int)] -> ... |
I made a site where you can add movies into the database. You can use up to 3 different hosts.
Everything works well, but it is very long. I would love to shorten it!
Code to enter the 3 hosts + the links to the host:
<TABLE>
<TR><TD width=120>Hoster*:</TD>
<TD>
<SELECT class="interfacefor... |
I currently have a container that has two features it allows adding objects to it and at the same time an independent thread continuously consumes items from it. It is a FIFO type deque. Which receives object at an extremely high rate. Following is the code for the container
std::deque<Some_object*> my_container;
void... |
I am working on going through "Head First Design Patterns" and I am trying to properly convert the Java code into C#. Here is what I have. Can you tell me if this is a good implementation/conversion so far?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Duck
{
publi... |
Common Lisp has a "special operator" called multiple-value-call, which does something similar to Scheme's call-with-values but with a nicer syntax, and allowing multiple producers (unlike call-with-values). So I thought I'd try to implement multiple-value-call in Scheme, using call-with-values (dressed up here as recei... |
Here's the start of some code for a clock that can display time in 24 and 12 hours.
What could be added to it? How could I can apply notions such as OOP, model and Enums here?
public Clock {
private int time = 0;
public int get24hrTime(){
return time;
}
public int set24hrTime( int newTime ){
... |
I wrote this as a way to deliver static portion of the app. I'm wondering if there is a better way to write this, as I am new to Express.
The goal is to let a single-page app to handle routing as needed. There is an API layer of this app that is defined under the /api/ route namespace.
I wanted to note that all assets... |
I have a manager class (included below) and sub data types that are included inside it. All of the different stored types are more or less the same with some wrapper functions calling the exact same named function below to the sub object. This feels dirty and I can't help but think there's a better way to do this. Sugg... |
For Coursera's Algorithms course, I have written Kosaraju's algorithms which calculates strongly-connected components in a directed graph using depth first search. The code itself is correct but apparently not very efficient, because it took me almost 24 hours to get the answer for the file SCC.txt which contains about... |
My page has been loading a bit slower than I want it to.
The website is www.digitechlab.com
I segregated so many files because they were pretty big and I wanted to be able to work on just one section of that page at a time without running the risk of breaking the entire page. This way I could work on, say, the header ... |
What do you consider the readability of this program?
Do you think it's easy to understand what the variables and functions do just by reading their names?
Would you prefer more, less, or this amount of comments?
Do the comments make it easier or harder for you to understand the program?
Do you like a program to have ... |
First of all, I won't include the spin game there, cause it's very simple.
I went a bit deeper into object oriented since the last time, I learned array lists, using them with objects, maphashes, and more.
They are pretty useful I must say!
Let's begin:
Mains.java:
public class Mains {
public static void main (Str... |
I've been writing a program to perform a kind of pattern-matching in XML and text files.
When my program reaches this section of the code, the CPU usage gets very high and the performance slows down to a point where the program seems to be frozen. It actually isn't, but depending on the input (number of text files a... |
I have written a simple command line program in Python 3 that accepts a function (in the mathematical sense) from a user and then does various "calculus things" to it. I did it for my own purposes while taking a math class, so I was more concerned with getting it to output the right number than with security.
I was jus... |
Can this be shortened, optimised or made more pythonic ?
a = [1,9,'foo',5,7]
b = ['bar',4,8,6]
c = []
min_len = min(len(a),len(b))
for i in range(min_len):
c.extend([a.pop(0), b.pop(0)])
c.extend(a)
c.extend(b)
print c
output: [1, 'bar', 9, 4, 'foo', 8, 5, 6, 7]
|
I am trying to capture screenshots as fast as possible from when it's displayed, meaning that I want the latency to be minimal.
Currently, I am using user32.dll to capture a window. So, if I have a game, I capture that window along with borders and everything. It's very fast, but I wonder if hooking into the API (Dire... |
I am using some string which contains an html. As follows
var pagerHtml = '<span>No.Of Records</span><select class="rmselect" id="records" ><option value="10">10</option><option value="20">20</option><option value="40">40</option><option value="80">80</option><option value="100">100</option></select>';
Another is with... |
I just wrote a little bash script for rsync push backups of my laptop to my Synology-Diskstation at home.
Since I am a bash beginner and don't have any experience with ssh, rsync and backups I am asking for suggestions how to improve the performance, reliablility, usability and security of my script and for suggestions... |
I am trying to solve the Longest Palindromic Substring problem on LeetCode, and I have come up with a DP solution pasted below:
public class Solution {
String string;
boolean[][] visited;
String[][] results;
private boolean isPalindrome(String s){
String test = new StringBuilder(s).revers... |
I've noticed that there are several ways of sending data through a TCP stream. I want to do it the fastest way in terms of latency.
One method I became aware of is with a binary writer:
using (MemoryStream ms = PrintWindow(process))
{
writer.Write((int)ms.Length);
writer.Write(ms.GetBuffer(), 0, (int)ms.Length)... |
here is the puzzle description
Your task is to decode messages that were encoded with substitution ciphers. In a substitution cipher, all occurrences of a character
are replaced by a different character. For example, in a cipher that replaces "a" with "d" and "b" with "e", the message "abb" is encoded
as "dee".
The ex... |
In the book Clean Code from Robert C. Martin are given many recommendations. Two of them are
to keep functions small and
within a function to only have one level of abstraction.
I already cleaned the following method up a bit by extracting a few methods (RemoveFontColor(), RemoveTextHighlight()). But i am not sure... |
It simply searches for an empty row in a given destination. If it is empty, it performs certain actions (copying, pasting, etc.). If it is not empty, it goes to another row. I managed to do it with dozens of If formulas, but doing it in such a way seems really ineffective. Moreover, doing it in such a way puts a sev... |
The following code works but is slow and I know can be better, just don't understand how to make it work. The end result is displaying the actual driving distance from the users current location to multiple locations (I'm only including two end locations here to try and save space). This way they can see which location... |
I am working on a C#.Net application that will generate an Excel report from a template. Although the code's not in the app yet, it will pull data from a SQL Server database to populate the report.
I am asking for help in reviewing my class design. My code is below, with some details of the functions removed for simp... |
I am looking for feedback on a solution to the following problem posed from a book that I'm working through (Java: How To Program 9th Edition):
Continuing the discussion in Exercise 16.20, we reiterate the
importance of designing check-writing systems to prevent alteration of
check amounts. One common security met... |
Please criticize the MatrixNotThreadSafe class and other classes. How can I improve the design of the Matrix interface? How can I make the classes and tests clearer?
Code on GitHub
Position.java
public class Position {
public final int row;
public final int column;
public Position(int row, int column) {
... |
For anyone who's unfamiliar with this grading system.
I'd like a general review of my code, and I have a few questions:
Are plain types okay for the letter grades and credit hours, or could they be public typedefs?
Should operator<< need to call calculateGPA(), or should I create a private accessor and have that calle... |
I am trying to learn some basic Python and am trying to find tricks to write speedy code:
import sys
if len(sys.argv) < 3:
print("You left out the arguments")
sys.exit()
gcf = 0
numbers = []
collections = []
unique = False
for i in range(1,len(sys.argv)):
numbers.append(int(sys.argv[i]))
for x in range(0,... |
I'm working on a general Requestmethod class which sanitizes and recasts the input of users in an automatic fashion. I've also tried to do array-access in cookies.
My biggest question are:
Is this too much for one class alone?
Is the readability/thinking right on this?
Code:
Example: (<input type="checkbox" name=... |
I've written a small code snippet that generates checkboard texture using cl-opengl.
(defun init-texture (tex)
(gl:bind-texture :texture-2d tex)
(gl:tex-parameter :texture-2d :texture-min-filter :nearest)
(gl:tex-parameter :texture-2d :texture-mag-filter :nearest)
(print *test-texture*)
(let* ((tex-... |
The following code takes a string and converts it to it's number equivalent.
A=1 ... Z=26, while keeping all other characters intact.
It formats the string using two delimiters. One for between characters and one for between words. I want to optimize it, and have fixed a lot of redundancy, and slow parts. However, I ca... |
I have implemented the following code which will be used to read in what are essentially key-value pairs from a file.
an example input file may look like
max_search_depth 10
enable_recursion false
job_name Khalessi
my main issue with this code is that I wish to return variables of different types based on the text in ... |
I have written the script, which unzips a zip file (passed as argument to the bash), loops through directory and files, then perform different actions based on directory or file. It is working fine.
However I would like to know some things:
Is it possible to do this without the unzip command? I somehow feel like that ... |
All this code does is transfer the files. In order to make changes to the file, one has to re-transfer the file. During this time, I stand by to automate the update operation, where the server listens to the files and updates them automatically whenever any changes are made.
fileserver.java
import java.io.*;
import j... |
I have a Customer class that has the code below. I can refactor the two if condition clauses into the Memebership class. Apart from that, I am wondering how I should refactor the if clause within the Benefits set property, without over-complicating thing.
Does any one of these below apply?
Patterns of refacotring if to... |
I want to create an like button like on Twitter. I used Twitter bootstrap and this code:
$(document).ready(function(){
$('.btn-follow').on('mouseover', function(e){
if ($(this).hasClass('following')){
$(this).removeClass('btn-primary').addClass('btn-danger').text('UnFollow');
}
})
$('.btn-follow').o... |
if ((key == null && group.Key == null) || (key is DBNull && group.Key is DBNull) ||
(!(key is IComparable) && !(group.Key is IComparable)))
Can the above code simplified like below,
if(key == group.key || (!(key is IComparable) && !(group.Key is IComparable)))
|
The following is a code written in Javascript. It let's me change the appearance of a canvas depending on user input.
The question is, how can I make this code more CPU efficient?
I ask that because this code is just barely snappy enough on the iPad 2 and any improvement in speed would be really great to have.
With spe... |
The function hash_blog is inspired by "how git stores its objects". It is supposed to take a String, append a header to it, compute the SHA1 of it, then compress it and write it to a file. The first two characters of SHA1 is a directory name, and the rest of the characters are the file name.
Since I am learning the lan... |
I recently set out to create an open-source ASP.net MVC web development framework. Specifically, I wanted to automate some of the tasks associated with the creation of data-driven applications. I've had to create a number of CRUD screens over the years and wanted to automate as many aspects of these screens as possib... |
I have a form that I'm turning into a string value for an email, but the string value that I turn it into seems very complicated, plus I believe this way takes up a lot of memory and is somewhat slow as well. Is there any other way to make a NSString with many arguments besides using [NSString stringWithFormat:]?
Here ... |
I wrote this with-input-from-pipe function for Guile. I’m not that comfortable with dynamic-wind or set-current-input-port, so I’d appreciate any critiques.
(use-modules (ice-9 popen)
(srfi srfi-26))
(define (with-input-from-pipe command thunk)
(let ((old (current-input-port))
(pipe (open-input-... |
The goal is to have a DataGrid of comboboxes, 10 rows, 3 columns.
Here's the XAML to create said grid:
<DataGrid Name="grid1"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Product">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
... |
I'm working on an old PHP website, and NetBeans is complaining about an uninitialized variable. I'm seeing some code like this:
$app->soapAPIVersion($apiVersion);
$_SESSION['apiVersion'] = $apiVersion;
The function looks something like this:
function soapAPIVersion(&$apiVersion)
{
$apiVersion = '';
$result = f... |
I am hoping someone can help me attain better performance and better ways of writing this script. Any help would be awesome!
Overall Goal: I have a dropdown that allows someone to select an option from it. It will add that record to the table below, and then the option will be removed. If they delete that row in the... |
How could this scala code be made more concise and/or idiomatic? Do I need to define each functions as a val in order to pass them as values, or is there a shorthand for this? Also looking for feedback on the disenvowel function.
// See: http://nurkiewicz.blogspot.com/2012/04/secret-powers-of-foldleft-in-scala.html
def... |
I have a Java/Swing/Guice application that uses multiple frames. When the application runs normally, I just want some of these frames to hide (and the "master" frame can unhide them).
When testing the view, I have various other main methods that can open just one frame, and perhaps populate them with sample data. Howev... |
I am quite new to Java, and I am trying to read a file into a string (or should I use byte arrays for this?). File can be anything, such as a text file or executable file etc. I will compress what I read and write it to another file.
I am thinking of using this code:
public static String readFile(File f) {
StringBu... |
I'm not so good with recursion, so I've decided to tackle an exercise consisting of drawing this pattern using characters:
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*
Here is my code so far. What could be improved? Furtherm... |
Would the following be considered idiomatic Go code?
My main concerns are:
The use of maps for this purpose. I basically want the data structure to be completely dynamic in size and have easy access to elements by id. This is because I will want to retrieve specific items on demand lots of times, so I don't want to ... |
public static bool IsAnagramOf(this string word1, string word2)
{
return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
}
public static void Main()
{
Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
string test = Console.ReadLine();
string[] split = test.Split(new Char[]... |
I have this code snippet below that I am looking for a way to make smaller if possible. Any help or suggestions would be appreciated, thanks!
Private Sub ShowAlternateRows(Show As Boolean)
If Show = True Then
splitter.Visible = True
lblAlternateActualPercent.Visible = True
lblAltEstimated.V... |
Here's a Python script to optimize JSON documents:
#!/usr/bin/python3
"""jopo - Optimize JSON documents."""
from collections import defaultdict
def optimize(data):
"""Optimize a JSON-like data structure."""
if isinstance(data, list):
if len(data) == 1:
return optimize(data[0])
di... |
I want to display a town name in my navigation, depending on the town I am requesting from the model. The following code works, but I am mixing logic in my view which I know is wrong and I haven't been successful in accessing the @town instance variable from my TownsController.
Can someone lead me down the road to enli... |
I have done some tests of my code, which I got help to improve here before. The code simply takes a screenshot of a selected process window, encodes it to JPEG (if I want), saves it to a memorystream and returns it (necessary for sending it).
My test simply runs the code 1000 times, and posts the time it took in ms.
I... |
I'm doing an exercise where I need to convert int to bignum in OCaml, for example:
123456789 -> {neg:false; coeffs:[123;456;789]}
There were a lot of things going inside my head when writing the function, and it was a load of fun. However, I'm not really sure if this is the cleanest, and fastest way to do this.
type... |
First off, I know there are other solutions and practices but I'm referring to MS proposed code from .NET documentation.
It goes like this:
client.Connect(anEndPoint);
bool blockingState = client.Blocking;
try
{
byte [] tmp = new byte[1];
client.Blocking = false;
client.Send(tmp, 0, 0);
Console.WriteL... |
I have an Eclipse plugin which creates a JavaSourceViewer to visualize specific source code in a separate view.
I would like to configure the font of the viewer to match the settings of the Java Editor Text Font preference:
JavaSourceViewer textViewer = new JavaSourceViewer(...);
...
// get the SWT component which dis... |
I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing these different tasks in an efficient and or correct way.
This section is of the MySQL database interaction... |
I'm looking to let people define arbitrarily nested lists of lists and return a random json document for them. Right now the assumption is that if you have a structure like this:
[item1, item2, [item3, item4]]
The desired document is:
{item1: value,
item2: {
item3: value,
item4: value
}
}
This is my curre... |
I am quite new to Java. I have data structured like this:
tree 503(there is a null character here)040000 tree 0bfec80bc7b7aa0a50e0b373044929cb0aae278b build/
100755 blob e30876c61eb7712ad09b50593a30513d9b173805 build.xml
100755 blob 1574df4a2de5d2884f33a5d3e30ae3daa5affee1 manifest.mf
040000 tree fdab6a12a56a709212f105... |
I've been working on a jQuery plugin for pulling tweets since the v1 endpoints were all closed off and you need oAuth now. This is just the jQuery part but if you want to see the php behind it I'll be happy to post. But basically, I'd love suggestions, as this is one of the first real plugins i've made, i'm really look... |
I wrote the code for an iterative pre-order traversal using stack for binary search tree. Below is the code for same. Please help me verify the correctness of the algorithm. Here t.t is the value of node t.
static void preorder(TreeNode t)
{
MyConcurrentStack<TreeNode> s = new MyConcurrentStack<TreeNode>();
whi... |
This code works by taking my user input and correctly pulling the information I'm giving it.
I'm having difficulty understanding the implementation of methods in classes. I'm pretty sure I'm not doing this the correct way. Can anyone show me the way it should be done?
class prog_setup:
def __init__(self):
"""Initi... |
I am doing sentiment analysis on tweets. I have code that I developed from following an online tutorial (found here) and adding in some parts myself, which looks like this:
#!/usr/bin/env python
import csv, string, HTMLParser, nltk, pickle
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_... |
I have an HTML menu with sub-menus and also sub-sub-menus. This code verifies each menu's trigger. If clicked, sub-menu opens. Sub-menus also have triggers that open sub-sub-menus and so on. A working example can be found here. This menu is a modified version of the menu found here, made by Mary Lou. I want this to be... |
I wrote a class to import a large XML file. It works great, but I feel like its ugly, and horribly inefficient although I do like how easy it is to follow what it does.
How can I improve this to make it better and to foster some better ruby writing ability?
require "rexml/document"
class Xmltube
def self.convert_s... |
My first question relates to the first Python module that I published on Python. This is a very small and simple module, the package contains only one class. This is a port of a Perl module Locale::Wolowitz this is a module for managing translations, but uses the serialization format JSON or YAML. Below the code of my ... |
I am making a WordPress "framework" for myself. Looking at the functions.php file file, is there redundant or bad code that could be changed or some code that could be good to add?
The functions.php should be a file that I could use in every web project with little or no change.
Is this code good to put in the function... |
I am new to C++ and to threading, so I'm sorry if my code is bad. I'm here to get it better and to learn.
Any kind of advice (both on C++ style, on Qt usage, or on threading handling) is welcome. Please feel free to comment anything, also if the question has to be reformulated.
I have this problem:
one thread that gr... |
I've put together the code below, which creates a new sheet in my workbook and applies dynamically-named ranges and page-formatting.
Sub UniqueOverheads()
Set rOverheadsList = Range([B4], [B4].End(xlDown))
Set rOverheadsActuals = Range([C4], [C4].End(xlDown))
Set rOApr = Range([D4], [D4].End(xlDown))
Set rOMay = Ra... |
This is a whole class I wrote. I am on my third day learning Java, so I think I would benefit a lot from a general review. At first I thought whole class would be too large, but this says it is ok.
/**
* WikiCategory
*
* There is no copyright, do whatever you want with this.
* @author Yaşar Arabacı
* @date 10.08.2... |
I am writing a board game program in Java. Slightly similar to chess or civilization in that each player has a set of units, and each unit has certain actions that it can take.
The base GameAction class has two methods: One which checks to make sure the action is allowed, and one to actually do the action. For example... |
Many years ago, I wrote a script in Perl that was meant to create a cached metadata of MP3 files (in Apple's plist/XML format) which iTunes uses when you insert a CD/DVD full of MP3 files (the same would be true for AAC files, but I limited the scope of my project, due to lack of usable libraries back then).
Since my P... |
Given a graph in [[sourcevertex,targetvertex],...] format with all the directed edges of the graph I am trying to optimize the code here because it still hasn't stopped running I don't know if it will take days or hours, although it is somewhat working for small input sets. I think the masking/vertex renaming part of ... |
If many threads Borrow() and Return() an instance of Packet from/to PacketPool could the Exception in Packet.Init() ever be thrown? Assuming only PacketPool ever called the Init() and UnInit() methods on a Packet.
class PacketPool
{
private Stack<Packet> pool;
public PacketPool(int initalNum)
{
poo... |
Here you can find my implementation of sieve of Eratosthenes in Java.
/**
* Return an array of prime numbers up to upperLimit
* using sieve of Erastosthenes.
* @param upperLimit
* @return array of prime numbers up to upperLimit
*/
public static int[] sieve(int upperLimit) {
// for corner cases
if (upperLim... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.