instruction stringlengths 71 71.9k |
|---|
I want to be sure that this isn't vulnerable to SQL injection. If yes, then how can it be improved?
$pid = $_REQUEST['product_id'];
$query1 = "SELECT * FROM products WHERE id = '"
. $pid . "'";
$result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1);
$thisrow=mysql_fetch_row($result);
if ($t... |
The following is a excerpt from a class that is supposed to represent a reflection of an object in a 3D world, like in a mirror.
After I started I discovered that mirroring is a property of an object, it is either mirrored, or it isn't. Multiple mirrors don't come up with unique objects but just keep flipping from one ... |
I have wanted a way to do code profiling in VBA for quite some time.
It becomes very complicated to figure out what methods are actually being executed for how long and how often in complex Access applications. A key reason this is complicated is that many form events or function calculations happen very often and not ... |
I started making a text-based RPG game and before I spend a lot of time on it, I wanted to know if there is a better way to make it. Currently I'm using switches to flow through the game, I also know some people use a lot of if statements, but is there a more efficient way?
Main
public class Main {
public static G... |
I'm a beginning C programmer. As an exercise, I have attempted to implement a stack of strings in C. This is my first real exercise working with pointers. I looked at some other similar posts on here, and read through the comments. It seems that most individuals have chosen to do this by using linked lists, whereas I'v... |
In A Tour of Go, you are given the following problem:
In this exercise you'll use Go's concurrency features to parallelize a
web crawler.
Modify the Crawl function to fetch URLs in parallel without fetching
the same URL twice.
This is the code you're given
package main
import (
"fmt"
)
type Fetcher interfa... |
I have been working on a port of JavaCC for Android. It is mainly an interface. I needed only to modify the original source to redirect output to a TextView. The point of this project is to rekindle my coding skills after years of dormancy, to actually finish a coding project, and to make a useful port of JavaCC that I... |
I have a package directory pkg with several classes that I would like to build into a convenient dict property.
The structure of pkg/ looks like:
pkg/base.py:
class _MyBase(object):
pass
pkg/foo.py:
from .base import _MyBase
class Foo(_MyBase):
pass
And in pkg/__init__.py, it is a bit clunky, but once pkg i... |
I want to control a motor which rotates a device over a gear.
Input values for the device are from 0 to 360 degrees. The motor should always rotate the device the shorter way around. For example, if the position is 30° and target position will be 340°, it should rotate over 0° counter clockwise.
The motor controller in... |
GetBootstrap-2.0 update from GetBootstrap-1.0.0.2
I just update my console application customizer and add some new features like disable minimize, maximize and close button, new color and simple popup box. Help me review my codes...
Here is my sample preview of GetBootstrap-2.0:
The preview contains Write(), WriteLine... |
I'm writing this as (eventually) part of a larger program. This will serve as the bulk data insertion from .csv files we parse.
I'm primarily looking for parts that are
breaking Go's formatting, styling, etc. rules
redundant and/or dangerous
Right now the code works and all 4 million rows of the .csv file were proper... |
I have used reflection for divide the complex property. For example, if I bind A.B[0], CustomerName means CustomerName is returned. Can anyone help to reduce the code?
var itemproperties = view.GetItemProperties();
if (itemproperties != null)
{
if (propName.Contains("."))
{
string actua... |
I'm working with C# and .NET Framework 4.0 and Windows Forms.
On my project I have three custom objects that inherits from MyControl class (MyControl class inherits from UserControl).
I have this code:
private void ShowControlForBatchStatus(BatchStatus batchStatus)
{
MyControl control = null;
panelContainer.Co... |
Input :
<h2>{translate} Dear Atteck {/translate} <br/></h2>{translate}Please complete registration</h5> {/translate}
Output :
<h2> Дeaр Аттeҗк<b/></h2>Плeaсe җомплeтe</һ5>
Main code:
private static readonly Dictionary<string, IOrderedEnumerable<KeyValuePair<string, string>>> TransliterationMaps = new Dictionary<strin... |
I made a cool roll-over in CSS which displays an animated GIF when the parent is hovered.
Codepen
The problem is that I will have about 40 .day like that, all playing the animated GIF behind the circle at any time. I'm not sure that any browser/computer/connection can handle that much.
I tried to figure out a solution:... |
I find this piece of Java code really ugly and cumbersome. How can I refactor it to be more clean and easier to read?
ByteArrayOutputStream out = null;
try {
out = new ByteArrayOutputStream();
workbook.write(out);
return out.toByteArray();
} catch (Exception e) {
e.printStackTrace();
} finally {
tr... |
I am trying to connect to a server.
If the connection goes through, then print an apt message.
If the connection does not go through, try for a total of n times. And quit after the nth attempt with an apt message.
I set up a mock server like this -
class Server:
def __init__(self):
self.connection_st... |
$("#colors_added").html(parseFloat($("#colors_added").html()) + 1);
This JS line makes my IDE go Duplicated jQuery selector with the following explanation:
Checks that jQuery selectors are used in an efficient way. It suggests to split descendant selectors which are prefaced with ID selector and warns about duplicate... |
I've written a function that wraps the classList API, allowing you to pass an array of classes to add/remove, or the variable arguments already supported by classList.
The methods are the following:
var flatten = function(array) {
return Array.prototype.concat.apply([], array);
};
var classMethod = function(method... |
This simulated annealing program tries to look for the status that minimizes the energy value calculated by the energy function.
The status class, energy function and next function may be resource-intensive on future usage, so I would like to know if this is a suitable way to code it.
#pragma once
#include <cmath>
#in... |
This is probably the noobiest SQL question ever, and I'm almost positive there's a JOIN or something in PostgreSQL for this, but I can't find it so I'm using a naive method. Here's a bit about my schema:
phrases:
CREATE TABLE phrases
(
phrase_id bigserial NOT NULL,
language character varying(4) NOT NULL,
text tex... |
I'm trying to sort an array with JavaScript. The objects should be sorted based on several properties (about 4 in my real scenario), which are all strings that may also be null or undefined. A null or undefined value should be treated similar, and should be "earlier" in the sorted array than items with values.
I used u... |
I'm learning Haskell on my own and I'm following the material of a course.
I would like to know if this is idiomatic Haskell.
asList :: [String] -> String
asList ss = "[" ++ (concat $ intersperse "," ss) ++ "]"
|
In our application, we have many function calls that we want to cache the results of. However, the result of these functions depends on database calls, so we want this cache to refresh every so often so that new data is pulled from the database on a regular basis. (Note: we know that these values are changing once a da... |
Disclaimer: I just asked this on the regular SE, but was suggested to post it in here since it's kind of a code review.
I've recently been playing around with component frameworks, and I'm trying to create a basic trigger component. The component should be able to take one (or more) pair of values that can be compared ... |
I created the following function below to merge the real values with the predicted values (when real are absent) in a new column in data.frame. The function actually works, but I would like to optimize it, because with the dataset that I work with, the function takes about two hours to run.
The function seems to be slo... |
I am building a php based mobile website that must be in both Spanish and English. This is my first bilingual site so I've been having to re-think a lot of coding practices I currently use to accommodate multiple languages.
I'm using a custom MVC pattern and currently I'm trying to use the same controller and model fo... |
I'm writing a simple utility class for sending an email. I'm not sure what's the proper way to present this to a consumer. Should I force them to use an array in send()? Or should I provide an overload so they can pass a single argument?
public class SimpleSender {
public static void send(String smtpServer, String... |
This is from my own question on Stack Overflow.
I want to get average numbers from a range such that they fit an intended average. I expect something bell-curve-like, but asymmetrical unless the average is the mean of the range. The function should allow for any degree of deviation. In my Overflow question, I wante... |
I have a class that I use to display on a web page fieldset. However, all of the properties of this class are optionally filled in by the user, which means all of them could be null/default. In this case I would like not to render the fieldset at all, instead of displaying an empty one.
I wrote a simple isEmpty() metho... |
I made a database for my Android app using SQLite and it works fine. However, as I understood, SQLite calls shouldn't be made on UI thread.
Is the below okay or not?
/**
* @param howMany Amount of Stations returned, passing null returns all.
* Sorted after last time searched.
* @return
... |
I have a script that contains functions from login in to posting status to friend request send and receive. Pretty much a social network script. Anyways i think my security is not up to date so if anyone can check my code out or review it live on the web: iphone.hostei.com. email is demo@demo.com and password is demo12... |
Here is my first Canvas/JS banner. I just got a flash one and hand-coded it from the beginning to the end.
I have several major concerns/questions:
I have seen several banners made in Adobe Flash, despite there being several external libraries are used (which is not cool in my case). There is also only ONE canvas, so ... |
To get used to Haskell, I wrote a little program using the Diagrams package which generates 100 random dots (larger dots are more likely to be in the center).
Sample output:
My questions:
Is the program well structured with respect to the IO monad and the random values (see types for randomDot and randomDots)? Should... |
I've reworked (for C++11) a section of PyCXX which contained an almost identical iterator and const_iterator.
I would like to know whether there is any way I can further tidy the code.
(Please bear in mind that the original was written maybe 20 years ago).
Here is the original:
template<TEMPLATE_TYPENAME T>
class SeqBa... |
I'm reading CLRS, and to practice, I rolled my version of radix sort and counting sort. I was looking at some reference implementations, particularly the LSD one from Rosetta Code, and mine performs significantly better (~10 times), especially on 64 bit inputs and if the maximum input range is known.
I think one place ... |
I was able to complete the problem doing it in this manner, but I would assume there has to be an easier way.
Sample input:
abc, cba
Output:
Both strings of characters are equivalent.
Or
abc, acc
Output:
Different
import java.util.Scanner;
public class StringTest {
public static void main(String[] args) ... |
I have written this Active Directory password changer script. Comments and testing is appreciated for things I may have overlooked, since this is my first AD Script.
There are two parts: PHP and PowerShell.
This is being run on an IIS Server with PHP 5.4.x with Fast CGI and PowerShell 2.x.
The IIS_IUSRS is a manager of... |
I've implemented the phoenix-singleton as a class template with boost inspired by Modern C++ Design. The code compiles fine with MSVC 2013 - and it seems to work, but I'm new
to multi-threaded programming and Boost. Are there any pitfalls in the code? Improvements?
TSingleton.h
#ifndef TSINGLETON_H
#define TSINGLETON_H... |
I'm new to Python and as a first exercise, I've written a function (module?) to calculate Kaprekar's constant using Python 3.
I'd like some feedback on whether this is Pythonic enough, and if I can improve it.
import collections
def kaprekar(value):
print("Starting value: %d" % value)
# Check ou... |
I am modeling an infectious disease with a fixed incubation period. I chose a queue to keep track of when people become symptomatic. I imagined using some operations like so:
queue' = enqueue numberOfPeopleWhoJustGotInfected queue
(numberOfPeopleWhoJustBecameSymptomatic,queue'') = dequeue queue
Since enqueue and deque... |
I have expanded a lot on my last project and had a lot of fun doing it. It was great to build out all the code. I am new to JS so these types of projects are really helping me learn. Please be honest about where I can improve the clean the code. I learnt about the helper functions after I posted here last time and love... |
I'm just learning Haskell on my own, and did an exercise to implement insertBST.
Is this idiomatic Haskell?
insertBST :: (a -> a -> Ordering) -> a -> BST a -> BST a
insertBST _ v Leaf = Node Leaf v Leaf
insertBST cmp v (Node left nv right) = case (cmp v nv) of
EQ -> Node (insertBST cmp v left) nv right
... |
I'm learning Haskell on my own, and I'm wondering if this is idiomatic Haskell.
In particular: is it a common pattern to "wrap" the result in a list in order to make a function total? (that's what I ended up doing to ensure the function was total and no compiler warnings about not matching a pattern).
safeHead :: [a] -... |
As a newbie programmer, I decided to try my hand at making a program whose function actually might be useful to someone, somewhere.
This utility takes a text file, reads it out to the user, displays its length (in bytes), asks the user if they would like to alphabetize, randomize, or do nothing to the contents of the f... |
Problem Statement:
Design a BALANCE class with account number, balance and date of last
updation. Consider a TRANSACTION class with account number, date of
transaction, amount and transaction type. Check whether the amount is
available or not in case of a withdrawal. Transaction object will make
necessary upda... |
The following code compiles correctly:
public ContextStatus Commit(string userName)
{
var status = new ContextStatus();
var task = Task.Run(async () => { status = await CommitAsync(userName, new CancellationToken()); });
task.Wait();
return status;
}
public async Task<... |
How could I make this code dry?
$("#btnSubmitToCheckOut").click(function(event) {
var isSelected = [];
$(".age_agree :checkbox").each(function() {
if ($(this).is(":checked")) {
isSelected.push("true");
} else {
isSelected.push("false");
... |
This is my first, very-very first attempt at java. I haven't started tackling the actual resolution of the sudoku puzzle (not even sure where to start, haven't looked at other weekend-challenge entries yet). I don't have much to go over here, but I'm sure it's filled with beginner mistakes already, so before I make thi... |
This is a Python script that generates a grid of random HTML colors. It works by reading random data from /dev/urandom and then encoding it as a hexadecimal string. This string is spit into individual values that will be represented as a color.
I am wanting to know if this is the best way to generate random values fo... |
I have written ExtendedConfigParser class that adds ability to dot access config values like ExtendedConfigParser().section_name.option_name:
from ConfigParser import SafeConfigParser
class ExtendedConfigParser(SafeConfigParser):
def __init__(self, config_file=None, type_conversion={}, *args, **kwargs):
... |
Even though it's the first time I'm writing something this "big", it feels like I know C# quite well (it is very similar to Java after all). It's been nice to learn LINQ also and I am very impressed by the features (which is just like Steams in Java 8), and perhaps I have overused it here (if it's possible to do that).... |
I'm trying to figure out a way to have cleaner, efficient code for a web audio project i've been working on. the code I have right now is this:
//OSCILLATOR INFO//
// Oscillator Pitch is in Hz.
// Oscillator Detune is in Cents & can be positive or negative values.
// 1 Octave = double/half the note frequency in Hz. (A... |
I am building an array of strings to form the "empty" representation of a puzzle onto which I will overwrite single characters as necessary for debugging purposes. However, building the array using scalar multiplication results in shared string instances among the rows which breaks when I modify them.
> grid = [["... "... |
I'm writing a function in Python that compares the modification time of a file in Linux (using os.stat) with a specific time and compare the dates. If the modification date is older than the date I specified, an event should happen.
import os
import time
import datetime
# File Modification time in seconds since epoch... |
Original
quicksort.h
#include <algorithm>
namespace quicksort {
template <typename iterator, typename value_type>
struct traits
{
static iterator choose_pivot (iterator first, iterator last) {
return first + (last - first) / 2 ;
}
static iterator partition (iterator first, iterator last, iter... |
I have some concerns:
Is it normal for the class to have at least one node? In other words, this implementation cannot have an empty linked list; the length is always 1.
Would this be a proper way to implement a linked list in, say, a professional environment? Or perhaps there is a better way to do it? I am not a pr... |
Let me start by saying that the code works as is but I think it has a lot of redundancy. It is written this way as I kept getting nullpointerexceptions if I try to put the fileCounter > gameDiff if/else inside one for loop.
The program allows a user to create directories and add images to them. It will also display a c... |
I have been changing this code and I don't get to make it much better. I changed a little bit the structure, reimplemeted a new function for splitting Strings which is more efficient, etc. I have been tested with MR-Unit (it's part of map-reduce code).
I'm testing the code with 1.5 millions calls. It takes about 35 sec... |
I have created a small HomeScreen Widget which displays random numbers.
Attached is the code. Please let me know if the approach is good.
https://github.com/gottp/HomeWidgetTest
MainAppClass.java
package com.example.homewidgettest;
import java.util.HashMap;
import android.app.Application;
public class MainAppClass e... |
I'm new to C# and OO programing.
I have an aspx page with 3 lists of checkboxes and I would like to generate them from the DB.
how should I structure my code?
Here is an example of what I did so far:
ASPX page
<asp:CheckBoxList ID="CheckBoxList1" runat="server"></asp:CheckBoxList>
<asp:CheckBoxList ID="CheckBoxList2" ... |
I am learning getopt in Python to parse and validate command line inputs:
#!/usr/bin/python
'''\nMailing Script
Usage: python script.py -y <year> -c <type_user>"
Arguments:
-y, --year any value from 2008 to 2013
-c, --campaign any value in:
'80c', '80d', 'allowances', 'late_filing',
... |
In my project i work with COM object via System.Reflection. COM object returns pointer on structure VARIANT, that i cast as object and then i cast one as byte array. There are many structures that i get from COM object. Since i know about how organize these structure i write static class to deserialize them byte-by-byt... |
I am working on a (HTML/CSS) website to improve my skills but I am not sure if I am doing it the right way, because I have a lot of floats and sizes. I also need help with some CSS things:
What I have:
What I am Shooting for
The red dimensions in the image are the dimensions I've tried to give the objects and which I... |
I'm using this method from my Downloads() class in a back-end admin system, where these can upload some files, which must be .rar or .zip I'm not to concern about filesize, yet. Eventually, these compressed files, will be holding only .mp3 files.
Well, here's the code. As you can see, I'm checking mimetype against an a... |
I have created a list of files using find, foundlist.lst.
The find command is simply find . -type f -name "<search_pattern>" > foundlist.lst
I would now like to use this list to find copies of these files in other directories.
The 'twist' in my requirements is that I want to search only for the 'base' of the file name.... |
I am looking for some guidance and optimization pointers for my custom JavaScript function which counts the bytes in a string rather than just chars. The website uses UTF-8 and I am looking to maintain IE8 compatibility.
/**
* Count bytes in string
*
* Count and return the number of bytes in a given string
*
* @ac... |
I am having problem with a simple Hanoi tower program. I need to do something to reduce its time.
#include <stdio.h>
#include <fstream>
using namespace std;
int hanojus(int n, char a, char b, char c) {
ofstream fr("hanoj.out",ios::app);
if (n == 1)
fr<<a<< " -> " <<c<<endl;
else {
hanoj... |
Considering the code sample below, which approach of service method design would be considered best-practice and why? The one used in SaveOrder1 or the one in SaveOrder2?
UPDATE: To be clear, I'm not talking about web service here, but application-type-agnostic service class from my business logic layer. I marked parts... |
Here is my attempt at Weekend Challenge #3.
Out of scope:
It only will do 9*9
It will stop at the first solution
Could have been smarter at re-using the cache when recursively calling solveGrid
I ignored OO as this is not an app, but a simple script
In scope:
Bitflags & cache for pencil marks
var grid = "...84...9... |
Project contains 3 classes:
/*************************************************************************************
The purpose of this project is to create 3 classes. Pile contains the number of marbles
in a randomly generated pile, and also a remove method to determine how many marbles are
to be removed. The player cl... |
def current_time():
'''Returns a tuple containing (hour, minute) for current local time.'''
import time
local_time = time.localtime(time.time())
return (local_time.tm_hour, local_time.tm_min)
(hour,minute) = current_time()
def ishtime(hour, minute):
import random
Starting_str = ['it is','... |
See, I have a file which consists of a bunch of lines like
NAME:0001;some text
ANOTHERNAME:000103;some more text
NEWNAME:42; blah blah
So what I need to do is to have a list of those names, list of numbers (IDs actually, so the order matters) and list of further comments. I wrote a code, which actually does work, ... |
I need to display a list of category links, like so:
Category 1, Category 2, Category 3
I've got it working already but the code seems pretty repetitive and a bit of a mess, I was wondering if there was a better way of doing it.
This is what I've got so far:
for (var i = 0; i < data['categories'].length; i++) {
var... |
Is it possible to combine all the functions into a single function? I'm providing my fiddle as well.
I am trying to test it for different scenarios..
but I am not sure how to combine all the scenarios into one..
var myNumbersToSort = [null, -1, 2, 0.001, -3, 4, 0.3,1,-0.0001];
function getClosestToZero(set) {
if(0... |
There is a pattern that keeps coming up in my ruby code and I'm somewhat ambivalent about it. It's somewhere between a Hash and a Struct. Basically
I used method_missing to return/set values in the Hash unless I want to
override a specific value with some logic or flatten out the complex underlying structure in the JS... |
Project Euler Problem 10 asks: "What is the sum of all prime numbers below 2 million?"
How do I speed up my code? It's taking forever and I have never gotten the answer. However, I am sure that my code is right; I cheated the answer from online as I couldn't wait for an hour.
def isPrime(number):
for n in xrange (... |
I have created a generic repository for my MVC 3 page. I am using interfaces and a UnitOfWork. But before I set out to do this? Is this the right way to separate my databaseaccess from my viewmodels and views?
WHY I DID IT:
I want to seperate my databaseaccess from my viewmodels and my views, I also want the option to ... |
I have made this search filter and it works fine, but I think the code looks a little messy and I have no idea how to clean it up.
I hope the following makes sense, otherwise please tell me which information you need, and I will provide it ASAP.
// GET THE POST VALUE FROM FORM FIELDS
$field_value_service = $... |
I have a program written in PyQt that has a lot of content. The basic way I've been doing it is using a stacked widget with all the content on pages and buttons to navigate through the pages.
However, a lot of the pages are just the same stuff with maybe a couple of different things. What I've been doing is:
Initializ... |
I want my code to be reviewed and I'd like to hear your opinions.
Sun's code to compute hash of string:
public int hashCode() {
int h = hash;
if (h == 0 && value.length > 0) {
char val[] = value;
for (int i = 0; i < value.length; i++) {
h = 31 * h + val[i];
}
hash = h;
}
r... |
The title could probably be better, but in any case here goes.
I am having a bit of a problem understanding how to move methods/functions to other classes to organize things.
So, I have moved a method of sorts, but as I am skeptical of it, I would like to get it reviewed and hear opinions on what can be improved.
Here ... |
I am using Dr.Racket, Intermediate Student with Lambda. I was wondering if there was any way I can simplify this code using any sort of method like lambda, abstraction, map, filter, etc.
; alien-at-edge?: alien --> boolean
(define (alien-at-edge? an-alien)
(or (alien-at-right-edge? an-alien)
(alien-at-left-edge? an-al... |
I am using Dr.Racket, Intermediate Student with Lambda. I was wondering if there was any way I can simplify this code using any sort of method like lambda, abstraction, map, filter, etc.
; DRAWING FUNCTIONS
; draw-rocket: rocket scene --> scene
; Purpose: To draw the given rocket in the given scene
(define (draw-r... |
Is there any other way to optimize the below code? I feel the below code is huge for the operations it performs.
{
if ((currentElement == null ||
(firstGridRow["Low"].ToString() == string.Empty ||
firstGridRow["High"].ToString() == string.Empty ||
firstGridRow["Mean"].ToString() == string.Em... |
I've created unit test for the "student" CRUD operations that looks like this:
[Test]
public void Can_Exec_CrudOps()
{
#region Prepare
var account = Processor.Execute(new CreateAccount
{
Email = "email@example.com",
Username = "username",
Password = ... |
This is more like a share and a request than a question. I converted Eric Lengyel's code, which calculates tangents of a mesh for the purpose of texturing and normal mapping, to support SIMD. For this I used DirectXMath library from windows SDK. I don't know if this is actually faster than regular floating point versio... |
I've played with F# for over a year, but I've only recently begun tentatively using it for professional work. I'm concerned that my c-style OOP principles are blinding me to the advantages of a functional language. I wrote the following code and it works just fine, but I feel like I'm just not quite using the language ... |
I have the following class designs, and I'm looking for the best practices, aligned to the OOP design principles/patterns.
The ParameterParser will be used inside a foreach block through 10 items approximately.
Any comments regarding the method body will also be appreciated, though the focus of the question is on the c... |
I recently started learning and programming Java based on a series of beginner videos created by a Youtuber (TheNewBoston), who had a tutorial on a calculator. So based on everything else I've previously learned, I have tried to mix it in to create a bit more advanced one. If you are able to minimize and clean up the ... |
I have a Django form with a lot of fields, including some FileFields. I want to validate the form based on the contents of the files: they must be valid gdal datasets, and if both are present (one of them is optional) then the optional dataset's extent must entirely cover the required file's extent.
To do this, I have ... |
I created a plug-in powered by jQuery that simplifies the developer's life to create responsive applications. It's flexible and I want to give to users a good syntax to write.
How can I improve this?
GitHub
; (function ($) {
var debug = {
ranges: [],
refreshRanges: function(ranges) {
thi... |
I'm working on my pet project with MVC 5 and EF, and everytime I'm adding a parent with it children (I have the children ID's) I have to go to the database, because if I just create a new child with this ID it just inserts a child object. Is there anyway to avoid this?
This is part of my code:
My classes:
public clas... |
I'm new to Java and have just started making JFrames. I wrote a program for a game project I'm working on and would like help on where I can improve. I'm not new to programming, I also know HTML and Python well.
I believe one of the goals for all programmers is to make a useful/fun program as simple and short as possib... |
The following code sorts an HTML table with JavaScript (without using any external libraries like jQuery). Are there any shortcomings or possible improvements I could make?
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=Windows-1252">
<script type="text/javascript">
var peop... |
I have created a MySQL query that works, but I feel there must be a better way. The query will be used by a PHP script whose purpose is to assign conditions & subconditions to new participants in an online experiment based on how many times each combination of condition & subcondition was already assigned to previous p... |
Below is my typical WindowController module for presenting a modal dialog (could be settings, asking username/password, etc) loaded from a XIB. It seems a bit too complex for something like this. Any ideas how this can be done better/with less code?
Never mind that it's asking for a password, it could be anything. What... |
Here is a implementation of the cryptographic hash function SHA1 written in Python. It does not use any external libraries, only built-in functions. I know that it would be faster to use an external library, but my code is for learning purposes.
I want to know if I am properly implementing the algorithm. Am I taking ... |
I am currently storing form data in an XML format:
<cfsavecontent variable="myFormData">
<cfoutput>
<ul class="xoxo">
<cfloop list="#form.fieldnames#" index="item">
<cfloop list="#form[item]#" index="eachItem">
<li><b>#xmlformat(item)#</b> <var>#xmlformat(eachItem)#</var>
</cfloop>
</cfloop>
</ul... |
I have used multiple lines of code in one if condition without using curly braces, which is executing properly. So what is the main necessity of using curly braces in if statements for multiple lines?
if (ggcCompareGrid.TopLevelTable != null)
foreach (GridRow row in ggcCompareGrid.TopLevelTable.Rows)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.