instruction
stringlengths
71
39k
So... I have a program in which I want to flip heads three times in the row. What I'm asking for is for proposals of other solutions for this program, in pro way, as You do in natural sense. That's my code as Java novice. /* * File: ConsecutiveHeads.java * ---------------- * This program flips a coin repeatly until ...
I've got this javascript function which was written a bit ad-hoc and I'm not really sure how to go about refactoring and improving it. It's basically an implementation of draft Unit-Testing/1.1 specification. // Runs the object as a test. The async paramater is an optional function // To be passed in if the test is to ...
I feel like I can make my switch statements more elegant with a function pointer, i.e. I'd like to set the digestLength and a pointer to a function in the same switch statement instead of setting the length, declaring the result array, then calling the function. - (NSString *)hashWithDigestType:(NSStringDigestType)type...
I was bored over the last couple of days and wrote up a string interpolation library for JavaScript. I'm very pleased with its functionality, it passes it 79 tests cross browser and the comments and README seem fine too. My main concern here are the regular expressions. I'm not a real pro in that area so I suspect the...
Writing a new site, has anyone got any comments on the HTML here? Is it all semantically correct? Thanks! This will basically be the template, so I want to make sure it's pretty perfect. <!DOCTYPE html> <html> <head> <title>Welcome to Scirra.com</title> <meta name="description" content="Construct 2 is a free...
We're calculating entropy of a string a few places in Stack Overflow as a signifier of low quality. I whipped up this simple method which counts unique characters in a string, but it is quite literally the first thing that popped into my head. It's the "dumbest thing that works". /// <summary> /// returns the # of uniq...
I often run into the problem of producing a javascript array on an ASP.net page from an IEnumerable and I was wondering if there was an easier or clearer way to do it than <% bool firstItem = true; foreach(var item in items){ if(firstItem) { firstItem = false; } else {%> ...
Here's my code: public static void CopyStream(Stream input, Stream output) { var size = 8192; var inBuffer = new byte[size]; var outBuffer = new byte[size]; IAsyncResult writeAsync = null; int count; while (true) { var readAsync = input.BeginRead(inBuffer, 0, size, null, null); ...
I want to create a validation wherein blank entries will not be accepted. So if I call this code: entry[i].setName(JOptionPane.showInputDialog("Enter Name: ")); if the entry is blank, it will not be accepted and an error will prompt: it cannot accept blank entries. Of course it could easily remedied with this code: St...
I have created a HashMap<string,int> in C++. I would like help determining if it is good or bad. I have not handled the errors or successes with messages. I have also not implemented the load factor in this map. As of now, once the size limit is reached, no more keys are accepted. I have written this code for just educ...
I have this piece of code I would like some help with. I'm running a lengthy process that I want to interrupt at any time. The thing is, as you can see in the code, I have if(stop) everywhere, also in the methods inside the for (since they have for loops also). stop is a member variable of the class, and the Stop() met...
public static class StringHelpers { public static string CapitalizeEachWord(this string sentence) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; if (String.IsNullOrEmpty(sentence)) { return String.Empty; ...
I wrote as an exercise in Test-Driven Development a piece of Python code that contains two functions: roman2dec(roman), that converts a roman number (string) into a decimal number (int) dec2roman(dec), that converts a decimal number (int) into a roman number (string) I'd like to read your comments on this code, if th...
I've gone back and forth a few times recently on my Perl coding style when it comes to module subroutines. If you have an object and you want to call the method bar with no arguments, then you can either do $foo->bar() or $foo->bar. At one point I started favoring the latter because I felt it cleaned up the code and ma...
I am creating a tab plugin. I want to know if there is a better way of doing this or if what I have is good. It works just fine, but there may be some shortcuts or a more optimized way of accomplishing this. I plan to replace the startTab variable with an options set, but I am not quite there yet. View the current upda...
Here is a snippet of code that generates a thumbnail from a given file. It works well, but is much slower than desired. Without using an external library (which I'm trying to avoid for learning purposes), is there anything that can be done to increase the speed? I know the fastest way would be to retrieve the stored ...
I am using the JSON output of the MediaWiki API documented here and here, and I have found that for Boolean values, it often returns an empty string if true and omits it if false. Thus, I want to "rationalize" the response. (Historical context: This was before a new output format was added that uses native JSON true an...
I have been generating English-language text from some machine-readable data, but now I want internationalization of my script to be relatively easy. The challenge is that some data might be missing and thus should be omitted from the output, possibly precluding any approach involving just "plugging in" numbers. Curren...
The following extension method is being used in our code base: public static bool ToBool(this object src) { return src != null && ((string) src).ToBool(false); } It leverages off another extension method: public static bool ToBool(this string src, bool defaultValue) { if (src.IsEmpty()) return defaultV...
I am implementing the command pattern in a project that I am working on and I have an interface, ICommandFactory that all of my commands are implementing. When I run the application I want to dynamically gather all classes in the current assembly that implement that interface, thus producing a list of all possible com...
I am stuck with this horrible object model coming back from a 3rd party product. It's six levels of objects deep, and I have to loop through the collection in each level, to get the values I need, in order to produce a small object model that I actually require. The code ends up looking like this (with variable and ty...
I implemented a multistep form with the method described by Ryan Bates in ep217 but I had some weird behavior when refreshing or moving between the steps Acts_as_good_style (old but still good) has a tip redirect when moving on that lead me to the change in the code that follows. In a nutshell, it says that if you're i...
This is some Erlang code I wrote to output a string of all the IP addresses of the machine. The string is simply printed to the user for him to read. -module(ip). -export([get_ip_address_string/0]). get_ip_address_string() -> {ok, IPAddress} = inet:getif(), filter_ip_address(IPAddress). filter_ip_address(IPAd...
I have written an Android application which downloads pdf files through web service. I am using kSoap2 android library to parse the response of web service which basically contains file name & file data. I have written following code. Please review & tell how to increase the speed I think there is some small defect in...
Trying to refactor this code and can't seem to think of a way to make it cleaner. Type is a property in my Person class. foreach (var item in list) { if (person.Type != PersonType.Employee && person.Type != PersonType.Manager && person.Type != PersonType.Contractor && person.Type != PersonType.Executive) { ...
I am not very good with thread-safety and often fall prey to subtle issues in concurrency. Therefore, I hope that someone here might be able to tell me whether there is a subtle concurrency issue (race condition etc.) in the following code, or whether it’s fine. In particular, have I used Monitor.Wait and Monitor.Pulse...
I have to generate a sequential number for groovy-grails app wide use and came up with the following. However, is there a better way to do this? Domain classes: class RoastIdCounter { int counter =0 static constraints = { } } This one has no views or controller associated with it. It's purely for db inte...
I have a hierarchy of of groups, and I want to get a collection of all the lowest level groups (or leaves if we'll look at this as a tree). I wrote the following code. Is it inefficient? public static class FeatureWeightGroupExtensions { public static IEnumerable<IFeatureWeightGroup> GetLeafGroups(this IFeatureWeig...
I need to parse an invalid JSON string in which I find many repetitions of the same key, like the following snippet: [...] "term" : {"Entry" : "value1", [.. other data ..]}, "term" : {"Entry" : "value2", [.. other data ..]}, [...] I thought of appending a suffix to each key, and I do it using the following code: word ...
I'm quite new to JavaScript, and I'd like a review of the code structure and syntax. It serves this little online regexp test (still a work in progress). The whole code (JavaScript, CSS & HTML) is on GitHub. application.js: function update_result_for(input, regexp_value) { var input_value = input.val(); var resul...
As I'm creating a 3D Tic-Tac-Toe game, I'm having several modules inside my JavaScript application. For example, there is a 3D module which handles perspective calculations, whereas a Multiplayer module manages everything with relation to online playing. Is it good practice to put functions of each module in its separa...
I am building a query that could end up look like this: SELECT "patients".* FROM "patients" INNER JOIN "users" ON "users"."id" = "patients"."user_id" WHERE (users.username LIKE '%Bob%' AND users.last_name LIKE '%Smith%' AND users.active = '1' AND users.disabled = '1') ORDER BY users.first_name DESC LIMIT 10 OFFSET ...
<% i = 0 %> <% @patients.each do |patient| %> <tr class="<%= i % 2 == 0 ? 'Even' : 'Odd' %>"> <td><%= link_to patient.id, patient %></td> <td><%= patient.user.username %></td> <td><%= patient.user.first_name %></td> <td><%= patient.user.last_name %></td> <td><%= patient.user.email %></td> <td...
Basically, I'm uploading an excel file and parsing the information then displaying what was parsed in a view. using System.Data; using System.Data.OleDb; using System.Web; using System.Web.Mvc; using QuimizaReportes.Models; using System.Collections.Generic; using System; namespace QuimizaReportes.Controllers { pub...
I am been using a code pattern for recursive database actions in my applications. I create two class objects of a database table, singular one (e.g Agent) for holding single record with all fields definition, plural one (e.g Agents) for database actions of that records like, select, insert, delete, update etc. I find i...
I generally encounter a lot of if/else. I would like to get some suggestions on my code: if( $blnLogged && isset( $_POST['postReview'] ) ) { if( $_SESSION['REVIEW']['SUBMITTED'] != '' ) { $arrSharedData['blnRetSave'] = $_SESSION['REVIEW']['SUBMITTED']; $blnShowForm = false; $blnReviewPos...
This class handles HTTP requests. It's a singleton class that parses URI to get the controller, method and parameters and then executes the controller's method. Maybe parseUri should be in another class and maybe there is too much responsibility for this class. I know that it can be improved. The execute method could b...
I am currently learning myself a little F# and have written the following code to practice. The code uses the Mono.Cecil library to inject some IL at the start of every method in each .net assembly found in a given directory. The IL will call a LogMe method in a Loggit.dll assembly. I want to make this code as function...
I have a function that returns a set of values from a Dictionary. I don't currently want to allow it to throw KeyNotFoundException, so I'm filtering the keys out before I try to select the values. I have a feeling this can be done in a more straightforward fashion, but I'm not sure where to go with it. // this.resource...
Is it bad to do return render? I am doing this to NOT also allow a redirect. def create @patient = Patient.new(params[:patient]) if !@patient.save @patient.user.password = '' @patient.user.password_confirmation = '' return render is_admin? ? 'new_admin' : 'new' else #Fire off an e...
I am writing an application aimed at the desktop but using web technologies. It will have an HTML interface and a server written in Python using Flask will do all of the filesystem interaction. It will have the ability to edit user settings so I want to make it impossible for other users to interfere. This is a little ...
I'm trying to port this little F# snippet while staying pythonic: ["something"; "something else"; "blah"; "a string"] |> List.map (fun p -> p, p.Length) |> List.sortBy snd In case you don't speak F#, it gets the length of each string, then sorts by length. Output: [("blah", 4); ("a string", 8); ("something", 9); ("so...
I am working on a helper method that maps properties from an ExpandoObject to a user supplied object and was wondering if the code could be cleaned up or made any more efficient. It currently has the correct behaviour from a simple test. public static class Mapper { public static void Map<T>(ExpandoObject source, T...
I am looking for some help with improving this bilinear scaling SSE2 code on Core 2 CPUs. On my Atom N270 and on an i7, this code is about 2x faster than the MMX code. But under Core 2 CPUs, it is only equal to the MMX code. void ConversionProcess::convert_SSE2(BBitmap *from, BBitmap *to) { uint32 fromBPR, toBPR, f...
I have used code which looks a little like this in an app I'm working on: module App module Settings class << self attr_accessor :console, :file end self.console ||= true self.file ||= [] end end I decided to use this method because I like the interface, I had the idea after reading the...
I'm just wondering if the following is the best way to write a dao function. Should I get the entity manager before the transaction and close it after the transaction every time? Should I write transactions inside a dao? public void sendBack(Long requestId,String comments){ EntityManager em = getEntityManager(); ...
Here is my problem abstracted to Bird classes. I know that number of Birds will increase on the future and new behaviors might be needed. With 10 Birds first design might not look so simple and lead to lots of duplicated code. On the other hand, second design can be perceived as "class explosion". Which of these two de...
Here's what I've right now: #!/usr/bin/env python # -*- coding: utf-8 -*- import functools import math import time class Timer(object): def __init__(self): self.__values = [] def start(self): self.__start = time.time() return self def stop(self): self.__values.append(int(...
Originally, I had everything in the base method #read_wall(). I'm not sure what happened with the array, but when I tried: array = result + second + third + fourth. I was left with data from only the original result. So I created this working disaster. Can you please help me refactor this? # Gets the user's Wall ...
Option 1 - nice and simple private void GetFileReady() { private StringBuilder fileContents = new StringBuilder(); using (var sr = new StreamReader("C:\A big file.txt")) { fileContents.Append(sr.ReadToEnd()); } } Option 2 - less simple private void GetFileReady2() { private Str...
It is an online learning application with different types of learnable items, that different users learn. The users learn by spaced repetition (once right, wait a couple days, ask again), success is mirrored in stages and mistakes made. I intend to use this for scientific data collection in the near future, so there is...
This a very simple function to expand the sizes between the given values. For instance, if the input variable is "S-XL" then the function returns "S, M, L, XL". Basically I'm not happy with this function. I think it's too complex for its purpose. function sizexpander($sizes) { $sizearray=Array("XS", "S", "M", "L"...
Here's a class that converts Hibernate proxies to normal classes. This is useful with GWT for example, when sending objects loaded from database to the GWT client. Please review it. package ru.minogin.core.server.hibernate; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.H...
namespace SharpDream.Api { public enum SourceType { Test, Xml } public class UserFinder { private IUserInformationSource _sourceType; private IParser _parserType; private string _source; public UserFinder(SourceType sourceType) { ...
How can I improve on this rather ugly method that builds an HTML unordered list from an XML file? I maintain a collection of ASP.NET webforms that all need to pull in the same site navigation as our main website. The forms have a master page that mimics the main site template, and we want any changes to the main naviga...
Here's the code which I use for my Android custom cursor adapter which I use to bind data to my list view. public class MessageAdapter extends CursorAdapter { private Cursor mCursor; private Context mContext; private final LayoutInflater mInflater; public MessageAdapter(Context context, Cursor c) { ...
I'm working on a managed OpenGL game engine for C#, and here's how I'm managing shader parameters (uniforms). Is it "alright"? Could it be better? I'm a bit unsure about using generics in this case. public abstract class ShaderParameter { public readonly string Name; internal readonly int Location; internal...
I'm creating a game in C#, and I've created a ScreenManager so I can call ScreenManager.MoveToScreen(typeof(ScreenClassHere)) to move to other game states. However, I feel that my method of creating an instance of the class is... not very optimal. See for yourself. public static void MoveToScreen(Type s) { ...
As far as I know the standard Delegate.CreateDelegate() which allows to create a delegate by using reflection, doesn't allow doing something as follows when the first parameter of method isn't exactly of type object. public class Bleh { public void SomeMethod( string s ) { } } ... object bleh = new Bleh(); MethodI...
I've just given this as a response to an absolute beginner on SO, and I'm wondering how terrible it is. Output for an odd number of lines: > >>> >>>>> >>> > Output for an even number of lines: > >>> >>>>> >>>>> >>> > The code: int lines = 7; int half = lines/2; String carat = ">"; int i; //better to declare first o...
I have 3 simple similar event handler functions that I would like to refactor. Any suggestions? private void btnBuildingList_Click(object sender, EventArgs e) { selectedExportType = (int)ExportType.Building; path = csvFilePath + String.Format("{0:yyyy-MM-dd}", datDate.DateTime) + "-BuildingList.csv"...
A fully functional demo URL: http://69.24.73.172/demos/index.html Note that in FireFox there is a small horizontal scrollbar bug which I have fixed at home. HTML: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Welcome to Scirra.com</title> <meta name="description" content="Cons...
I have the following code which is a private method inside the form and retrieve all context menus from the form. I feel, that it is not that concise as it should be. Would be grateful for any suggestions. private IEnumerable<ContextMenuStrip> GetContextMenus() { var type = this.GetType(); var fie...
I have 3 methods(* BindingSource are bindingsources, context is data context, cache* -are some List for cache operations): private void AddUpdateRowDocuments() { try { tRANSMITDOCDOCUMENTSRELATIONSBindingSource.EndEdit(); var t = tRANSMITDOCDOCUMENTSRELAT...
How can I use a more generic method to clean up the redundancy in the switch statement below? I'm working on an ASP.NET webforms app that will have five identical user controls that I will be showing and hiding based on the value of a dropdown list. (I have already been down the path of trying to add and remove the con...
Is this, technically, a recursive function? It only gets called once by itself, but it cleaned up my code quite a bit, I think. Or, does it needlessly complicate the code? sub check_backlog { my $topic = shift; my $prev_backlog = shift; my $backlog = undef; my @status = `$CMD -topicstat $to...
This is a simple linked list program which creates a list by appending an object at the tail. It compiles and runs perfectly. Is the coding style, logic etc are fine? How can I improve this program? Is there anything redundant or did I miss out some important things? #include<iostream> #include<string> using namespace...
Just as a refresher I put together a simple Map implementation and I would love to get some feedback on it. open System open System.Collections.Generic type Node<'a, 'b when 'a : comparison> = { key : 'a value : 'b left : option<Node<'a, 'b>> right : option<Node<'a, 'b>> } type Map<'a, 'b when 'a :...
I have a function that returns an array and I want to check that a certain value is not set in the array. function testFunction() { return array('key' => 404) } if (testFunction()['key'] < 404) { // stay calm and carry on } else { // uh oh } I understand that the above will not work in php 5.3 (or anythin...
I would really appreciate it if someone could review my quicksort implementation. Additionally, I generated my list dynamically and wrote a couple of tests. Of course, I realize that the tests are not complete, but I decided to stop where I was and see if I could get some feedback. (defun categorize_list(pivot thelis...
What it does is: Reads from a RSS feed using Google Feed API Shows the list in an unordered list How good/bad is the code snippet? $(document).ready(function(){ var FeedManager = { config : { feedContainer : $('#feedContainer'), feedUrl : 'http://rss.bdnews24.com/rss/english/home/rss.x...
class Pool(type): pool = dict() def __new__(clas, *a, **k): def __del__(self): Pool.pool[self.__class__] = Pool.pool.get(self.__class__, []) + [self] a[-1]['__del__'] = __del__ return type.__new__(clas, *a, **k) def __call__(clas, *a, **k): if Pool.pool.get(clas)...
This takes an array of numbers then splits it into all possible combinations of the number array of size 4 then in another array puts the leftovers. As I want to take the difference in averages of the first column and the second. import itertools #defines the array of numbers and the two columns number = [53, 64, 68,...
Is there a simple way to create a comma delimited string from a list of items without adding an extra ", " to the end of the string? I frequently need to take an ASP.NET CheckBoxList and format the selected values as a string for insertion into an e-mail. It's straightforward to loop over the selected checkboxes, get t...
$privilegeStrings = array_filter($privileges, function ($s) { return is_string($s); } ); Is there a better way to specify that I want just the string values in the given array?
I've been using FlexLib for its dockable toolbar feature. When you shrink the window, it will try to wrap rows if the stage width is less than the row width. Unfortunately, it won't reverse the process when you expand the window. To get around that, I wrote the following method to add to the class (the caller is res...
I often see this for custom events: void InvokeCustomEvent(EventArgs e) { var handler = CustomEvent; if (handler != null) handler(this, e); } But is creating the handler variable required, best practice, or superfluous, when compared to: void InvokeCustomEvent(EventArgs e) { if (CustomEvent != null) Custom...
In answering a question on SO, I provided this example. The intention was to provide a thread safe service that queues requests to make directories. I figured I could definitely use some review on my use of threading, singletons and general Java skills. package mkdir; import java.io.File; import java.util.concurre...
I have the following code: private ScatterViewItem FindScatterViewOfSourceFile(SourceFile find) { foreach (ScatterViewItem svi in classScatterViews) { if ((svi.Tag as SourceFile).Equals(find)) { return svi; } } return null; } Now I'm asking myself if this is valid or if I should ...
I'm currently creating an OAuth provider in Java using Jersey. To the best of my knowledge Jersey does not provide a method to create oauth tokens so I'm creating my own. For those unfamiliar with OAuth, the tokens will be used in a somewhat similar fashion to public/private keys to sign and verify all requests to the ...
I'm using Entity Framework Code First CTP 5 for a current project. There is still no enum support in Entity Framework so this is what I am using in order to avoid having magic numbers or casts littered throughout my code. Simplified Example: Domain Model Consumed by Code First public class Address { // This would n...
I've been spending a long time working on this template, I'd like to know if its CSS/HTML is good, and mainly if it is speedy to load, accessible, semantic and SEO friendly. I've tested it in IE7+, Chrome, FF and Safari and am happy with the output in each. Working URL /* Main Layout Elements */ body{ margin: 0; ...
I've used jQuery for a long time, and now I'm going to do some animations with vanilla JS. Here's my code so far: var box = document.getElementById('box'), a1end, a2end, cdend, a3end, a4end, animate1 = setInterval(function() { if (box.style.top === (window.innerHeight - 120) + 'px') { ...
This is going to be rather long and generic, so apologies in advance. I've been reading a lot about Haskell lately, but I've never really programmed anything with it beyond simple experiments in ghci. So, I wanted to finally try and do some coding exercise that was easy but non-trivial and ended up choosing the "Reclus...
I am doing a CS practice exercise in which you are supposed to sort exactly three numbers using only if statements. I wrote the following code in LISP and would appreciate any suggestions how to improve on my code. Thank you! (defun generate-three () (loop for l from 1 to 3 collect (random 25))) (defun result (a b...
I wrote the following Ruby script several years ago and have been using it often ever since on a Bioinformatics computer cluster. It pulls out a list of hosts from the Torque queuing system qnodes. It ssh'es and runs a command on all the nodes. Then it prints the output and/or errors in a defined order (alphabetical so...
This is a simple LISP program to read in three sides of a triangle and report what kind of triangle it is (or isn't). Any feedback would be much appreciated. (defun read-side (side) (format t "Enter a value for side ~d: ~%" side) (read)) (defun is-a-triangle (a b c) (if (and (< a (+ b c)) (< b (+ a c)) (< c (+ a b)))...
I want to create delegates to access properties of different objects without knowing them in advance. I have the following definitions public delegate T MyMethod<K, T>(K data); public static MyMethod<K, T> CreatePropertyGetter<K, T>(PropertyInfo property) { MethodInfo mi = property.DeclaringType.GetMethod("g...
I answered a question in stackoverflow but I gave a solution that looks a little dirty to me, I'd like your opinion because I think there is a much smarter way to do it. A guest user should be able to choose between two different view modalities. My approach was to implement an action and store the choice in the sessio...
I've got three tables I need query to display to a user for a web application I've written. Each table (Url, Note, Quote) has a foreign key relation to the User table. For every User, I need to sort all Bookmarks, Notes and Quotes based on a _date_created_ field, then deliver that to the template as one iterable. This ...
I had a file that looked like this: Mar 06 22:00:00 [10.251.132.246] logger: 10.64.69.219 - - [06/Mar/2011:22:..... Mar 06 22:00:00 [10.251.132.246] logger: 10.98.137.116 - - [06/Mar/2011:22:0.... that I wanted to split into smaller files using the ip address after "logger" This is what I came up with: file = ARGV.shi...
I have a std::set<std::string> and I need to know the total number of characters (sum of all strings length): static size_t SumLength(size_t value, const std::string &str) { return str.length() + value; } size_t TotalLength(std::set<std::string> &stringSet) { return std::accumulate(stringSet.begin(), stringSet....
I'm working on a network monitoring application, that pings an unknown number of hosts. I've made a class PingHost with a function zping and I called it with the help of a timer once every 2 seconds to let the 2 pings to finish, even if one of them gets TimedOut. But I think a better solution is to generate a new threa...
I wondering what people think of this game of life. I don't think it is working properly, but I am interesting in what people think of the general design. module GameOfLife where import Data.List --Our types type Coord = (Int, Int) origin = (0, 0) --Think of an image more like an infinite manifold type DiscreteIma...
In C++, to simplify string conversion between std::string and std::wstring, I created the following utility template functions: #pragma once #include <vector> #include <string> #include <cstring> #include <cwchar> #include <cassert> template<typename Td> Td string_cast( const char* pSource, unsigned int codePage = C...
This Common Lisp exercise is to write a program that can calculate the weekday given a string of the format "M-D-Y." It was more challenging than I expected. If you have suggestions about how to simplify this code, I will be very grateful. ;; 2.7 Day of Week. A program for converting Gregorian dates in the form mont...
This article has left me a little confused. In explaining a method on how to design MVC into Java Swing apps the author defines the controller class as Singleton and relays a series of calls to the Controller for each operation. In a view object: ... Controller.getInstance().setOwner(this); Controller.getInstance(...
As an exercise, I have implemented a circular bounded queue using arrays as the base data structure. I'd appreciate it if someone can review it for me. class BoundedQueue<T> { T[] que; int head; // remove from head int tail; // insert at tail public BoundedQueue(int quesize) { ...
This Common Lisp program is an exercise to print an integer and its digits reversed to the screen: (defun read-number () (format t "Enter a number: ~%") (read)) (defun reverse-string (the-string) (if (eq (length the-string) 0) "" (concatenate 'string (reverse-string (subseq the-string 1)) (subseq the-stri...
I need to place a Google map in Colorbox overlay and am wondering if there's a better way to do this. I've just started out with Google's tutorial so there's nothing fancy going on. Right now I'm hiding the div that Google loads the map into: <div style="width:0; height: 0; overflow: hidden;"> <div id="map_canvas"...