instruction stringlengths 71 71.9k |
|---|
I'm developing an Android application which would remotely connect to an insurance database and perform some basic CRUD operations and I'd like to learn how to keep clean app's architecture from Fernando Cejas' and Uncle Bob's blog entries. Presented below domain layer contains entities and use cases which I don't want... |
This program is eventually going to be a screen recorder, but right now I just want it to capture screen images.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Syste... |
I wrote a transition table which allows the client to:
Create States
Create a TransitionTable or some kind of StateManager
Create StateNodes using that table
A StateNode is what I use to link one state to other states. It has the mainState and an ArrayList<State> full of states it can jump to.
After creating nodes, t... |
I have to do multiplication of two billion by billion sparse matrices (on a CPU), hence any help or hints in optimizing the below given code would be extremely useful.
Note: I am only showing the code to compute number of non-zeros in the output matrix. Buffer based adjustment of memory is not an option for such a larg... |
Input: String : Title; List Tags
Problem statement:
Need to map title to tags, e.g. title is "china man japan beijing bell" and tags are ["china man" "beijing bell"], output should be ["china man" "japan" "beijing bell"]
What I am doing:
List<String> getTitleSplits(String title, List<String> tags) {
List<S... |
I recently applied for a job where the company gave me the following prompt for a code challenge. They have since told me "yeah, no thanks" but provided me with no feedback about why they came to that decision.
Would you be so kind as to review my code? You can even be harsh. I'd just like to know what this program is ... |
I'd like to know if there is a standard way of creating a matrix like the one shown below using the R programming language.
$$
\begin{bmatrix}
1 & \rho & \rho^2 & \cdots & \rho^{T-1}\\
\rho & 1 & \rho & \cdots & \rho^{T-2}\\
\rho^2 & \rho & 1 & \cdots & \rho^{T-3}\\
\vdots &\vd... |
I'm new to GNU Smalltalk. I'd like to port a script I've written in Ruby, Scala, CoffeeScript, and several others. It's the one I use to try to learn the classic OOP concepts of abstract classes, abstract methods, overriding, dispatch, etc. It goes like this:
Define an abstract class Animal with a constructor to set t... |
I wrote simple jQuery code and I want suggestions as to how I can do it better and shorter.
Basically the following code is used to change the menu icon on each click event and also hide and display menu accordingly. If I did it correctly, then fine, but is there any way to make the code shorter and faster?
if ( $('.si... |
The PHPSESSID is stored in the clients cookie so I don't consider it as secure. Someone might bruteforce it and perform some action (like a Facebook status post) whenever a session was successfully hijacked.
I was wondering how I can protect against attacks like that. Maybe by locking out suspect users? My solution I c... |
I have a search box for searching for people in a list of names.
Here is the code that runs every time the query changes. I could not find anything open-sourced for this, so I wanted to make sure this looks good and efficient.
How does it look?
private final List<String> mTotalNames = ............ // some ArrayList<St... |
Today I wrote a JavaScript module (with module pattern) which generate gradient texts using canvas tags. This is my first JavaScript "program" (I don't know how to call it) created for a real need.
I would like to receive opinions about:
The performance factor: Is creating canvas slow? Or is it acceptable?
The maintai... |
Over the course of the past month I've worked on a little visualizer to show how different algorithms are sorted. I'm pretty happy with how it turned out but would be interested in any feedback pertaining to the design of it or the coding.
I'm still a bit of a novice to Swing, so I'd love some feedback on my usage:
pub... |
Find the last element of a list from codewars.com
Example:
last( [1,2,3,4] ) # => 4
last( "xyz" ) # => z
last( 1,2,3,4 ) # => 4
I completed this kata several times tonight. My current answer is a mashup of several other people's solutions.
I do not understand why I cant change .respond_to?(:index) into .is_a? A... |
I am creating styles for the comment posts for a projects using BootStrap. I am wondering if this is good HTML markup and the extending of BootStrap's CSS.
Using HTML5 markup recommendations the HTML for the comment posts is as follows.
<div class="container">
<div class="row">
<div class="col-md-8">
<h2 class="... |
I'm somewhat new to SQL (only had to use it in Database classes). I have a simple table of stylesheets, from which I want to select specific ones in a specific order (e.g. reset, then layout, then colors). Below is an example selector that my current algorithm might generate. Is there a better (more efficient or more i... |
I am working with very large datasets in a distributed environment. In particular, I am writing some code in Python for analyzing web logs in Spark. Because of the nature of Map-Reduce computing and the size of the logs I am working with, I would like to restrict the amount of data being passed around as much as possib... |
This code is used to get the users location and deliver it as a resource to the controller. The aim is to have this data shared across multiple controllers in the application. So far this does deliver the data as a parameter of the then() method on the promise. Is this pattern a suitable way of sharing a resource whic... |
This isn't too complicated but I usually code in C++ instead of C. Doing memory management and IO in C always makes me feel like I'm doing everything wrong and making a mess. This is a small sample that has both which I think came out reasonable. I don't have C people to talk to so any critiques are welcome.
The goal h... |
This piece of code is working - It gives me a lot of JSON back, which I have yet to parse, but I'd like to show my code here first to get tips on how to improve what I already have:
VenueService.swift
class VenueService {
private let __kVenueServiceClientID = "CLIENT_ID"
private let __kVenueServiceClientSe... |
I have modified my code as per the suggestion given by some of the developers. Let me know if there are any further concerns or scope for improvements.
Original Version
#include"iostream"
template <class T>
class Mystack
{
private:
T *input;
int top;
int capacity;
public:
Mystack();
~Mystack();
... |
Is there a better way, or the correct one to have this approach for a JSON object that hast the following structure? (it's only a portion of my object, the most important one)
{
"Questions": [
{
"AnswerType": "single-choice",
"Answers": [
{
"Answer... |
I have serious problem with my Hexadoku (16 x 16 , a - p) solver. I'd like to run the program in under 2 seconds but my solution solves it in 10 seconds.
Native Code:
#include <stdio.h>
#include <stdio.h>
int isfree(int hexadoku[][16], int radek, int sloupec, int num)
{
int rowStart = (radek/4) * 4;
int colStart =... |
I am fairly new to Assembly language programming and, for practice, I gave myself a problem: count down from 10 and right after 1, say "Blast off!".
section .text
global _start
_start:
mov eax, '10' ; asci 10
mov [num], eax ; num now equals ascii 10
mov edx, 2
mov ecx, num
mov ebx, 1
mov ea... |
In my college Java course, I wrote an ASCII Turtle Graphics. My professor said the only thing he could suggest was to turn the turtle into a class and create an instance of it (I hadn't because we hadn't covered classes yet). What do you think?
package javaapplication74;
import java.util.Scanner;
import static java.... |
This takes a collection of Objects from JavaScript and puts them into a Java project. How can I improve this code? What's the best solution?
// JavaScript fetch data into List ChartData
int i = 0;
int k = 0;
// output
for (Object currObj : ChartData) {
// get all fields of Object
for (Field field : currObj.g... |
I haven't used Python in a number of years, but recently started working on a project called Photoshell which is written in Python 3.
As I attempted to learn the "Pythonic way", I wrote a parser for Canon's CR2 raw image file format. I'm not sure how "pythonic" the parser is, so I'd love to get some feedback on how it ... |
This is a question from a phone interview I had.
The question was in 2 parts:
a. find("cat") -> T/F suggest a data structure to find is if a word
exists in a large dictionary, how will one node of that data structure
will look like?
b. Implement a bool Find(string str) function which returns true or
false if the... |
private static int Sum (int[] a, int from, int to){
int total=0;
for (int i=from; i <= to; i++)
res += a[i];
return total;
}
public static int Method3 (int []a){
int temp=0;
for (int i=0; i <= a.length; i++)
{
for (int j=0; j <= a.length; j++)
{
int c = Sum(a,i,j)... |
My code is very very slow. Could you give me hints on how I can make it much faster?
for (stdext::hash_map<unsigned __int32, CVertex*>::iterator it1 = graph.begin(); it1 != graph.end(); it1++)
{
for (std::vector<CVertex*>::iterator it2 = it1->second->getNeighbors().begin(); it2 != it1->second->getNeighbors().end();... |
I wrote a Python script to collect a list of directories containing third party libraries and submit them all to dependency-check, a program that compares library versions to known-vulnerable third party libraries. This code works correctly and I'm after feedback about Python programming, especially my testing methods.... |
This question suggests a different (improved?) implementation for searching/filtering names based on a search query. This is based on the question here: Name filtering in Java
A Trie allows the prefix of terms to be used as a search mechanism. The Trie requires pre-processing the data in to a data structure that has ve... |
I literally spend all day working on PHP and I think I figured it out, but I need some reviews in order to make my code secure & okay. I am asking you about functionality here. The code below works.
index.php
<form action="upload.php" method="post" enctype="multipart/form-data">
<div id="file_container">
<i... |
I implemented sequenceA:
sequenceA :: Applicative f => [f a] -> f [a]
sequenceA [] = pure []
sequenceA (x:xs) = (++) <$> (fmap (\y -> [y]) x) <*> sequenceA xs
I don't like the fact that I'm making a new list, and then concatenating the result via ++.
However, I'm not sure how to make use of cons, i.e. :, in this f... |
I have constructed an API service that dives into a storage engine and retrieve data.
I have tried my best to apply the MVC modelling with services (repository) in mind where the controller (as it should) is just the data direction (input goes in and it redirects the output with the Repo in the middle doing all the hea... |
Here's some code I wrote quickly to get a nice millisecond countdown going. It displays the number of milliseconds until the new year in whatever timezone is next to be in 2015 are in in huge font, and spits out the timezone in small reasonable font below.
<!DOCTYPE html>
<html>
<head>
<title>Newyear Coun... |
I made this piece of code to detect inactivity on different aspects of my app. It is part of a set of pieces to analyze user behavior.
Not saying it's ugly, but good looking constructive criticism to help me improve my code and could be useful to me for other similar components.
function InactivityTimeout(idle_time, ... |
I am an absolute beginner to programming and am learning it using C. I have just learned function pointers and tried to implement a quicksort function using function pointers to determine the nature of sorting.
//Program implementing a quick-sort function using Hoare method
//to partition using a random pivot.
//Funct... |
The goal of my current piece of work is to read from a global config file all the settings and then from the local file only those settings that a user has chosen.
Firstly I wrote a function but then I needed a class. It's my first working class in Python, and I ask if you can kindly note its defects. Although it works... |
I have five groups in Group table as Group1, Group2, Group3, Group4, Group5 and whenever a new role added into Role table I have to make an entry into GROUP_ROLES table as below:
declare @gid1 int, @gid2 int,@gid3 int,@gid4 int,@gid5 int,@rid int
select @gid1 = id from Group where name = 'Group1'
select @gid2 = id from... |
I am coding a 2D board game. I let the user choose the difficulty level in the beginning, which influences the skills points of the player.
Here is the code I wrote for the Player class:
package model;
public class Player {
// VARIABLES ---------------------------
private Position position;
private int ... |
I want to backup my GitHub repositories since there is news about blocking GitHub in India. I wrote Python code to automate this and would like for it to be reviewed.
import os
import requests
API_TOKEN='xxxxx'
#from https://github.com/settings/applications
api_repo='https://api.github.com/user/repos'
url = '%s?acce... |
I wrote a simple sound player to use as part of my MorseString class. I am new to using sounds (in fact, I was helped a lot by Google) and I don't know if this is the correct way to play a sound.
The method takes a specific frequency and a duration as parameters, and plays the frequency for the specified duration.
pri... |
What would be the preferred method for handling errors when using the PDO to connect to a MySQL database? I was using mysqli_error($this->pdo), but I heard this was bad practice. Any feedback would be much appreciated.
class Database
{
/*
* Database properties
*/
private $server = 'localhost';
p... |
Note: A run is a series of adjacent chars that are the same.
I just want to answer a few questions:
Is this readable?
Does it need commenting or is it self-descriptive enough?
Are there any efficiency tweaks this could have?
Is this a good way to test?
Which is the preferred/conventional syntax?
int maxCheck = 0,
... |
I'm very new to AngularJS. I'm using a directive for translation of category objects like:
{
"id":17,
"order":2,
"published":false,
"createdAt":"2014-12-29T16:22:43.000Z",
"updatedAt":"2014-12-29T16:23:22.000Z",
"CategoryTranslations":[
{
"id":13,
"name":"Fishes",
"description":"Fishes desc",
... |
The purpose of this code is to find a password with brute force cracking where as it will try all the possible combinations until it finds the correct password. For example, it will start like a then b then c . . . ab . . . cz . . . dd and so on until it finds the correct password. All of it works, but the performance ... |
I'm new to JS and jQuery. I wrote this function which just does what I want, but it seems very unreadable, and because of my experience, I don't know a better way to handle it.
Could you please give advise me how to refactor it?
function new_section(id, name, order) {
return $('<tbody>')
.attr('id', 'secti... |
I am trying to simulate a window system with java. I don't know much about Java graphic-APIs, so i began with AWT (I am using Graphics2D here, so far I don't need it, but I think it will come in handy at some point). So far I just have two functions: Each window can draw its own individual content and windows are put o... |
I got a proposed exercise from a Java2 book. This one wants me to find out the numeric centers.
A numeric center splits two list of numbers that make the same result when you add the numbers in each list. For example, 6 is the first numeric center because 1+2+3+4+5=15 and 7+8=15 too. The second numeric center is 35 bec... |
Is this Test Case overkill?
I am new to Unit Testing so I am learning and I'd love to hear your opinion about it.
use Application\Tests\TestCase as TestCase;
class RoutesSubmissionsTest extends TestCase {
public function setUp()
{
parent::setUp();
$this->app['router']->enableFilters();
}
... |
Problem:
Given 2 strings, consider all the substrings within them
of length len. Len will be 1 or more.
Returns true if there are any such substrings which appear in both strings.
Compute this in linear time using a HashSet.
Solution:
import java.util.HashSet;
public class Standford3 {
public static void... |
I have a Windows-Runtime app (very similar to WPF), and I am using (at least I think I am!) the MVVM style. I want to make sure I am doing this the proper way, and not just a working way.
This is my MainPage.xaml:
<Grid Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" x:Name="Item... |
First time writing a big project in OOP. I am quite used to scientific programming but not to OOP, and even less to building GUIs. I am writing a 2D board game: the player can move on a map from tile to tile, meet Helpers and Enemies, and win a Trophy in the end.
I used the MVC pattern and the Model parts consist of t... |
I'm new to Angular and I would like some advice on how I can improve my code. The main things that I want to focus on are decoupling and code correctness.
HTML:
<body ng-controller="myController as myCtrl">
<fieldset>
Select movie to display:
<button ng-click="myCtrl.change('mortalkombat')">Mortal Kombat</but... |
I'm learning Swift and would appreciate any code review suggestions (the more nit-picky, the better). In particular, I'm wondering if there's a more efficient way to format the time in the timeToString function I wrote, since I'm repeating myself three times.
import UIKit
import Foundation
class ViewController: UIV... |
public class WmSync : IDisposable
{
public WmSync()
{
var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync;
Thread.MemoryBarrier();
}
public void Dispose()
{
_sync.Dispose();
}
public void BeginInvoke(Action a... |
I have studied the strategy pattern and understood it w.r.t the example given in the PDF that I referred. I wanted to make sure that my understanding is correct, so I have written a simple program in C++ and designed the strategy pattern using the family and vehicles as the subject. Please provide corrections/suggestio... |
I attempted a solution to a seemingly simple problem:
Peak Finder
Let input be a list. input[i] is a peak if input[i] > input[i + 1] and input[i] > input[i - 1].
Implement a recursive algorithm of time complexity \$O(\log n)\$ to find a peak if it exists.
def peakFinder(input):
n = len(input)
middleIn... |
This prints out the sum of the numbers that have same remainder and quotient according to the input number. It's an online judge problem, and it currently throws a time-out since it's taking too long. Yes, the number being divided could be any positive integer.
Are there any suggestions on speeding up this code? And ar... |
I'm writing this app that's based in the terminal, and of course there's a lot of input involved, especially numerical input. I've decided to use the method of reading an entire line of input and converting into a number and displaying an error message if the input is out of bounds or just straight-up invalid. This hap... |
I am using PDO prepared statements to store user entered input and store that input to the database. The code will store a text input and 5 uploaded images.
Will this code protect from data SQL injection and XSS attack? Will it be secure? If not, what are some things I should make secure?
<?php
$db_username = 's... |
I just finished Project Euler #12 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
The sequence of triangle numbers is generated by adding the natural
numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7
= 28. ... |
My method takes a long time to respond, so I'd like to make this method more efficient. I'd also like this method made with joins.
def all_shows_with_videos
@arr = []
tvs = Tv.all
tvs.each do |tv|
tv_tmp = {:name => tv.name, :id => tv.id}
tv_tmp[:videos] = tv.videos
tv_tmp[:seasons] = []
... |
I needed a way to cache a large number of objects with two different types of keys.
In my case:
A String key represents my object in a serialized form. This way if I get the same serialized object from an outside source, I an easily determine if it already exist and avoid re-parsing it (I just re-put() the existing en... |
I wrote a Tamagotchi-like game where to feed the pet, you do math questions instead of just pressing a button. It's persistent, in that on loading, it figures out long it's been since the last save, and "simulates" the elapsed time. Hunger increases over time, and either causes the pet to heal, or become hurt, dependin... |
I posted another snippet of code a few weeks back when I started learning C++. Here's my second try now that I have some time to play with this again. The goal is to write a generic algorithm for reversing the "words" of a container with a bidirectional iterator. Separators of words are any values that a functor parame... |
This is a Markov text generator I've created in JavaScript. I'm pretty sure the term "Markov" applies, anyway.
The way the generator works is like this: it first divides the source text into unique "chunks" of length n (specified via the order parameter, greater = more coherent result), and, for each chunk, determines ... |
I made a quicksort implementation based on this code. Please review my C++ version.
template<typename I>
I partition(I low, I high) {
auto p = *low;
I i = low, j = high+1;
while (true) {
while (*(++i) < p) { }
while (p < *(--j)) { }
if (i >= j) {
break;
}
... |
This is based on a library called Consoledefender V 3.3.
I made a minimal class for personal usage based on this library by using C++11. It actually takes user input and prints it back on the console screen and acts like an echo. I would like this class reviewed.
Console.h
#include <windows.h>
#include <conio.h>
#inclu... |
I have made this little program for fun, to add on my personal webpage. I remember seeing something like it some time ago, don't remember exactly where, and I tried to reproduce it myself.
As it turns out, I figured out that it isn't quite fun to have your CPU stressed out by 25% because of a funny single homepage, so... |
There isn't a very reliable way (in my opinion) to get the mime type of a specific extension, regardless of the file actually being of that type or not.
This type of thing usually is used when sending a different Content-type when you intend to send, for example, an image.
class MIMETypes {
/**
* @var string ... |
I have a service that monitors failure and success directories for files that are generated by an engineering program. I want to check the change was in the success or failure folder, and if it was a new file creation. When those criteria are met I need to check if the file type matches one of the keys for a dictionary... |
I'm using HMSegmentedControl, an open-source UISegmentedControl subclass. I'm trying to react to the user tapping on the currently selected segment. HMSegmentedControl only supports reacting to a segment CHANGE, with either UIControlEventValueChanged or a block that executes when the index is changed. I need to react t... |
A discussion in The 2nd Monitor made me realize I had never 'solved' the N-Queens problem. Additionally, as I read up on it, I realized that the 64-squares in a chess board would work well if represented as bits in a 64-bit long.... That was a nice thought, but it became complicated, and really, 8-size chess boards are... |
In interrupted bubble sort, we need to stop the sorting based on the iteration count. This seems pretty straightforward to me. I have this code, which seems to work fine, but it isn't fast enough for larger input sets. How can I make this faster?
s = '36 47 78 28 20 79 87 16 8 45 72 69 81 66 60 8 3 86 90 90 | 2'
ls = s... |
In Groovy 1.8.6 I need to move a line just before another one. I'm interested in any improvements.
fileToChange = new File('.classpath')
linesToKeep = []
fileToChange.eachLine {
if (it.contains('line to move')) {
lineToMove = it
} else {
linesToKeep.add(it)
}
}
fileToChange.withWriter { out ... |
The following class (that was my first class ever in python) was used in an eye tracking context. Imagine a context where you always will have a single gaze-point and some closed contours. How can I return all possible relations between them?
For example, for two contours, the point can be:
Relation 1: inside contour ... |
As an exercise I have written a basic binary tree implementation in Go.
Tree struct:
type Tree struct {
Key *int
Value interface{}
Left *Tree
Right *Tree
}
func New() *Tree {
return &Tree{}
}
It a annoys me a bit, that Key is a pointer, but this is needed at the moment, because I use nil as an ... |
In a few months I'll work on a C++ project that could span a year or two. I've a strong C background and for the usual reasons I always chose C over C++ (please forgive me). To extend my capabilities and to move from C to some more powerful language, I felt the time has come to take a serious step towards C++. In order... |
As noted below, this is more or less a direct translation from http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#C. I'm fairly satisfied with its readability right now compared to the C code; but still wondering how to make it more succinct and clear. Any ideas/opinions?
{-
In-place quicksort algorithm.
Adapted ... |
Continuation of Correct MVVM format. This is what I have done so far, and of course it works:
To start with, this is my MainPage.xaml:
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="100" x:Name="TitleRow"/>
<RowDefinition Height="*" x:Name="DataRow"/>
</Grid.RowDefinitio... |
A while ago, I was working on a chess project with a couple other people. In the end, I wrote all but a couple of the lines of code, including these:
class Piece(list):
def IsValidMovePattern(self, FromCoord, ToCoord):
print(self, "Validation not done")
return False
class King(Piece):
def I... |
I needed a priority queue that allowed efficient searching and changing of keys. I tried std::priority_queue, but the interface was extremely limiting. Not being able to search for existence wasn't a big deal since I could separately keep a std::unordered_set<key_type> around, but not being able to modify key value was... |
I have asked a previous question but at the last moment I realized that the code does not work as intended as it has some small bugs.
I got some ideas for improvement though, but they didn't seem to work as well, so I decided to re-write it. This time, I was following the logic all the time.
char *tbl_getline (char *so... |
I've created a console server which is supposed to update 30 times per second, I'd like you to review it and also I'm curious about the accuracy of the server's loop.
using System;
using System.Diagnostics;
using System.Threading;
namespace ZGServer
{
class Program
{
//------------------Variables------... |
I just finished Project Euler #13 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
Work out the first ten digits of the sum of the following one-hundred
50-digit numbers.
37107287533902102798797998220837590246510135740250
463769... |
This is a follow-up to
Quicksort function
Like the previous code, this does not optimize for containers with large numbers of duplicate elements. How can I improve this code, particularly with iterators?
template<typename C>
void insertion_sort(C low, C high) {
for (auto i = low; i < high; ++i) {
for (auto... |
The following code will generate a number plate and then generate a random speed and see if it's speeding
import random, string, time
class Car:
def __init__(self):
self.plate = self.genPlate()
self.limit = 60
self.checkSpeeding()
def checkSpeeding(self):
self.speeding = random... |
I've worked with PHP for a few years now and have a degree of understanding about classes / objects, but I've never written my own until now.
In that vein then, I'm looking for a bit of confirmation of the code below and that I am doing things properly before I go any further. Any advice / critique is greatly appreciat... |
I am building a small DSL for iOS' autolayout feature. Obviously I want to have a typesafe way to define autolayouts instead of doing VSL. I came up with the following:
//in reality this will be a Xamarin/iOS View
type View =
| View
type Constraint =
| Max of int
| Min of int
| Eq of int
| B... |
I have recently written this little Bulls and Cows game in Python:
"""Play Bulls and Cows."""
import random
NUM_DIGITS = 5
class IllegalNumber(Exception):
"""An exception to raise when the class Num has an instance of an
illegal number."""
pass
class Num(object):
"""Represent a number that consists of... |
Below is a piece of code which takes a list of IPs, pings the hosts and returns (prints) the list for "Alive" and "Dead". Any feedback on what can be done better is welcomed, mainly, speed and reliability! Would you accept it as production code? What about try/except blocks and logging?
import subprocess
from multiproc... |
Outside of the jQuery DSL I've hardly ever written any JavaScript. I never bothered learning JavaScript until a couple of months ago. After a slow start I got stuck in and created this game today.
I usually program in Ruby, and this is proving to be an obstacle because I'm thinking in ruby while writing JS.
The code ma... |
The task is to select all posts tagged with a certain tag, along with other tags the post may have, given as text rather than ID.
Table posts
CREATE TABLE `posts` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`text` text NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyIS... |
First of all, I'm new to Lisp (I currently use CLISP and SBCL). There probably are huge mistakes in this code so any guidelines are welcome :)
I'm very confused about how to do this. It's just about a habit and I don't want my actual help to implement an algorithm, as the one I came up with is not the best one.
Is it o... |
When someone suggested that I solve Knight's Tour, I did so with heuristics and recursion.
It takes a lot of time to solve even a 8x8 board:
N-A1
N-C2
N-E1
...
N-E6
N-F4
Time used to solve: 5417011 nanoseconds
That seems quite a lot, but the most interesting part of my algorith is that it takes only six times the tim... |
I'm still very much a beginner, so I don't really know much about best practices or the speed of any particular C functions.
You'll notice that I included a "cs50" library. This is from a MOOC I'm taking, all it does in this program is allow me to use their "bool" data type. I realize I don't need to delegate all of th... |
I'm working on a game with Slick2D and am just working through the Entity class. I'm making every variable protected and then accessing them with getters and setters. Yet it feels like I'm over-complicating things and it is more efficient to simply let some of these properties be public.
public abstract class Entity {
... |
Here is a group of questions (hidden by default except the first one) with yes|no buttons
<div id="email" class="form-item">
<h2>Q with 1 more option?</h2>
<input type="button" value="true" data-value="web" />
<input type="button" value="no" />
</div>
<div id="web" class="form-item">
<h2>Q with ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.