instruction stringlengths 71 71.9k |
|---|
I am writing a Java app that gets the metadata of files in a directory and exports it to a .csv file. The app works fine if the number of files is fewer than a million. But if I feed in a path that has about 3200000 files in all of directories and sub-directories, it takes forever. Is there a way I can speed up things ... |
I have several controls that are bound from database tables. Putting my OOP thinking cap on I figured since all of the controls will have a SqlCommand name and an associated SqlDataReader object I decided to make the following interface to program to.
public interface IBoundControl
{
string GetCommandName... |
The code creates a Ruby bingo game for the console and works properly. I believe the code I wrote needs some work, though, as I am new to Ruby. Any help would be appreciated.
require "color_text"
class Bingo
def initialize
#map of all places that are possible wins
@columns = [
[:a1,:a2... |
I'm fairly new to scripting in Python. I'm looking for suggestions on improving any of the following in the below script: my coding style, performance, readability, commenting, or anything else.
"""
META
Author: James Nicholson
Date: 8/16/2013
DESCRIPTION
This script takes a list of groups from a text file and creates... |
I am working on creating an interface gem that works with the Jira-Ruby gem.
I have several questions and would like a general review for both my code and my attempt at creating a gem (I've never written one before). Any advice on where to go next would also be appreciated.
File structure:
jira_interface
lib
... |
I have some problems in my View.ascx.cs file because I'm reusing my code and modified it based on the situation. For example, when I apply pagination I have different code in all places. I just want my code to be simpler.
using System;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.En... |
I wrote a class that finds values in a huge search volume. I have a pretty strong feeling that my code is not good and would like to get your opinion on it. My experience with C++11 threading is very limited and I think I use the wrong features for my task.
#include <iostream>
#include <vector>
#include <utility>
#incl... |
I am working on hospital management system project. I have implemented it using the following design. Is it a good design?
I have created four classes: Patient, Doctor, Hospital, and Demo. Inside the Hospital class are two ArrayLists of Patients and Doctors. Also, inside the Doctor class, there is a list of Patients (... |
I've built a Twitter plugin recently and was wondering if I could get some feedback on it. There is also a PHP side that grabs the actual tweets and I can post that code if it's needed.
http://jsfiddle.net/cKfDd/
;(function ( $, window, document, undefined ) {
/*************************************
Plugin Functions ... |
I have written below code for the famous Josephus problem, or inky pinky ponky game, or many other names. Does this looks good or is there any loophole if anyone can highlight. I shall be looking forward to optimize it now as much as possible.
#include <stdio.h>
#include <stdlib.h>
typedef struct ll_core
{
int c_l... |
I have recently written my first jQuery plugin. It is a responsive jQuery carousel plugin. It seems to be functioning well apart from on window re-size. Sometimes if the window is re-sized too fast I get the following console error RangeError: Maximum call stack size exceeded, despite a timer function being used to pre... |
I have to create a class Data with dates and there should be some methods and constructor. Maybe some method can be done in another way, especially the method wichIsEarlier, because I made it static and I'm not really sure about it. Please take a look on this class and say what is good and what is bad. Is it better to ... |
I'm a beginner PHP developer and it's my first time using MySQLi. I'm not sure if this is a correct implementation of the connection and query because some people defend this method and some others not. I need a solid implementation for heavy database usage.
Connection:
class bbddConnection {
private $_host = 'localh... |
I have written a plugin loader in Ruby, and I would like to know if it uses the best technique to handle classes, or if anyone has any recommendations on how to improve my code.
I have written a class called PluginManager, and an accompanying module named Plugin. The names of these are self explanatory, one handles the... |
I'm a beginner in C# and am doing a simple programming exercise. I would like to put the Item.price and Item.Name into Listbox2.
Is it possible to put the array name into a variable and iterate with a foreach loop? This is to avoid a very long if, switch, or while loop. It could also be useful in the future if I have... |
How could I make this code more efficient? Instead of using many if-statements, should I make a function, array, or switch? How would I do that?
<form method="post" action="trivia2.php">
<ol>
<li>How many days are in a week? <input type="text" name="daysweek"></li>
<li>How many days are in a year? <input type="text" ... |
I am running a timer for updating some of my operations, such as buffers. But I also want ping to be added.
It is added, but I think it can be improved. This is because I think it's running on the GUI thread, which is not preferred as it will freeze the GUI if something goes wrong with it. I think such a thing has oc... |
I'm currently writing a pure ruby webserver, and one of the things that I have to do is parse a HTTP request. The method I've pasted below takes a HTTP request, and puts it in a map keyed by the header field names.
The biggest issue I faced while doing this was dealing with the lack of an EOF from the TCPSocket on req... |
I've recently read this article, and I agree that the new keyword is not good practice.
Thus, I've made an improvement on John Resig's Simple JavaScript Inheritance in order to use the Class.create method instead of new:
// The dummy class constructor
function Class() {
// I remove the initialization procedure in co... |
I've answered the following question as best as I could, but I need some help with my design and am wondering if I've taken the correct approach. I would appreciate it if anyone could please point out any mistakes I've made and any improvements I could make.
Question:
Please implement an address book that allows a use... |
This works fine but I find it quite big and had hoped there was a cleaner/smaller "toggle" function or alike which I could use but it seems to be related to visibility only - and I want to set a variable (for later usage).
Can this be optimized, if I want a toggle function which should be used to sort a column (and get... |
I have a piece of code that has a bit of a problem. Not that it doesn't work, though. The problem I am having is figuring out the optimal way of working with the MemoryStream, which I find quite difficult to do in this case.
while (checkBox1.Checked && tt1.Connected)
{
tcpstream.Read(lenArray, 0, 4);
... |
I've written a text parser that extracts useful information from a given text. Texts are formatted different, so there are different specialized parsers. I've designed them so that they all must define the methods from the interface Parser.
class Parser:
def parse(text):
raise NotImplementedError
def p... |
Since Qt still does not support to set timeouts on QNetworkRequest objects, I wrote this little wrapper class:
/**
Usage:
new QReplyTimeout(yourReply, msec);
When the timeout is reached the given reply is closed if still running
*/
class QReplyTimeout : public QObject {
Q_OBJECT
public:
QReplyTimeout(QNetworkReply... |
I wrote this jQuery code to animate the opacity (sort of Fadein) of certain elements on my page in consecutive order. It feels very inelegant, though.
(function($) {
function animateFadin($delayedElement, delayTime) {
$delayedElement.delay(delayTime).animate({
opacity: 1
}, 700);
}... |
I need to remove inline javascript for a given string. Examples:
If user typed: <img onload="something" />
I should need to convert into <img />
I created this PHP code and it works(apparently without issues):
http://writecodeonline.com/php/
function test_input($input){
//I have a list with all events but for this ex... |
I am trying to write my first script that checks users against a database (MySQL right now) and if they aren't in the database, registers them. I've tried my best to sanitize and validate the form data before setting variables to be used from it. I would love any constructive criticism or critiques on any aspect of my ... |
Below is the code that I would like to refactor in order to avoid if-else statements in cellForRowAtIndexPath and numberOfRowsInSection.
Depending upon what user selects, section order and numberOfSections will differ each time. numberOfRowsInSection will also vary.
I do need it to keep track of each cell (didSelect... |
I've made a Tic-Tac-Toe program (non-AI) for 2 human players. I will implement AI for a computer player later on. I am a beginner programmer and am also new to classes, which I've implemented in this program. I want to know how this could be optimized.
//the main class is all the way at the end
#include "stdafx.h"
#i... |
I'm just looking for someone to give a critique of my currency converter. I want to see if I could clean it up first before dummy-proofing. I know you want to avoid floating types for working with money, so I made a Cents class. I'm not fully confident in how I did it, so any pointers on that would be nice.
Converter.... |
I just wrote this fuzzy snippet to identify any 2-byte character in my data file which assumes only 1-byte characters (ANSI). Please review and suggest me any better solution!
File.open('data.txt', 'r') do |f|
line_number = 0
while line = f.gets
line_number = line_number + 1
line.each_byte do |c... |
I have figures - TriangleItem and CircleItem:
public abstract class BaseItem
{
protected int _id;
protected string _description;
}
public sealed class TriangleItem : BaseItem
{
public int TriangleId { get { return _id; } set { _id = value; } }
public string TriangleDescription { get { return _description; } se... |
I am embedding my size in a Stream in the first 4 byte. When I think about it, it should be possible to do it better, but that depends.
Here is how I currently do it:
bsize = ms.Length;
tcp.GetStream().Write(BitConverter.GetBytes(bsize), 0, intsize);
tcp.GetStream().Write(ms.GetBuffer(), 0, (int)bsize);
As you can se... |
I am trying to create a web crawler for student research. I have already finish it, but I would like to tell me if the way I use is the best one. (probably it isn't :p)
The crawler is for the cnn site and the only thing I want to get, is the text of the news.
Here is an example link: link
Here is my code:
def cnn_crawl... |
When my Debian server deploys it can run a shell script so I wanted to make one to install postgreSQL, create a role, create two databases and then import a schema into one.
Can anyone please look at this code and tell me if I have done an ok job?
# POSTGRES
apt-get install -y postgresql
echo "CREATE ROLE deploy LOGI... |
I wrote a simple program in Haskell which takes Hex input from stdin, converts the input to ascii and writes it to stdout. An example use:
$ echo -n '48656c6c6f2c2043522e534521' | unhex
Hello, CR.SE!
And here the source code:
import qualified Data.ByteString as B
import Data.Bits
import Data.Word
unhex :: [Word8] -> ... |
I have the following jquery mobile + phonegap app. I'm finding when I load the app, the images in the separate pages load pretty slowly. Any advice on how to speed up loading this app?
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name... |
I'm using the repository pattern with a context and ninject as the IOC. I have a service which handles getting and setting page properties in the database.
public class MyContext : DbContext
{
public MyContext() : base ("DefaultConnection")
{
}
public DbSet<PageProperty> PageProperties { get; set; }
... |
I have written a working code that generates a simple linked list of dates and associated holidays. I realize that I have a problem with memory leaking as I copy lists repeatedly, so I wrote a freeList function. I am just having issues determining where to place this function.
//Creates a linked list of dates/holidays... |
I made this function to teach myself about hash tables. Any ideas? I commented out free(addition) because it was giving me a compiler error, but I need to figure out how to deallocate the memory.
#define hashSize 1000
typedef struct hashElem{
char* date;
char* holiday;
}hashElem;
typedef struct hash{
str... |
I made a small Vim distribution that uses vundle. I decided to make a small function that checks if the repository must be updated.
""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
"... |
The below code uses Promises/A+ (specifically rsvp.js) to generate a token. It does so by either taking an existing token or downloading and parsing a token from a web page. Is it possible to chain this to LoadURIPromise more cleanly? Usually one can chain together promises without causing as much indentation drift.
... |
It has been mentioned in the Clojure Style guide to avoid functions longer than 10 SLOC but mine has more than 10 (47 to be exact).
The code is an web api implementation and follows like this:
(defn classify
"Sends a text to a classifier and returns a classification"
[keys texts classifier & user-name]
{:pre [(ch... |
The purpose of this script is to calculate the nonlinear reflection coefficient of a crystalline silicon slab.
It takes some input files (columns of data separated by whitespace), converts that data to NumPy matrices, then operates on that data via some formulas that are coded into different functions. Finally, it spit... |
I am building my first real php web app. as many you know this requires building LOTS of pages.
in attempting to streamline the repetitive stuff i placed most of my stuff within a content.php page which looks like this
?php include_once ('config3.inc');?>
<?php if(isset($_GET['p'])){
$page = $_GET['p'];
}else {
... |
After getting much improvement, it´s still one issue that concerns me.
And that is the sync between my 2 threads.
I use AutoResetEvent, but sadly, it has some delay with it, and would love to use something else if possible. Would be great if something could be connected to a Bool or the Queue i am using. Here is the Co... |
In C# I have the following two extension methods.
public static void WaitForMilliseconds(this IWebDriver driver, int milliseconds)
{
var timeout = new TimeSpan(0, 0, 0, 0, milliseconds);
WaitForTimeout(driver, timeout);
}
public static void WaitForSeconds(this IWebDriver driver, int sec... |
Suppose I have following elementary DTOs, each DTO corresponding to a database table:
class Event {
String name
}
class Player {
String name
}
DAOs for elementary DTOs:
class PlayerDao {
def insert(Player p) {
//sql to insert local members
}
}
class EventDao {
def insert(Event e) {
... |
This works fine but I feel it can be better optimized.
#!/usr/bin/env py
s = "1:5.9,1.5:7,2:10,4:18,8:40"
load_value = raw_input("Enter a load value\n")
li = s.split(',')
driver = None
for index,item in enumerate(li):
if load_value == li[index].split(':')[1]:
driver = li[index].split(':')[0]
print... |
I have an application which polls a bunch of servers every few minutes. To do this, it spawns one thread per server to poll (15 servers) and writes back the data to an object:
import requests
import threading
import time
servers = ['1.1.1.1', '1.1.1.2']
class CallThreads(threading.Thread):
"""
Auxiliary cla... |
I've made the following program that takes a list of email addresses from a table in MS Access and sends each a test email.
'Send email to mailing list
Function SendNotificationEmail()
'Handle any errrors
On Error GoTo ErrHandler:
'Create Outlook object
Dim olApp As Outlook.Application
'Namespace
D... |
I move back and forth between Python and C++ and I often need a nice/quick way to output STL objects to the screen for debugging purposes. I'd like the output to match the output of a comparable Python object, thus I have different templates for vectors, sets, etc...
Is this the best way to go about this?
template <cla... |
The following code is part of an application I maintain that has a VT100/Xterm style graphical user interface that is implemented using text (Think Midnight Commander. Retro, I know.)
Part of the code involves producing collections of rectangles that represent regions of the screen that may require redrawing. These a... |
I wrote a script for getting the stats of codereview.SE from the front page into a file. Github link if someone prefers reading there. Here is data_file.txt's current contents
23-08-2013
dd-mm-yyyy, questions, answers, %answered, users, visitors/day
22-08-2013,9079,15335,88,26119,7407,
23-08-2013,9094,15354,88,26167,... |
This is my first Python script, and I was hoping to get some feedback. I do have one specific question: is the use of global variables considered a bad practice? When I used them below, my programmer's instincts immediately went off as though I was creating a code-smell, mostly because it seems much less elegant than... |
This method allows me to filter by date a data structure list of hash that contains articles. I would like to have your opinion on the code:
=method article_by_date
$articles->articles_by_date( month => 12 );
Return a list of articles filter by date specified:
input: month (Int) : optional, month to match
... |
I have been trying to parse results and make sure when I am doing so that I don't repeat the same data. I tried to use a few different options built into php with no luck. I did find an example of a recursive array search that seems to work but it's very intensive and adds a lot of time to the script.
What I'm needing:... |
Is there a better way to write it? I need the best way to write it. It is this principle? Please show me a better way
it breaks SRP?
public class PlacementLocation
{
public int Row { get; set; }
public int Column { get; set; }
public int Location { get; set; }
}
public class PlacementLocations : Placement... |
I have two threads, where one listens on TCP and the other renders in a loop:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
try
{
if (ReceiveCheck.Checked)
{
tcplisten.Start();
ListenThread = ... |
I've written an Entity Component System using C++ for my game engine. I'm still inexperienced so I've probably made a lot of mistakes. Thus I've decided to ask here for an honest review.
The complete code is fairly large (although not too large IMHO) so it wouldn't quite fit here. Still if anyone here wishes to browse ... |
I made this simple chat in php. You have suggestions on how I can improve it?
This file configures the connection to the server
This file is a simple form "login" ( only username required )
<form action="chat.php" method = "post">
Username: <input type="text" name="nick"/><br />
<input type="submit" name="butt... |
Is there anyway to make this piece of code more elegant? It's not a nice view, but I can't really see a way to improve the looks of it or shorten it.
private void Send(CancellationToken CTSSend)
{
try
{
NativeMethods.Rect rc;
NativeMethods.GetWindowRect(hwnd, out rc);
IntPtr dc1;
... |
I'd like this improved.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Add New Games</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le sty... |
I would like to get some feedback on my AS3 code below. It's for an Adobe Air mobile app to preload a website in a StageWebView container.
That container will be moved on screen later in the app process. My goal is to show the website content to the user as fast as possible.
// OFF SCREEN - PRELOAD
var webView:StageWeb... |
The following code would strip 0 (all numbers ending with 0, it can contain 0, eg: 105 can be is valid but 150 should be eliminated) and return a number in decimal series if all numbers ending with 0 were stripped.
Example : 0 -> 1, 10 -> 11, 19 -> 22.
I would just appreciate any code reviews.
public static int get... |
Is there any way to make this work faster?
Here is my sample code in vb.net. This adds a point on a chart at mouse position but it is quite slow.
Private Sub Chart2_MouseMove(sender As Object, e As MouseEventArgs) Handles Chart2.MouseMove
Dim coord() As Double = GetAxisValuesFromMouse(e.X, e.Y)
Dim test As Series
Try
... |
I'm looking for general feedback on how to make this useful to other people. This is a subset of underscore.js with some additions, and what I feel are improvements.
The code passes jslint and minifies well with clousre.
Please let me know what questions I can answer to receive a better review.
/**********************... |
This code finds the intersections of all overlapping intervals.
Example: if [0-20], [15-40], and [25-50] are the 3 intervals then the output should be [15-20] and [25-40].
I could not find an answer with complexity less than \$O(n^2)\$. Please suggest a better solution if one exists. Additionally, assume the input inte... |
private void rect_ManipulationStarting(object sender, ManipulationDeltaRoutedEventArgs e)
{
startingColumn = Grid.GetColumn(e.OriginalSource as Windows.UI.Xaml.Shapes.Rectangle);
gLValue = headerGrid.ColumnDefinitions[startingColumn].Width.Value + e.Delta.Translation.X;
if (gLValue < 5)
... |
The code I'm trying to improve modifies a URL according to the options passed in a hash:
{
:image_aspect_ratio => "square",
:image_size => 50
}
or
{
:image_size => {
:width => 50,
:height => 60
}
}
The code looks like this:
module X
module Y
class Z
def image_url
if raw_info['picture'] && im... |
I've implemented a rate limiter for redis in Lua, and I'm wondering if anyone has any suggestions that might improve the performance.
An example use:
eval '[sha] mykey 1234567 60000 1000 1 10' 0
Which translates to:
Create a hash under key mykey
The current ms since the last epoch is 1234567
Limit over a period of 6... |
I have created a polymorphic system, but I don't know whether this is the correct way of doing it. Am I abusing Polymorphism here? Here is the code:
class WriteObj
{
public string Obj1 { get; set; }
public string Obj2 { get; set; }
public string Obj3 { get; set; }
}
The above code is a data object that I a... |
Can you please take a look at my code and improve it (if necessary)?
http://jsfiddle.net/U6R6E/
Javascript (with jQuery)
function random(min, max) {
return min + parseInt(Math.random() * (max - min + 1), 10);
}
function generatePassword() {
var length = parseInt($('#pwLength').val(), 10),
charset = $('#... |
This is a quick and dirty implementation of coroutines that implements yield by saving and restoring the stack to and from the heap. Here's an earlier version, which does the most naive possible thing, and just allocates enough space on the stack for every possible coroutine. The relevant bits from the current code are... |
I need to bind a dropdown to an enum. For this I've made a key_value_pair class and I manually go through each enum option to add it. Is there a more elegant way to achieve this?
HTML:
<select data-bind="options: regions, value: region, optionsValue: 'key', optionsText: 'value'"></select>
TypeScript:
class key_value_p... |
I want to access some of the methods from outside of the plugins scope, namely showPopup(), hidePopup() and updateColor(newcolor).
Initialization
<span class="cp"></span>
<script>
var cp = $(".cp").ColorPickerSliders({
flat: true,
order: {
hsl: 1,
preview: 2
}
})... |
Please review my code.
public class CircularLinkedlistinsert {
private Node first;
private static class Node {
int element;
Node next;
public Node(int element, Node next) {
this.element = element;
this.next = next;
}
}
public void insertNodeInCi... |
This is only my second Python script, so let me have it! If anything seems off in style or implementation, please nit pick away. I want to learn. I know it could've been done in less lines of code without making separate functions and whatnot, but I wanted to approach it like I would an actual project.
#!/bin/usr/py... |
I am writing a small application that would interactively allow user for xml file manipulation with d3 interactive charts.
My xml file has the following hierarchy :
<?xml version="1.0" encoding="UTF-8" ?>
<testcase>
<measurement>
<type>M8015</type>
<interval>15</interval>
</measurement>
<measurement>
... |
I know my naming is not good. Please exclude variable / function renaming reviews from your comments.
import java.util.NoSuchElementException;
/**
* http://stackoverflow.com/questions/2216666/finding-the-intersecting-node-from-two-intersecting-linked-lists
*/
public class Interserction {
private Node first;
... |
The following code gets the recipient's email address, email subject line and email body from a table. It then creates the emails and sends them to a pickup directory. There is a db connection class that I did not include here, but I invoke it in the code below.
The code below runs fine. I am wondering if its speed ... |
The following working code basically swaps the content of two divs. The divs are created dynamically, then the user checks which records they want to swap, and then clicks on a swap button that triggers a function to swap an inner div element.
The part that swaps the div's seems really messy to me. I'm only a beginner... |
So I'm working on a register form and I have four fields: name, username, email and password. I pick up the values of these fields in jQuery and depending on if all the fields are filled, I pass them onto a PHP script via ajax. Is that safe for form validations? I was worried about data getting manipulated by the user.... |
Previous question (without AI): Tic-Tac-Toe optimization
This new code has a main file, a base game class, and two derived human and computer classes.
I welcome any suggestions for improving my code. Also, if I'm being needlessly complex on writing the code, let me know. That is my main concern.
Here, I have the welc... |
How can I make it faster, more efficient, and simpler? Are there any obvious mistakes I've made, or things which will make my code "fancier"?
It's my first time working with any form of pathfinding, so I'm sure I've made plenty of mistakes. It still works, though.
I've ended up adding a lot of comments because I keep ... |
I have written the following program for next word prediction using n-grams. The data structure is like a trie with frequency of each word.
Any suggestions are welcome, but I am more concerned about the compareTo and equals method, where the contract of if(obj1.compareTo(other)==0) then (obj1.equals(obj2) is not honore... |
I've looked for a good method to generate an integer inside a range of values. I think using modulo is not a good method because the values are not perfectly mapped in the range. So I mapped the pseudo random generated number in the range by using double variables types.
What do you think about this method? I know t... |
I'd like to create a cookie wrapper in my application to help support a DRY approach to coding common cookie methods, provide IntelliSense for cookie-type properties (keys), and protect against typo-errors when working with cookies from multiple classes and namespaces.
The best structure for this (that I can think of... |
I recently started working on my code's cleanliness/logistics and would appreciate it if you could give me some tips on how to improve certain things.
Here's a simple console Hangman game I've made:
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#includ... |
In order to make cert creation with easy-rsa as practical for others, this script was created and it works so far. The questions are:
where can it be improved?
are there flaws that are not obvious to the author?
The commentary is a bit extensive, but whomever will come across this in the future should be able to und... |
Is there a better way to write this, as I am using the condition of the Cancellation Token to tell if it should use a byte[] from another thread or not.
SharpDX.Windows.RenderLoop.Run(form, () =>
{
if (CTS.IsCancellationRequested)
form.Dispose();
if (Queue.TryTak... |
I wondered if there was any better way of doing so.
I had a hard time figuring it out (it seemed nobody else already tried to do so).
import re
import string
class BetterFormat(string.Formatter):
""" Introduce better formatting """
def parse(self, format_string):
""" Receive the string to be transform... |
I currently have a solution to increment numbers within a range:
i % x + 1
Where x is the maximum number in the range and i is the previous number.
It is nice and simple, and gives this array: 1,2,3,4,1,2...
I also need to do this in reverse, which should produce this array: 1,4,3,2,1,4,3...
This is my solution:
i == ... |
So I have this code that i use for addition of funds to a certain item.
def addFund
fund=params[:fund]
if(fund.to_i>0)
@fund=fund
if(@item.fund+fund.to_f>@item.price) #the fund added should be less than price-current fudn
respond_to do |format|
format.html { redirect_to @item, er... |
I am developing an Android app. Due to my low experience and the requirement for network operation, my class uses a lot of AsyncTask instances and it grew quite large. I'd like to know how I can split this in to different classes, and generally make it better (not required).
I am really confused in cases where I have t... |
I want to insert and edit values on the same button click. The code is working fine and I am using the same code for both insertion and deletion.
function saveToDB(){
var value= pageValidation();
if($('#jobid').val()==" "){
if(value!=false){
var data = {
"names": $('#names').val(),
"os"... |
I have a function which gets called very often, for this test 30,720,000 times. It has to run in real-time, so performance is very important. Are there possible improvements?
// This function looks up in the vertice table wheter a vertice at that position already exists
// - If yes, return the vertice index
// - If no,... |
class Youtube
{
private $url = null;
private $id;
public function __construct($url)
{
$this->url = $url;
$this->parseUrl($url);
}
protected function parseUrl($url)
{
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)... |
Based on the answer to my previous question on Stack Overflow, I put together the following Queue class. I realize there are already libraries out there to do this. However, I wanted to actually understand the concept and implementing it yourself really drives the knowledge home (it also provides much more fun and a gr... |
I have a situation where I have multiple objects that each needs to connect to a different MongoDB URI.
I am currently testing this using Mongolia but the concept should be the same if I were to use the collection() method of MongoDB's native driver.
Mongolia requires a db object when creating a new model, and since I ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.