instruction
stringlengths
71
71.9k
Project Euler Problem 12 asks (paraphrased): The nth triangular number Tn = 1 + 2 + … + n. T7 = 28 has 6 divisors (1, 2, 4, 7, 14, 28). What is the first Tn to have over 500 divisors? After asking for some help on Stack Overflow, I've managed to write this code to solve it: #include "stdafx.h" #include <iostream> #...
I'm coding an algorithm to remove a parameter (let's call it foo) from URL strings. Of course, after the foo parameter removal, the query string should remain valid (with a leading ? and remaining parameters separated by &). I'd also like to remove the leading ? if foo was the only parameter. Details: Domain and pathn...
I have an application for transferring files from clients to a server. A client opens, transfers a file to the server and closes. The server is open and may receive multiple files. Also, when transferring a file, a loader bar is created on both server (the server must have some way to display multiple loaders simultane...
I know there are countless questions on SO, and several articles on the web regarding this subject, but after looking at all the options, I was moved to write my own code to address my own requirements. However, this has raised a couple of questions for me that I would appreciate your valued input on. First, the code: ...
I am writing an "Enter key pressed" event-handler, so when user presses the "enter" key in the input of type text, this code is called: var email = ""; var subscriberInput = $("input[name='subscriber_email']") // Subscribe RSS subscriberInput.keyup(function(e){ if(e.which == 13){ // Enter key wa...
Review this code for code quality. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Data URI encoder</title> <style> #dropbox { padding: 18.5px 0; max-width: 499px; border: 2px dashed #bbb; border-radius: 5px; color: #bbb; text-align: center; } </style> </head> <body> <h1>Data URI encoder</h1> <p...
Here is a solution for Project Euler Problem #7. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10,001st prime number? I've used the pseudo code from the Wikipedia page for the Sieve of Eratosthenes. Input: an integer n > 1 Let A be an array of Bool...
I wrote this code for a dynamic stack and would like to know what would be better if done differently. It can increase memory by a percentage and/or fixed value when needed. It can also be set to not increase automatically at all, so slots are only allocated by the user. The stack is just a structure holding any data t...
I wrote this JS code with some jQuery and got a one-click-text-selection. Maybe someone can improve this code, because I think it's not "clean" and short engough ;) But I don't want to use an input field. Let me know if you have some ideas! function SelectText(element) { var doc = document, text = doc.getEl...
I've created a variable order Markov chain built on top of a tree, but I can't train on datasets >1MB worth of text without running out of memory. I'm sure the tree can be replaced by something else more efficient, but I'm struggling with figuring that out. I've heard a linked list might work, but I'm not sure how. Bel...
I'm looking for corrections, optimizations, general code review, etc. final class TreeData<T> { private T item; private boolean left; private boolean right; public TreeData(T item) { this.item = item; } public T getData () { return item; } public boolean getLeft() { ...
I want to optimize my Apriori algorithm for speed: from itertools import combinations import pandas as pd import numpy as np trans=pd.read_table('output.txt', header=None,index_col=0) def apriori(trans, support=0.01, minlen=1): ts=pd.get_dummies(trans.unstack().dropna()).groupby(level=1).sum() collen, rowlen...
An interviewer asked me to write clean Java code for clockwise and counterclockwise spiral matrix traversal. e.g. {{1,2,3}, {7,8,9}} becomes {1,2,3,9,8,7} and {1,7,8,9,3,2} I've tried many methods and wrote down the below code while keeping in mind that it should be as clean as possible. But I am not sure it is the rig...
Can someone tell me if my code is too long for what it does? package Tests; import java.util.Random; import java.util.Scanner; public class DuelMain { public static void main(String[] args) { Random battle = new Random(); @SuppressWarnings("resource") Scanner input = new Scanner(System.in); int hero...
I'm in doubts what approach to take here, please have a look on the code below: private void processBarCodeResponse(String decodedQrCode) { JSONObject jsonObject = JsonUtil.composeJsonObject(decodedQrCode); SalePoint salePoint = parseSalePoint(jsonObject); if (salePoint == null) return; // handl...
Rails AR. validate one field, with 4 validators & 2 condition block validates :inn, presence: { if: -> { user.is_a?(Client) } }, inn: { if: -> { user.is_a?(Client) } }, uniqueness: { if: -> { user.is_a?(Client) } }, absence: { if: -> { user.is_a?(Department) } } Could I have som...
I've encountered a problem that I have to solve using dynamic_cast to invoke different functions, depending on the type of class State family. I was re-factoring a Parser I wrote before, from a freaking nested class State inside Parser so that I could separate them and extract common parts using templates. Here is a mi...
I am working on a little project to visualize the algorithm for the Traveling Salesman Problem. I have cities, which are movable objects painted with AWT and Swing. Also I can make a connection between two cities in the form of a undirected edge. Each city should have at least one connection between another city. In m...
I'm just beginning web design, and I've come up with this code to scroll to a place in the same page. I don't know if this can or should be improved much longer, so I'm asking for any tips that can make this code better. I know it's messy, but I will clean it later. I just want to know if there's a better method. ...
I've created this PHP script to print a batch of usernames with encrypted passwords locally on my computer because the user/pass format is always the same. username = username password = username + "admin" example = homer / homeradmin Then paste them into two different .htpasswd file and upload to an public Apache se...
In this code, I'm overriding the sorter and matcher for Twitter-Bootstrap's Typeahead functionality. The reason for the override is to allow state (technically Jurisdiction) abbreviations to be used to match the full state name. I've reduced the length of the source array in this example for brevity, but a full version...
I've created an admin login area for an application I am planning to code, and I've used the following login.html page to let the user type in his data (I left out parts like "id", "placeholder" etc. to make it shorter): <form method="post" action="login.php"> <input type="text" name="username"> <input type="passwo...
How can I reduce the amount of repetitive code in my Android app? A lot of the code seems to be doing the same thing twice. I think that there is a more compact way to do this. What are some ways that I can reduce lines of code in this program? Is there a better way that I could write this program? I think that I am...
Looking for code review, suggestions for improvement, best practices etc. The problem definiton is Jump Game Given an array start from the first element and reach the last by jumping. The jump length can be at most the value at the current position in the array. Optimum result is when u reach the goal in minimum ...
Below is a generic code for parsing strings (read from file for example) and converting them to .java types, such as primitives (and their wrappers), java.io.File, Enum etc. There is also possible to register custom made TypeParser's, for non-standard java types (Or provide a static factory method named: valueOf(String...
The following code is my answer to a Stack Overflow question: #include <string> #include <vector> #include <fstream> #include <cstdio> #include <cassert> // #include <stdint.h> => DWORD #ifndef int32_t #define uint32_t DWORD #define int32_t int #endif struct MapItem { std::string term; std::vector<int32_...
I was playing around with Java Card and I try to do one of the examples. P1 is what it has to do (e.g. decrypt, encrypt, etc) and P2 is to select which key to use in P1. Here is what the code looks like - well, half of it anyway, since I'm not really used to formatting in this site and it takes awhile to copy the code ...
Goal: To create a function that returns the relative time difference between two given timestamps, using the DateTime class. Current approach: function time_elapsed($date1, $date2) { $dt1 = new DateTime($date1); $dt2 = new DateTime($date2); $diff = $dt1->diff($dt2); $ret = $diff->format('%y years, %m ...
I have two numbers: a and b. I want to put the smaller of them in one variable, and the larger in another variable (if they are equal, then any of them can be in any of the variables). Currently my code (in Javascript / Java) takes 7 lines: if (a<=b) { small = a; large = b; } else { small = b; large = a...
I observe the same pattern in a number of my classes but can't extract/abstract it due the tight coupling inside each particular implementation. Having the class accepting an optional number of dependencies onto its constructor: public Repository(IBuilder, IFormatter, ILoader, ISelector) With the single method passing...
Storage.prototype.setExpire = function (arrObj) { var date, now, days, deletes, items, fa, ta, newItems = [], storage = localStorage.getItem('limitStorage'); items = JSON.parse(storage || "[]"); date = new Date(); date = date.toString().split(' ');...
The SDL code example on the SDL_Init page seems to be overly verbose, creating an exception class entirely for SDL_Init. I wanted to tone it down a bit by making everything std::runtime_errors. Does it make sense to have global variables and a cleanup function? Is it necessary to check if win is a valid pointer before...
As per a similar question, following a lockfree list implementation. Note that this list has a pre-defined maximum set of elements which can be inserted (N argument in the template declaration). Please let me know if I've missed anything. // Lockfree FIFO list, with N pre-allocated slots template<typename T, size_t N =...
Is this correct? Or am I overloading the responsibilities of the view? <table class="table table-striped table-hover"> <thead> <tr> <th>Estado</th> <th>Prioridad</th> <th>Responsable</th> <th>Categoría</th> <th>Solicitud</th> ...
I am working on an Android app that has an Abstract view controller class. I am using that Abstraction and implementing it for an Android Spinner view. It has a method that assigns the view to be controlled. I implemented it as: @Override public void setView(@Nonnull View view) { super.setView(view); mView = (S...
This questions is originally from http://contestcoding.wordpress.com/2013/06/28/fizz-buzz-bizz-fuzz/. Print the integers from 1 to 100, but for the multiples of 3, print "Fizz" instead and for multiples of 5, print "Buzz". If the number contains a 3 (for example 23), print "Bizz" and if the number contains a 5, pr...
Is there a better way of doing this? // Definition: Count number of 1's and 0's from integer with bitwise operation // // 2^32 = 4,294,967,296 // unsigned int 32 bit #include<stdio.h> int CountOnesFromInteger(unsigned int); int main() { unsigned int inputValue; short unsigned int onesOfValue; printf("Ple...
I would like to improve code readability and reduce the complexity of my code to improve the maintainability of the source code. If you have any tips, please say so. I was also wondering if it would be a good feature to add a 2-player option to this game. Currently, the game runs off of a word list in which it randomly...
I should preface this question by saying that I'm a Java programmer working on my first C++ application, so perhaps there are certain obvious things I don't know. Some background on the problem: Our application had data read from a socket stored in a character array, which was a fixed length message header, containing ...
I'm kinda curious how I'd refactor this in the best way. I've only used Linq for simple queries. What it does: Depending on the type that is submitted, we're grouping events or payments by duration (eg. every year, every month, every day (for the moment). I'd like to extend this to Quarterly and Weekly, but the class...
I'm playing around with switching some code to using Parallel.ForEach and I have a question about whether I need to be concerned about the effects of concurrency here. Here's a simplified version of what I'm doing: public IList<Item> RetrieveAllItems(int paramValue) { var itemFuncs = new List<Func<int, IEnumerable<...
I wrote my very first login/register PDO system today. I know there is still a lot of flaws, but I was wondering what tips and advice you have to help me improve this. I know that PDO is much more secure than MySQl, so would you say my code is secure? If so, to what extent, since I'm using PDO? Any tips and advice w...
This week's Code Review Weekend Challenge is about implementing a simple console game. Here's my game loop: class Program { static void Main(string[] args) { var player = new Player(); var intro = new IntroScreen(player); var nextScreen = intro.Run(); while (nextScreen != null) ...
I am using the cURL tool in MATLAB 2013b with Ubuntu to download a whole bunch of files. The files have one of three possible versions: 1.0.0, 2.0.0, or 2.1.0. Using the HTTP, I first check the headers with three queries to see which version exists. Then whichever exists I download it. If none exists (because of nonexi...
I have a myCon=getUnusedConnection() method that gets a connection from Connection pool. I also have a releaseConnection(myCon) method to release Connection to the pool after finishing using it. When coding, I need to select data from the database many times. I also want to reuse my code. I want to have many methods ...
I am supposed to take this code (that I made): public void showUpdatedStatus() { if(((itsUsersNumber - itsSecretNumber) <= 2) && ((itsUsersNumber - itsSecretNumber) >= -2)) JOptionPane.showMessageDialog(null, "You're hot!"); if (((itsUsersNumber - itsSecretNumber) <= 6) && ((itsUsersNumber - itsSecretNu...
Code review for best practices, optimizations, bug detection etc. Also please verify my complexity as mentioned within the function comments. /** * Util class with 2 functions, * 1. find the next consecutive prime * 2. find the nth prime. */ public class PrimeUtil { private PrimeUtil() {} private stati...
I've made lots of improvements on my text-editing app. Please review it again. (function() { "use strict"; if (!window.File) document.body.innerHTML = "<h1>Sorry your <a href='http://whatbrowser.org/'>browser</a> isn't supported :(</h1>"; var textarea = document.getElementById("textarea"), statusBar = docu...
I wrote a simple text-templating/processing system which resembles PHP, except that it works with Clojure. The main goal was to provide an easy way to use Clojure PHP-style for small files. This is a usage example, the following file <?clj (def theName "Soonog") (defn replaceAs [input] ...
I'm working on an app for my school (not homework, an app that's going to be used by students), that's supposed to display our week schedules. I get the data from a webapp, but it has no API that I can use. So I have to parse the HTML. This HTML is a serious mess (and on top of that, they use Finnish in their pages), a...
int FindStr(char* str, int strsize, char* fstr, int from) { for(int i=from, j=0; i<strsize; i++) { if(str[i]==fstr[j]) j++; else {i-=j; j=0;} if(fstr[j]=='\0') return i-j+1; } return -1; } The function searches for a string fstr in str and r...
So I've read numerous tutorials on handling game states in XNA, and to each tutorial I've been read, it was different from the others. Now I want to ask which way is more efficient? I've created my own ScreenManager and what not, but it wasn't satisfying to me because it was inefficient since I didn't unload any unused...
I wrote this code for dynamic strings and would like to know what mistakes I've made. It's just a struct that gets filled on the first call to ds_allocate and freed on the first call to ds_free. It uses memcpy for concatenation and supports a few basic operations. Here's the header #include <string.h> #include <stdlib....
I have used this guide to implement prepared statements in order to avoid SQL Injection. I made some tests and no error was shown. However, I would like to ask you if you see any flaw in the code, so that I can improve it. This is the code for a simple login: <form action="conexion_PDO.php" method="post"> <label>User:<...
A website I have designed uses a nav menu that shows submenus on :hover. The initial site did not use any responsive design: it targeted only the desktop environment. I am now using responsive-design techniques to target mobile devices and tablets, many of which are touch based rather than mouse based. The big issue I...
I have a deck of flashcards that I want to shuffle. Here's the method I'm using to shuffle them: func (deck *Deck) Shuffle() { rand.Seed(time.Now().UnixNano()) randomIndexes := rand.Perm(len(deck.Cards)) shuffledCards := make([]Card, len(deck.Cards)) for i := 0; i < len(deck.Cards); i+...
I'm trying to learn Python and am working on a simple Tiled Map Format (.tmx) reader as practice. So as to not post too much code at once, I'm only publishing the <data> element which stores the tiles displayed in a tiled map. I'm looking for any critique, no matter how harsh, on quality of code, the Pythonic way of co...
The problem to the question is: Write a program that takes 3 integers as an input from the user using input dialog messages and sorts the three numbers. I just want to know: is there any major differences between my code and the book's code in terms of efficiency or anything specific that I could have done better in ...
I am building a one-page JS app similar to redditinvestigator.com, and my goal is for it to be 100% done in JavaScript. Coming from a PHP/Java background, I'm more used to working in class oriented languages, so I just want to get a sense if I am implementing them correctly in JavaScript. My code works as expected, and...
I am trying to print all the strings given in a N x N Boggle board. Its basically a N x N scrabble-like board where words can be made from a position - horizontally, vertically and diagonally. Here is my naive implementation. Is this correct? Any hints on optimizations? Any other useful links? public class BoggleSolver...
This was my first attempt at writing a program in LISP. Can anyone give any guides as to how it could be improved? The multiple loops in best-pattern seem awkward (I'd normally do that in just one loop but there doesn't seem to be a way of doing that with LOOP, although I'm told there's an iterate extension that can do...
I am not wondering about error checking (I will add that soon). I would instead like to know about correctness, efficiency and simplicity. #include <pthread.h> #include <stdio.h> #include <unistd.h> #define NTHREADS 7 #define RUN_N_TIMES 37 pthread_cond_t new_task_available = PTHREAD_COND_INITIALIZER; pthr...
My entry for Weekend Challenge #5. In scope : Old Skool green on black text adventure Keyboard handling A story with 2 mini-quests 2 endings Virtues ( Hi Ultima ) save the day Out of scope : Mouse handling, save games, high scores Biggest concern : Because both controller and view have a reference to model, I ca...
I am trying to write some string algorithms which I want to work for any kinds of strings and/or locale. I managed to get some results that do work, but I am not sure that what I am doing is idiomatic or anything. Here is a function: template<typename String> auto upper(String str, const std::ctype<typename ...
What are your thoughts on the following code? is it secure enough? Note: $password is used to represent the secret, which would essentially be a SHA512 hash of username . password . signupdate(unixtime) Do you think I'm covered? Here's a demo for the testing purposes. error_reporting(E_ALL & ~E_NOTICE | E_STRICT); ini...
I am trying to implement two simple convertors: date/time to time-stamp and vice-versa, without any dependencies on time library routines (such as localtime, mktime, etc, mainly due to the fact that some of them are not thread-safe). I have the following date/time structure: typedef struct { unsigned char second; /...
I have some questions regarding a common implementation of the UoW, Repository Pattern and EF: public interface IAppUow { void Commit(); IRepository<Customer> Customer{ get; } // IRepository<T> IOrderRepository Order{ get; } // implements IRepository<T> } My questions are: If I need to add a new ...
I have an integer list l and a predefined integer value row (which is never manipulated inside the code). If value of row is 5, then I want the loop to exit if l contains 1,2,3,4. If it is 3, then l should contain 1,2 and so on for any value. I have devised a way of doing this, but since I mean to use this in an app, ...
I've been working on a website and Rails and am fairly proud of my HTML semantics. However, my CSS code has become enormous in size, which is largely unnecessary for such a small website. How could I shorten my code, make it easier to understand, and remove redundancy? I would prefer to have an automated process for th...
I have started working on my first open source project making an LDAP library in Python. I have coded quite a bit and am starting to think about a couple of the details related to design. I have been considering what to do is in regard to the protocol part of the library. Here is a sample of what I have for an encod...
I need to speed up the function below: import numpy as np import itertools def combcol(myarr): ndims = myarr.shape[0] solutions = [] for idx1, idx2, idx3, idx4, idx5, idx6 in itertools.combinations(np.arange(ndims), 6): c1, c2, c3, c4, c5, c6 = myarr[idx1,1], myarr[idx2,2], myarr[idx3,1], myarr[idx...
I have a large JavaScript function to calculate the number of chips, and which denomination of chips to show as the players chip stack. It's done on the base of 10. I have chip denominations worth 1, 10, 100, 1000, 10000, 100000, 1000000. For a total of 7 different chip values, and 7 for loops in my JavaScript code. He...
I'm trying to refactor the following code and could use some suggestions. Basically, three functions generating random numbers in different ways are called: import java.util.Random; public final class JP_RandomNumbers { /** * @param aArgs */ public static void main(String[] aArgs) { genRand...
I wrote the following code to parse some weak ciphers out of an nmap.xml report. I am wondering if there is a more elegant way to write this code in order to avoid the nested for loops with the double if loops. Also, I had to create the two queues. There has to be a better way using list comprehension or a generator o...
I'm trying to improve my JavaScript (I'm usually a copy/paste guy but can do basic DOM stuff with jQuery too), so I decided to try and make a function to validate an email address without using Regex. The code seems to work, but I'm interested in hearing how it could be improved. I'll include the code below, but you ca...
Here is an API key gen script for a cryptocurrency trading platform I am building. First it checks to see if a key exists in the db for the user ID. If it does exist, it displays the key. If it doesn't, it creates one. Next it checks to make sure the key is unique, by polling the db for identical keys. If one is found ...
I wrote a simple android app to export the browsers history as JSON, but I do not know if the resulting JSON is a format that the user will easily be able to parse and use. Is there any way that i could improve the resulting format? Will it be easy for the user to use? I have the title of the page first, should I ...
I have recently been looking into the concepts/patterns behind dependency injection, inversion of control, and registries/service locators. I have searched about the internet on the subjects and have come up with some decent understanding about them, but some things still seem a little cloudy. To start, I would like ...
I have written this working block, but is it optimized? I am getting currency in this format: 1.234,25. public static String convertCurrency(String value, String exchangeCurrencyId) { java.text.NumberFormat format = null; value = value.replaceAll("\\.", ","); char[] chars = value.toCharArray(); chars[va...
I would like to refactor code below and get rid of if statements for classes from view. .container .tabbable.tabs-left %ul.nav.nav-tabs - @related_tasks.each do |task| %li{class: ("active" if @task == task)} = link_to task.name, "#tab#{task.id}", data: { toggle: 'tab' }, class: @current_us...
I have a complicated select procedure that I solved with a 5 query select, so I am posting it here to get suggestions on how I can shorten it up a bit. I am hoping that someone can help me make it a single query select. I'm using nhibernate query over here. I have 7 tables which are t_user t_category t_event t_announ...
This program attempts to solve the following challenge: There is a 2D grid of cells containing N lamps. Each lamp illuminates its own cell as well as its eight neighbours. How many lamps can you possibly remove such that each cell that was originally illuminated remains illuminated? My code: import java.util.*; cla...
The following code will add to each code block a 'Select Code' button that will select the code belonging to that block. Please review for maintainability. In order to use this, visit http://codereviewcommunity.github.io/CodeReviewBookmarklet/ javascript: if ($('button').length === 0) { /* Stack Exchange does not d...
I've just replaced my bash script with a Python script, and this is my first script where I used class. Please review and give me suggestions. #!/usr/bin/env python # This Script will compress One day old file means yesterday files from __future__ import print_function import os import sys import time import glob imp...
I'm curious if this is the right way of going about the issue: function sortWordsByIncorrectAnswers(array) { array = array.slice(0) var sortedArray = array.sort(function (a, b) { a = a.fields.false; b = b.fields.false; return a < b ? -1 : a > b ? 1 : 0; }); return sortedArray } ...
I will admit that this code looks sloppy and repetitive. Which is why I'm asking how I can improve the efficiency and readability of this code. // Sidebar tab highlight when clicked $("#sidebar-tabs-container table td").click(function() { $("#sidebar-tabs-container table td").removeClass("sidebar-tab-selected"); $(...
I was trying to write some of the Haskell list functions into Java, and I realized that one of the key strengths for many of the functions was the ability to pass in a boolean expression. I decided to write a parser to facilitate this. It has worked perfectly as far as I have tested it, but I want to know just how [in]...
I've been working on a MutationObserver es5 shim and would appreciate some feedback on my technique for identifying changes between a node and its clone from earlier state. The reason I'm asking for this code review is that this function is likely not perfect (i.e. will have to be updated in the future for missed/incor...
Because the MLlib does not support the sparse input, I ran the following code, which supports the sparse input format, on spark clusters. The settings are: 5 nodes, each node with 8 cores (all the CPU on each node are 100%, 98% for user model, when running the code). the input: 10,000,000+ instance, and 600,000+ dim...
I implemented an algorithm that gives me a list of points that should be drawn in order the get a line between two points. Please note: it works only in a coordinate system whose origin (0,0) is in the upper left corner. I'd like to get some review on my Haskell code, could it be improved in terms of the language const...
I need a special dictionary that would do as follows: if key is set to more than once, the values are a list of all set values. Such a list is returned as value on get. if key is set only once, it is set to that value, and returned as value as well. Sort of like MultiDict from Paste, but that does not seem to have th...
I was solving Project Euler problem 16, which asks to find the sum of digits of the number 2 raised to the power 1000. Using Python, it can be solved in one line of code: sum(map(int, list(str(2**1000)))) It felt too easy so I decided to write a function in C to do the same job. Here's my program. In what ways can I i...
I'm responsible for maintaining a web service project in c#. I have one service class with a bunch of methods that look a lot like this: [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "v1/Login", ResponseFormat = WebMessageFormat.Json)] public string Login() { try { ...
NodeData stores all information of the node needed by the AStar algorithm. This information includes the value of g, h, and f. However, the value of all 3 variables are dependent on source and destination, thus obtains at runtime. @param <T> I'm looking for reviews on optimization, accuracy and best practice...
Is there a way I could improve my code's readability, or have I finally won the war against sloppy coding? Here's a game launcher I made for The Sims 3 to fix the awful performance caused by big cache files. using System.Collections.Generic; using System.Diagnostics; using System.Windows.Forms; namespace Sims_3___Anti...
I want to get the number if items with state 4 and 1 from my database for each day between a certain date. Is there a smarter and more performative way than this one? I am aware that I should use MySQLi and that MySQL is deprecated. Code explanation: the for loop is to go through everyday between 2 dates $sql_conditio...
I am trying to concatenate the echo statements but I am failing. Also any other tips are appreciated in your review. <?php // load all 'category' terms for the post $terms = get_the_terms($post->ID, 'category'); // we will use the first term to load ACF data from if( !empty($terms) ) { $term = array_pop($terms); ...
I wanted to write a simple Log class for PHP, I use ajax calls with AngularJS and often return the log in an array Example: $return['data'] = $returnedDataArray; $return['log'] = $logDataArray; $return['status'] = 'success'; echo json_encode($return); I was hoping to implement a logging system in my other classes, lik...
I'm a complete neophyte to Haskell with only a smidge of FP experience – I did some Racket programming academically and have written some semi-FP JavaScript professionally, but now I'm trying to learn Haskell (and FP better). So I read Haskell Fast & Hard with no problems up until the last chapter. Monads. Make a prog...
#include "stdafx.h" #include <iostream> using namespace std; int main () { for (int i = 0; i <= 3; i++) //give the user 4 guesses at the word. { std::string guess; cout <<"Guess the word" <<endl; cin >>guess; if (guess == "Dog") { cout <<"You guessed co...