instruction stringlengths 71 71.9k |
|---|
Take any natural number n. If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add 1 to obtain 3*n* + 1. Repeat the process (which has been called "Half Or Triple Plus One", or HOTPO) indefinitely. The conjecture is that no matter what number you start with, you will always eventually reach 1.... |
This is my naive (but currently working) attempt at reading JSON commands from a Java game server in Objective-C. I am afraid I might be doing something wrong, so hopefully this question will be a learning experience for me.
To give a little background, someone else built the game server in Java in order to communicat... |
I have a handful of images working as jQuery toggle switches - Showing or hiding an element on a click event.
The code below mostly works as intended, but I'm fairly certain I'm using a lot of unnecessary stuff to make it happen. Any suggestions on streamlining?
Also, any suggestions on closing (toggle to hide) any vi... |
now = datetime.datetime.utcnow()
now.strftime('%d %b %Y %I:%M:%S.%f')[:-3] + now.strftime(' %p')
Is there a cleaner solution for this? I don't want the extra 000 to appear everytime in %f.
EDIT: Got some more possible combinations:
now.strftime('%d %b %Y %I:%M:%S.%f')[:-3] + (' PM' if now.hour > 11 else ' AM')
now.str... |
I wrote a function that allow me to read a binary file using 3 blocks what ever the length of file.
I've decided to divide the length of my file into 3:
block 1: ______________
block 2: ______________
block 3: ____
As you can see, this is almost the length of the 3 blocks that I will have using my function.
(What is... |
I'm trying to design a protocol for sending/receiving serial data.
The basic plan is to allow for text data to be entered in the command prompt, translate that to a hex string and send it out over the serial connection.
The hex protocol with the serial device is as follows:
byte[0]: address of the serial device periphe... |
I have some code that requires the user (an admin) elevate to a system admin account to perform a task.
I wish to prompt the user for the admin credentials to use.
I believe returning a NetworkCredential provides a "protected" (SecureString) password (assuming I dispose correctly).
The concern is retrieving a NetworkCr... |
Simple algorithm based HackerRank challenge.
The Utopian tree goes through 2 cycles of growth every year. The first
growth cycle of the tree occurs during the monsoon, when it doubles in
height. The second growth cycle of the tree occurs during the summer,
when its height increases by 1 meter. Now, a new Utopia... |
I am new using regex expression. After much digging I came up with this code. I would like to know if this is the correct way. I want to search in Joomla for some html tags with specific class and then replace the code between those tags. I want to use an array ($patterns) with tag and classes and another array ($repla... |
I've been imposed with the task of implementing an income tax calculator via J2ME. I have managed to devise the following program solely by myself, however the person who decreed me to carry out this task deems my code to be atrocious and says it can be optimized and altered to be better, asking me to figure it out. I'... |
On selection from drop-down A (HTML select) I need to populate another "sub"-dropdown with a different list of values. For instance, on selection of country in dropdown A, dropdown B should be filled with the list of cities of selected country.
This is my first attempt of writing such a thing in jQuery. Please point ou... |
I'm trying to implement the unit of work pattern with dependency injection / inversion of control and entity framework version 6.1.1 Code First, in an asp.net-mvc project.
public interface IGenericRepository<T> : where T : class
{
IQueryable<T> AsQueryable();
IEnumerable<T> GetAll();
IEnumerable<T> Find(Ex... |
I created my first program in C: a simple calculator. I want to know if it is possible to make this code more effective. Is it, for example, possible to change the calculator function so that I don't have to use switch, but the code knowing what to do because of the character that is entered?
#include <stdio.h>
#includ... |
This review is very short and very straight-forward. There are two people in the team and the checked-in code looks as follows.
string parameter = GetUnitType();
string target = "PM4000";
if(parameter.CompareTo(target) == 0)
CarryOutProcess();
I got stuck here and needed to re-check the usage of CompareTo. I can't f... |
I have one entity that depends on another however in my API service class I would like to just deal with the dependent entity. Am I doing this correctly and is there a better way to go about this?
Post Entity
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq... |
This is my first attempt at learning binary trees. I'm looking for general feedback on how it could be made cleaner, more idiomatic, or more efficient.
data Tree a = ETree | Node (Tree a) (Tree a) a deriving (Show)
tInsert :: Ord o => o -> Tree o -> Tree o
tInsert x ETree = Node ETree ETree x
tInsert x (Node lT rT a)
... |
This is a follow up to Extending the VBAExtensibility Library. It turns out that code had a really nasty bug. Anytime vbeProcedure.StartLine got called, I was running the risk of hitting runtime error 35 because CodeModule.ProcStartLine has to be told what kind of procedure it's looking for. Everything blows up when yo... |
I'm looking for some assistance on an exercise for my C++ programming class. Unfortunately, I was rather ill the previous week an was unable to attend class, meaning I have only been able to use the textbook as a resource. I have done my best to complete the exercises, but, both because of my absence in class and my be... |
I am writing a book database, and ultimately a library system, in Django. When a book is created without a title set, the ISBN will be used to automatically fetch book data from WorldCat I have just created a form to add new books to the database, but it has no real error-handling. Also, as I am new to Django, I suspec... |
I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is the correct one?
Here is my string:
2014-09-12T00:00:00
Here is the regexp, what is used:
\d.+\-\d{1,2}
I am getting t... |
I have made this small game called 'Guess the word, save yourself'. I want to make the code shorter. But how can I do that? Please see the code and give suggestions. I will greatly appreciate it. Also how can I improve the display to make it seem more attractive?
import random
VODOO = [ '''
+------+
| [o] |
| /|... |
I would like to detect which is the line-endings type of a file. I wrote this function:
open my $fh, '<afile.txt';
seteol($fh);
Here the eol detection subroutine:
sub seteol {
my $fh = shift;
my $byte;
my $i = 0;
while (sysread($fh, $byte, 1)) {
if($byte eq "\n") {
$/ = "\n... |
I'm trying to select a grand child from an array in an array.
If it was C# I would have wrote something like below
SubSteps.Select(item => item.First(subitem => subitem == 1)).First();
I have code that works, but I'm not sure it is the best way to do it:
ko.utils.arrayFirst(ko.utils.arrayFirst(self.SubSteps(),
... |
What is a good way to compose std::function objects in C++?
I tried the following, and it seems to work well:
template<typename ... Fs>
struct compose_impl
{
compose_impl(Fs&& ... fs) : functionTuple(std::forward_as_tuple(fs ...)) {}
template<std::size_t> struct int2type{};
template<size_t N, typename ...... |
I have WCF Service using .NET 4.0.
I have similar methods, similar code and I want use good patterns for improvement the code for get high level quality.
I want reuse code, maybe using Action<T>, and improve exception handling, ...
Is it possible?
Interface
[FaultContract(typeof(MyCompany.VSIntegration.SvcDespliegue.Fa... |
I'm still relatively new to C++ and I've written a program that could do with being a bit shorter and faster.
I use this same set of for loops many times to cycle through the whole tree of values. I'll use the JSON format to show you a much shortened version of the tree (in reality the tree has another layer of depth w... |
This is a follow-up question to Iteration of password hashing in PHP
I've gone trough a lot of documentations and stuff to get a feel for this hashing jungle, and done some adjustments to my code along the way.
PBKDF2 seemed like a good fit, so that's wath I went for.
Also, it's important to know that I don't have acce... |
I have built a slideshow using jQuery and CSS3.
jQuery is used to trigger class changes (.slide1, .slide2 ...) on the slide container (#slideshow) and CSS3 is used to handle the transition animations between slides according to these classes.
My main concern is about the jQuery script. I feel it is very verbal as it is... |
I have a bash script, where I need to get the user's geolocation (latitude, longitude and country code). If a GPS device is present, I use gpspipe. But a lot of laptops/computers don't have GPS devices (yet). I need the location as accurate as possible, and getting the geolocation by IP address is (by far) too unreliab... |
We have asked to keep the MVC controller as thin, so we decided to move
all the service calling/business logic into the ViewModel class.
But is it good approach to use a ViewModel class to make a service call?
Does this follows the OOPS/SOLID principle?
public class EmployeeController:Controller
{
private IEmpl... |
I have a catalogue of 56000 objects and I want to replace some columns with new values for instance replace NaN with -99 and 0 for specific columns (as you can see in the following code). Then I need to compute a value for some columns with a function which is called get_ebv_from_map
and subtract it from some other co... |
I've got an array like this, which is a result from a Google analytics request. I asked for the amount of visits for the last three months.
$statPerMonth
array (size=2)
'08' => // The month (August)
array (size=34)
0 =>
array (size=3)
0 => string '08' (length=2) // Month again
... |
I was wondering how to vectorize the following code instead of using the for-loop and still be able to check for a condition.
# n is a numpy array which keeps the 'number of trials' parameter for the binomial distribution
# p is a numpy array which keeps the 'probability of success' parameter for the binomial distribut... |
I've written some code that uses a SortedDictionary to count the number of occurrences of a character in a string.
How can I improve this code? What should I be doing differently? Any advice at all would be helpful.
static void Main(string[] args)
{
string longText = @"The quick brown fox jumps over the... |
I have the code below that I am using to thread certain tasks. Basically, you pass in a function reference, a list of data and the number of threads. It will run the function for each item in the list with the specified number of threads.
I currently have this in a separate py file that I import as needed. Performance... |
I commonly need to trim characters from the end of a string (when building SQL queries, I have trailing commas, brackets, even words sometimes), so I wrote the following:
class String
def trim(amount=1)
self[0..-(amount+1)]
end
def trim!(amount=1)
self[0..-1] = trim(amount)
end
end
The dangerous metho... |
I recently asked on Programmers:
How should one handle a Parent-Child relationship using MVP?
Based on the comments received, I tried this:
IParentView
public interface IParentView { }
IChildView
public interface IChildView<V> where V : IParentView {
void Show(V parentView);
}
IChildPresenter
public interface ICh... |
In this list, each newly inserted element is put in its place in order using IComparer<T>. The implementation uses a LinkedList<T> for the increased performance of insertion. Are there any problems with this object?
public class SortedCollection<T> : ICollection<T>
{
private readonly LinkedList<T> _sortedList;
... |
I have a custom framework that I am not sure if certain things I have applied are wrong and if so, just why.
I am not well versed in any framework, so I was forced to use mine.
Here is an example of a controller found in /app/controllers/UserProfile.php
<?php
class UserProfile
{
public function showUs... |
So I have three methods and I'm not sure how to optimize them. I will be working on this and updating this post while I do but basically running these three methods is central to some parts of my application and they are causing a great deal of slowdown. I just have too many queries being ran because of them. If I coul... |
This is working code presently visible here. Basically, this is still a work in process, but I do not want to go much further down the road without peer review. I've limited the source to the servlet. I am managing multiple servlet requests with parameters. I'm looking for feedback on that pattern--and anything else th... |
The code below works & as far as I can tell the result is correct. Would you please review and let me know what I could have done better?
I tried to use variables as much as possible, that way it could easily be adapted to using other numbers instead of 3 & 5.
I learned quite a bit just writing it, and I hope I can lea... |
I was told I'm using factories wrong, but I'm not so sure. Any ideas? (I know I should be using GET; I've only just noticed that)
app.factory('apiFactory', ['$http', function($http){
var apiFactory = {};
apiFactory.initUser = function(){
return $http({
method: "POST",
url: "api... |
This is sourced from the Stanford Coursera self study DB class SQL quizzes:
Students at your hometown high school have decided to organize their
social network using databases. So far, they have collected
information about sixteen students in four grades, 9-12. Here's the
schema:
Highschooler (ID, name, grade)
... |
I am using Netty to exchange messages between a client and server. For this, I am maintaining a channel pool on client side. Please help me in optimizing this code.
public class Client{
private static final Logger s_logger = Logger.getLogger(Client.class);
private static volatile Client s_client;
private fi... |
I've made a function to print all paths from root to all leaves in a binary search tree. I already have an insert function, which I haven't included in the code here as I felt it was irrelevant to the question. However, assume that it works. The code provided does produce the correct results. However, is it optimal? Is... |
I have 11 data items and would like to print them as a group. Each group will have header and at the end of the group I need to print continue label.
For that, I use this Underscore template and multiple conditions. I'd like to make this more compact.
<script type="text/template" id="header">
<div id="recourseParamete... |
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.GeneratedMessage;
public class ProtoToJson(){
//msg is any protobuf object
public static String generateJsonFromMsg(GeneratedM... |
I am using Dapper ORM in my Data access Layer, but I think analysis of the code below doesn't depend upon any specific ORM. What should be the single common place throughout the entire Data Access Layer to initialise the Connection String?
Base Abstract Class
abstract class Repository
{
protected static ID... |
I've created a simple (300 SLOC) API for a new configuration format (I'm not the author of it). Unfortunately, the specification is only in Polish at the moment, but you can see how it looks here.
The format has a few additional features besides simple data storage. For example, many files can be linked together to cre... |
I'm playing about with JavaScript and wanted to create a simple validation script.
It works ok but is a bit clunky. How could I improve it?
var el = document.getElementById("username");
var el_pwd = document.getElementById("password");
var el2 = document.getElementById("feedback");
var el3 = document.getElementById("o... |
I have the following solution but I am trying to optimize it to run in O(n) time, any thoughts?
I first split the string removing any non-alphanumeric characters, then split the words using spaces and then sort the new string. The rest is just looping to get the duplicate words and its count which I sort one last time ... |
I'm writing some code for someone to update a pivot table field based on the contents entered in a particular cell.
I am unfamiliar with VBA and programming for excel but I followed some tutorials and would like if someone here could look over what I've done just to see if everything looks ok before I give it to them a... |
I'm using Searchkick in a situation where a user might write the location they are searching for, or the thing they are searching for, or both.
I've been working on the below code for most of the day. As you can tell, I'm quite the beginner.
Ideally, what I want is something like this:
@portfolios = Portfolio.where(:p... |
My first bigger C++ project: a vector class for personal use and statistical computation.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
template<class T>
class vect
{
std::vector<T> m;
size_t s;
public:
// default constructor
vect(): m(0), s(0){}
// overloaded const... |
I was hoping if anyone could tell me if I'm doing this correctly, I know there are other questions like this but everyone codes different and I just feel that I'm not doing this right. I'm trying to make a modular OOP site so all the files will be called through the one index file which will then route the user to the ... |
Sometimes the best way to teach is show what you feel is a shiny approach instead of letting a student muddle through coding and potentially loose a future brilliant coder.
This is what I would show for 'Determine the largest averaged array`. Please review any and all aspects.
'use strict';
//Return the average of 1 a... |
The Dir() function in VB and VBA can accept wildcard characters (* and ?) but only in the basename of the path.
Dir("path\*.txt")
is a valid request but.
Dir("path\*\*.txt")
will return Error 52 "Bad File Name or Number", because * is an invalid folder or file name. I created the ability to use wildcards in the f... |
Purpose: to make an adjacency PHP array with parent_id, name, level and root_id (the id of the root category) starting from a "flat" table-like structure.
This is the starting array where name1, name2 and name3 represents the category name and nesting level:
$categories = [
['id' => 1, 'name1' => 'A', 'name2' => 'B... |
This is a sort of follow up to my previous question:
Counting the number of character occurrences
This time I have written code that still counts the number of different characters in a string, but with the added ability to find categories of characters. For example, finding how many numbers are in the string, how many... |
Any comments about style (especially any "non-pythonic" code), performance, readability, etc would be much appreciated! I've tested this on CentOS and OSX 10.9. Works for Python 2.7 and 3.
#!/usr/bin/env python
#
# This script will run on Python 2.7.x and later
#
# By default, iter_modules looks in sys.path which is in... |
I have done my best to write Welch method implementation for python for multidimensional time series and still in the case of one dimensional time series I am getting inconsistent response compared to original Welch method. I have added comments and tried to be clear. Can anybody guide me about the mistake that I might... |
I made a menu to display a list of games and their info so that they can be uniformly launched from an arcade cabinet like set up. I was asked to do it in Python so I learned python using this and this. I have a Java background but no prior Python experience.
I have a working product but I realize that my code doesn't ... |
This is an implementation of Mat's List using by Pseudo-inheriting my Pythonic-List. Inheritance is not built into VBA, but it can be simulated by composing the inherited class and mimicking all it's public methods and members. It's a PITA because a modification of a base class needs to be propagated to all sub-classe... |
I use SQL Server, and though not pertinent here, Railo's CFML engine.
I'm not great at SQL Joins, but I worked through this one and got the result set that I want. This particular SQL will only ever return 10 to 20 records, so even if it's a weak method, I'd probably never see a lot of grief from it since it's on an ad... |
I needed a way to remove elements on a List while iterating through it.
Supposedly something like this (illegal code):
List<Integer> nums = new ArrayList();
nums.add(1);
nums.add(2);
nums.add(3);
...
nums.add(10);
System.out.println("BEFORE REMOVE: " + nums);
for (Integer integer : nums) {
if (integer < 3) {
... |
I'm using boost::program_options to parse input from the user. However, while the standard library makes this an easy task to do, it's causing an (in my opinion) excessive amount of allocations. Of course, for such a small program on modern systems, it probably isn't that big of a deal, but I would like to nip the prob... |
I am pretty new to Python, so I want to listen to any advice that improve my coding style in a "pythonic" way, even about naming style of variables. The following code reflects a very general paradigm that formulates a problem as depth-first search in a tree, which I find interesting and powerful.
Suppose arr = [3, 5, ... |
Description
Generate Property Classes for JavaFX
Java 1.8 is used.
This code can also be downloaded from PCloud:Zip File ,
Github
File Summary
FXMLController.java: Controller for Scene.fxml
JavaDataType.java: Java Data Type Enum
MainApp.java: Main Application Sub Class
PropertyClassBuilder.java: Code Generator
Prop... |
I have recently implemented a code to accomplish Object-to-String. Can you suggest any pros and cons with regard to the code?
public static string ObjectToXml(object obj)
{
var oXmlSerializer = new XmlSerializer(obj.GetType());
var oStringWriter = new StringWriter();
var oXmlSerializerNamespaces = new XmlSe... |
Often I have to skip some actions on the first (or last) loop iteration. Now I need to append some arguments to a URL and separate the arguments by the & character.
For example:
http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml&cnt=7
To do so, the code looks like this:
public static String prepareUrl(St... |
For my CS class I have to write a HiLo game using multithreading. I am brand new to multithreading and not sure how to best implement it. The program below works, but I am wondering if there is a better way to do it. When it is run the user will input an int, which is the amount of time that they will have to guess ... |
The basic idea of the code is to calculate the push or pull force at a vertex, given the number of "push causing molecules" and "pull causing molecules" at a polygon vertex.
The code thus mainly performs arithmetic (including the function it calls, calculate_edge_force), and has a couple of if-statements. The function ... |
Upon coming face to face with the mighty cross-origin request block, and needing to get a JSON file from an external source, I decided to use the Yahoo Query Language in order to achieve this.
I'm starting to wonder however whether this code is really the most efficient way of doing it, considering the source can be in... |
I did the following code challenge for a job interview. They apparently didn't care for my solution and I'm not sure why.
What could I have done better?
Here is the challenge:
Create a small app with the following characteristics:
With the device in the portrait mode, display a fragment with a single
EditText instr... |
I wrote a function, which takes a list of Integers, and then makes a balanced binary tree.
Please critique it. I'd like to know know how to make it more concise and idiomatic.
-- Note that the Integer represents the height of the Tree
data Tree a = Leaf
| Node Integer (Tree a) a (Tree a)
de... |
This is my first relevant code in OpenCL. Please, let me know if I'm doing something wrong in a logical level (i.e., I guess it can crash in situations?) or accounting for performance (bottlenecks, bad use of resources, misunderstanding some concepts, etc).
void accumulatedSum(
volatile __global u32* completeBlocks... |
I am creating user profile logic for a blogging platform. I have the UserProfile model and then two separate models, UserSocialLink and SocialLinkType to control the user's various social media contacts (i.e. Facebook, Twitter, Google+, etc...). I am looking for feed back on the execution of the methods used to Add n... |
I have written a procedure that
shows a ProgressDialog
sends an SMS
updates the View from another thread
hides the ProgressDialog
But it seems to me that this is not the best way to do this. I would like to hear advice and my mistakes. It seems to me that it is possible to optimize the code for quick work procedures.... |
I want to do dynamic modal. Is there a shorter way? Am I doing it right?
angular.module('vidyotorModal', [])
.directive('vidyotorModal', ['$document', '$compile', function ($document, $compile) {
return{
restrict: 'A',
link: function ($scope, $element, $attrs) {
$sc... |
I use this block of code to check if the user is logged in (login stored in cookies as a plain text and pass MD5 crypted). As I'm a novice in PHP, I'm not sure that this is a correct way. Are there other easier ways of checking that you use?
if(isset($_COOKIE['login']) AND isset($_COOKIE['pass'])){
$login = $_COOKI... |
I wish to know how to make this code (and similar) more intuitive:
<?php
$query = 'INSERT INTO `depositors` (`name`, `surname`, `mobile`, `telephone`, `email`';
$query = $this->_params['state'] === 'active' ? $query : $query.', `state`';
$query = !empty($this->_params['hours']) ? $query.', `hours no.`' : ... |
Could you please offer some suggestions about my self learning project?
It is really hard-coded, but I have no idea what to do next. I'm using angular (only few features for now) and grunt + bower.
tester.html
<table class="table table-bordered">
<thead>
<th>First form</th>
<th>Second form</th>
<th>Third... |
This is the only Servlet I have:
package com.tugay.shopping;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
impo... |
To learn more about Rust, I implemented Project Euler #11 "Numbers in a grid". Contrary to some people, I prefer not having the actual data grid in my code, so I put it in a file, which I read in the beginning.
I'm wondering how 'Rustic' my code is. Specially I wonder about the following points:
How to most concisely ... |
I will ask my question using the following example:
HTML
<div>
<input id="ABC" placeholder="abc"></input>
<textarea id="XYZ" placeholder="xyz"></textarea>
</div>
JS Code
var valArray = [{id: "ABC", value: "INPUT"}, {id: "UNKNOWN", value: ""}, {id: "XYZ", value: "TEXTAREA"}]
function process(arr) {
fo... |
This is the AuthenticationService I made based on Barry Jaspan's design, which is way better than the code of which I asked in a question a couple of months ago.
I would like it mainly reviewed on a couple of aspects:
Readability (clean code)
Accurate comments
Accurate naming (especially for the last class)
Authentic... |
I haven't done much Python in the past, so I was wondering if you could look over my code and make sure everything is up to snuff?
I know programs that do this exist already, but I am having a challenge with my friend on who can build a simple backup system for our college files.
I have run the code through Pylint and ... |
I am currently trying to learn bash scripting and I've made a script that backs up or restores my home folder. My main question is whether my code is readable or very messy. I would love to learn to write my scripts understandable to others and also optimally. This script isn't made for sharing right now. Any tips on h... |
Please provide a sanity check on my below JavaScript pattern to be used for a custom edit control. The goals are:
Centralized code
Avoid name collisions
Minimize memory use (putting functions on the prototype chain to accomplish?)
Ease of use for other developers
My specific question is, are there any "gotchas" in... |
I need a shorter way to do this.
input: an ordered list of string pairs L; and a string s
task: for each pair (a,b), replace each occurrence a in s by b
note 1: the replacements have to be independent. The result of one replacement can not be taken as a trigger for a subsequent replacement
Example: L=(("a","b"),("b"... |
I'm building an iOS app for test-taking and I want to be sure of my model before proceeding.
I found this post very helpful and tried to implement a simplified version for Core Data.
Here are some of my assumptions:
Each User can take multiple tests
Each User has one set of answers per Test taken
Each Test has one... |
I have written a program which basically reads a file named "data.txt" line-by-line. As a line is read, it validates the line with a certain specification. If the specification is met, it will output the data within a file named data.txt. If the line does not meet the validation criteria, then it will output that sp... |
Whenever I need logging functionality in .net, I use a logging framework, such as NLog. Obviously there's no logging framework for vba, at least none that I know of.
As much as I love using NLog, the way it works, with targets, rules and loggers, was going to be way too heavy and complex for my needs.
So I kept the ide... |
In short, the code picks up to 9 different ids from li in jailplayer.
If a hillside, it shall save the value of the id, and then checks if there are more li, up to 9 pcs.
Then I save this in an array, depending on how many ids were found.
This looks like a mess. Can someone help me shorten this code and make it easie... |
I'm using a index system to say:
On index i use:
<?php core::doPage(); ?>
Core code is:
<?php
class core
{
public static function doPage()
{
if(!isset($_GET["page"]) || empty($_GET) || !is_string($_GET["page"]))
{
if(!include_once('./_pages/index.php')) die("404 - File not found.")... |
I was prompted to give someone advice about the following problem:
Given a string with equal amount of vowels and consonants, re-arrange it so that it follows the sequence { consonant, vowel, consonant, vowel, ... }
For Example given "abed" modify it to be "bade". The order of the vowels and consonants must be the sa... |
Recently I wrote a logging API that features an ILogger interface. I wanted to extend my library with a DatabaseLogger implementation, and I had to modify the API a little bit for this to work, but I think it was worth it.
Each ILogger instance now has its own ILogMessageFormatter. I no longer needed all loggers to be ... |
A Stack Overflow coder said my code is too rigid and inflexible. Would someone critique my form validation code, and give some pointers on being more efficient?
Code Logic:
If the field has an error (empty or a RegEx fail) with either on submit or on change, the user will see a suitable message indicating the error an... |
I'm developing an Android app in which I would build a card layout with a custom library. I think that my layout has not been optimized, but I don't know how I can this. It's not a very simple layout for me, but I'm new to this and I can't make better.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/and... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.