instruction stringlengths 71 39k |
|---|
The Demo for what I have made is located here
Basically I am trying to make a self playing JavaScript baseball game with the use of no libraries.
Is there anything I could improve on in the code?
var writeDown = {
delay: 110,
add: null,
div: document.getElementById('playArea'),
log: function() {
... |
I am new to the world of coding as well as CSS. This is my first attempt to put together a page that required a negative value. I am aware that it is recommended that paddings do not use negative values and it is acceptable for margins to use negative values however am unsure if my use of negative values is acceptable.... |
This is a Perl program intended for my chemistry class. Since I am just learning to write in Perl, which is my first language, can you tell me if you think that this is well written? If not, could you tell me what is wrong with it or what could be improved?
## Name:Titration
## Beginning of Program
#Input Variables
sy... |
I am implementing RSA in java using BigInteger and I have a method to return a random relative prime number based on the modulus m.
The method looks like this:
BigInteger prime = new BigInteger(m.bitLength(),rnd);
while (prime.compareTo(BigInteger.ZERO) <= 0 || !prime.gcd(m).equals(BigInteger.ONE) )
{
... |
I would love some feedback on this little utility function:
/**
* Copy $src to $dest, renaming it if the desired destination already exists. The
* string '.versionX' is inserted before the file extension if a file must be
* renamed, with X incremented as needed.
*
* @return boolean true if copy was successful, fa... |
There's a follow-up: Waiting for a lock to release with ManualResetEvent and Quartz.
I've written a simple Lock-Mechanism which is saving the states of the locks in a database. Now I need to wait for a Lock to release or timeout after a certain amount of time (blocking the main thread, this is intentional). My implem... |
I'm wondering if I could handle the following situation with a single function or regex call. Given the folowing input:
Some text
> Foo
> Bar
>> Baz
> Foo
The output should be:
Some text
<blockquote>
Foo
Bar
<blockquote>
Baz
</blockquote>
Foo
</blockquote>
The following two functions do handle this ... |
I am learning C++ on my own and was hoping for some feedback on this simple text-to-binary converter. The program runs and I haven't encountered any errors with it yet. Any input is welcome.
#include <iostream>
#include <string>
#include <bitset>
using namespace std;
int main()
{
char letter = ' ', playAgain = 'y';
... |
I am learning OOP and have written a class for Likes. There is a load, add, delete method and I think this code can be improved since there is a lot of duplication. Please let me know how I can improve on this code and secure this code:
fileA.php:
include_once dirname(__FILE__) . "/like.class.php";
$like = new Like($db... |
I have a very good grasp of the syntax and features of F# as well as some of the concepts that mesh well with the language. However, I do not have enough experience writing it to feel comfortable that the way I am handling the language is appropriate.
Ignoring the fact that I do not provide proper escaping functionali... |
I have this code which looks for query words in a given text. I preprocess the give text and store it in an inverted-index (dictionary with word as key and position in text as value). Searching for a query words then becomes contant time operation.
The below code also prints the surrounding text which contains the max... |
I'm looking for (and be as brutal as you like) ways to improve the code or the algorithm (I'm aware there should be comments) - I'm a recreational programmer and would like to be improving my skills. My next step is to get the targetNumber value from a nearby file without losing the current count.
<!DOCTYPE HTML PUBLIC... |
I am trying to design a program that will read a XML file and based on the tag name will perform certain requirements checks. I feel that there is probably a better way of doing this and any comments or suggestions are welcomed.
Thank you.
public enum AccountCheckType
{
UserIsMemberOfGroup,
DomainUserExists,
... |
I know it's a good idea to put all data-related logic in your models in CakePHP, but what would you say about keeping every Model::find() and its particular params in the model? Is this good practice, or just taking things too far?
For example, is this:
PostsController:
function index() {
$posts = $this->Post->getL... |
I wrote a little Python script to replace some files in usr/bin with symlinks to files in a different location.
I wouldn't mind anyone telling me where I could do better.
#!/usr/bin/env python -tt
"""Xcode4 installs and expects to find a git installation at /usr/bin.
This is a pain if you want to control your own inst... |
My coding skill is pretty rusty and moreover, I have never paid much attention to writing elegant code. I want to start on this. Problem is to merge 2 sorted linked list. Algorithmically this is trivial, but looks a good problem to practice coding.
struct node
{
char *data;
struct node *nextp;
}
typedef struct node ... |
Given an array which contains integers (may contain thousands of elements), you have to write a program to find the second largest element of the group.
int secondmax(int array[],int n)
{
int max;
int secondmax;
assert(n>1);
max=array[0]>array[1] ? array[0] : array[1];
secondmax=array[0]>array[1] ? array[1] : arra... |
Given two binary trees, you have to find whether the second is a sub tree of the first.
First attempt (brute force):
int issubtree(tree *tree1p, tree * tree2p)
{
if (tree2p == NULL)
return 1;
if (tree1p == NULL)
return 0;
if (tree1p->data == tree2p->data)
return (issubtree(tree1p... |
I'm starting to dive into TDD with NUnit and despite I've enjoyed checking some resources I've found here at stackoverflow, I often find myself not gaining good traction.
So what I'm really trying to achieve is to acquire some sort of checklist/workflow —and here's where I need you guys to help me out— or "Test Plan" t... |
I'm new to this page I want to ask you to critique my code on jInternalFrame. Basically the problem is that there is no complete example on using this, so I wrote this "template" but I don't know if it lacks of something.
So here is the code(It does 'nothing' just calling, positioning and basic stuff):
Main.java
packag... |
Problem:
n students have marks and names. Rank students based on their marks and print their names.
#include <stdio.h>
#include <assert.h>
struct student
{
int marks;
char name[50];
};
struct listnode
{
struct student * data;
struct listnode *next;
};
addtofrontoflist(struct listnode *listhead,str... |
I know that this is very very basic, but now I am starting from group up after getting frustrated with my coding practices and knowledge of standard idioms out there and elegant way of coding corner cases. The problem is to insert into tail of a linked list.
void insertattail (struct node *head, int data)
{
//First c... |
A schoolmate is going through the interview process, and was given the question of detecting if a linked list data structure has an infinite loop in it. I wrote this example, and wanted to see what experience programmers thought of it.
/*
* detecting loops in a linked list, java
*
* This linked list doesn't have a payl... |
I've written a fairly small library that abstracts cookie functionality in a way that mimics working with a database model. The repository is on bitbucket and the code is small enough to embed here:
class SimpleCookie {
/**
* Cookie value char limit
* @var int
*/
const valueLimit = 2000;
/... |
The method must search Products found by criteria and store them in @products.
The criteria are as follows:
If the user enters something in text_field (:search_keywords) then the product's name needs to be matched with that word
If the user specifies product_type (:product[:type]) then all the found products must be o... |
This is a social share widget for guubo.com. The live widget can be seen here (though you need to be signed in guubo.com, otherwise you will see a logged-out user interface). JS is not my first language, therefore some reviews are welcome.
// create iframe
var iframe = document.createElement('iframe');
iframe.set... |
This is my first attempt at a jQuery plugin. Any tips or comments in regards the the plugin setup would be appreciated. I'm also looking for a general review over the code itself. I'm wondering if there is a better way to encode the font. The way I'm doing it now makes it easy to see, read and create the characters,... |
I commonly run into the need to implement IDisposable in my code. To correctly dispose of both managed and unmanaged resources requires a reasonable amount of boilerplate code. Based on the documentation found here I have created the following base class.
My intent is that any object I create that needs to dispose of r... |
This code comes straight out from the example code in a Django book. I find it quite bad, mainly because the use of flags (if ajax then again if ajax) and unnecessarily bigger variable scope (set title='', tags='' and then use these variables in different flows). The function body also seems way too long.
I guess I'll ... |
This is the first PDF class I have made for the iOS using code from Apple's samples. There could easily be stuff here wrong that I am missing.
I intend this to get images out of for a layer, for example:
image.contents = (id)[self.test imageForPage: 3 size: CGSizeMake(4*dpc, 2*dpc)].CGImage;
Here is this hopefully d... |
I want to write some basic code on graph like DFS, BFS but before that I am coding graph representation in adjacency list, and some basic functions like readgraphfrommatrix. (This will initialize graph from adjacency matrix which is easier to supply as input to test the program.)
A vertex can have some info like name (... |
I'm working on a few JavaScript functions for myself that I hope come in handy sometime. The first I wrote was a Capitalization function (yeah i know, real original. whatever)
I was just wondering if
I'm doing anything incredibly stupid
There's anyway to make the code below more concise (like cool JS concision feat... |
I have this "pretty" date string generator in C# - pass it a date and it returns a string with "5 minutes ago" or "2 weeks, 3 days ago", etc.
It's a little verbose and hogs 61 lines, and I'm wondering if I'm missing out on some nice C# features or something. What (if any) is the best way to clean up this code? Are ther... |
I have a loop structure, that I really don't like. It's the initialisation I find appalingly ugly. Is there a nicer way to do the following?
Queue<Integer> queue = getMyQueue();
Integer element = queue.poll();
while (element != null){
calculate_smart_stuff(element);
element = queue.poll();
}
A for loop is slightly... |
I would like to improve this function to reduce the run time and optimize it.
function [Pl,Plm] = funlegendre(gamma)
Plm = zeros(70,71);
Pl = zeros(70,1);
P0 = 1;
Pl(1) = gamma;
Plm(1,1) = sqrt(1-gamma^2);
for L=2:70
for M=0:L
if(M==0)
if (L==2)
... |
I need to classify each line as "announce, whisper or chat" once I have that sorted out I need to extract certain values to be processed.
Right now my regex is as follow:
var regex = new Regex(@"^\[(\d{2}:\d{2}:\d{2})\]\s*(?:(\[System Message\])?\s*<([^>]*)>|((.+) Whisper You :))\s*(.*)$");
Group 0 is the entire mess... |
Last weekend I was writing a short PHP function that accepts a starting move and returns valid knight squares for that move.
<?php
/* get's starting move and returns valid knight moves */
echo GetValidKnightSquares('e4');
function GetValidKnightSquares($strStartingMove) {
$cb_rows = array('a' => 1, 'b' => 2, 'c' ... |
Can this code be improved? I'm avoiding using the QueryString collection because the query string may contain eg: OrderBy=Column1&OrderBy=Column2 and it didn't seem helpful to start with those switched into QueryString["OrderBy"]=="Column1,Column2";
var query = "";
if (urlHelper.RequestContext.HttpContext.Requ... |
How can I write the following T-SQL query part in a shorter way without using dynamic SQL?
WHERE
( (@Max IS NULL OR @Type <> 'Products')
OR (@Max IS NOT NULL AND @Type = 'Products'
AND ProductCount > @Max ) )
AND ( (@Min IS NULL OR @Type <> 'Products')
OR (@Min IS NOT NULL AND @Typ... |
Email<input type="text" id="email" /><br />
Re-enter Email<input type="text" id="confirm-email" />
I'm thinking that I want a model so that I can have this partial page strongly typed. But what a lame model....
It would look like this, and if this is a good Idea, what should I name this model?
public class ConfirmEma... |
I have a T4 Templates project that generates methods to "convert" one Type (class, struct, enum) from a source Assembly its corresponding Type in another. The two types have the identical names and property names, just different namespaces and different types. This may be a re-invented a wheel. Nonetheless, I didn't fi... |
I'm going through the CoffeeScript book by Trevor Burnham, and I was curious as to what the best style is for a function I was writing.
In the book the author writes the function like so:
strToCoordinates = (input) ->
halves = input.split(',')
if halves.length is 2
x = parseFloat halves[0]
y = ... |
I've never done anything like this before so I'd like someone else to look at this before I get too carried away :)
Am I making this more complicated than it needs to be? I'm trying to make it EASY for other modules/scripts on this system to store and retrieve their settings. Hence why I trap the ConfigParser.NoOption... |
<p style="background-color:#<%= debate.bg_color %>;" >
be_color is a method of Debate that returns a string like 45FFFF.
Although it does what I want, this seems like a tremendously bad idea. What would be a better way to accomplish this? (I'm very new to both Ruby and Rails. And new-ish to web development in general.... |
Following the normal pattern of adding inline scripts to gridview row/s is a bad practice it used to work like below
protected void CustomersGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.DataRow:
DataRowView d... |
I made this PHP class that loads any image you specify and resizes it to any size you want.
Features
If the size you specify is greater than the original, it will not stretch the image but use padding instead. Or if the size you requested is not the original aspect ratio, it will not distort the image but use padding t... |
I've been asked to keep track of how long a user has been connected to a site without interruption.
So far the solution I've come up with is to use ajax to poll the site every now and then to check how much time has elapsed since the last call.
Any suggestions for possible improvements would be appreciated.
P.S: Not su... |
In my particular usage here, I'm using two functions to deal with one thing.
Lets say the user request comes in to select "ALL" the records, in which case I would pass on some code such as:
function getRecords() {
return some_sql("Select * from whatever WHERE id > 0;");
}
But then I want to run just one record, I'... |
I've been working on putting a new app up against Zend. In my admin section, I want the nav links to only show if the user has rights to see the page. So I set up some Acls. But this doesn't seem like the right way to do things. What's the "right" way to do this stuff?
Bootstrap.php
<?php
class Bootstrap extends Zend_... |
I've come up with this small function to make user submitted strings safe for MySQL. I'd be grateful if someone could point out any security holes in this. I've tested it out, and it happily replaces quotes and the like. The only issue I can see is the lack of escaping ampersands, but this shouldn't matter right?
$keyw... |
I have implemented a simple iterator. Just want to check if I have missed anything.
interface iterator<E>
{
boolean hasNext();
E next();
}
class Iterator<E> implements iterator
{
E[] arr;
int curPos = 0;
@Override
public boolean hasNext()
{
... |
The basic idea is this:
There are two buttons: a DoWork button and a Cancel button.
The DoWork button should launch a thread to do some work, unless that thread was already launched and not canceled.
The Cancel button should cancel the worker thread, if it's running.
Please ignore the fact that it calls Thread.Abort() ... |
Ax, Ay, Az: [N-by-N]
B=AA (dyadic product)
means
B(i,j)= [Ax(i,j);Ay(i,j);Az(i,j)]*[Ax(i,j) Ay(i,j) Az(i,j)]
B(I,j): a 3x3 matrix.
One way to construct B is:
N=2;
Ax=rand(N); Ay=rand(N); Az=rand(N);
t=1;
F=zeros(3,3,N^2);
for i=1:N
for j=1:N
F(:,:,t)= [Ax(i,j);Ay(i,j);Az(i,j)]*[Ax(i,j) Ay(i,j) Az(i... |
The C in CRUD Silverlight:
Create new Silverlight business application "CRUD"
Add ADO.NET Entity Data Model to CRUD.web
Select the db, the tables, build the project
Add Domain Service Class to CRUD.web
Select the tables and also select the allow editing option for the table "tname"
Build the project
Keep two textboxes... |
This is the way I'm currently getting data from XML, but it seems to be really inefficient, checking every localname in every iteration. How should I be doing it?
Here is a sample of the XML I am trying to parse, followed by my code.
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<result>
<properties type="array">... |
I know that getopts is available but I wanted to write my own as a way of improving my bash. Below I show two function definitions and an example of the use of them in a bash script. Finally I show the output of the script.
Please comment.
#!/bin/bash
# Produce a string variable which can be used by function isoption... |
Is there anything wrong with this implementation of Queue with array?
I have started front = rear = -1.
Some references tend to start front = 0 like this:enter link description here
I think if front starts with 0, the source code becomes cumbersome.
#include <stdio.h>
#include<ctype.h>
#define SIZE 5
int queue[SIZE] ... |
Please make some comment about this code of QuickSort.
My code is based on the example shown in this book.
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define SIZE 12
struct StackItem
{
int StartIndex;
int EndIndex;
};
struct StackItem myStack[SIZE * SIZE];
int stackPointer = 0;
int myArray[SIZE]... |
I have over 300 questions that I plan to include in the program. The flow is pretty much like this:
Create a window with the question
Store answer in variable
Create NEW window with question
Store NEW answer
(This continues on for over 300 questions.)
I have 2 questions:
Will this eventually lead to a crash since I'... |
I was thinking of building a F/OSS project as a cPanel for Ubuntu Server, since Ubuntu doesn't have this, and yet making it easy for a hosting company to use this, where users will find it just as intuitive as cPanel.
Trouble is, PHP web pages on Ubuntu run as www-data, and lots of senior PHP guys recommend not running... |
I found a example of Java PostMethod here.
But I want to post several times by using for loop. I made it like this.
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import java.io.BufferedReader;
import java.io.I... |
There is a application with a very slow query (listed below), and I have to optimize to run faster. The truth is that I don't know where to start. Any help?
SELECT DISTINCT v.order_ANC,
v.order_ANC2,
f.codi_arxiu,
f.nom_arxiu,
f.codi_grup,
... |
This is my first attempt to create a reusable and tested module. Any comments is highly appreciated.
#-*- coding: utf-8 -*-
"""
Micron: a micro wrapper around Unix crontab.
Micron is a thin wrapper around Unix crontab command. It let you add and remove
jobs from the crontab file or remove the entire crontab file. "cro... |
I have included the code from a second year project that I would like some advice on. Basically it utilises WMI to query a NIC card from a selection (depending how many are installed in the host machine) and shows various settings such as IP info, DHCP info etc. It also has a ping function.
How can I improve this to ma... |
How does this recursive selection sort look to everyone here? Am I missing anything 'pythonic' about the way I have done it?
def selection_sort(li, out=None):
if out is None:
out = []
li = li[:]
if len(li) == 0:
return out
small = min(li)
li.remove(small)
out.append(sma... |
I have an account page where I have three forms. A user can change his name, his email address, and his password.
There are two difficulties I am having from trying to do this:
1) the request.user information is not updating accordingly (e.g., it will lag behind by one change or it will update if the form is not valida... |
I was reading Mathematics: A Very Short Introduction and it mentioned prime factorization. Being a curious person I had to write my own implementation in Perl.
This program outputs the prime factorization of the numbers between 0 and 1001.
I don't like listing all of my subroutines before everything else, but I'm not ... |
Looking for a code review, and hopefully to learn something if someone has a nicer solution. Here's what I wrote:
from __future__ import division, print_function
from future_builtins import *
import numpy as np
def _walk(num_dims, samples_per_dim, max_):
if num_dims == 0:
yield np.array([(max_ - 1) / (sam... |
I've made a quick finally type in C++:
template<class F>
class finally_type {
public:
explicit finally_type(F f) : function(f) {}
~finally_type() { try { function(); } catch (...) {} }
private:
F function;
};
template<class F>
finally_type<F> finally(F f) { return finally_type<F>(f); }
(Edited to add... |
I'm creating a chat UI with jQueryUI:
$.widget("ui.chatwindow", {
options: {
nickname: "obama";
},
setNickname: function(nick){
var self = this;
var id_pre = 'wchat_' + self.options.nickname;
$('#' + id_pre + '\\:name').text(self.options.nickname);
},
setStatus: funct... |
I want to write an article giving a Haskell introduction specifically to Java developers, and would like to get feedback on my implementation. Please keep in mind that I don't want to be "too clever", as too advanced Haskell concepts would only confuse the readers. On the other hand I need to show some really interesti... |
I'm looking for the fastest way to find all neighbours of a vertex in an undirected Graph. Please improve on the code if possible.
neighbours[g_Graph, v_] :=
Module[
{vl = VertexList[g],
pos},
pos = Position[vl, v][[1, 1]];
Pick[VertexList[g], AdjacencyMatrix[g][[pos]], 1]
]
I need it to work fast both for... |
This code is executed very often, so I'm wondering if it's already ideal or if it's possible to optimize it further.
var highlightLinks = function(e)
{
var anchors = e.target.getElementsByTagName("a");
let file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.in... |
I'm working on the registration process for new users of a small web app, and as this is largely a learning project I'm doing it from scratch.
Here is my user class: Class_user.php
<?php
class User {
// The class variables are the same and have the same name as the db fields.
private $userID; // Mu... |
I have two kinds of lexical analyses of sentences that I need to process. One type of data comes in a "tagged" format, and the other comes in a "parsed" format.
Tagged
The input (@subsentences) looks like:
5.4_CD Passive_NNP Processes_NNP of_IN Membrane_NNP Transport_NNP 85_CD We_PRP have_VBP examined_VBN membrane_NN... |
I am currently doing Encoding on Dropdownlist in our project.
Could you please review and provide your comments about the following approach? After the encoding on dropdown, if there are any special characters it is displaying in the form of encoded characters, please let me know is there any better approach than this... |
I wanted to launch a bash script (read: bash not sh script) as a root not as the user calling it, however bash ignore setuid on scripts, so I chose to write a very small script that takes a script/arguments and call it with setuid set.
This worked well and I went even further to verify that the script has setuid set on... |
I'm trying to create an app for the Palm Pre. It is a prayer app, more specifically a rosary app. If you are not a Catholic, a rosary is kind of like a necklace on which you count beads.
What I'm trying to do:
You click on one of 4 buttons to select one of 4 sets of "mysteries".
The page then displays
the title o... |
I have a query like this "abc=1, def=2, ghi=3" and I need to parse it into arrays like this keys = [abc, def, ghi] and values = [1,2,3]
currently my code is like this
String[] terms = query.split(",");
int termsCount = terms.length;
String[] keys = new String[termsCount];
String[] values = new Object[termsCount];
for(... |
Is this code Pythonic?
def emit_decorator(method, signal_name):
def decorated(self, *args, **kwargs):
retval = method(self, *args, **kwargs)
getattr(self, signal_name).emit()
return retval
return decorated
class Model(base.Transformer, Node):
"""
Transformer subclass that implem... |
Is there a better way to have a minimal Python plugin mechanism than the following?
(This was inspired from this post.)
import sys
import pkgutil
import os.path
import plugins
pluginsPath = os.path.dirname(plugins.__file__)
pluginModules = [name for _, name, _ in pkgutil.iter_modules([pluginsPath])]
dictOfPlugins = {}
... |
I've tagged this as homework because it was originally a school project, it was accepted but I'm not satisfied with the code.
I've used cramers rule to find the intersection of 3 lines in three dimensional space given the x, y and z coefficients but the code is hideous.
def trinomial():
print "Trinomials requir... |
How can I refactor this code? I know it's repetitive but I'm not sure how to fix it.
$(function() {
$('#category-1-button a').bind('click', function() {
$(this).css({opacity:'1'});
$('#category-2-button a,#category-3-button a').css({opacity:'0.4'});
$('#blog-headers').css({backgroundPosition... |
I'm making a function that multiplies all numbers between an "a" input and a "b" input with do loop. If you please, check my function and say what's wrong since I don't know loops very well in Scheme.
(define (pi-function x y)
(let ((result y))
(do ((limI x (+ x 1)))
((= limI y) result)
(set! result... |
Using C#, create a class which gets an action (parameter-less
delegate) in its construction and has a single public method bool
execute() which does the following:
Executes the action only if no other thread is currently executing the action
If another thread is already executing, wait until thread is finished be... |
I have written this Perl code, and there is still more to add, however I was hoping that I could get some opinions on whether it could be written better.
Specifically, there is a central if-elsif structure. Should I make this a subroutine or not? What's best practice?
Also, look at the 2nd block of code, and let me kn... |
Conditional parsing (aka read some tokens and return true or false).
As a solution to this SO question, I wrote following code:
bool nectar_loader::resolve_conditional( const std::function<bool(const string&)> &config_contains )
{
bool result = true;
// My very own recursive implementation
/*
- each s... |
I tried to implement a definitive, reliable URL query string parser that handles every corner case:
it tries to be efficient by avoiding regex
it takes full URLs or just query strings (as long as the query string begins with a question mark)
it ignores the hash value
it handles multiple equal parameter names
it handle... |
Please review this Android UnitConverter App which has been designed using Strategy Pattern.
public class UnitConverter extends Activity
implements OnClickListener, AdapterView.OnItemSelectedListener {
/** Called when the activity is first created. */
private Spinner SpinnerUnit;
private EditText inpu... |
Please review the sales tax problem which has been designed using strategy pattern.
The Problem:
Basic sales tax is applicable at a rate of 10% on all goods, except
books, food, and medical products that are exempt. Import duty is an
additional sales tax applicable on all imported goods at a rate of 5%,
with no ... |
I know exactly how I would handle this in PHP, Python, JS, and AS, but I want to confirm that this is the correct approach to Enums in Java.
I have a database view which has a status column. It will only ever have one of four values (in MySQL, I would have made it an enum type column, but the type doesn't really matter... |
public delegate DataTable loadDataTable();
DataTable shops = (cmbShop.Text == "All Shops") ?
new loadDataTable(() =>
{
Program.con.GET_Table_From_DataBase("sh", "select * from shops ");
return Program.con.dst.Tables["sh"];
}
).Invoke()
:
new loadDataTable(() =>
... |
I'm an experienced programmer, but just a beginner in Python, and would like some input on a small function that's working but which I'm not very happy with.
It's used to produce XML tags (strings). The content argument can be a string, a number etc., but if it's a datetime I have to format it properly. Also, if there ... |
<select name="checkInDay" tabindex="3" onchange="calcDay();" class="ffe selectform" id="checkInDate">
<?php for($i=1;$i<=31;$i++) {
$value = $i < 10 ? "0".$i : $i;
?>
<option value="<?= $value ?>" <?php if($i == 12) {?> selected="selected" <?php } ?> > <?= $i ?> </option>
<?php } ?>
</se... |
i have created simple php engine, i want that this engine used html/php codes from mysql. Here is this php code and please if you find out some mistakes or bugs, please post here. I realy want to use this code for my website but i want to be sure this code safe and bug fixed, so help!
<?php
session_start();
if (isset($... |
I'm sure there's a better more 'jQuery' like way of writing this. In particular the selector $(this).closest('div.login-box') being in there twice. Perhaps it's possible to use $(this)?
$('.close-box').click(function () {
$(this).closest('div.login-box').slideToggle("400");
if ($(this).closest('div.log... |
Mostly for the experience (but also so I could waste hours playing it), I made a simple memory card game in JavaScript. I built it so it has a backbone framework that could be easily extended by stripping off my actual implementation. It's the backbone I'd like reviewed here, and mostly:
My OO - anything wrong; anythi... |
I have a ActionScript 3 AIR class that I'd like you to check for robustness. I know it's quite a lot of code and It's not required that you review the full code, but maybe you see general problems in the way I handle exceptions or maybe you spot something that could make troubles.
The purpose of the Class is to load a ... |
I am terrible with writing JavaScript code that outputs HTML. So, here's how a string literal looks like in a project that I'm working on:
tweet = '<div class="h-ui-box">'
+ '<table>'
+ '<tr>'
+ '<td id="first">'
+ '<img src="' + item.profile_image_url + '" alt="' + item.from_user + '" width="56">'
+ '</td>'
+ '<td... |
I have one large view function where a user can Add, Edit, Delete, and Update his education. I am currently doing this all in one view because I haven't yet learned how to split up views by function. Here is what I currently have --
I have a single URL pointing to the view --
url(r'^profile/edit/education/$', 'views.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.