instruction stringlengths 71 39k |
|---|
Is there a better way to implement this class, or does it not constitute implementation in the first place? This is one of my first few tries at OOP. Any suggestions will be much appreciated.
#include <iostream>
#include <vector>
#include <cmath>
class PrimeList
{
public:
std::vector<int> vPrime;
... |
Here's a simple algorithm that walks the DOM given a node:
function walkDOM(n) {
do {
console.log(n);
if (n.hasChildNodes()) {
walkDOM(n.firstChild)
}
} while (n = n.nextSibling)
}
I wanted to implement it iteratively as an exercise, and came up with this:
function walkDOM2(... |
I started learning JavaScript a week ago, and I made a sorting function on my own. It does work, but I need reviews and how to write a better one.
<body>
<ul id="list">
<li>Art</li>
<li>Mobile</li>
<li>Education</li>
<li>Games</li>
<li>Magazines</li>
<li>Sports</li>
</ul>
var list = document.ge... |
var timeToWait = TimeSpan.FromSeconds(20);
var interval = TimeSpan.FromMinutes(5);
var t = new Timer(s =>
{
tracker.ProcessAuditLogs();
}, null, timeToWait, interval);
I'm looking to run a timer or an indefinite period of time, as long as my program/service is running. Will the above work in a producti... |
This function code works very slowly. How can I speed it up?
CREATE OR REPLACE FUNCTION bill."ReportIngredients"(
_from date,
_to date,
_beginning_date date,
_has_inventory boolean,
_inventory_id uuid,
_restaurant_id uuid,
_stock_id uuid,
_ingredientIds uuid [],
_sort_by character va... |
I am currently learning JavaScript and created this cross-browser event utility as a learning exercise. It was not meant to be used in production code, and I just tried to cover only the cases that I'm aware of, so there might be a lot of edge cases that are not covered.
I'd be happy if you could check it and let me k... |
In my ASP.NET MVC code, I like to use controller service classes for my controllers. These service classes contain methods for retrieving viewmodel objects.
Here is an example controller snippet:
public SubscriptionsController(ISubscriptionsControllerService service)
{
_service = service;
}
public ActionResult Ind... |
I am currently learning JavaScript and created this cross-browser AJAX utility as a learning exercise. It was not meant to be used in production code, and I just tried to cover only the cases that I'm aware of, so there might be a lot of edge cases that are not covered.
I'd be happy if you could check it and let me kno... |
This code fetches reviews for the top 100 products on NutraPlanet, finds the Bayesian estimate for each average review, then prints out all reviews sorted by that Bayesian estimate.
How can I improve this code (correctness, elegance, best practices, etc)?
<?php
// echo "Remove exit from script to run."; exit;
define(... |
I have written the following Query to retrieve some object's ID. If there are objects in the list that have a larger numbinbatch than the saveditems number in the batch, then it should take that. If not, then it should take the first number from the lower number in batches.
I am wondering if this could be shortened. I'... |
I'm currently working on a logfile parser for a pretty old videogame called Team Fortress Classic, which can be compared to Counter-Strike 1.6 and is available on Valve's Steam platform.
I started out trying to make a collection of nicknames for each player. Every player joining the server has a unique ID, the STEAM_ID... |
I'm a C++ beginner and have made a simple class. But I'm not sure if this is well-written. It's basically just a Date class.
#include <iostream>
using namespace std;
class Date{
int d, m, y; //Day, Month, Year
public:
Date(int dd = 1, int mm = 1, int yy = 1);
int addDay(const int &dd) { d += dd; }
... |
Suppose I've got a JavaScript function that I'm treating like a class - that is, I want to make many instances of it:
function Blerg() {
this._a = 5;
}
Blerg.prototype.getA = function() {
return this._a;
}
Blerg.prototype.setA = function(val) {
this._a = val;
}
This class has one attribute, a, which the constr... |
This was too slow for my computer:
int f(unsigned int x)
{
if(x <= 1) return 1;
else return f(x-1)+f(x-2);
}
/* main */
int main()
{
for(int i = 0; i < 50; i++) cout << f(i) << endl;
return 0;
}
So I've made a faster implementation. It works, but is it well-written? Is there some way to improve it? ... |
the purpose of this class file is to design a Saving account that stores a saving account's annual interest rate and balance. I have not wrote the test program yet, seeing that I believe I made a few mistakes with my class file. Also, at the end of classfile, I hid a method because I didn't understand how to word that ... |
I'm just wondering if this code is good against SQL injection attacks. I don't know how to check if is good. Also I would like to know if is good how I'm working or this is just bad practice?
<?php
if (isset($_POST['register'])) {
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password... |
Please take it easy on my as this is my first OOP web application I plan on converting it to some deeper degree but not sure yet.
The basic functionality is there I think, but I'm looking for some feedback on how I can improve this in terms of OOP and simplicity. Sorry for any simple mistakes only been doing php for a ... |
I've started reading C++ Primer a few weeks ago and there's an exercise that asks you to compare two arrays for equality. The code I made works, but is it good? What should I fix?
If the number of elements don't match, they're not equal. If the elements are different, they are not equal.
#include <iostream>
using nam... |
It is usually inefficient to find bugs in a longer code. Unfortunately, after spending too much time in debugging my code, I realize that a good programming habit is important. Please give me some advice about codestyle, design... anything important to write high-quality code.
import numpy as np
from numpy.random impor... |
I was learning a bit about about observers. Ruby has an Observable module, but I decided to make my own with a few tweaks.
The first important feature is that this module calls one or more observer methods when the observed object's state is changed. When you add an observer, you also have to specify the method that wi... |
I've been thinking about making Javascript Prototypes that represent HTML elements.
For example a form prototype with build in ajax requests and form element prototypes. Or a list with list item prototypes.
I think that the biggest benefit of this approach is that it reduces repetitive code.
Here is an example of what... |
I've got the following code to monitor the network usage on a network interface. I'm mainly looking for feedback on the design, but if you see any code improvements please let me know! This is also the first time I've actually added 'official' documentation so tell me if I'm forgetting something.
For those that feel mo... |
I've built a small library for comparing objects based on their members here (related SO question).
There's a need to compute hash function in order to conform to IEqualityComparer<T> interface. In my case this function has to be computed based on the hash functions of members. So the main problem is how to compose the... |
I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better for timing analysis.
My main focus on timing analysis is for conducting many test cases on 2 variations of the same function. In this example code I used 2 variations of function for reversing ... |
I'm an advanced C# programmer learning F#. As an exercise I'm porting a function that calculates the check digit of a US ABA (routing) number. Here are 2 C# implementations:
int CalcCheckDigit(string rt)
{
var s = new[]{3,7,1,3,7,1,3,7}
.Zip(rt, (m,d) => m * int.Parse(d.ToString()))
.Sum();
ret... |
Before I get started I have spent much time searching for the answer. It seems the most referenced way is here, http://www.developer.com/print.php/3794146. I am not quite understanding how to optimize. See below.
public void CalculateStdDev()
{
arrayItemCount = 0; // integer
average = 0; // double
double it... |
I created a Queue object when answering this question and I was wondering if it could do with some improvement.
Here is the current code:
var Queue = (function () {
Queue.prototype.autorun = true;
Queue.prototype.running = false;
Queue.prototype.queue = [];
function Queue(autorun) {
if (typeof... |
I wrote this class to ensure that anything done in any of my worker threads can be displayed on the GUI via events, but I ran into non-thread-safe problems.
This class should take an action or a function with one or no params, i.e. the event delegate.
Is this code actually thread-safe, and, how could it be improved upo... |
I started learning my first functional programming language (Haskell) yesterday and I have been working on a lexer for an expression evaluator. The lexer is now basically feature complete, but I'm not sure what I can do to improve the code.
import Data.Char
import Data.List
data TokenType = Identifier |
... |
This is my Fibonacci generator:
package main
import "fmt"
func main() {
for i, j := 0, 1; j < 100; i, j = i+j,i {
fmt.Println(i)
}
}
It's working, but I don't know how I can improve it, so I'd like more expert approaches to solving it.
|
I am planing to create a small game using C#, so I've decided to create a small logic for that game. I immediately opened Visual studio and started to create some classes to hold on the player's data, so I came up with something like this. However, I don't know whether or not there is better ways to achieve such thing... |
I've built a basic image slide show with jQuery, nothing particularly fancy, but there a few specific things I wanted it to do and I managed it - I just don't think I did it the best way possible. Hoping to get some pointers on where I can improve it.
So the basic visual structure is:
__________________________________... |
I am supposed to be creating a doubly circular linked list, but I am now have problems creating the actual linked list. Is there a problem with the classes? Also, for the assignment, the list is suppose to be a template class, but now I just want to get the code to work.
#include <iostream>
#include <string>
#include ... |
This is my interface, all of my transport concrete classes will be implementing this interface.
interface ITransport
{
void Travel()
}
These are my existing implementation class:
class Horse : ITransport
{
public Horse()
{
}
public void Travel()
{
Console.Writeline("I am travelling on ... |
I'm trying to make a MultiClient Chat Application in which the chat is implemented in the client window. I've tried server and client code for the same. I've got two problems:
A. I believe the code should work but, server to client connections are just fine but information isn't transferred between clients.
B. I need a... |
My aim is to sort a list of strings where words have to be sorted alphabetically. Words starting with s should be at the start of the list (they should be sorted as well), followed by the other words.
The below function does that for me.
def mysort(words):
mylist1 = sorted([i for i in words if i[:1] == "s"])
my... |
The following are an example of methods supported by a proprietary device:
Monitor
ControlTemp
PutPeakInfo
GetPeakInfo
I have a class that builds the packets for the above corresponding methods:
GetMonitorPacket
GetControlTempPacket
GetPutPeakInfo
Example:
public byte[] GetMonitorPacket(int ddcNum)
{
byte... |
I'm only two weeks into learning Java and just finished creating my first program. I have a feeling I've added unnecessary things, but not sure. I'd like someone to take a look at it and let me know if there are ways to simplify or approach the code. Basically, I'm just trying to create a simple GPA calculator.
impor... |
I have a User class that will throw an exception if the userid provided in the parameter does not correspond with a user.
I've written a helper function that will return true or false depending on whether a userid belongs to a user or not, but was wondering if my use of a try {} catch {} to do so is correct:
privat... |
I'm not sure that I fully understand this pattern. I've written a simple application that uses MVC. Please criticize my approach to the use of this pattern. For convenience, I'll post the source code of the main classes. The source code of the project can be found here: SoundLights on GitHub
The app has one screen. Scr... |
I'm getting data to fill out an e-mail template, and I'm wondering if this method is too long. How could I refactor it?
sub getEmailData
{
my $self = shift;
my $defs = QuickContentFunction::Simple::QuerySearchFieldDefinitions->new();
my $phParams = decode_json($self->parameters);
my @aFields = split(/... |
While working with someone else's code I've isolated a time-killer in the (very large) script. Basically this program runs through a list of thousands and thousands of objects to find matches to an input (or many inputs) object. It works well when the number is below 50 but any input higher than that and it begins to t... |
I want to verify that I'm correctly handling risk of "Overflowing fixed-length string buffers." I'm also aware that I'm using C-style strings, which falls short of full C++ code.
Main
/*
PURPOSE:
attempt to implement, without using given/known-good code, various concepts
of c++.
one exception:
code in header fileT... |
I'm working on a TCP Server using .NET and the following code is my first attempt to process the received data (from the socket) to create a packet to deliver. Basically, the packet has a header (7 bytes) where the first 3 bytes are always 0x12 0x34 0x89 and the next 7 bytes are the message length. For example:
0x12 ... |
users_controller.rb:
class UsersController < ApplicationController
def new
end
def create
user = User.create(params[:user])
if user.id
session[:user_id] = user.id
redirect_to '/city/map'
else
redirect_to new_session_path, flash: { error: 'This name is already taken.' }
end
end... |
This is (supposedly) a multi-threaded scheduler for one-time and/or repeating tasks. The tasks are simple std::function<void()> objects. I built it to be a crucial part of a larger project I'm working on, but I developed it stand-alone, so no context is missing for a review.
I'm making heavy use of C++11 language and l... |
For my current project, I have elected to represent database rows as objects.
So an individual comment can be retrieved as a class like so:
$comment = new Comment(1);
Here is the Comment class code:
<?php
class Comment
{
private $userid, $postid, $content, $date, $name, $ip, $legacy;
public function __constr... |
I'm getting into jQuery and I figured I'd start with log in / sign up form. (As an aside, I'm fully aware log in / sign up forms exist ad infinitum; this is more as a learning exercise than anything)
The idea is that the form fields will fade in depending on whether the user wants to log in or sign up to the site. Mos... |
Each data structure has its own time complexities. The biggest one that jumps out at you is the hash table. The average times for Insertion, Deletion and Searching are all O(1). But it's really just constant time, since there can be multiple reps through each of these to find the right spot. The real question is, c... |
I have a C++ class which acts as an abstraction for an IO device which is controlled through file descriptors. As I am very new to C++, I would be glad if you can give me devastating feedback on things I've done wrong.
This especially covers:
Code style
Design patterns
Error handling
Things which are open for failures... |
I want to remove not only spaces, but certain characters, as well from the beginning or end of a JavaScript string.
function trim(str, characters) {
var c_array = characters.split('');
var result = '';
for (var i=0; i < characters.length; i++)
result += '\\' + c_array[i];
return str.replace(new RegE... |
I have multiple different implementations of an object, which implement this custom interface I made called Board.
Board contains a method that looks like the following
public void ConvertFromString(String formattedString);
Each object implementing Board calls ConvertFromString() in its constructor.
Looks like the fo... |
I've received reviews on the last version here, but as an update would make the answers not fitting anymore, I think it is wise to open a new post.
I followed most of the hints of the last review and now want to check if I done things write or made new mistakes.
If you are interested in the complete source click here
g... |
I am creating an application just for practicing c# as well as new programming ways. So i came across the idea that i create an application that stores information about "soldiers" ex. Names, ranks, titles, etc... but the trick here is that i want the soldier title to be automatically upgraded when it's rank increases.... |
I'm working on a simple blogsystem (for learning purposes, not to reinvent the wheel). In this system the user can add existing or new tags to a blogpost. I wrote a method to achieve this, but it's ugly, inconvenient and probably of bad performance.
Some facts:
I make use of Propel as mapper to a PostgreSQL database
r... |
Here is my script of a simple jQuery-powered galler I've decided to create while studying JavaScript. Please point out my mistakes and let me know how the script can be optimized!
JavaScript
// define globals
var overL = $('div.overlay_p');
var temP = $('div.pre_load');
var imgM = $('span.p_img');
var fCont = $('p.ali... |
It works fine, but it is slow.
Could anybody help make this faster?
import itertools
from decorators import timer
from settings import MENU, CASH
class Cocktail(object):
def __init__(self, group, name, sell, count=0):
self.group = group
self.name = name
self.sell = sell
self.coun... |
I have a query which selects a show from anime_series, then selects corresponding information from other tables (such as studio, which is stored as a SMALLINT reference to another table). The below query works as intended, but I really don't believe my code is as efficient as it can or should be.
The real complexity is... |
I am starting out with Java programming and get limited feedback from my professor. Following is an assignment that I handed in, and just re-factored. I wanted to see if people with Java experience could give some pointers on improving how it looks. Last semester I took a C++ course so splitting sections up into public... |
So I came across an interesting problem awhile back, and I finally got around to solving it. Basically, it needs to allow the user to provide two words, and have them progressively splice together, like so:
Word 1: 123
Word 2: abc
Result: 123abc
12a3bc
1a2b3c
a1b2c3
ab1c23
abc1... |
I've written a program:
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.commons.io.FileUtils;
/**
*
* @author Mohammad Faisal
*/
public class FileContentMatcher {
public static void main(String[] args) throws IOException {
String te... |
I am was writing a practice program in javascript and it turned out to work quite alright, however I am not entirely happy with the code. I can't shake the feeling that there is a lot of code which doesn't have to be there, I feel that it can be improved.
The idea of the program is basically, you have a selector, each ... |
I (ruby beginner) have a performance issue with the following ruby code. The idea is to aggregate a CSV into a smaller, better-to-handle file and calculating the average of some values. Basically the same code in groovy runs about 30 times faster. And I can't believe that Ruby is that slow! ;-)
Some background:
The fil... |
I have a module in Python for dealing with SVG paths. One of the problems with this is that the SVG spec is obsessed with saving characters to a pointless extent. As such, this path is valid:
"M3.4E-34-2.2e56L23-34z"
And should be parsed as follows:
"M", "3.4E-34", "-2.2e56", "L", "23", "-34", "z"
As you see, anythin... |
I need to improve this by using switch statement in which I want to set the text and setFullScreen. Is there any more elegant way to implement this?
final String change[] =
{
"Full Screen", "Exit Full Screen"
};
final MenuItem fullScreen = MenuItemBuilder.create().text(change[0]).build();
fullS... |
I'm new to Perl, learning on my own. I've wrote many scripts (utilities) for myself but never posted them online. I would really appreciate any feedback on this script before I post it on a forum.
The script takes list of files names on command line, writes the name list in tmp file and opens it with vi(m). After user ... |
Here is a light command line I built with JavaScript. I would like to ask if there are many stupidities, bad code and such? The only test command right now is add arg1 arg2 so writing add 1 1 should get you >>> 2. It will print Command *** not found with other commands than add. See the fiddle below.
jsfiddle.net
http:... |
This plugin is initialized like so:
$("#calendar").ksdCalendar({
feedUrl: "http://www.kent.k12.wa.us/site/RSS.aspx?DomainID=275&ModuleInstanceID=4937&PageID=4334",
elemHeight: 750
});
I would like a review on the code, structure, or anything else that comes to mind. What this plugin does is take an RSS feed fr... |
$controller = new UserController();
if (isset($_POST['submitform']))
{
$validated = false;
$inputs = array (
'username', 'email', 'password',
'repassword', 'password_f', 'repassword_f',
'display'
);
$i = 0;
foreach ($inputs as $key)
{
if (isset($_POST[$key]... |
I need to crawl web contents from some websites and then do some processing. Note that this is a small application, so the dataset is relatively small (need to crawl about 30,000 pages every time, once a week). The problem is that I can't start too many threads to crawl the pages at the same time. Otherwise my IP will ... |
I have a project from my college. I'm making a site which will display different quotations each time the page is loaded. I use the following code:
$con = mysql_connect("localhost","root","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xlsx_db", $con);
$result = mysql_query("SELECT * FR... |
This is my attempt at problem 12 from Project Euler. However, my code freezes my old, linux computer when I run it. I've only got 512MB of RAM and an old Intel Core 2 Duo processor on my machine which, I assume, is why it can't run the code.
Is there a way to optimize this code without using up too much resources?
#!/b... |
Consider (simplified)
low_count = 0
high_count = 0
high = 10
low = 5
value = 2
What is a clean way to check a number value versus a min low and a max high, such that if value is below low low_count increments, and if value is above high high_count increments? Currently I have (code snippet)
high_count = 0
... |
Sometimes I need to ensure that some references won't be processed while examination from the associated ReferenceQueue. Generally at those moments I don't know reachability status of the referent.
The only way I've came up with:
class MyReference<V> extends SoftReference<V> {
private boolean active = true;
pu... |
A friend of mine wanted an array-to-CSV string function for Node.js, so I came up with this. Basically, it can take in a single object, a 2D array or an array of objects.
If the children or parent is an object then the object properties become the headers, if the children are arrays then the first array is the headers... |
After considerable effort, I've come up with the following code to generate a list of primes of a given length.
I would be very interested to see how an experienced coder would modify my code to make it more readable, more concise, or somehow better. I won't be able to follow fancy-pants coding that doesn't involve ba... |
I am developing a website and I want to use PDO and MVC.
Before, I was coding in procedural MySQL, but I'm starting to understand the object-oriented programming.
My problem is the following:
If I understand the MVC pattern, there are 3 parts
View (It's my Html)
Model (PHP requests)
Controller (Control and form valida... |
I was reading more about the instancetype on Stack Overflow and now my question is:
For every convenience constructor that I write, do I need to have the corresponding one using init?
For example:
RandomItem.h
#import <Foundation/Foundation.h>
@interface RandomItem : NSObject
@property (nonatomic, copy) NSString *aSt... |
We have a linklist which is made of alphabets. We have to shift the vowels towards the end of the linklist, without changing the order in which they appear. So,
A->C->E->F->G->O
should become
C->F->G->A->E->O
This is the code I have written
#include<iostream>
using namespace std;
struct node
{
char ch;
node... |
I want to list the contents of a folder and mail the list using a shell script. I Came up with the following script, please let me know if it is okay:
for file in *
do
if [ -f "$file" ]; then
echo "$file" | mail -s "List of files" Someone@somewhere.com
fi
done
|
This passes the value of true/false to model which I can use in my controller.
How can this be cleaned up?
<div data-role="fieldcontain" class="inline-toggle">
<label for="IsAuto">Auto <a href="#"><img class="smallInfo" src="/sites/dev-demo/mobile/assets/images/info@2x.png"></a>:</label>
<select name="I... |
I'm making a calendar and this is one part of the larger project. This adds a tooltip with more information when a calendar event is clicked. It then disappears after 10 seconds, or earlier if a click is detected. The exception being if the click in on the tooltip itself. This code works but feels kind of "cheaty" to m... |
Is this a good form validation script?
$(document).ready(function() {
$("form").submit(function() {
var shouldSubmit = true;
$(this).children(":input:not(:button, [type=\"submit\"], [type=\"reset\"])").each(function() {
if ($(this).val() == "")
{
shouldSub... |
Is this try/catch block written correctly?
public String execute() throws Exception{
try{
//Do blah
return "success"; //Assuming everything goes well, return success.
}catch (Exception e){
e.printStackTrace();
}
return "error";
}
Should the return "error" be inside the catch cl... |
I'm trying to see if there is a better way to do this when I just need one column with one row. Do not mind the lack of use of a prepared statement, I will put it in.
public <T> T getValueFromDb(String col, String table, String cond, Class<T> returnValueClass) {
T val = null;
try {
ResultSet rs = getS... |
I have this data for the knapsack problem:
List of product prices = MENU
Most popular product count = MOST_POPULAR_COCKTAIL
Knapsack price = CASH
Knapsack length = CHECK_LEN
I need get all knapsack combinations from a list of products prices which satisfy:
List of product prices bigger or equal knapsack length
Each ... |
I think the arrays here are slowing down my code due to incorrect usage.
There is a lot of stuff going on here, it's understandable if nobody responds. Just looking for some pointers. Thanks.
for MN in xrange(RowModel,TotalModels):
if(MN%5000==0):print 'Examining models', MN,'to', (MN+5000), '...'
fobs=fobst... |
Edit: The method call discussed is a public extension method in a shared library. I'd like it to be safe for others to call.
A little background: I'm maintaining an ancient system written in ASP.Net Webforms. There are lots of validation groups for different user controls, and we want to display the error messages ... |
I'd like some opinions about my approach at using SQLite databases in android. Everything seems to work very well, but there may be something wrong that I hadn't noticed.
I don't like working with create/alter table statements in code, so I prefer creating my database with some SQLite client out there and putting it in... |
I've taken a stab at making a context menu using BackboneJS.
Here's the overall structure:
Collections:
/collection/contextMenuGroups
/collection/contextMenuItems
Models:
/model/contextMenu
/model/contextMenuGroup
/model/contextMenuItem
Views:
/view/contextMenuView
To start off, lets take a look at my template:... |
Is this acceptable for readability or would it be better to refactor it into smaller methods?
Tips? Comments? Examples?
def save_with_payment
if valid?
charge = Stripe::Charge.create(:amount => (self.plan.price * 100).to_i,
:currency => 'usd', :card => stripe_card_token, :descr... |
I frequently write Python scripts that require three command line arguments:
config_file — A CSV configuration file
input_dir — The directory containing the input files to be processed
output_dir — The directory where the output files should be stored
I found myself copying/pasting two functions all the time: is_vali... |
I've got a class with a property TotalCost, which is calculated by some simple math of two other properties, CostOfFood and NumberOfPeople. The code works the way I want it to, but I was wondering if this is a satisfactory method in the long run of application development, a bad idea to have one property that depends ... |
Yesterday, I introduced a bug into our codebase by calling #titleize on a string that could possibly come in as nil:
def route
medication.route_name.titleize
end
This threw an error on production and a coworker fixed this by adding try:
def route
medication.route_name.try(:titleize)
end
I'm not totally happy with... |
Straight to the point: Can you give me pointers on how to make this code more maintainable? In the future, I want to add more more things to this, but first it should be easy to maintain/read. Should making a library be considered?
What it does:
Takes input from the serial line and converts it to servo commands + all t... |
I'm trying to re-learn some JS fundamentals and wondered if anyone knowledgabe could tell me if I'm doing something very wrong in my approach to this simple word counting class.
I want to create a class that takes arbitrary text and returns information about its wordcount, frequency of words, etc. One of the methods I... |
I like to keep my code organized, usually in several files. It is good for CSS.
For instance:
I have three files:
First - layout.html, this is the main template.
Second - grid.css is style sheet where I decribe position of all elements.
Third - style.css is where I describe appearence of elements.
Listings:
<!DOCTYP... |
I am trying to return a value (a.tnAddress) from a custom class based on a lookup (foreach loop). Depending on the type of transaction, I will need to do the foreach loop based on different properties (sExecID, iMsgSeqNum, orsClOrderID). I prefer to not have 3 differentforeach` loops just but I am not sure how else t... |
I am trying to find the best way to structure this. I want to avoid if-else statements and reduce the number of code lines.
def get_parent(relationships,GU)
parent = []
if relationships.class == Array
relationships.each do |y|
if y[:relationship_roles][:relationship_role][:to_role][:name] == type
... |
In this code, I'm getting the json from backend. Once I find the json availability, I loop and make 5 columns. Once the columns are made, I append after the legend of my form.
Can this be improved any further?
if(data.hasOwnProperty("allLocales")){
var col0 = $("<fieldset />"),
col1 = $(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.