instruction stringlengths 71 71.9k |
|---|
I've got a problem where I need to parse a line in a parameter file of the form
PotentialName [... variable number of parameters]
I've got code which works however it seems like it will be horrendous to maintain when I add more than a few options here.
What would be the best design pattern to avoid the long chain of e... |
Are there any ways I can clean this code up to make it more user-friendly?
import random #Random Function
import os
print("What is your name?") #Asking User Name
name = input().title() #.title() capitilises the first letter in each word, so when the name is printed in later code the first letter will always be capitil... |
I have several routes, and I need Facebook authentication only in the routes that start with /admin:
app.get('/admin/dashboard', passport.ensureAuthenticated, .....);
app.get('/admin/dashboard/new/email', passport.ensureAuthenticated, ....);
app.get('/admin/dashboard/new/question', passport.ensureAuthenticated, ....);
... |
Haven't any experience writing recursive functions.(Generally tend to avoid them - not sure if that's a negative). What do you think about the following?
This is also my first time using JUnit, I'd appreciate input if I'm doing something wrong there.
Challenge: Create a digital Root Function.
Specifications:
A digital... |
Original question:
Average interval between dates with random blanks
I have a spreadsheet with order date data:
I need to find the average interval in days between each order date. I have to both find a way to get past the blank cells in the row, and also take into account that some clients have 5-10 orders and some ... |
I'm doing a bunch of work with echonest audio objects (as returned by the echonest API) in the Python CLI and rather than having to recreate them each time, they can be saved.
This bit of code reloads them all, referenced via a dict:
def get_saved(directory = 'audio/', extension = 'en'):
return glob.glob(directory ... |
I am implementing a search bar here. I have finished basic UI. I have been recently developed a taste for scalable and robust HTML/CSS. Therefore I am closely following things like BEM and OOCSS
Am I on the right path? Also, how can I make the UI responsive?
index.html
<div id="container">
<form class="search-box">
... |
I came across it as a problem to solve. What kind of limitations are there?
public long parseLong(String number)
{
long n=0;
if(number==null || number.isEmpty())
{
System.out.println("Number is null or empty");
return n;
}
boolean isNegative = false;
if(number.charAt(0)=='-')
... |
I writing a hash table with double hashing. This code works ONLY with ASCII text files and finding the number of occurrences of each word in input file! Please point out mistakes and shortcomings.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define STRINGSIZE 50
#define EXP 2
#define TABLESIZE 100
str... |
My approach to solving the problem of selecting the best match on a bejeweled board is a fully object oriented approach. Some of the other relevant code can be found in my previous questions regarding bejeweled, but this question will only be about the DMMatchFinder class and associated classes.
I should note that I o... |
In my project, I have a type BalanceByBucket that is an immutable type and has a bunch of methods.
I have another class called a FundBalance which is basically just a BalanceByBucket that has an extra int FundID property applied to it. I want this FundBalance to also have access to all the same methods as BalanceByBuck... |
I have a function that accepts a \$255\times1024\$ array and remaps it to another array in order to account for some hardware related distortion (lines that should be straight are curved by the lens). At the moment it does exactly what I want, but slowly (roughly 30 second runtime).
Specifically, I'm looking at the ne... |
I am trying to optimize an object filter function. Given an array of keys, I need to filter an object. I feel that creating a new object each time may degrade performance. Is there a way to mock the Array.prototype.filter function for objects?
function main() {
var Types = {
INTEGER: { value: 'int' }... |
This bit of code is a small game to see how long you play a game of FizzBuzz without messing up.
Code:
The top of the code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef enum {false, true} boolean;
typedef enum {FIZZ, BUZZ, FIZZBUZZ} FB;
int n = 0; // the number that is being incremented
char inp... |
I've been learning Common Lisp lately and I've implemented ANFIS network based on Sugeno model I.
Network layout and details can be read in these slides by Adriano Oliveira Cruz.
I use sigmoid as the fuzzy set membership function of each input (in layer 1)
\$
\mu(x) = \sigma(x) = \frac{1}{(1 + e^{b * (x - a)})}
\$
T-no... |
I am just testing out a few small functions for learning purposes:
def peaks(iterable):
# returns a list of int for those values in the iterable that are bigger
# than the value preceding and following them.
itr = iter(iterable)
peak =[]
curr = next(itr)
last = next(itr)
try:
while T... |
I'm trying to implement generic queries and handlers so that I can make requests with simple syntax, like this:
var query = new HelloQuery("hi");
var result = processor.Process(query);
This post explains a brilliant technique for accomplishing this, but it uses reflection and dynamic to resolve handlers for queries. ... |
In the code below, $rows is the result of database query. In the view that consumes this, I need to break the results into a separate table for each vendor.
The below creates a structure that allows this in the template, but it seems like a clunky way of doing it. Advice on how to improve it?
$byVendor = [];
i... |
Making an Android app involves making a lot of images of various sizes:
The app's launcher icon, in high/low/medium resolution
Buttons, menu buttons, if any, in high/low/medium resolution
Images for listing on Google Play: main icon, feature graphics
To simplify this, I use high-resolution source images
+ ImageMagick... |
I have array contents with some date ranges, fetched from the database:
$calendar = array
(
array
(
'check_in' => '2015-01-02',
'check_out' => '2015-02-28'
),
array
(
'check_in' => '2... |
I am just testing out a couple of small classes for learning purposes. Here is my current working code:
class Permutation:
'''An int list a permutation if starting at any index, one can reach every other index by
repeated index accesses. The list [4, 0, 3, 1, 2] is a permutation: for example index 0
stor... |
You are being watched
Code Review has an open system
A machine that spies on you on every hour of every day
I know because I built it.
I designed the machine to detect suggestions to post on Code Review but it sees everything
Horrible comments involving ordinary users
Users like you
Comments that Stack E... |
Please have a look at this little coroutines library ccoro: http://sam.nipl.net/code/ccoro
I'd appreciate a general code and style review, and your kind comments!
ccoro.h
/*
* ccoro - Coroutines in C
* Sam Watkins, 2009
* this code is public domain
*
* ccoro uses setjmp and longjmp to achieve coroutines in plain ... |
The goal of this code is to take dollar or cents input from the user and give out minimum number of coins needed to pay that between quarters, dimes, nickels and pennies. If this code can be shortened, how would one do it?
#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <math.h>
int main(void)
{
float... |
I'm making a 2048 clone and my method to move and merge tiles is really long. I've heard of helper methods but I'm a little lost as to how I should use them. I feel like my code is a little too long and can be made shorter but I don't know how. What can I do to make it shorter and cleaner? I'll also take any constructi... |
This is a small personal project where most non-sensitive data is distributed to some globally hosted CDN servers, which store the JSON. Now one problem we've seen during testing is a few deadlocks during spike loading of Ajax resources at the precise time that the cache is being distributed to the cache servers. So I ... |
I have such method where:
primary_images is dict,
additional is dict,
get_uri_text is some decorating method,
marker is telling how to parse two dicts.
How can I simplify this method?
@staticmethod
def decorate_sort_images(primary_images, additional_images, get_uri_text, marker=False):
srt_keys = ... |
I have a set of directories. For each directory I have a set of relative file names. I would like to select any of these relative filenames using completion, and then later reconstruct the absolute path of the filename.
In order to create a list of relative filenames for a given directory, I created this function:
(de... |
Question:
Input String 1 = {1, 2, 3, ... , 26}
Input String 2 = {A, B, C, ... , Z}
Output Result 1 = {1, A, 2, B, 3, C, ... , 26, Z}
Output Result 2 = {1, A, 2, A, B, 3, A, B, C, ... , 26, A, B, C, . , Z}
Solution:
public class Combinations {
private static String stringNumbers[]; //1, 2, 3, .... |
I am looking for the fastest way to parse an 80GB csv file with 300 columns in Python.
The csv file does not have backquote commas, e.g a,"blah,blah,blah",c
I have tried Python's built-in csv module which gives me ~50MB/s speed.
with open(file_name) as csvfile:
reader = csv.reader(csvfile,delimiter=',')
for ro... |
The gauss function takes 3 parameters:
a pointer to the matrix of coefficients
the number of variables
a pointer to matrix of solution
#include <stdio.h>
#include <stdlib.h>
int gauss(double* matrix , int x, double* sol);
int main(){
int x;
scanf("%i",&x);
double *mat = malloc((x+1)*x*sizeof(double)), *s... |
I am very much new to design pattern. I'm trying to modify the Rock, paper, scissor game from an example book where I try to add more various design pattern. But I am encountering two similar switch statement which I think have duplicates and I don't have any idea on removing those duplicates.
A abstract class:
abstrac... |
I'm trying to create a 2 way communication socket in python. The socket will listen for connections from the client until it gets the data formatted in string like this: 'PHONENUMBER|STATUS'. I will need to split that and convert it to json which will be sent via http request to a web api. When the api receives, it wil... |
I made an algorithm in C# that solves any system of linear equations using the Gaussian elimination. There are 2 text boxes in the program for input and output. Input is in the format of the coefficients of the variables separated by spaces and lines. I want to know if this code can be cut shorter or optimized somehow.... |
I have code which currently loops through one folder, finds two matching pdf-filenames and merges them into 1 pdf-file always in the same order. File 1 then File 2. My code is slow, maybe because merging PDF files takes a long time, but also because it has to search one folder and match filenames. Before I searched thr... |
I have a controller that pulls gets data from two different JSON files. One of the calls loadProducts happens when the controller is initiated. The other one, loadPrices, is called when a user clicks a button on the interface.
I have noticed that the controller is starting to get bigger and I was worried about the stat... |
I'm working on improving my knowledge of OOP in JS. I just created this custom dropdown selector. It's working nicely, but I'm not super happy about the Filter constructor. I would like to make all that code more readable. It's basically just defining some attributes and setting some event listeners.
function Filter(el... |
I've been practicing using recursion lately and thought this was a case where it would prove really useful, is this good use or is there some superior non-recursive way to go about it?
Challenge:
Write a program which determines the number of 1 bits in the internal representation of a given integer.
Specifications:
... |
Here is my simple implementation on XML parser for XML which I received from a server response. Also I've tried to use XmlPathDocument but failed to get child elements for a node in XmlPathIterator.
public OutboxResponse CheckSendResponseForOutboxPacket(Outbox outbox)
{
var responseContent = ... |
I have a couple of functions in WordPress that I'm rewriting to OOP. All these functions are interlinked in some way and also reuse code from other functions.
This is an example of the first class I'm trying. I'm very new to OOP, but I have learned about separation of concern, so basically each concern get its own clas... |
Is this the best way to construct a vector of 2D points for return?
I don't entirely understand new and delete so I'm concerned about any memory leaks that I might be incurring.
std::vector<Point2D> results;
results.reserve(max_results);
... inside a loop /
Point2D* point = new Point2D(x, y);
results.push_back(*point)... |
This is my first attempt at creating an STL-style iterator. Is this code ok?
std::set<std::wstring> getVolumeNames()
{
class FindVolumeWrapper : public std::iterator<std::input_iterator_tag, std::wstring>
{
WCHAR m_curVolName[MAX_PATH];
HANDLE m_hFindVol;
DWORD m_dwEr... |
Would it be possible to refactor the following methods?
If so - how would I go about best doing it?
public void PlotListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (PlotListView.SelectedItems.Count == 0) return;
var selectedItem = (PlotComponent.PlotList) PlotListView... |
I have the need for load balancing in my MSD-radix sort routine and doing it optimally is not an option. So I tried to play with two simple routines for putting integers into a prespecified amount of buckets such that the sums of buckets are "close" to each other.
My main question is: Can you suggest more optimal, poly... |
I'd like to truncate 160-bit output from SHA-1 to receive a (weaker) 64-bit digest.
It has been a while since I did the type of low-level C pointer arithmetic in the but-last line. Could you please review it for me? It should return the last 64 bits of the the byte array in a uint64_t. (I guess conceptually I could ju... |
I am working on a project in which I need to make a URL call to one of my servers from a bash shell script.
http://hostname.domain.com:8080/beat
After hitting the above URL, I will be getting the below response, from which I need to parse and extract the value of state:
num_retries_allowed: 3 count: 30 count_behind: ... |
I'm learning WebAPI framework for ASP.NET and C#. Is the following way of handling incoming data correct?
[HttpPost]
[ExpiredCookieCheck]
public IHttpActionResult Auth([FromBody]AuthenticationData authenticationData)
{
try
{
if (authenticationData == null)
usi... |
I am implementing a set, using an array as the backend.
Here is how I declared it (and some method implementations):
public class Set {
private int[] elementData;
private int size;
....
public void remove(int value) {
for(int count = 0; count < size; count +... |
I've attempted to implement a 1-to-1 dictionary in Objective-C. I'm probably missing some convenient methods that one might commonly want to use.
These are both declared in the same .h file and implemented in the same .m file. I think if much more code is added to either of these, splitting them into their own files ... |
Below is the code to find the cheapest route for a passenger. stationsUnexplored is a Queue to which stations are added and examined. Once we are done with a station, it is removed from Queue and added to a Set stationsExplored. The purpose of stationsExplored is to avoid queuing of stations more than once. Before addi... |
I want my QuickSort class to have a static sort method that sort any List for any object that extends Comparable. Have I coded my class correctly? Can I make the use of generics a bit cleaner or is this the only way to code the signatures of the methods?
import java.util.List;
public class QuickSort{
private ... |
I created some functionality for JavaScript datepicker.
I'm trying to store a value in the datepicker with the selected month along with which half it is. To do this, I wrote if/else statements to account for every month.
Among the rules I noted were:
28 days - February
30 days - April, June, September, November
31 da... |
This code sorts string that may contain numbers in natural order, that's it, "item 2" comes before than "item 10". It currently ignores case. I plan to implement options to handle case sensitivity and descending order.
For me it's fast enough, faster than other implementations I've seen using regexes. Apart from the fi... |
I've got this code to work, but being really new to PHP, I don't know if this is proper. This is my first time using PHP to increment.
I have 10 fields for YouTube videos (using Advanced Custom Fields in WordPress - I don't have the repeater fields and won't be getting them)
The video/html elements only show if the co... |
I wrote a Rock Paper Scissors game and was hoping to get some feedback on issues like:
Am I utilizing object oriented techniques correctly? What can I do better?
Am I using main() correctly? My understanding is that it should be a main controller for the rest of the program. Should I be utilizing a counter in a dif... |
I wrote the following code to permute the characters of a string assuming there is no repeated character.
I also want to make sure the space complexity of this algorithm is \$O(n*n!)\$: There are \$n!\$ recursive calls, for each of these calls, I copy a string of size \$n\$. Am I right?
Time complexity: \$O(n!)\$: \$n... |
I have a college assignment in which I have to make a Tic Tac Toe game work. Some of the code has been provided by my instructor like method signatures etc. Now the rules for this particular project state that a player wins if they get n consecutive spaces on an nxn grid. So 3 for 3x3, 5 for 5x5, etc. Now I got it to w... |
I'm trying to compare two lists of floating point data and see if they might have come from different underlying distributions. The two samples are a before and after, so by comparing the two I thought I could detect whether any change occurred between the two timeframes.
To do this I'm using the two-sample Kolmogorov-... |
I am creating config file for every other project and try to set all necessary things at once but sometimes miss the things.I have used many framework but most of time I need core and minimal config file
Can you please highlight what things must be included in config file.
right now what I do in config
namespace
add c... |
VBA comment syntax is fun... and VBA line continuation makes it even more fun.
Picture a VBA module like this:
Rem this is an old-style comment.
' this is a more standard comment
Rem this _
is _
a _
multiline _
comment
Private Sub Foo() ' this _
is _
also _
... |
I decided to spend some time working with parsec. I've written some code to check for primality and for whether something is a Fibonacci number. I'm mainly hoping for feedback on readability, but if you have any performance tips I'd be interested in those as well.
import Text.Parsec
import Text.Parsec.Error
import Cont... |
Can you please check my code if it is correct for the problem 100 doors?
This is the problem:
You have 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, you visit every door and toggle the door (if the door is closed, you open it; if it is open, you clo... |
Another challenge from CodeEval that's causing me great pain...
Trying to find out if a sequence if a Jolly Jumper, which is
A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1.
I ended up adapting this idea i... |
I’m using decorator objects in a Rails app so that I don’t have to do nil? checks in views. Everything is working nicely and it’s easy to test, but I’m suspicious that my test:code ratio is a little high. Am I being too verbose? Is there a better way this could be done?
Test suite:
# spec/decorators/client_decorator_sp... |
I am designing a small questionnaire web service application but however I would like if someone can look at my design and see if it good approach I am taking.
The application has the following classes:
Questionnaire
Answer
IQuestionRepository
QuestionRepository implements IQuestionRepository
In the QuestionRepositor... |
I'm using the following Bash CGI to upload a file:
#!/bin/bash
echo "Content-Type: text/plain"
echo
if [ "$REQUEST_METHOD" = "POST" ]; then
TMPOUT=hello
cat >$TMPOUT
# Get the line count
LINES=$(wc -l $TMPOUT | cut -d ' ' -f 1)
# Remove the first four lines
tail -$((LINES - 4)) $TMPOUT >$TMPO... |
This code is very large and seems quite confusing. I tried to refactor it to make it more readable and make the code seem less...(scroll below). However, I am not sure if this can be refactored more.
TableTypeDescriptor baseDecriptor = base.CustomTypeDescriptor as TableTypeDescriptor;
if (this.IsObjectBeingVa... |
I am starting to explore automated testing of code, so I decided to write some trivial code about the cartesian plane and test it. I am particularly interested in automated testing conventions and tips.
cartesian.py
def pytagoras(a,b):
return (a**2 + b**2)**0.5
def distance(point_1,point_2):
return pytagoras((... |
Last weekend my teacher asked me to create code to solve a problem:
Giving a dynamic array, we want to pass the array elements from a file. The first number in the file N gives us the array length. They follow N numbers, the actual elements of the array.
Three brothers are going to work in the shop of their father f... |
I am studying C++ and I wrote the following Merge Sort algorithm. I need some comments from skilled C++ programmers to understand where it can be improved, in terms of execution time, memory usage and "style". I am aware this question is rather generic but really, any comment is appreciated, even more if well motivated... |
I'm currently reviewing a bit of an older console application which performs certain tasks depending on the command line argument that is given. These tasks are called through Windows Task Scheduler.
However reflecting on this I find the code to be ugly and I'm wondering if there is a better way to do something like th... |
I've created a code generator generator, which is hosted here.
I need its parser portion reviewed for OOP, OOD, and C++ best practices.
gengenparser.h
#ifndef GENGENPARSER_H
#define GENGENPARSER_H
#include <string>
#include <boost/algorithm/string.hpp>
#include "linecodegenerator.h"
#include "staticcodegetter.h"
#inclu... |
A project I am working on requires me to check the first character of an input string, to determine if it is a numeric character. I have developed the following code:
public static boolean IsLeadingCharNumfName(String fName)
{
CharSequence[] numbs;
numbs = new CharSequence[10];
numbs[0] = "0";
numbs[1]... |
Hopefully this is not too complicated. I have this code that will generate a username based on the pre-configured schema the admin types in. The fields they can use are:
<first_initial>
<last_initial>
<first_name>
<last_name>
<role>
So, if my name were John Doe, and I had the role of "author" in the system, the functi... |
I am using a way of making error messages, and it works fine. It is just starting to get a little annoying as my project gets larger.
I was wondering if there was a way to do with with out having to rename every part of the error, and make a code so it would pick up the function it occurred in.
Private Sub tsbEditNeigh... |
I'm doing a Java text based game as a course project.
Everything is fine but the part where it shows a conversation, then gives you 2-4 options, then each actions will lead to different text and stats changes.
For now I can only come up with declaring a string array to store all the text, looping through the text until... |
This is an implementation of BIP0039 in Rust (I used python-mnemonic as a guide). I'd like my first Rust program to be critiqued.
I would like to know if the program is structured correctly, if I've chosen the right constructs to use where, any other general comments on what to improve to make it cleaner and more Rust-... |
I have created a small script that aims on comparing two versions of a file by doing a git diff. Is there a better way to code it?
import subprocess
def diff_versions(file_to_be_compared, directory):
try:
out = subprocess.check_output(["git", "diff", "origin/master^", "origin/master", file_to_be_compared],... |
I have 2 long[24] arrays. Both of them contain values for each hour of a day. One of them has hit count and other queue times. Now queue times in ms are 5 digit numbers, counts are 2 digit numbers. I want to show them in one chart, because queue times are to some degree corresponding with hits, but the scale is totally... |
What do you think of this code?
#include <utility>
namespace
{
template <typename F, int I, typename L, typename R, typename ...A>
inline F cify(L&& l, R (*)(A...) noexcept(noexcept(
::std::declval<F>()(::std::declval<A>()...))))
{
static thread_local L l_(::std::forward<L>(l));
static thread_local bool full;
... |
I have a paid app on the app engine. At the moment, usually there is only one instance. The app has a download handler that sends an image after re-sizing it if it is too big. The problem is: if a web page contains many big images (60 or more) the app engine creates another instance. I'm trying to keep the app as cheap... |
I'm trying to mimic the SFML library to be suitable for text-based games. The library called MSLIB in GitHub here.
Here is a sample of the library implementation. It prints gray square onto the screen and it can be controlled by arrow keys to move it up, down, right and left.
How can I improve MSLIB?
Game.h
#ifndef GAM... |
I was wanting some clarification on my code, as I am new to pointers in C. I am trying to return an array from a simple function just so I can understand exactly what it is that I'm doing.
Here is the code I have so far and, to me, it seems as if I haven't even used the pointers correctly.
#include <stdio.h>
#include ... |
I am trying to optimise my tokenizing of tab delimited strings:
static void split_line(string &line, input_record &rec)
{
int col = 0;
char *row = &line[0];
char *token = strtok(row, "\t");
while (token)
{
switch(++col)
{
case 2 : rec.sequence = token; break;
... |
I made a simple notepad webapp, called Notepad5. You can use it to make notes while browsing the web and don't want to open up a separate application or extension to put the notes down and don't want to store them on an external server (more). Please review the code.
/*!
* Notepad5 v1.04
* https://github.com/uddhabh/... |
I am attempting to create a stored procedure that looks at one table and imports changes in that table to another.
This stored procedure is going to be preformed on multiple source tables and will dump out into multiple log tables. The way the data in the log table is stored looks like this:
ID | Source_PK_field | fie... |
Implement the "paint fill" function of image editing programs: Given a
screen point and new color fill the surrounding area.
Any comments on the code below?
Time complexity: \$\mathcal{O}(N^2)\$
Space complexity: \$\mathcal{O}(N^2)\$
static int N = 6;
static boolean[][] colored = new boolean[N+2][N+2];
static... |
I just decided to write a unit test, and see how to do it. This is my unit test:
[TestMethod]
public void TestSearchSort()
{
System.IO.File.WriteAllText(@"C:\Users\Hosch250\Documents\Visual Studio 2013\Projects\ConsoleApplication14\ConsoleApplication14\TestFile.cs", string.Empty);
var TestInstance = new Progr... |
Is there a way to make this code shorter and more succinct? Thanks
My objective is to:
Take an array of objects (someArray)
Use get() to get one specific property of each of someArr's objects (which is also an object itself, as I am working with a json object)
And push this object to the 'tabs' array of the newly crea... |
I am making a to-do list application in Python that will show tasks/subtasks/sub-sub-tasks in a tree view, but with higher-level clades of tasks grouped into blocks (e.g., Work block, Home block). So something like:
To Do List
|--Home Tasks
| |--Clean room
| |--Get storage unit
|
|--Work Tasks
|--Analysis
|--Sort... |
I've made a small program that calculates the cost of flooring for a given area based on the price per sqft and total sqft. I have only been programming for a few days now so I am sure that there are some things I could be doing better.
from decimal import *
import time
print("This program will help you find the cost ... |
I have multiple multidimensional arrays that each have the same structure with different lengths.
arr1 = [["23 Jan",3],["29 Jan",10],["19 Jan",23],["25 Jan",23]]
arr2 = [["31 Jan",7],["29 Jan",12],["01 Feb",4]]
My result would be a merged array without duplicate dates ordered by the date. For the dates that get combin... |
I'm trying to solve this problem but am getting a timeout. Can someone help me to improve?
using namespace std;
typedef multimap<int,int> MMap;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t;
cin>>t;
for(int tcase=0; tcase<t; tcase++) {
// contai... |
I am currently working on a PHP-Formmailer. I`m completely new to PHP but I do have knowledge about HTML, CSS and Javascript. I would learn PHP starting with the basics and everything but I´ll be leaving the day after tomorrow so I would be very happy to see a quick solution :)
Mainly I´m concerned that the formmailer ... |
I have a button that will validate the textbox for the service provider and the dropdown list for the locations. I have 3 tables: Locations, Service_Providers, and Service_Providers_Locations with a many-to-many relationship. But the tables that are affected are mainly Service_Providers and Service_Providers_Locations.... |
I am learning from a book, which uses SHA1. I've changed the code to password_hash(), by checking online. Here I query only the password and verify it. I managed get it working, but I feel a bit paranoid about the code. Is the code proper or wrong?
At registration:
//at registration
$p=mysqli_real_escape_string($db... |
(I've improved the code from my last question)
My program....
Downloads a file (web tracker)
Update if version is lower
Connects to a server using the tracker information
If one of these operations were to fail, the program stalls for a minute and goes back to step one.
A few wrong things I can notice for myself:
re... |
I wrote this CRUD class in PHP that has methods to do database interactions, but I want to know if it is good/secure/elegant?
It works fine and all and it hasn't ever given me any troubles, but I'm really trying to improve my coding habits, so any feedback would be great!
class DbCrud {
private $conn;
/**
... |
This algorithm should return a boolean value, telling if there is a path between two nodes in a given directed graph.
public enum State{
White, Grey;
}
public class Node {
State state = State.White;
List<Node> neighbors = new ArrayList<Node>();
//Assumption: Every node already knows about its direct ad... |
I love boost::lexical_cast but its usage of exceptions there is not preferred in most situations I use it.
I have implemented a version and it seems to work but I want to share it here to hopefully find any defects and/or simply find improvements.
template<typename T1, typename T2>
T1 lexical_cast(T2 const& value, T1 c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.