instruction stringlengths 71 71.9k |
|---|
I have an array for an English sentence (enSentence) and for a German sentence (deSentence). Each value represents one word. I want to print every possible phrase pair (enPhrase and dePhrase), where no phrase contains more than maxhPhraseLength words. A phrase can consist of a single word, all words of the sentence, an... |
I have this small piece of code written in a class. I am looking for a nicer way to write this, preferably avoiding nested if statements like what I currently have:
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
{
TheatreListDataWrapper[] selectedOperations = getSelectedDatas();
boolean ... |
Just started learning Java Strings. Tried to implement the Soundex algorithm.
Package to hold the String related functions
package com.java.strings;
public class StringFunctions {
/**
* Removes all the spaces in a given String.
* E.g: : "A B CDD" becomes "ABCDD"
*/
public static String ... |
You have one form and you can register a user. It can be god or mortal, but it also requires all the information to let you save the user or the change. When you have all the registers that you want you can edit one or delete it.
I'm new using Angular and I want tips to use it better. I also want to see other ways to d... |
Using OCR, my program reads the current selection for each of these categories: format, invert color? and storage. The OCR result will always have inconsistent error here and there, which is why I need a Regex match and return the correct wording for each selection:
//format
private Regex bmp8 = new Regex(".bmp... |
As a learning exercise, I decided to implement a BST and add functionality to it slowly. I'd appreciate any feedback.
I should also point out that I borrowed the template from the here.
tree.h header file
typedef char treeElement;
typedef struct TreeNodeTag{
treeElement element;
struct TreeNodeTag *left, *right;... |
The syntax for specifying multi-dimensional types in C++ is messy. For example, to specify a two-dimensional std::vector<int>, one has to write std::vector<std::vector<int>>. The syntax doesn't scale. So, I wrote a handy tool that provides easy syntax for this. Any kinds of comments are welcome ^_^ (original version of... |
I made a UI picker tool, like a "rolling select" to pick vales (demo here).
I made first a independent module with a ES6 Class, basically:
class ComponentPicker {
constructor(target, data){
// init stuff
}
deployHTML(target, data) {...}
getValue(){...}
setValue(val){...}
onChange(callba... |
I wanted to have a custom section in my app.config file in which any element could reference and reuse (or better said could inherit) any string value that is defined in it or above it in the element hierarchy. In other words, a child element could reuse any string value that it has or that its parents have.
For exampl... |
I am creating a drawing-app. I want to have a toolbar populated with tools. Each tool is defined in a separate js file. Right now i have defined each tool as an object that contains functions and variables that dictate it's behavior, for example i have 'setDragBehaviour()' and setDrawBehaviour()'.
All these functions i... |
I've built a class that handles all my connections to a MySql database.
These are the function I use to create the connection(not really sure about the two dispose functions) :
public class dbConnection : IDisposable
{
public MySqlConnection conn;
public MySqlTransaction transaction;
private static Logger... |
This code gets the cell's colour regardless of whether it's set from conditional formatting or not. It currently works on 2010 and unsure about older versions of excel.
My question is is there a way to make this code more efficient?
Such as being able to highlight an area for the code to search rather than setting For... |
The following is a (somewhat messy) implementation of the BouncyCastle cryptography library. I create a self-signed certificate (hopefully correctly), store it in a Java KeyStore, and use it to create an SSL (TLSv1.2) socket session. I am not concerned about efficiency, as this was mainly a proof of concept code to fam... |
I'm working on a booking application and am in the process of porting some legacy code to a more SOLID and testable architecture. Right now I'm working on the process of canceling bookings. Over the years, we have changed the steps involved here. The core has been the same (update booking entity status, make the timesl... |
I'm doing the Racket track on exercism.io and solved the grains exercise:
Write a program that calculates the number of grains of wheat on a chessboard given that the number on each square doubles.
(test cases etc on exercism)
So I wrote a straightforward recursive solution:
#lang racket
(provide square total)
(def... |
One of my github issues is below. I am having some problems with my security, is there anything that I should or need to improve. Here is an example of code that I use, but throughout the script there are some problems.
<?php
session_start();
error_reporting(0);
include '../config.php';
$pass = substr(sha1($_POST['pas... |
Here is a shell script which installs and configure owncloud on a Debian server. It also installs apache2 and MySQL as dependencies and fail2ban with a specific rule for owncloud. Apache2 is also configured to use a self signed SSL certificate.
The script seems to work properly (everything is installed and works fine) ... |
I wrote this factory class in order to pass parameter to Singlton class, is it a good design in term of design for multithreading environment?
public static class LoggingServiceFactory
{
private static string _connectionstring;
private static readonly Lazy<LoggingService> _INSTANCE = new Lazy<LoggingService>(()... |
From SICP
Exercise 2.69: The following procedure takes as its argument a list of
symbol-frequency pairs (where no symbol appears in more than one pair)
and generates a Huffman encoding tree according to the Huffman
algorithm.
(define (generate-huffman-tree pairs)
(successive-merge
(make-leaf-set pairs)))
... |
(See the next iteration.)
I have rewritten a Fibonacci heap implementation from Java to C.
fibonacci_heap.h:
#ifndef FIBONACCI_HEAP_H
#define FIBONACCI_HEAP_H
#include <stdbool.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct fibonacci_heap_t fibonacci_heap_t;
/*****************... |
I did a project in WPF MVVM. Just a single Window with single Frame control and few Pages. My problem was communication between pages without not violating MVVM principles. I'd like to use all bestprogramming-practices.
Can you check if this code agrees with the all best principles?
My solution has two projects: WPF c... |
Can this query be improved? Is there a way to eliminate the duplicate function call?
-- a Special Group has many Items which have many Bookings
create function f_BookingsForSpecialGroup(@specialGroupId varchar(99))
returns table as
return select * from v_Booking where ITEM_CODE in
(select ITEM_CODE from v_I... |
I feel like I’m violating a lot of DRY rules here but can’t think of a better way to do this. I have two event methods (there are actually four total just showing two) that are doing a lot of similar actions but on different DOM elements. Is there a better way to re-factor this so I’m not repeating myself so much.
... |
Now that we can move across the bridge, it's time to finally set up the problem so that it can be solved. A reminder of what the assignment is:
Welcome to the Bridge Crossing Problem. Person Pn can cross the bridge
in n minutes. Only one or two persons can cross at a time because it
is dark, and the flashlight mu... |
I recently added this ConfigLoader class to my project : it loads information (in this example for a window) from an XML config file, using boost. I would like to ask your advice if this is a good implementation of a ConfigLoader using type_traits, or if I could improve it; here is my code:
ConfigLoader.h:
#pragma once... |
I used a Raspberry Pi and Adafruit LCD with buttons to build a small thermostat for my house.
This is the hardware I used to you can imagine how the button and the code work:
https://www.adafruit.com/products/1110
I know I need to build some kind of state machine but I don't know how to handle persistance in python tha... |
I've built a class for an e-commerce Item, and the ShoppingCart class for checkout functions.
The thing I'm most concerned about is my use of pointers. I think I've used them properly in this situation, but I could be wrong.
Item.hpp
#ifndef Item_hpp
#define Item_hpp
#include <iostream>
using namespace std;
class It... |
My friend requested a navigation menu for his code that he has since he didn't really know how to do it, so I had created one for him. I just wanted to get it reviewed since I'm a beginner with C and want to see if there is any way to shorten or improve this.
//
// main.c
// Oyster Top Up Menu
//
// Created by JStud... |
As of reading the following input.txt file:
1 6 14
1 2 7
1 3 9
2 3 10
2 4 15
3 6 2
3 4 11
4 5 6
5 6 9
I wanted to make a list of lists containing each line as a list of integers
[[1, 6, 14],
[1, 2, 7],
[1, 3, 9],
...
[5, 6, 9]]
I achieved that by doing the following
with open('input.txt', 'r') as f:
# gets l... |
I'm new to Java and is trying to solve the beginners problem of finding out the number of vowels in a string. I was just wondering if there is any alternatives to any of the steps that can improve efficiency as well as simplicity.
import java.util.Arrays;
import java.util.Scanner;
public class CountVowels{
publi... |
Compile with: gcc -std=gnu11 -o "portknock" "portknock.c" -lpcap
I did this as a learning experience, and it actually ended up being something useful. I made a port-knocking spawned reverse TTY with it, and it could easily be made into a port knocking firewall daemon.
#include <stdio.h>
#include <stdlib.h>
#include <pc... |
I am trying to figure out a more efficient way of converting money into change. The code below is what i have written so far. It works perfectly but i know the code can be improved. Is there a more efficient way of writing this code?
public class Problem2 {
public static int quarters(int total)
{
retur... |
What do you think about this file system manipulation helper? There is an utility class Folder which I can use to define directory structure of my app:
static class Folders
{
public static Folder Bin =>
new Folder(Assembly.GetExecutingAssembly());
public static Folder App => Bin.Up();
public static... |
This was asked in the SQL Helpline room:
I have a sql query concern. Could you help me?
It goes like this. I have a table with the Records
A B
A C
B A
B C
C A
C B
How do I get only the records that there aren't duplicated in both columns
A B
A C
B C
While it seemed simple at first, it was surprisingly difficult t... |
I am a self-taught programmer and would like anyone to point out anything that is not the standard or professional way to do things. Any help/advice is greatly appreciated.
I would love to post a lot of my code or perhaps make a youtube video explaining certain portions for feedback. Let me know in the comments what yo... |
This set of code is very large, and I'm hoping if someone could show me a more efficient way of doing this. In particular, the JavaScript code, but HTML and CSS corrections are just as welcome.
$(document).ready(function () {
var item1 = "active";
var item2 = "unactive";
var item3 = "unactive";
var it... |
Sonar/FxCop are telling us that we shouldn't use void async methods. That's ok.
This is the current implementation:
private async void InitMethod(ServiceControl serviceControl)
{
if (serviceControl != null)
{
await Task.Factory.StartNew(() => serviceControl.Execute());
}
}
// fire and forget ... c... |
I have built real-time markdown editor in order to learn AngularJS by practice. I think what I'm trying to do can be done a better way. Any suggestions appreciated. Here's my code:
var myApp = angular.module('myApp',[]);
myApp.factory('Data',function ($window) {
return {message: $window.localStorage['stuff']}
});
... |
I am using PHP in order to create a custom wrapper for including files, for this I have written this class:
<?php
class Refrences
{
#region properties
private $_basePath;
#endregion
#region public members
public function __construct() { $this->_basePath = $this->cleanDirName(dirname(__FILE__)); }
... |
I have written a windows service that I am currently not that happy with as I am facing design issues (first windows service).
The aim of this service is to monitor CPU usage and send an alert when it reaches a threshold (coming from the DB).
So the user has set a threshold of > 60% CPU usage for 10 Seconds. Then the c... |
I have created a function that helps me generate pagination really easily but I am concerned about its performance mainly.
The function accepts 2 parameters:
A list of items (has meaning in the framework I'm using) which contains information about the state of pagination itself and state of the storage layer - more pr... |
I receive daily files (filename_%m_%d_%Y.csv) from a client and I read those in pandas, process them, and store them in Postgres. Sometimes there are delays and we do not get the data for a few days. The problem is that I have everything on a scheduled task and I do not want to manually check if the files exist or not ... |
Based on the feedback and suggestions I received in my previous post (Lightweight shorthand JS library), I've updated and optimized Mozart JS.
Again, the goal is to have some jQuery-like functionality in a minimal size. Thoughts on this updated version?
Full library on GitHub.
Mozart JS
Element Retrieval
Shorthand fo... |
public class Encrypt extends Activity {
EditText Filename;
EditText secretKey;
EditText msgContent;
Button save;
Button cancel;
public String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Encrypted Files";
@Override
protected void onCreate(Bundle savedInstance... |
I have a Windows forms application which we deployed in my firm for use on thin clients. The app lives locally on each user's machine, but pretty much all of the work the users do is over a Citrix session.
One of the options (the main option) available to the user is the ability to restart their own session. I recently... |
I just came across the Ackermann–Péter function a few weeks ago, found it to be very interesting, and decided to write a simple implementation of it in a favorite programming language of mine.
def ackermann_peter_10(m, n):
assert isinstance(m, int) and m >= 0, 'm is unacceptable'
assert isinstance(n, int) and n... |
Sometimes, we create a one-dimensional object, but want to access it in a multi-dimensional way. For example, you can access an int[8] array object in a 2x2x2 way. So, I made a multi_view class template to make this easy. Any comments are welcome~ Original code can be found here and documentation here.
template <typena... |
I am newbie in scala don't know how to refactor to make it better because currently it kinds of boring when read it.
I have 2 classes BidWinPostData and BidEventPostData.
They are kind similar the different between of 2 is in modifier when call getSelectorAndModifier.
I am using it at
bidEventRDD.foreach { line =>
... |
I know a module like this already exists on CPAN, but I wanted to write my own simplified version that accepts wildcards in the input.
I don't write many Perl modules so I figured I would post the code here and see if anyone could give me advice on how to make this code more efficient or user friendly.
I also included ... |
I'm trying to optimize the main loop portion of this code, as well as learn any "best practices" insights I can for all of the code. This script currently reads in one large file full of tweets (50MB to 1GB). It uses pandas to play with the data, and matplotlib to generate 2D graphs.
Currently, this does not scale well... |
To complement this Java question on palindrome identification, I came up with this C++(14) version:
#include <iterator>
#include <algorithm>
#include <functional>
namespace detail
{
template <typename RandomIt, typename BinaryPredicate>
bool is_palindrome(RandomIt first, RandomIt last, BinaryPredicate pred,
... |
Adding another level to my previous question on 'normal' palindrome identification, in this one I'm interested in identifying genetic palindromes. Here's my attempt:
#include <iterator>
#include <algorithm>
#include <array>
namespace detail
{
static constexpr std::array<char, 128> complement_table
{
4,... |
I am trying to pull back records that include child records for the View I'm putting together. Right now I have a working Linq statement, but it's big, and I think I could make it cleaner.
var reqMatsInc = (from rm in db.RequiredMaterial
join p in db.Project on rm.ProjectTemplateId equals p.ProjectT... |
I recently followed a tutorial on a JavaScript snake game. I tried to improve that game by adding bad fruit which will make your snakes tail incredibly long.
//constants
var COLS = 26,
ROWS = 26;
//IDs
var EMPTY = 0,
SNAKE = 1,
FRUIT = 2,
BADFRUIT = 3;
//direction
var LEFT = 0,
UP = 1,
RIGHT = 2,
DOWN =... |
I am considering
<input type="checkbox" name="arConfig[3]" value="payout"
<cfif ListFind(attributes.config[3], "payout") NEQ 0>checked="checked"</cfif> /> Payout<br />
<input type="checkbox" name="arConfig[3]" value="points"
<cfif ListFind(attributes.config[3], "points") NEQ... |
i have found this article on how to loop through multi-dimensional arrays quickly.
http://nadeausoftware.com/articles/2012/06/c_c_tip_how_loop_through_multi_dimensional_arrays_quickly
I am using Method 6: Nested loops with linear array and single incrementing index.
It says Method 8: Single loop with linear array and ... |
I have a script which can only be run by one specific user on a system. I need to let all users on the system have access to run that script and see the output. But there must never be more than one instance of the script running simultaneously.
I came up with this program to be run as the specific user who can run the... |
This code correctly returns a View_appointment. Is there a better way to
accomplish this with using left joins and unions? I'm trying to learn Linq a little bit better.
Components:
PostgreSQL 9.3 (backend database)
Telerik DataAccess (the entity framework)
Overview:
I am writing an appointment book for my office. Eac... |
I was working on an assignment and I was hoping to know if the merge sort algorithm I wrote in Python was not making any unnecessary computations.
def sort(some_list):
if len(some_list) > 1:
return merge(sort(some_list.__getslice__(0, len(some_list)/2)),\
sort(some_list.__getslice__(len(some_list)... |
For some of those in The 2nd Monitor, you know that I was creating a new golfing language. For one or two (@Quill), you have heard from me how tough it is.
A-Ray (that's what it's called) is a functional programming language. A sample program looks something like:
T0~f"Fizz"~b"Buzz"f{?=%t+960{p`fp`b}{?=%t30{p`f} ?=%t50... |
I made a dynamic CSV serializer as a learning challenge a while back, I'm hoping to get my code picked apart so I can learn what I can do better.
This is a bit long, so I wouldn't expect anyone to take the time to pick apart the entire thing. If it helps, here is the github page for a download with some instructions.
T... |
While implementing things like repositories we often can see that reading and writing parts can be done totally independently. The same time client side will win from the single reference (who wants to inject two parameters instead of one in many places). What do you think about a little bit of IL magic?
Let's say we h... |
Given a class which is an event dispatcher whose underlying store is a dictionary of events whose key is the event type private readonly Dictionary<Type, Delegate> _applicationEventHandlers;, is this the correct way to remove all remaining delegates when the class needs to be disposed?
private void RemoveAllListene... |
I'm attempting to implement a basic hash table in Python using only lists. Any tips would be appreciated (including better hash functions).
I intend this to handle collisions with separate chaining.
Are there any features I didn't implement that are standard in hash tables?
Are there any things I handled incorrectly ... |
For one of my university assignments, we were asked to take an unsigned int, reverse its digits, find the absolute difference between the original and reversed, then reverse that, and you receive the "Magic Number".
$$ R(\ \lvert R(A) - A\rvert\ )$$
where \$A\$ is a positive integer and \$R(n)\$ means reverse.
We were ... |
I'm building the above mentioned parser.
It reads a string of assembler instructions.
I want to become a better coder, so I wanted to get a code review to start learning to do things property.
As we know instruction is a string with an instruction mnemonic like "mov","lea","add" followed by 0 to 3 operands, separated ... |
EDIT:
The code i provide includes a asynchron task in each interation, therefor i need the recursive function, my question is how to beautify the code and apply the proper use.
I want to:
Remove the processTask(); function call and let it call itself instead.
Choose the best function declaration.
connection.query(quer... |
This is my first 'proper' script since learning python and I'd love it if I could get some feedback on things I've done wrong / things I can improve on.
The script takes clipboard data from after effects, containing information on position, rotation and scale.
It then gets out the numbers, converts them to keyframe d... |
Design a class TIME which stores hour, minute and second. The class
should have
the methods to support the following:
User may give the time value in 24-hour format.
User may give the time value in AM/PM format
Display the time in 24-hour format.
Display the time in AM/PM format.
User may like to add minute with a ... |
I am working on a node.js sails.js app that handles a number of API calls and uses Bluebird for promises. The API calls have been reliable but I would like to build in handling for if they do not respond. I'm wondering if there is a good standard practice for handling timeouts (or a different approach) if the API servi... |
I recently create a function to combine some arrays of associative arrays in a single array in response to a stackoverflow question, where you can found more details about this.
The function works as expected, but I think their description is very obscure. In addition, i choose constant T_OBJECT_CAST as option to conve... |
I am creating a game with destructive terrain. Before I used a flat array to store the blocks, in chunks of 32^3.
As I am aiming for detail and long view distance I would of course need some sort of LOD. Therefore I decided to use a octree instead. Memory usage is significantly less than the flat array, but accessing n... |
I'm looking for some feedback on some code, designed to allow me to strongly-type parameters, which get passed to functions.
I'm only really looking for comments on making my parameters more strongly typed, as well as the existence of the factory method. The implementation of the FindUser method is not relevant.
At the... |
I have this Quicksort implementation that sorts arrays of int (not Integer). It has comparable performance to Java's DualPivotQuicksort, especially when the size of the range is below one million elements or so.
IntegerQuicksort.java
package net.coderodde.util;
import java.util.Arrays;
import java.util.Random;
public... |
I have this project that should respond to events. Can my code can be refactored and become shorter? Am I using actionListener properly?
public class DifferentShapes extends JPanel implements Shapes{
protected JMenuBar menuBar = new JMenuBar();
protected JRadioButton small = new JRadioButton("small");
protected JRadio... |
Since I'm a big politics nerd, I wanted to write a little script that would analyze the frequency and content of political fundraising emails. I signed up for the e-mails of 6 campaigns, donated a dollar to each so I'd get hit up for more money often, and let it sit. Unfortunately you won't be able to run the script ... |
I have tried my hands at "functionalising" a toy problem I had: find the expected number of throws of a six sided die until all sides have been seen (the answer is 14.7)
My starting point is my imperative solution
import scala.collection.mutable.SortedSet
import scala.util.Random
def dice(nsim:Int) : Double = {
va... |
This code is for a magic 8 ball in Python. What do you think?
import random
import time
choices=[
"Definitely",
"Yes",
"Probably",
"Mabye",
"Probably Not",
"No",
"Definitely Not",
"I don't know",
"Ask Later",
"I'm too tired"
]
while True:
input("Ask the mighty 8-Ball a question\nOo")
for i in range(0,3):
... |
I'm giving a presentation in a few days. I'm preparing my material in LaTeX; however, I am relatively new to it. How can I make my LaTeX code more concise and less repetitive?
Here is a reduced version of my presentation, which contains the following features that I'm seeking to improve and tighten up:
Code samples ... |
I wrote a test program (and first "real" Haskell program!) that receives a zmq request on 1 socket, and forwards part of that message to another socket.
There are a 2 things I specifically don't like:
I couldn't figure out a way to build a protobuf message without specifying every field. This is especially annoying f... |
I am trying to find a phrase or a string in file and count the number of occurrences of that string:
private static HashMap<String, Integer> bruteForceSearch(
String stringToLookFor, List<File> list) throws IOException {
HashMap<String, Integer> result = new HashMap<String, Integer>();
for (File file : ... |
Let's assume I have 2 objects Product and Volume. 1 Product must have at least 1 Volume which means: Product ----> 1...* Volume.
I want to keep the consistence of Product at its creation, in other words, I want to block the user to create products without any volumes.
I have a ready working code, but nonetheless I want... |
I've written an interrupted bubble sort, which prints the intermediate result after some specified number of iterations of bubble sort. But I seem to have an speed issue. Could anyone help me spot some places that need to be optimized or are just plain wrong?
#include <iostream>
#include <fstream>
#include <string>
#in... |
I have a stack of numbers ranging from 1 to 1 million representing a pile of numbered DVDs. Given the stack in random order I am to sort the stack by only taking an element from the stack and push it to the top and then calculate the minimum of such pushes necessary. My code is way too inefficient when dealing with lar... |
I wrote this, which I'm not sure if it's of any use yet but at least it saves me some time when writing atomics to a file or raw memory.
What I was thinking is that the conditional in the write()/read() methods isn't very good and maybe I should add methods like calcwrite()/calcread() for calculating the space required... |
I wrote a minimal implementation of a hashtable in python as an exercise.
from copy import copy
def init_nested_array(size):
arr = []
for i in range(size):
arr.append([])
return arr
class hashtable:
def __init__(self):
self.mod = 3
self.num_items = 0
self.arr = init_nested_array(self.mod)
... |
I am relatively new to Angular and need to put together an application to update / save / display values. The code is working, but I wanted your input the make sure that I am doing this 'the angular way'.
JavaScript
var app = angular.module('store', []);
app.controller('TableController', ['$scope', '$log',function($sc... |
This is just a simple little drum machine. Since it loads sounds files, I can't just put it on JSFiddle. I tried Github pages too, but am not sure how to get the sound files working. However, you can clone the repo, run a server with python -m SimpleHTTPServer 8000 (it won't work if opened with the file:// protocol), a... |
I was interested in finding some of the weirdest question/protection combinations, basically out of curiosity.
I heuristically defined this as:
Low view counts
Not a moderator/SE employee
From users who protect multiple questions
I'm... let's just say not an expert in SQL. Though this query works, it feels super inef... |
I just started learning Erlang. Here is my crack at the Seive, based on (https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf):
-module(seive).
-export([seive/1]).
seive(N) ->
L = lists:seq(1,N),
{Megass, Ss, Micros} = erlang:timestamp(),
S = doseive(L, 2),
{Megase, Se, Microe} = erlang:timestamp(),
... |
I have implemented a LRU cache using ConcurrentLinkedHashMap. In the same map, I am purging events if my map reaches a particular limit as shown below.
I have a MAX_SIZE variable which is equivalent to 3.7 GB and as soon as my map reaches that limit, I am purging events from my map.
Below is my code:
import java.util.c... |
I am a nurse and I'm learning to code. I have coded this simple tool that helps me doing some common nursing formulas for medication. It works, however I think it is too bulky/redundant. Can you help me with some ideas for refactoring it?
class NursingFormulas
def initialize
puts "What do you want to do?"
put... |
I made a simple JavaFX calculator. It does basic calculations, and works to the best of my knowledge. However, I'm a novice at both Java and JavaFX, so I seriously doubt this is as efficient and clean as possible. I personally think it could be more modular, maybe put those huge loops in functions or something.
package... |
I built an application class that should be runnable as a Thread and it would be nice to hear opinions of Java developers to improve my coding style.
Main class.
package com.ozankurt;
public class Main {
public static void main(String[] args) {
Application application = new Application();
applic... |
I have to swap the characters in a string before sending said string to a device to show the information sent through a LCD, the method I developed is as follows:
private string StringSwap(string stringToSwap)
{
if ((stringToSwap.Length % 2).Equals(1))
{
stringToSwap += " ";
}
char[] array = st... |
I am a self-taught programmer and would love any advice / suggestions. I wanted to implement some sort of n-tier Architecture, but not sure how to move all my code around.
My program will take movies from my hard drive and eventually allow me to view the results in a nice Netflix like UI.
The code below is just the beg... |
I am a relatively new Rails developer and doctor doing research. In my Rails based research projects I often have questionnaires for which I provide a "% complete" parameter.
Here is an example. You can see that each of the score attributes is given a value and then I can create a %. It looks awful and very un-Ruby-li... |
I have a Ruby programming task. My code passes all the rspec requirements, but I am not sure if I've done it in the right way. And I'm not quite sure why I need :entries there...
Here is the rspec test:
# # Topics
#
# * Hash
# * Array
# * instance variables
# * regular expressions
require '11_dictionary'
describe Dic... |
I am working on a simple mouseout and mouseover functions. Basically, I have color boxes (or swatches) and I have to get the color of the specific box when hovered and when selected. You can see how it works in the fiddle.
So I came out with a working script. But I am not sure how I can optimize or shorten the script s... |
template<class Compare, class Iterator>
void merge_sort(Iterator start, Iterator fin, int sort_type) {
Compare comp;
typedef typename iterator_traits<Iterator>::value_type _value_type; //black type magic to infer data type
if (distance(start, fin) > 1) {
vector<_value_type> left (start, start+di... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.