instruction stringlengths 71 71.9k |
|---|
I have this type:
type Future<'a> () =
let mutable _value: 'a option = None
member x.Resolve value =
if _value.IsSome then failwith "can only resolve once"
_value <- Some value
member x.IsResolved with get () = _value.IsSome
member x.Value
with get () =
match _va... |
I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly.
Currently I have implemented this in the following way:
Private Sub Monitoring(installationCode As String, drive As String, syncFolder As String)
InitializeDatabaseConnection(in... |
I'm currently trying to create a macro, to edit a document that is around 280k rows and 12 columns. For the first steps I found a macro to delete the rows I don't want based on certain criteria, but the code repeats itself a lot. Every time I run it, I change the criteria and link the macros.
Also, is there a better w... |
This code is working fine, but it looks awful (yes, I am a rookie on this thing). How can I improve it to look better?
Private Sub Worksheet_Change(ByVal Target As Range)
'Conditional Formatting
Application.ScreenUpdating = False
If Target.Column > 6 And Target.Column < 8 And (Target.Value = "G" Or Target.Value = "Y... |
I have a function to display or hide some elements. What I want to do is to manage the display of those elements regarding a value.
How should I replace the term toggle? Toggling for me means 'show the element if it's hidden, or hide it if it shown.' (yes, I mean toggling visibility)
function togglePassengers() {
v... |
You are given a string of lowercase letters. Your task is to figure out the index of the character whose removal will result in a palindrome. There will always be a valid solution.
Here is my quick solution:
public class Main {
private static final String AAA = "aaa";
public static void main(String[] args) ... |
This is pretty much the first Powershell script I've ever done and I am here looking for a quick review of it. Is there something I could have done better? Is the format okay? I don't know much about expected standards, and this was cobbled together as a result of me wanting to learn.
$Company = Read-Host 'Enter Co... |
This is how my LinkedList class looks like in PHP. I am trying to figure out if I can rewrite my reverse_list_recursively() function more elegantly without having the funky $current = NULL. The reason I have it is because I need to pass $current in my recursion call. I'm not sure if there is another way to do it.
<?php... |
I've been been working on a vertical histogram that prints an asterisk in place of a number in a certain range (say 1-10... and so on). My code is working as required.
Is there a better, simpler or more efficient way of doing it? If so, would you mind explaining or showing me better code if you have it handy?
import ja... |
Any suggestions for improvement or critiques are welcome!
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="400" height="200" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<input type="button" onclick="alert(ColorToText())" value="Click Here"/>
<script>
funct... |
I know I have seen this before and I can't remember how to fix it or find where I saw how to fix it:
def product_matcher(item)
product = []
if !item.blank?
product = self.products.where(:id => item.id).first
else
product = self.products.where(:id => token.id).first
end
product
end
It seems wrong to m... |
As an assignment, I was to create an \$n\$-dimensional vector type for \$n \le 20\$. This vector only has to support addition and scalar multiplication.
I tried to write good code, with proper memory management, error reporting, and a nice API. However, I have little experience with C so I would welcome any feedback on... |
I'm trying to create a C# brute force MD5 password checker. If I run it with "test1" without MD5, it completes in 15 seconds. I would like to make it faster, but I'm a c# beginner, and don't know how to optimize code anymore.
Basically, instead of nested for loops, if using flags (of type boolean), so if you have 4 cha... |
How would you improve on this? It's been fairly long since I last did something slightly more extensive in C++, so I'm looking for ways to be more compatible with modern C++ ways, and this style of OOP. I think especially the user action part and new opponent generation might be what needs the most work?
main.cpp
#incl... |
I can clearly see I'm repeating myself, but I don't know how to refractor this without making it really ugly. What I have:
class ChildModelController < ApplicationController
def new
@model = ParentModel.find(params[:id])
# Does the current user have permissions on the parent model
if si... |
I am looking for code correctness and design usage as I think I might be over doing it in the class department.
There are two things I'm mostly concerned with.
The possible redundancy of classes derived from IPerks. As
CommonPerks, UncommonPerks, etc, all look identical except for
the rows/columns in its internal perk... |
def return_year_by_month_and_period(month)
pw = self.property_water.first().billing_increment
case pw
when "12"
self.property_water.where(period: month).first().year
when "6"
case month
when 1, 2
self.property_water.where(period: 1).first().year
when 3, 4
self.property_water.wher... |
Can anything be improved in this code?
#include <iostream>
using namespace std;
void print(int *a, int n)
{
int i=0;
while(i<n){
cout<<a[i]<<",";
i++;
}
}
void swap(int i,int j, int *a){
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
void quicksort(int *arr, int left, int right... |
How to optimize this merge sort code to make it run faster? And how to call merge_sort function without user input by declaring necessary array in the code?
#include <iostream>
using namespace std;
int a[50];
void merge(int,int,int);
void merge_sort(int low,int high)
{
int mid;
if(low<high)
{
mid = low + (high-low)... |
If it is possible I would like some comments on the overall style of the program. It feels like I am writing the whole program as one big script and I'm not sure how to break it down into several compact modules. Also, I feel like I'm writing the program like I do in VB.NET because of the global variables. Any comments... |
I have a function which goes through every name in an object. This object has an array parameter materials which holds other objects. Those objects have the same array parameter which hold more objects and so on.
My code lines 3-5 just repeat while adding .material and another variable. Also the code will only go into ... |
How can I improve it and its running time efficiency?
Problem (SPOJ/CANDY)
Jennifer is a teacher in the first year of a primary school. She has
gone for a trip with her class today. She has taken a packet of
candies for each child. Unfortunately, the sizes of the packets are
not the same.
Jennifer is afraid tha... |
The issue I have with this class is that most of the methods are almost the same. I would like for this code to be more pythonic.
Note: I plan on replacing all the for loop constructs with list comprehensions.
class Sorter(BaseCrawler):
def __init__(self, base_dir):
self.base_dir = base_dir
def by... |
This is part of the project I started just now. It is a function that returns the offset address of a first occurrence of a string match into a given range of memory blocks.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct
{
unsigned long offset;
unsigned long terminal;
} Range;
unsig... |
I've created a working query in Entity Framework and I'm curious if there's a better way to do this. Since there's a lot of field on my models, I will only publish the relevant ones here.
My Models are like this:
public class Category
{
public int Id { get; set; }
private ICollection<Product> products = new Li... |
This is a function to determine if a number is between x and y. It is part of a library of mine called EOL or "Everything in One Line".
#include <stdbool.h>
#ifndef _WINDOWS_H
#include <windows.h>
#endif
bool between (WORD n, WORD x, WORD y) { return (n >= x && n <= y) ? (true) : (false); }
|
The goal is to call startManager on application start so that the manager is initialized in background without blocking application main thread.
Is it a safe implementation? Any recommendation or best practice? (use an Executor, use a synchronized block, ...)
public class FileConverter
{
/** The Constant logger. */... |
The recommended way to report something as "progress" back from a async function is to use IProgress<Type> or IProgress<Class>.
When the caller invokes the async function, it can provide an implementation for IProgress. This object is then used inside the called instance to report back progress.
For a better descriptio... |
In the bit of code below:
How can I make add_day, add_ week and add_month work as a single function? They are almost copy-paste of one another. I'm trying to follow the DRY rule.
How can I set this so that I don't use the variables day/week/cur_day?
import datetime
from collections import defaultdict
class ParsedDa... |
I've just started working with SQLite in C# to test various features of an application. In building my first SQLite example I wanted to insert a large .csv into a table (Person) with two columns, A and B. The .csv file is 50MB in size and contains multiple rows of the same data ("abc, def").
I wrote the following code... |
Can anybody give me suggestions for making it faster? (Project Euler #14)
import time
start = time.clock()
def collatzChain(n):
count = 1
while n != 1:
if n % 2 != 0:
count += 1
n = (n * 3) + 1
if n % 2 == 0:
count += 1
n = n / 2
return coun... |
This is my first game that I made. How could this be improved?
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>
using namespace std;
int snakelenght=2;
char direction='d';
char field[20][30];
class Past
{
int m_nx;
int m_ny;
public:
void Init(int x,int y)
... |
The code below is a publisher base class. I've never really liked the way I implemented this class. Are there any improvements/simplifications I can make to it?
Background:
The execute(...) method is called periodically from ServiceImpl.
ServiceImpl is just a generic service class.
package me.munyengm.core.publish;
im... |
This question has been superseded by C++11 lock free collection similar to std::forward_list - follow-up 2
Thread safe and lock free collections are very hard to write, so I'd appreciate any feedback, especially regarding bugs. The code below is a self contained cpp including some tests.
This question is a new iteratio... |
For a quick summary: I've created this internal web application, and I've hit a point where I can really see the mess I've made. I need some help separating the logic, the view, and the data.
More detail: Over the past few months, I've been doing all I can to learn more about JavaScript built web sites/applications. I'... |
So, I fixed my problem with a public ViewModel for my MainPage like this:
MainPage.xaml.cs:
private static MainPageVM Data = new MainPageVM();
public MainPage()
{
this.InitializeComponent();
SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
this.DataContext = Data;
this.SizeCh... |
In my MUD game engine, I built a messaging api that allows objects to subscribe to concrete implementations of an IMessage interface. Is there anything glaringly bad about the approach I have taken?
The intended use-case is for objects, such as an IPlayer implementation, to subscribe to WhisperMessage and ShoutMessage ... |
The following code:
import random
def keygen():
l = list('abcdefghijklmnopqrstuvwxyz123456789!@#$%^&*()_-+={}[]|\:;?/~`"" ')
random.shuffle(l)
return l
def encrypt(x):
key = keygen() #or a static key for consistency
y = list('abcdefghijklmnopqrstuvwxyz123456789!@#$%^&*()_-+={}[]|\:;?/~`"" ')
z... |
For an input triple (a, b, c), the task is to count the number of integers in the inclusive range [a, b] which have c distinct prime factors. This entails factoring each of the numbers in the range [a, b] and establishing how many distinct prime factors each has.
I need faster code so my program runs faster and works o... |
While checking my SPs today I found that I have,
SELECT COUNT(*)
,CASE WHEN ISNULL(MIN(COALESCE(MP.NewPrice, MP.Price, 2147483647)),0) = 2147483647 THEN 0 ELSE ISNULL(MIN(COALESCE(MP.NewPrice, MP.Price, 2147483647)), 0) END
FROM MerchantsProducts MP
I need to replace this with something which make more sense. Can ... |
How can I improve this game?
#include <iostream>
#include <deque>
#include <vector>
#include <chrono>
#include <random>
#include <conio.h>
#include <Windows.h>
#include <tchar.h>
using Matrix = std::vector<std::vector<int>>;
namespace
{
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_I... |
I have an alternative algorithm to the same problem as Finding missing items in an int list.
My implementation includes optional min and max bounds to selectively fill in the list.
The linked implementation is much simpler.
My Questions are:
How do our two algorithms compare, efficiency wise?
Besides the algorithm lin... |
I think performance won't be a big issue here as the concatenation only happens once (2-3 at worse because of multiple threads). Out of the two methods, which one would you prefer, in terms of readability and performance? Is there any better way to accomplish the task of calculating desired string:uaInfo?
public stati... |
The Situation
I have created some code in the form of modules that each represent a medical questionnaire (I'm calling them Catalogs). Each different questionnaire has its own module as they may differ slightly in their content and associated calculations, but are essentially made up of simple questions that have boole... |
What is considered to be a good programming practice for returning value from the function? For example, if we have a function in C named list* after( list *node), which returns the node which is after the node pointer.
First option:
node *after(node *first_ptr, node *nod_ptr)
{
if (!(is_last(first_ptr, nod_ptr)) ... |
I've to do a generic method Classify<T> that, given a sequence of elements of type T and an arbitrary number of predicates, returns an array of n+1 lists (where n is the number of the predicates). More precisely, if the element satisfies the first predicate then it is added to the first list. If not, then if the elemen... |
I want to create a circular queue using a linked list. I also want to create many instances of that data structure (queue) without repeating the code.
This is what I came up with:
#include <stdio.h>
#include <stdlib.h>
struct queue
{
int info;
struct queue *next;
struct queue *front;
struct queue *rear... |
Suppose we have an application which process packets from somewhere. We should choose right handler for the packet depending on packet type and also we know that it might be necessary to change algorithm of handlers and add new handlers in the future.
The question is: how can I write maintainable code?
Here is my draft... |
I have this code inside a post route:
The first one is to alert me when a user registers on my site:
sendgrid.send({
to: "my@email.com",
from: "myother@email.com",
subject: "[ALERT] " + req.body.eventDate,
html: "SOME HTML",
},
function(err, json) {
... |
I've started using Code Climate to assess some of my code quality and ran into a situation that I can't seem to find a good solution for. In short, in trying to solve some code duplication that resulted in a low "grade" by using metaprogramming, I simply get a low grade for code complexity instead.
Anyone know a good a... |
I wrote a program which computes the harmonic partial sum to N terms with multithreading capability. I've been working on this to sharpen my C++ skills for the upcoming semester. Just wondering if there's anything that doesn't follow the C++ standard and/or glaringly wrong. Also wondering if I can make any further opti... |
I am trying to check if an Array A contains all the elements of Array B and similarly Array B contains elements of Array A, the order does not matter.
Some examples:
A B Result
{1} {0} false
{0, 0, 0} {0, 0, 0} true
{17, 4, 11} {4, 17, 11} tr... |
I have created a simple program in which the user is prompted for various details about their employment. In my Employee.java file, I have all the methods.
Employee.java:
import javax.swing.JOptionPane;
public class Employee {
private static String name;
private static String jobTitle;
private static int ... |
I am creating an algorithm to take a series of labelled points placed randomly and move them until they fulfil a set of constraints.
The constraints have been pre-computed and are each a lower and upper bound of the distance between two points. There is definitely a solution that satisfies all constraints.
The procedur... |
I am a beginner in programming languages, so I apologise if my code is badly formatted or doesn't make any sense.
My program gets an image and a RGB color range as input and it counts how many pixels are in each group. A group only contains pixels connected directly, not diagonally, so for each pixel, it searches for v... |
I am trying to encrypt the input string using the following rule:
1st Character of string will be increment by 4 ( a will become e )
2nd Character of string will be increment by 1 ( a will become b )
3rd Character of string will be increment by 7 ( a will become h )
Rest of the characters will be replaced using the ab... |
This programme uses a genetic algorithm to get the string "Hello, World!". It can be summarized as follows:
Create a random initial population.
Let the best reproduce and kill the worst until we get a 'good_enough' result.
I used doctest to verify correctness.
import doctest
import random
def random_char(start=' ',e... |
I have implemented this compile time map as a way of learning templates and constexpr classes:
template<class K, class V>
class Element {
public:
const K key;
const V value;
constexpr Element(const K& key, const V& value) :
key(key), value(value) {};
};
template<class K, class V>
constexpr Element<K, V> El(... |
I'm trying to solve simple Java problems in various ways. Could anyone comment about the code, like how it could be better, and what could be a problem?
// When using already-defined-method is allowed
static String reverseStringByChar1(String str) {
return str == null ? null : new StringBuilder(str).reverse().toStr... |
I'm trying to generate a bunch of uniformly distributed unit vectors around the unit circle. Here's my code, which is working, but unfortunately I have a for-loop. How do I get rid of this for-loop?
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
def gen_rand_vecs(dims, number):
vecs = ... |
My problem is that I have a sequence, potentially infinite, of strings. Let's suppose it to be
{"Mickey Mouse", "Bugs Bunny", "Winnie the Pooh"}
I have to make an exthension-method Initials that returns a sequence of their capital letters in uppercase, so in this case, doing:
var names = new string [] {"Mickey Mouse... |
I'm not normally a C programmer but thought I'd take a shot at making something useful. This is a C utility I wrote to judge how similar several files are using the algorithm I think diff traditionally uses. I'm interested in general feedback. I don't write C usually but I do read it from time to time to try and pick u... |
I need to read an archive file format which stores filenames as 8 characters for the name (null-terminated if less than 8 characters, not otherwise), immediately followed by 3 characters for the extension (i.e. without a dot). So basically, I need to read the components and add a dot between the name and extension (nam... |
I'm trying to parse an estimated travel duration and distance between two waypoints using Google Directions API. Tap on this to see an example of data received.
private class func parseTravelData(
data: AnyObject!,
mode: ESTMode,
completion: (NSDictionary?) -> Void) {
var receivedData = data as? NSD... |
I have written a Sudoku solver, for the euler problem and also packaged it into a ruby gem. In my solution strategies I do a lot of iteration (double/triple nested loops, I am coming from Java/C). One method in particular has a lot of if checks and iteration. Would it be better to package this iteration into an enum... |
I have written a type with the following public API:
public sealed class InitializationGuard
{
public bool IsUninitialized
{
get;
}
public bool IsInitializing
{
get;
}
public bool IsInitialized
{
get;
}
public InitializationTransaction BeginInitializati... |
I'm a student and still studying. I just made my own Pastebin tool to generate source code. I've also contributed this project as an open source. You could see this project from here.
If you wish to see the demo, you could visit here.
Now after this, I've made this project using JSP and servlet. Actually, when the user... |
I'm trying to implement Knuth's Five-guess Mastermind algorithm in my own version of Mastermind, but when running step 6 it takes my code hours to actually run through everything to get the neccesary information. I was wondering if any of you would know a better way to obtain the same results?
Here is my code with rele... |
I'm an experienced programmer trying to learn OCaml. I figured a good way to do that would be to pick a simple task on Rosetta code that didn't yet have an OCaml example and do it myself. With that in mind, I wrote this program to find the last sunday of each month in a given year. It works by using Gauss's algorithm t... |
Is there a better way to implement bootstrap tabs routing with SammyJS besides this?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="lib/bootstrap.min.css" rel="stylesheet" />
<script src="lib/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="lib/bootstrap... |
I am doing a background image animation using the function. It works, but I think I am doing more coding than what it requires. Can anyone please help me to minimize it?
Don't recommend the CSS animations, I am working for IE9.
Live
var call = function () {
var x = 0;
return function () {
x++;
x... |
Is this merge sort following good coding standards? What are some improvements I can make to make it cleaner?
public final class MergeSort {
private MergeSort() {
// prevent instantiation
}
private static Object[] temp;
public static <T extends Comparable<? super T>> void sort(List<T> arra... |
With native JavaScript, I intend to traverse a collection of elements in the DOM that contain a link and an image (and possibly other elements). The image may or may not be inside the link—in most cases the image will be in the link, but in some cases it may be directly adjacent to the link, or it may be a child of ano... |
Here is my C solution for Sherlock and Queries @ Hackerrank.
Watson gives to Sherlock an array: \$A_1, A_2, ..., A_N\$. He also gives to
Sherlock two other arrays: \$B_1, B_2, ..., B_M\$ and \$C_1, C_2, ..., C_M\$.
Then Watson asks Sherlock to perform the following program:
for i = 1 to M do
for j = 1 to N do
... |
I want to use dependency injection with Unity in my application. I am not following repository pattern and unit-of-work (and don't want to). I also have ViewModel in my controller action method. Please review my code and add your comments.
public class ProductCatagoryController : Controller
{
private dataBaseContex... |
I would like comments on my implementation of a stack:
template <class T>
class Stack {
public:
void pop(T& element);
void push(const T& element);
Stack();
private:
int elementCount_;
int stackTop_;
static const int MAX_ELEMS = 10;
T elementArray_[MAX_ELEMS];
};
template <c... |
I have a scenario where my BaseRepository gets a lot of commands in a short time period. At other moments, this doesn't happen. What I want to achieve is to throttle these commands. I.e., when a command must be executed, wait for a short period (0.2s) for any other calls. If none are made, execute the command (go to th... |
I have written a Tic Tac Toe application with the focus of clear design and easy to read code.
The current algorithms are very crude. I also want to separate them using interfaces. Any tips on improving the design, and making the code cleaner, change variable names?
TicTacToe.java
package tictactoe;
public class TicTa... |
Ruby doesn't have a pass method to 'do nothing' the way Python does - if I want a ternary statement to do something on true, but nothing on false (as in the code below). Is it bad practice in Ruby to fake it this way?
beverage_links = []
beverage_info.each do |bvg|
self.is_menu_item?(bvg) ? beverage_links << bvg["h... |
As part of some code I've written, I needed to perform a 1-D convolution. This convolution ends up happening quite often, so I wanted to optimise it (in some way other than using a FFT, though I could do this if necessary). I expect that my convolution kernels will be ~100, and the vector they are convolved with ~5k.
m... |
A program that creates a grid 10x10 and assigns a random number in each tile. It then asks you if you want to:
create a new grid
view the current one
count how many of each number there are in the grid
sum the rows
sum the columns
exit the program
import java.util.Arrays;
import java.util.Random;
import java.util.Sca... |
I need an implementation of PBKDF2 in C#. There is already a class Rfc2898DeriveBytes, but it uses SHA1, and I need SHA512. The problem that I faced with during implementation is intensive allocation of memory after each hash computing iteration. The proposed solution is to change a little bit SHA512Managed class imple... |
I just recently made an attempt at implementing what I have been led to understand is called a RoundStack, simply meaning contrary to .NET Stack's default behavior of doubling internal array size when it hits capacity, simply starts dropping off items at the bottom of the stack. I am developing this class for the purpo... |
I'm trying to grasp this whole MVC design pattern idea but I'm in the dark if I'm doing it correct. This is where I need some feedback on what I've done so far. Here's what I'm wondering:
Does the hideMenu and showMenu fall under the view or controller?
Have I put viewNewPage in the correct block?
How can I make the a... |
This is "my" version of a basic C++ calculator, that requires a single line input (like 1+1) to calculate the result. I have been (self)learning the language for 2 months now. I don't pretend to have invented this code, but I haven't taken the time to search for this variation.
The functions included are:
Addition: 1 ... |
I was wondering if such a design was a bad idea in C#. Here I have a static class EventLog which holds a list of instances of Event class. This is a simple event log of actions players can do in a game. What can I be doing in a better way?
public class EventLog
{
private const int maxEventsInLog = 50;
private s... |
Original post:
Tic Tac Toe game with emphasis on design and readability
I got great help, but I feel like I have to ask how I can keep the GUI and logic loosely coupled. Is there any best practice that I should follow?
I tried to pass MainFrame object to Games constructor instead, but then I had to redesign MainFrame ... |
I made a Python 3(.4.2) program that only adds classes and is meant to be imported. It allows the creation of files that store usernames and hashed passwords. It uses salting as well. It also can easily check if any given string is the original password (through the User.check() attribute of the User class.)
"""A simpl... |
This is what my class hierarchy looks like. I have an abstract superclass, AbstractLinkedMyList, that contains common operations for both sorted and unsorted linked list.
Here's the declaration for it and the method I have a question about:
public abstract class AbstractLinkedMyList<Type> implements MyList<Type> {
... |
I am trying to reverse a sentence contained in a string and return a string in the quickest way possible using the least amount of memory. Also I don't want to use any unsafe code, so no pointers are allowed. Please let me know if anything can be improved.
My input example is
string mystring = "Hello! my name is";
... |
I have made a merge sort algorithm but am unsure of the 'Space Usage' of the algorithm.
public class Sorting {
public static void mergeSort(int[] arr) {
if (arr.length == 1) {
return;
}
int[] newArrLeft = new int[arr.length / 2];
int[] newArrRight = new int[arr.length - ... |
Challenge: Design a cash register program
Specifications: Your register currently has the following bills/coins within it:
'PENNY': .01,
'NICKEL': .05,
'DIME': .10,
'QUARTER': .25,
'HALF DOLLAR': .50,
'ONE': 1.00,
'TWO': 2.00,
'FIVE': 5.00,
'TEN': 10.00,
'TWENTY': 20.00,
'FIFTY': 50.00,
'ONE HUNDRED': 100.00
Your progr... |
For a game implementation, I have a very large overview map with multiple layers (namely base-map / units / highlight & info / fov-shading) of which the first is CPU-intensive to generate. I have implemented a caching mechanism in which the base layer is drawn once and held in system memory, then drawn on demand by th... |
I'm creating an event loop for an asynchronous event execution library for PHP in PHP. Note that this is for a library and not an application. My event loop is just that -- a simple event loop that doesn't know how to poll / wait for anything specific. It just executes callbacks in order.
Events being waited for are ab... |
I updated my code based on the feedback from my previous question. There is one for the home page and one for the product pages:
Home page code:
<div itemscope itemtype="http://schema.org/TravelAgency">
<span itemprop="name">NAME OF TRAVEL AGENCY</span>
<link itemprop="url" href="HOME PAGE URL">
<span itemprop="descrip... |
I came across this blog post by Adam Drake from around a year ago which is now making the rounds again.
I made some improvements to his code, but wish to see if there are additional tweaks that could be made to make it run even faster.
The task is to extract chess game results from PGN files. The files contain sequenc... |
I want to use the variables that have been declared in a config.php file in a class for testing. I am not sure if this is the right way like I have done it.
I have a configuration file, config.php:
class Config {
public $hosts = array(
'a' => '192.168.1.10'
'b' => '192.168.1.11',
);
public... |
The method creates a link, an edge between two nodes, and calculates the Euclidean distance.
I'm testing that after linking, the link does indeed exist, and that the distance is correct.
I've used a variety of test cases, to check that it works for both horizontal and vertical links (just incase there's a divide by ze... |
Word Ladder
Given a start word and a goal word, convert the start word to the goal word by changing one letter at a time. Each step must also be a valid word.
Is my code modular? I mean are functions are concise, class design etc.? Could someone please review the code and let me know if code is good and if it has so... |
In our application the views and the viewmodels are created in parallel to increase the performance and when the viewmodel is created it is attached to the datacontext.
While there is no datacontext the view shows an indefinite progressbar. To hide it we use the following code:
<!-- Loading background. It gets remo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.