instruction
stringlengths
71
95.1k
OK, so I recently posted this solution in Python to the longest non-decreasing subsequence problem, and cleaned it up with some expert advice. As a next step, I wanted to translate this solution into Haskell. This presents a challenge because the algorithm as originally formulated depends heavily on mutable arrays wi...
I am studying about the converting int to string and string to int without using toString and parseInt method. I already made methods. However, I don't believe that my way of doing was the best. I would like to improve these function. For example, the first converts from String to int: public static int StringToint(Str...
I have a website on which for every request, the scraping of other websites is done to get accurate data. While it works well, it has a slight impact on the performance. public ActionResult Index(int id) { Product product = pe.Products.Where(p => p.Id == id).First(); foreach (var pricing in product.Retailer_Pro...
I am adding new functionality into a legacy application. For my new classes I have introduced Unit Testing. I still need to work with the existing code. One of the problems I face is that a lot of static methods have been used. Below is an example of a class I need to use: public class HelperClass { public static b...
What is the best way to refactor the following script? <script type="text/javascript"> $(document).ready(function() { $(".rolesList").hide(); }); $("#legendFunction").click(function() { $("#divChkUserRoles").toggle('slow'); var text = $("#lblExpandFunction").te...
I'm working on chat client for mobile devices, and I need to get new messages from server as fast, as possible and, if it possible, keep battery alive. I've created such class, that listens for server on it's own thread. Here is run method of Thread: @Override public void run(){ try{ //actually these lines ...
I'm doing a side project at work and I consider it as a learning opportunity more than work itself, but it does hold a purpose if I can complete it. Anyway, I'll post the code, what it actually does and hopefully people can critique/improve what I've done. os.system("bjobs -u all| awk ' NF>1' > file") lines = open('fi...
I've been using CSS and HTML for a while and I'm trying to start to use better methods of coding. I've tried my best not to hack anything. Could anyone let me know how I'm doing at the moment in terms of using things which are better practice? Please note - I've taken some image names and comments out to protect the pr...
I have this Queue declared in my class: static private Queue<SignerDocument> QUEUE = new Queue<SignerDocument>(); I fill this Queue with some items to process, and I want to process it using multithreading. Did I need to use lock in this case, to ensure that QUEUE.Dequeue is thread-safe? static protected void ThreadP...
I've created a sliding panel menu that works (JSFiddle), but I can't wrap my head around shortening the jQuery for it. Right now, when you click one of the links on the left, I wanted it to show that link's div and hide the others, which I've done, but I don't understand how I can make it more efficient. I'd like any "...
I'm just wondering how my model looks. And by this I mean did I perform the correct tests with the results on each function and use the return at the right points. If you can check all functions. I'm curious to know about if I did the sendMessage function correctly. <?php if ( ! defined('BASEPATH')) exit('No direct scr...
I'm trying to get the peaks/zero crossings from a basic 1D signal and am not sure if my naive/basic approach is correct: float[] signal = {168.02423,167.11852,167.50813,166.8597,166.05814,165.11226,164.18024,162.52278,159.26706,154.01059,151.02512,145.88942,139.96555,131.64963,128.41841,125.55873,123.26397,121.80526,12...
This is some of my first real F# code ever. I have done a bit of reading and watched a few videos however. I chose to do a code kata for string calculator to try it out. The kata I was working on is here by Roy Osherove, though I may have strayed a bit. I am pretty happy with this, but wonder if there are things that c...
Any thoughts on my code? It's a simple hashing code that runs from the command line. There just appears to be a lot of condition if / elif entries in both of the main functions (hashingmethod and hashcalculator). # hashcalculator.py import sys import hashlib args = len(sys.argv) def inputVerification(): if sys...
I am looking for a Perl (5.8.8) script for CSV parsing that would follow CVS standards. (See Wikipedia or RFC-4180 for details) Sure, code should be fast enough, but more important is that it should use no libraries at all. This is what I have for now : #!/usr/bin/perl use strict; use warnings; sub csv { no warning...
I'm new to Django and learning my ways around it. I'm writing a fake basic CRUD app to get me started. In the following code I pretty much copy and paste the same code four times with minor adjustments between each. I only pasted it here twice for the Bands and Album models. Am I doing this right? from django.shortcut...
Is it possible to make this algorithm faster ? Algorithm represents primality test for Wagstaff numbers . import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import java.math.RoundingMode; public class WPT { public static void main(String[] args) { int n; n = Integer.parseIn...
Got this idea from the php.net website on extending exceptions. The main thing I wanted with this was to have the exception name auto imprinted on the exception message, so I wouldn't have to write it in each message. So far its working, just wondering if this is efficient or not? Thanks class DataException extends Exc...
Just needed a quick way to convert an elementtree element to a dict. I don't care if attributes/elements clash in name, nor namespaces. The XML files are small enough. If an element has multiple children which have the same name, create a list out of them: def elementtree_to_dict(element): d = dict() if hasattr...
I just programmed a basic neural network in F# to learn the logical OR function. As I am very new to F# and especially functional programming, I did it the imperative way. And even tho it works, I find it highly unattractive. I would like to improve it to make it as functional-like as possible. I though about overloadi...
How would you improve and shorten this small piece of code? It basically update a textarea label with the number of characters inside the field itself. It saves the original label and restores it when characters count is 0. jsFiddle here while sprintf is from here. $('#send_sms_content').keyup(function() { // The ...
Is this bad coding? Is it OK to use 'OR' to specify argument alternatives? // This function will throw an error if it has no arguements and local stroage is not available var buildLoginUrl = function(username, password, account) { var user = username || localStorage.getItem("...
Thanks in advance for any insight. All used classes are at the top, and everything starts at the comment: // where the magic happens In particular, I am looking for feedback on my attempt at using the factory method and dependency injection. However, I would appreciate any other feedback as well. I have a list of vari...
Finished Someone helped me see that i was framenting the output by writing to each file inside the for loop instead i needed to have one big for loop for each file so that the harddrive didnt have to move its head everytime https://stackoverflow.com/questions/9913788/outputing-dictionary-optimally I have 4 Dictionar...
I wrote a script that I decided to refactor so I could add functionality to it as my coworkers think of it. I only saved four lines in the effort, but the main change is I removed both methods and reduced the number of called variables in favor of string interpolation/manipulation. Is there a preference for this? Is it...
I have the following table called info: info_name | info_value name | Susan desc | Human I'm trying to print Susan without knowing that the value is Susan. The following code works, but I want to know if what I wrote is correct. I'm open to any improvements. Config Class: class Config { pr...
I'm re factoring some code and have come across a method which is throwing 7 exceptions, the method length is approx 20 lines. The method caller wraps this method in a try catch, and just catches the generic Exception. Is there a better way to handle this ? I don't think I should handle each possible exception thrown i...
While working on a project with a friend of mine, I noticed the following syntax: public IObservable<X> GetXs() { return from x in xs select x; } He said that while xs is an IObservable<X> field, this is the way it is supposed to be written in Linq, and everyone does it this way. It also allows one to a...
This code works great and does exactly as it should, but there has to be a better way of doing this and I just can't figure out how! I'm pretty new to jQuery and am trying to use it more myself instead of using plugins and I can get stuff to work fine. It just isn't the tidiest or neatest code, which I'm trying to move...
I'm working on caching library which is intended to work with all types of values. Values are represented as instances of value_type: value_type holds a std::vector<char> for the raw data, and a uint32_t flags integer value which is used to indicate the format of the stored data. I would like to make it easy for the us...
I am writing a scraper, using Scrapy, in which I need to populate items with default values at first. Could my method be improved? def sp_offer_page(self, response): item = MallCrawlerItem() for key, value in self.get_default_item_dict().iteritems(): item[key] = value ...
Example speaks for it self: function writeSpecialTabContentForTtm(){ document.write('<div style="float:right;width:250px;min-height:200px;display:block;border-width: 1px 1px 1px">'); document.write('<form id="ttmsetpointrun" action="" style="text-align:right">'); document.write('<input style="f...
Not sure if this question will be considered "off topic". If it is, I'll remove it, but: I hadn't see this yet so I wrote it and would like to know if this is a good approach to it. Would anyone care to offer improvements to it, or point me to an example of where someone else has already written it better? function clw...
I'm using CasperJS and CoffeeScript for integration testing of a hobby project. Page Objects seem to be a useful abstraction. I had two major requirements: Support for node.js style callbacks - mainly because tests can then be written using async.waterfall Support extending (subclassing) to encapsulate common function...
I'm trying to dynamically generate some MarkDown formatted documents, with header fields of arbitrary lengths. I want to have a title of arbitrary length underlined like this --------------------------------------------------------------- This should work to ------------------- The code I came up with to do this in m...
I am wondering about the best way to save on RAM/memory when there are many required arrays (I plan to have many more NPCs and various other arrays with text and items). And I am wondering what I can improve on so far. #include <iostream> #include <cstring> #define NUM_NPC 10 // Number of NPC players #d...
We want to create a TransactionScope factory class that we can use as a central point for instantiating TransactionScopes with varying configurations throughout our app. One requirement we have is that a method can either: Instantiate a plain TransactionScope whose settings are driven by the defaults in the App.Config...
This is pretty much my first "bigger" application besides some "Hello World!" stuff, so I would appreciate critiques to improve my style. It can be started with Mastermind.play(<difficulty-setting>), with being a number from 1 (easy) to 10 (hard). public class Mastermind { public static void play(int difficulty) {...
This is a general poste about what I can improve in my coding style while wrapping C libraries up into C++. #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <png.h> #include <iostream> #include <vector> #include <string> class PNGFileReader { public: PNGFileReader(); ~PNGFileReader(); ...
After reading a bit about the System.Runtime.Caching in the .net 4 framework I've added a simple Cache class to my application. Can I improve it or add additional useful functionality? Typing it out here I see that the cache checking is somewhat duplicated; could this be refactored? Note: the two properties SuperUsers...
I've written some class which allows me to derive from it to make objects lazy-instantiated. Do you see notational improvements or maybe even cases where this method might not work (multiple inheritance etc.)? What else could I try? class LazyProxy(object): def __init__(self, cls, *params, **kwargs): self._...
I am writing this code in the controller. I want to know is this the right way to write it or not. Because I don't want to write If else conditions and then either redirect or render the pages. Here is my sample code : def create @stud = Student.new params[:student] @stud.save! redirect_to students_path(@st...
I have class that handles HTTP requests: public final class RestHttpClient { /*there is no fields*/ /** * @param mhttp - HTTP request that need to send * @return HttpResponse, that contains information about server response */ public HttpResponse sendRequest(final HttpRequestBase mhttp) thr...
I'm doing the git dot files thing and created a script -- my first Unix shell script -- to synchronise the repo dot files with those in the user's home. It checks which dot files exist in the repo folder (except for .git) and then archives any clashes in the home directory before symlinking to the repo... I wrote this ...
The function of this code is to show/hide divs by way of fadeIn/fadeOut, starting with an empty div (home) and fading in one of the other divs (work,cms,contact,) on click, then fading out the last div and fading in the next on click, and then fading out any div and fading in 'panel' (an empty div) when you click on ho...
I only want to create this SQL function if the dependent Assembly exists. I can do it using dynamic SQL, but it seems messy and I lose syntax checking (in management studio). This function's dependency (for various reasons) may or may not be available on an individual developers machine, and I don't want to interru...
I could use some feedback on the class I designed for the above purpose, the complete code is here: https://github.com/tom-dignan/android-switched-service/blob/master/src/com/tomdignan/android/libs/switchedservice/SwitchedService.java My main question is, does this make sense for its intended purpose? But I will paste ...
I've been learning about Racket sequences and noticed a hole where nested iteration is concerned. We have the in-parallel construct but no in-nested construct. There's the for*/... family, but that's syntactic, and can't be extended to an arbitrary number of sequences known only at run time, so here is my attempt at ...
I was using the jQuery form plugin to process form submission (found here) on my page but now have to switch to using an purely jQuery AJAX based method (without using any the form plugin but I can use jQuery). What would be the best method of achieving this? I'm having difficulty translating it across. What would an i...
I am at the point where I feel that I am not doing it right. It works and does the job, but I am sure that there are more efficient and smarter ways of doing it. I would like to see if there is a way of making it more efficient, clear, and easier to use. This is my query getter: public DataTable querySQL_DT_Return(...
I use Python dictionaries to count words in a corpus: words[a] = number of times I saw a in the corpus. Every time before incrementing a counter (words[a] += 1), I need to check a condition: does the dictionary entry words[a] actually exists? My code: if a in words: words[a] += 1 else: words[a] = 1...
I need some comments on the code that I "assembled". I want to know if it is efficient because I intend to use it on a live site. jsFiddle HTML: <div id="hourForm"> <div id="Monday-Friday" class="day"></div> <div id="Saturday" class="day"></div> <div id="Sunday" class="day"></div> </div> jQuery: $('.day').each(functio...
Is this a proper way to implement an equality check? In Equals method, I am relying on bad_cast exception to know if the objects are of the same class or not. Is there any other way to implement Equals() in C++? class Shape { public: virtual ~Shape() = 0; bool operator==(const Shape& s) { re...
I'm creating a system to generate math problems. As you know in mathematics, there are several different kinds of problems: Binary problems, fractions, decimals, comparating two numbers, etc. I'm creating an abstract problem factory, where this one is like a black box, which receives a Configuration as input, and retur...
I'm looking for some feedback on my implementation of MVC and functional inheritance (as described by Douglas Crockford in his book The Good Parts) in an app that uses the YouTube API. This is my first time building anything remotely object-oriented so I'd really appreciate some advice on this app. You can view the app...
This code will be brute force specific site using http POST method. def BruteForce(url, username, password): userfile = open(username, "r") userlist = userfile.read() userlist = userlist.split("\n") passfile = open(password, "r") passlist = passfile.read() passlist ...
I have been writing a very slim MVC framework to drive a small personal website. It's nothing intricate, just mostly for fun and a learning experience. Specifically, this is the initial part of the MVC and just the entry point. I don't want to develop all this logic for the models and views if my dispatcher is not goi...
I'm trying to implement TCP connection pooling and return a connection back to the pool using IDisposable. I'm wondering if my implementation is correct. It seems to be working but I think because the base class also implements IDisposable and finalize, my code might be leaky. public class BaseClass : IDisposable { ...
I am creating a small Node.js application, but I think the file becomes unreadable. I am certain the file can be split into some better managable file. Here is my app.js var sio = require('socket.io'), fs = require('fs'), express = require('express'), connect = require('connect'...
Are these methods getNewId() & fetchIdsInReserve() thread safe ? public final class IdManager { private static final int NO_OF_USERIDS_TO_KEEP_IN_RESERVE = 200; private static final AtomicInteger regstrdUserIdsCount_Cached = new AtomicInteger(100); private static int noOfUserIdsInReserveCurrently = 0; ...
I am a C++ programmer new to Ruby and someone suggested that I post my code here since it doesn't quite match Ruby standards. Is there a more Ruby way of doing this? I have created a 2D array full of MapTile class objects and then I draw the tiles to the screen by iterating through the 2D Array using a for loop. Here i...
What do you think about this for a generic singleton? using System; using System.Reflection; /* Use like this public class Highlander : Singleton<Highlander> { private Highlander() { Console.WriteLine("There can be only one..."); } }*/ public class Singleton<T> where T : class { private static...
Here is a simple working Java implementation of primality test for Fermat numbers. Is there something that I could change in code to achieve a better running time? import java.math.BigInteger; public class FPT { public static void main(String[] args) { double n; n = Double.parseDouble(args[0])...
While working with Android GUI my approach to adding Listeners for GUI elements is usually: Button helpBt = (Button) findViewById(R.id.help_button); helpBt.setOnClickListener(new View.OnClickListener() { /* Code */ }); Currently, I am at learning stage. However, will this approach be maintainence 'friendly' as I ...
This is all about a whole lot of animations which should happen sequentially. That's why I am using promise().done() functions. In the end I'm binding a function to the mousemove event (similar to a dragging feeling on hover). How can I optimize / shorten it? function showSpecialNavigation(){ $('.special-navigation...
I have implemented a simple generic wrapper for MemoryCache class. Its interface looks like ConcurrentDictionary class but I tried to keep it simple. I tried to keep operations atomic, hoping not to break the thread-safety. Is there a mistake about thread-safety? I also want to know if I there are some boxing-unboxing ...
I used this code on my own site and now trying to transfer it to my new site which uses codeigniter. I'm not sure how I can eliminate some of this code and still maintain its purpose and functionality with merging it into my controller, model, and library. <div id="headerCharacter"> <?php if...
I've searched the web if there is a generic indexer in c# (4.0 / WPF) but could not find anything about it. So I came up with my own solution and would like to share it with you. I hope to get some feedback on improvements. public dynamic this[string attribute, Type type] { get { try { ...
I've a jQuery validation script to check all form fields for a valid value and prevent form submission and display an error message if any fields fail. It was requested that the validation script not check fields one by one, but that it check and highlight ALL fields that failed validation. It works perfectly. But I am...
I humbly ask that you review my simple (albeit a little over-done) program. The intention is to create a deck of cards, shuffle them, and draw the first five off the deck as a poker hand. Can you offer some feedback, particularly if something can be done more efficiently? I intentionally left out much of the error-cor...
#!/usr/bin/env python """ Safely copies .mpg files from one volume to another using temporary filenames and hash verification """ import os from datetime import datetime from hashlib import sha256 from shutil import copy2 #ask user for origin (where to get files) def choose_drive(drives, label): while True: ...
I have the following code, to store a web service name value pair response into DB. I am saving it in xml column of DB. Kindly highlight the issues with this approach. Please note that the name value pair (i.e response.details) array is dynamic and i cannot directly map it to individual db columns. XElement ex = new XE...
With the help of some users here, I finally terminated the conversion of this code from C: #include <windows.h> #include <stdio.h> #define IS_IN_SEARCH(mb, offset) (mb->searchmask[(offset)/8] & (1<<((offset)%8))) #define REMOVE_FROM_SEARCH(mb, offset) mb->searchmask[(offset)/8] &= ~(1<<((offset)%8)); typedef struct ...
I'm learning Haskell and I needed to work with discrete cosine transform matrices, so I made a program that generates text (usable in WolframAlpha) containing the generated matrix. The elements of the n-square matrix C are defined as: \$[C]_{jk} = \gamma_jcos\dfrac{\pi(2k+1)j}{2n}\$ where \$\gamma_{j} = \begin{cases}\f...
Note: I am very new to Javascript. The code I provided is long but not complicated. The code below works and runs fine. But I would like to seperate it out into logical 'pure' functions to make it clearer whats going on. I started to re-factor this myself and made some good progress, however, I quickly started to ...
I have a method which loads data from a remote app (send TCP request and parse response). Now, I have a simple class for sending a TCP request: public class PremieraTcpClient { public PremieraTcpClient() { QueryItems = new NameValueCollection(); int port; int.TryP...
Some time ago I posted on Stack Overflow an imperative C# implementation of Kadane's algorithm for finding a subarray with maximum sum. Then I considered implementing the same functionally in F# and came up with the following: let kadanes (xs: int []) = xs |> Array.mapi (fun i x -> (x, i)) |> Array.fold (fu...
Taking the following cases in consideration. Witch one would you prefer and why? Suggestions appreciated. Using Delegates private void cmdDelete_enterClick(object sender, EventArgs e) { var accountManager = new BLAccountManager(); accountManager.OnAccountInUse = (msg) => MessageBox.Show(msg)...
I'm not very experienced in C++, but I am trying to circumvent a kind of 'constructor order' situation, where I have class A wants class B in its constructor, and vice versa. They don't really want eachother, but both implement an interface and need each other. I decided to give object A a future. Is this even remotely...
I want to scale some sub images from an original image. I need to use TCanvas.CopyRect function for about 5,000 times and it is very slow (from a simple BMP image). Do you know any other method that is faster that simple TCanvas.CopyRect method for the same job? Again the job is to stretch some rects (different rect...
I am completely new to Objective-C. I have written a simple SingleView Tic Tac Toe Application application for learning purposes. While writing the app, I've tried to be as much sound as I could. Since this is my first shot, I think it can be improved a lot. Please tell me what you think about it and what you see I ma...
I wrote a small JavaScript libary that aims to simplify JavaScript cookies. You can find the code on Github: https://github.com/js-coder/cookie.js I tested it in various browsers and it seems to work everywhere. It's not a lot of code so I'll insert it here as well: I updated the code quite a bit so I posted the new v...
I'm in QA Automation, and C# isn't my first language. I've written a small class of methods for GETting and POSTing to web URLs. I use these when I want to test certain things that really fall outside the jurisdiction of Selenium, but are still roughly "black box" type testing. Link scanning, and culling data from POST...
I coded a linear (without threads) app, which looks ok and has normal solving speed. Also, I coded a multithreaded app, and it is ok when I use 2 processors and 2 threads. It is also fine when I use 4 processors and 4 threads. But when I try to solve with 6 processors and 6 threads, I am not satisfied with the solving ...
The problem is find the number of factors of (N!)^2. This is the code, I wrote: int prime[]={//list of primes <(10^6)}; int num_fac_of_factorial(int n, int x) { int p=x, z=0; while(n/p>0) { z+=n/p; p*=x; } return z; } int count=78498; //Count of prime numbers <10^6 int main() { ...
I want to create a ExtensionMethod to ordenate my linq query, called Ordenar. I'll sort it depending what columns is in sortColumns ListDictionary. I tried some ways, but the best way I arquieve was this : static class ClienteBusinessExtensions { public static IQueryable<Model.View_Clientes> Ordernar(this I...
I have a function that takes a point, and given its velocity, and acceleration, calculates the time(s) for the point to collide with the line: def ParabolaLineCollision(pos, vel, acc, line): """A pure function that returns all intersections.""" pass I have another function that wants to calculate the smallest ...
I've got this transform method with a triple-nested loop. The Generate methods do their own caching so they are fast. K will have a worst-case value of 150. N will have a worst-case value of about 20000. It's that 200002 that's killing me. It looks to me like the innermost loop could be moved out, but would you store e...
Our application uses some singletons for localized strings. These calls used to be long and dirty. Therefore some co-worker created extensions for the int and string type to ease the usage of translations. What does the code do: Find a translation string based on the key (the int value). If it cannot be found it falls ...
I'm just getting my feet wet with F#, by implementing some simple algorithms. First up: Djikstras shortest path. There is one piece I've written in this code which confuses me as to why it works: the contains function. As I understand it, List.isEmpty returns true when a list is empty; but in this case, I would want to...
I am contemplating working with a development firm, and had asked for this piece of sample code. Could you please take a look and let me know if this is a quality piece of work, or if it needs improvement? // textures pvr -(void)startWaitAnimation { if(![self numberOfRunningActions] && self.visible) { ...
I'm new to coffeescripts. Can the getSum method be simplified more? Thanks MyObject = checkCondition: (num) -> return true if num is 5 getSum: (num) -> total = 0 total += i for i in [1..num] when @checkCondition i total I tried removing the last total but coffeescripts compiler goes nut :-/ Any he...
I have a java function that reads a csv and returns its content as a Vector<Vector<String>>. The function seems to work as I need it, but my gut feeling says it could be better (never mind the fact that it is declared throws Exception). So here it is: private static Vector<Vector<String>> readTXTFile(String csvFileName...
I'm mostly looking to get feedback on how well I've implemented the C++ language. But I would also like feedback on my algorithm. Did I make it more complex than it needs to be? Is there anything I could have done better? Things my algorithm prevents: IIII <- "too many multiples," better represented as IV IIIV <- "can...
I was preparing myself for an interview at a well known .com firm. One of the question that they often ask is an algorithm to solve sudokus (that have one solution). Here is what came to my mind. Any hints criticisms or suggestions to tune it up? import itertools sudoku_str="""003020600 900305001 001806400 008102900 7...
I've been cooking with gas since I got Daniel C Sobral's help on my last question. I am now re-reading Odersky's "Programming in Scala, 2nd Edition" (finished my first reading about this time last year). I am eager to understand how to alter my mental modeling of problems to more fully embrace the functional programmin...
I'm looking for a code review on the following C++/STL graph implementation: #include <list> #include <algorithm> #include <vector> #include <utility> #include <iostream> #include <stdexcept> #include <assert.h> namespace Graph { template <class T> class graph { public : explicit graph(const std::vector<st...
This is a simple filter that I have been using for a project reading data over a serial connection, and thought it would be good to use it as my first attempt to write docstrings. Does anyone have any suggestions? I have been reading PEP 257. As it is a class, should the keyword arguments come after the __init__ ? If t...
I was trying to solve the following Programming Praxis problem: Write a function that takes a string and determines if the delimiters in the string are balanced. The pairs of delimiters are (), [], {}, and <>, and delimiters may be nested. In addition, determine that string delimiters ‘ and ” are properly matche...
I originally posted this in stackoverflow.com but the question may be too broad. I'm trying to figure out the best way to download and use an SQL database from my server. I have included the code i whipped up but I'm not sure if it's a viable way to accomplish this so peer review would be extremely helpful :) As it s...