instruction stringlengths 71 71.9k |
|---|
I just finished creating a fancy checkbox and am hoping for some tips to help improve my code, as I am still learning.
$(document).ready(function(){
function checkbox(){
var y = $("#yon");
var n = $("#non");
var cx = $("#chex")
var cbx = $("#checkbox");
var chval = false;
$(".cspan").click(f... |
I'm working on an experiment to parse speech out of an emote in a text roleplaying game (MUD) so that if you can't hear it correctly, or if it's in a different language, you won't understand it. This works correctly, but I was just wanting to make sure it was as clear and efficient as possible.
import java.util.Scanner... |
I am writing Rijndael for academic purpose, following wikipedia's description.
https://en.wikipedia.org/wiki/Rijndael_key_schedule
I would like to know, if up to this point it is correct, both from pragmatic programmer and strict cryptographer views.
class KeyExpander
{
private static final int COLUMN_SIZE = 4
... |
The input is read in line by line from stdin.
Input Format
The first line contains an integer, T, denoting the number of test
cases. The subsequent lines describe T test cases, and the input for
each test case is as follows:
The first line contains an integer, N, the number of (x,y) pairs in
the test case. The ... |
I would like to get some advice on WAI-ARIA markup I have added to my paginated post navigation.
Does this look correct, am I missing anything?
Should anything be added/removed to the current page link (#2)?
Also, curious on my "Page Count" and "View All" sections what if anything can be added to make it more ARIA-fr... |
Sometimes we need to map a .NET type to some custom nice looking text and resolve it back to the type latter. We could use it while implementing polymorphic behaviors in JSON API, or persisting/rehydrating class hierarchy.
Sometimes we need something more complex than 1:1 mapping. Let's say that we backed up part of ou... |
I'm working on writing tests for a rails application using cucumber and capybara. I have a scenario for a user editing a post, and making it invalid.
The scenario looks like this:
Scenario: I edit a post and make the data invalid.
Given I have 1 post
And I view my 1st post
Then I click "Edit"
And I fill in the ... |
I'm writing a Direct2D game in c++ / WinAPI. I need to render things 60 times every a second using fixed time step.
__int64 time_before = 0;
__int64 time_now;
__int64 frequency;
__int64 time_elapsed;
double frameTime;
if (QueryPerformanceFrequency((LARGE_INTEGER*)&frequency)) {
frameTime = (double)frequency / 60;
... |
I have made my first game in Python.
My program can determine when there is a winner, however I am unsure what to do if the board is full and there is NO winner (a cats game).
import cTurtle
import random
import sys
def DrawTicTacToeBoard(t):
#Vertical Lines of board
t.pensize(3)
t.up()
t.goto(.5,-.5)
... |
I am solving a coding challenge whose objective is to print the right diagonal of a matrix. And below is my code to do that.
package basics;
import java.util.*;
/**
Problem statement : Print right diagonal of a matrix. Example: For input : a b, c d ; the right diagonal is b c
**/
public class PrintRightDiagonal{
p... |
I am writing a Tetris program in C# for programming practice, and I've got it working. This will be the first post in a multi-part series. Future posts will cover the TetrisBoard (the game logic), the WinForm, the AI, and maybe a graphical board and sounds that I will code later.
Design
Some design decisions worth ment... |
I have one class Number (base class) and two child class Fraction and Integer. I am suppose to provide the functionality to add and compare two Integer obj, two Fraction obj, One Integer One Fraction obj by operator overloading. Below is what I have come up with. Can someone kindly review it. I am trying to avoid memor... |
Here is problem to be solved
TradingAlgorithm employs a trading algorithm which, based on the prices it receives, will return a trade to execute.
The trading algorithm must implement the following interface:
public interface TradingAlgorithm {
Trade buildTrades(Price price);
}
A Price is made up of a p... |
I used to write a bit of BASIC years ago, and recently found an old book called "Fun Mathematics on your Microcomputer" with some mathematical games in. I'm learning Python and have tried to implement one of the games, called "Treasure Hunt," which I played as a kid on a ZX81(!).
This is the first project for me where ... |
Here is my approach. Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
import java.io.InputStreamReader;
import java.util.Scanner;
public class Query {
public static void main(String[] args) {
Scanner scanner = new... |
isPalindrome :: Integer -> Bool
isPalindrome n = reverse x == x
where x = show n
is3x3 :: Integer -> Bool
is3x3 n = any (\x -> cond1 x && cond2 x) [101..999]
where
cond1 x = n `mod` x == 0
cond2 x = length (show $ n `div` x) == 3
main = print $ head [p | p <- [999^2,999^2-1..], isPalindrome p... |
I'm working on updating a GitHub project that I use at work, but I think the person abandoned the project as there is a pull request for it since 2014. At work we use a Repository pattern with NHibernate and mappings and so forth but this project they use Entity 4.? I had to update the project to use .Net 4.6.1, and be... |
I need help to enhance the performance of java source code. The code take txt file that has name, amount and date in form (name) (amount) (date yyyy-mm-dd) separated by spaces. After reading the file the data will be (name) (amount) (date dd/MM/yyyy).
public static void main(String[] args) throws IOException {
... |
I decided to play around with doing my own super-basic animation. For a previous Javascript project, I needed the ability to flash an element. The code below is the result of me attempting to generalize the main animation loop function, and learn Typescript at the same time.
What I'm looking for suggestions on:
The na... |
I started learning C# and this is my first "project". Its main purpose is to calculate the equivalent value of two resistors or capacitors connected in either series or parallel.
I just finished it and was wondering if you could review it for me. I'm open to learning what's bad, what's good (if it even has any in it) a... |
I'm making a photo marker application and need to make a factory pattern for marker. I think it is not very flexible and overall not good.
Would you check my code and suggest what could be improved?
import Foundation
enum MarkerType: String {
case Shape, Image
}
enum MarkerError: ErrorType {
case ImageNoExis... |
I am making a GIF editor in C#, and I am currently working on the eraser tool. I am not sure what I can do to make it more efficient, because when I make the thickness (diameter) more than 30 (pixels) it starts to get a bit slow.
if (click && eraserSelected)
{
new Thread(() =>
{
... |
I'm working on a simple dice roller for a Python IRC bot. The particular game this roller is for uses six different kinds of dice, which I've defined using a simple base class, and created six instances of it, passing a string array with the possible values of each dice.
class DiceBag(object):
def __init__(self, di... |
I decided to start working on the Euler project exercises. I'm doing fine for now but the seventh problem is running quite slow and I can't think of anything to make it work faster. It takes around 1300-1500 ms to finish which doesn't satisfy me while I know it can be done in maybe 20-30 milliseconds.
int index = 1;
Li... |
A simple algorithm that can be run by two processes to ensure mutual exclusion for one resource.Shared variables are created and initialized before either process starts. The shared variables flag[0] and flag[1] are initialized to FALSE because neither process is yet interested in the critical section. The shared varia... |
I am writing a Tetris program in C# for programming practice, and I've got it working. This is the second post in a multi-part series. My previous post covered the TetrisPiece. You can view the TetrisPiece code and critique here. Future posts may cover the WinForm, the AI, and maybe a graphical board and sounds that I ... |
I have been programming for a long time, but nobody has given me any feedback if my code is good or not. Please review it, and give me feedback where I could be better.
The source code is also on GitHub.
GameEngine.java:
package com.marcellelek.sudoku;
import com.marcellelek.sudoku.view.sudokugrid.GameGrid;
import an... |
I needed to do transformations on a data stream, not on an element-by-element basis, but on subsequences. This is what I've come up with:
https://github.com/peterjoel/rust-iter-replace/blob/master/src/lib.rs
I am relatively new to Rust, and would love some feedback on any areas of the code: style, design, memory/perfor... |
I have made this small quiz with 10 question and 40 JRadioButtons. One question and 4 JRadionButtons for each panel. So I had to create an array of JRadioButtons and JPanels, and for all I need to call setText.
Can this project be done with only four JRadioButtons, so when someone clicks on next question, the radio but... |
Question
Link to the exercise : https://projecteuler.net/problem=11
I'm currently working on the Project Euler exercise's and I just finished the eleven exercise. It's working fast enough it takes around 15-25 ms to calculate the output, the volume of the code is probably bigger than it should be.I barely used any math... |
I'm building a Django (1.8.12) application that parses a .bc3 file (Standard Interchange Format for Databases of Construction and Real State) and loads all the data into the database (PostgreSQL 9.3.9).
A .bc3 file looks like this, and a common one has more than 2000 concepts (those records that start with ~C).
To sum ... |
I am writing a 2D game engine library that I can use for simple future games, and I've been told that it is written very procedural rather than objected oriented. I was wondering what I should do to fix this, or how other game engines are usually written. My engine is very laggy, and I think this is why. Here is the ma... |
Please review my balanced parenthesis string checker code below.
I would love to know how to improve my algorithm and if you have any other feedback.
// comments inline
function validateParenthesisString(inputString){
if(inputString.length === 0){ // empty string is as good as a valid string
console.log('Strin... |
I wrote a Python script that, given a literary work in text file format, takes it apart, makes a word list, counts how many times each words appears in the literary work, and then checks if it follows Zipf's Law by performing the chi-square test.
For those of you who don't know Zipf's Law, put simply, it is a law that ... |
Please review my Secret Santa random pair allocator written in JavaScript. Random pairs will be generated every time you run the code.
Input data is hardcoded for now (line # 41).
I would love to know if you have any suggestions on improving the algorithm or any other feedback that you might have.
function getSecretS... |
I have two these methods. Their loops are pretty similar. I'd like to refactor it to avoid duplicate nested loops. How could I do that?
@Override
public boolean isValid() {
for (final FormSection formSection : getFormSections()) {
for (final Component fieldComponent : formSection) {
boolean isFi... |
I wrote the code to fetch the JSON Data. For that I tried to do this in 2 projects.
First Laravel project which has API code for database interaction only.
Sample code in API controller
class CountryAPI extends Controller
{
public function AllCountries() {
return response()->json(['CountryList' => \App... |
I have written a small Python function to extract version info from a string.
Input is of format:
v{Major}.{Minor}[b{beta-num}]
Eg: v1.1, v1.10b100, v1.100b01
Goal is to extract Major, Minor and beta numbers.
import re
def VersionInfo(x):
reg = re.compile('^v([0-9]+)([.])([0-9]+)(b)?([0-9]+)?$')
return reg.fi... |
We have about 14G files and each is about 150k.
I'm writing a script to upload them to Azure Blob storage and would like to run an upload() function (each with own file to upload) in 5 threads.
Here is how I realized it and it looks like it works - but I still have doubts about how correct this code is.
...
class Loade... |
Would this be secure enough to hash passwords?
/**
* Creates a SHA-256 hash
* @param string $salt Salt for hashing algorithm
* @param string $string What is getting hashed
* @return string Returns a hashed string
*/
public function hash ($string, $salt) {
$crypt = crypt($string, '$5$rounds=5000$' . $salt . ... |
Method.create(domain_id: domain.id, type_notification: type, message: title, url: url, owner_id: self.user.id)
How can I reduce this line to 80 ?
|
The following code has begun to smell, but I have not yet decided with what to replace it, other than, obviously, a database.
I made a very unsatisfactory workaround for my attempt to make relationships among tuple members as I assigned them.
How can I modify a piece of code like this that contains some hostnames or a ... |
We have a requirement for a script which polls an SQL database for scrape commands which need to be run. These commands are added to the SQL database on an ad-hoc basis. The scrape commands themselves are in the form of psexec commands, and need to be run by the listener script which is constantly polling the database ... |
Just for fun I tried to write a chess game in Haskell, in the hope that it would eventually be good enough to beat me. It's not perfect at the rules (it doesn't know about promotion, castling or en-passant yet) but it does manage to make legal moves, and they're not always totally stupid. I've tried to make the code ne... |
Here is a code file (I use it as a stand alone header file to be included in my projects) that contains macros to generate ANSI encoded strings that when printed are colorized. Also, the module contains useful string functions that are found in PHP standard library: strpos, stripos and substring functions: substr, sub... |
What could I do better in my code or logic?
Wikipedia Search
$(function(){
$('.search-input').keyup(function(data){
var pesquisar = $('.search-input').val();
$('.box-logo').fadeOut(500, function(){
$('header').css('padding','12px 0');
});
$.getJSON('https://en.wikipedia.org/w/api.php?format=json&actio... |
I made a simple text-based UNO game in Java. It lacks some features of the original game, but it's good enough for now. I'm new to Java, so I would like to receive as much feedback and suggestions as I can on my code.
The Unocard class:
import java.util.Random;
public class Unocard
{
public String color;
publi... |
This is in ASP.NET MVC, but that shouldn't make a difference. I have a large number of rows in my database for Songs.
var songIndex = Context.Songs.ToList().FindIndex(x => x.Id == 500);
var songs = Context.Songs.OrderBy(x => x.Id).Skip(songIndex).Take(10);
However, the ToList() and OrderBy seem pretty heavy just to ta... |
I decided to learn JavaScript and what better way than wrestling with a Sudoku solver. I'm guessing there are (many?) optimizations that I missed. I'm thinking of adding a generator also, but this for another time. Thoughts?
<!DOCTYPE html>
<head>
<title></title>
</head>
<body>
<form action="" method="post" acc... |
I am using this code in an MVC application to manage objects that should only have one instance per request.
/// <summary>
/// Manage all the resources that we want to scope to a single HTTP request.
/// </summary>
/// <remarks>
/// This class should not be directly referenced in many places.
/// In general, infrastruc... |
I'm arguing here with a colleague over two implementations of how to handle a processing logic:
VERSION 1:
public class SomeManager {
private readonly Dictionary<Type, Action<IData>> dataHandlers;
public SomeManager() {
dataHandlers = new Dictionary<Type, Action<IData>> {
{typeof(DataTypeO... |
This is a correct version, for computing a small matrix multiplication: C += A * B, where C is 12 * 4 in non-transpose setting, A is 12 * k in non-transpose setting and B is k * 4 in transpose setting.
Computation is scheduled k number of matrix rank-1 update. 12 and 4 are choose to best use available register file. On... |
This is my code that interprets my own golfing and esoteric language, Fuzzy-Octo-Guacamole.
It has 2 stacks to store information in, and various operations can be performed on each stack, or both at once.
This is also my first real project using classes, so any advice on how I did would be much appreciated.
#!/usr/bin/... |
I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one.
I already have this working solution for my problem, but it seems a bit too much code for me so maybe you have a better idea :)
HashMap<T, Integer> s... |
how to make this algorithm to display palindrome that was done with fewer permutations ?
#include <bits/stdc++.h>
using namespace std;
#define M 26
bool isPalin(string str, int* freq)
{
memset(freq, 0, M * sizeof(int));
int l = str.length();
for (int i = 0; i < l; i++)
... |
My question has to do with :
(a) Can this be made more secure?
(b) Are there best practices in relation to setting timezone?
(c) What best approach should be taken defining use of utf8?
$my_success = 0;
$my_message = '';
$my_id = 0;
try {
# declare & set variabl... |
Recenlty I have finished this primitive console string calculator in C. I need your balanced criticism, I'd like to know what I have to correct, remake and learn.
Permitted operations: + - * / ( ) ^
Sample input string: 11 * -10 + 15 - 35 / (35 - 11) + 2^2 =
main.c
#include "stack.h"
#include <stdio.h>
#include "calc... |
Requirement
Validate two inputs (from and to). Input can be either Number or String (value hast to be date in UTC format)
"from" and "to" both cannot be empty or null but one of them can be empty or null.
Pre condition : Use only Java 7
My simplest validation logic. Please let me know if I can optimize this code.
Ig... |
I'm working on figuring out what the current 'business' day of the month it is. For instance, if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month.
Is there a better way of doing this?
var first = DateTime.Today.FirstDayOfMonth();
var businessDayOfMonth = 0;
for (var i = first; i <... |
I've been to C++ lessons a long time ago and now I want to create a simple console program for switching Steam accounts. Please help me analyze my code and find my mistakes or better ways of doing something.
Main
#include "stdafx.h"
#include "functions.h"
using namespace std;
bool getNumberOrQuit(int &num, const int ... |
I have the following controller with a couple of database queries and I'd like you to review it.
I've tried to make it clean for other developers but the communication with the database can be improved (more effective). The exception returned when nothing is found, so I'm not sure if it's the best way to do it.
public... |
This code basically allows you to provide a collection and a lambda and have the lambda operate on each value iterated even allowing modification of the data if you wish.
I would like to be able to reduce the calling of my template advfind to something more concise along the lines of what I could do if I used std::find... |
I have the following code which produces successive generations of Conway's Game of Life:
life =: 3 : '+./ (>(($ y) $ 1);y) *. > =&(+/ (>,{ ;~(1 0 _1))|. y) each 3 4'
Usage:
RR =: 5 7 $ 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
NB. First five gens of RR
life^:(i.5) RR
NB. in ASCII
' *' {~... |
This is my first time using password_hash and password_verify in PHP. Would this be the correct usage of password_hash and password_verify to log the user into the site? Is there anything I could do to make this function more secure?
/**
* Initiates User Login
* @param mixed $data Post data
* @return mixed Checks i... |
Here are a few questions on my mind:
What improvements to the above code can you think of?
I want to say new UnionFind(x) where x is a Set[T] (I emphatically don't want to say new UnionFind(x.toList). Is Traversable[T] (and .toList inside the UnionFind) the right choice for that?
Note that the union method requires an... |
I have a query in MSSQL, where I get a summary by days from a range in a table, and this is in union with other queries. This query is used to generate days in a specific range, then add the registry per day, and exclude the registry that are equal to others (in this case, count the rows that tipo is 1, and tipo = 0, a... |
I want to standardise the CSS I use, and am leaning towards bem — I know I'll get a lot of benefit from the predictability of its pattern.
I have hacked their formula ever so slightly - I don't include the B part of the classname on child elements. For me this makes the html easier to write, and maintain.
Pure BEM
<ul... |
The program starts at the center of the screen and starts drawing a line in 50ms steps. When the line hits the edge of the terminal it will be reflected and continue drawing. steps takes the number of drawing steps to perform before finishing while until-key finishes on a key press.
Apart from the lack of comments, wha... |
In my application I have code which should run every hour on a new items and execute some expensive operation with multithreading:
int i = 1;
//noinspection InfiniteLoopStatement
while (true) {
try {
Logger.printIterationNum("Text analysis", "beg", i);
Document query = new Document("fetchStatus",... |
I'm building an event recorder. So far the code looks clean, but I feel like I'm missing something that can make this code even better.
Is composition a better solution? If yes, how can I do it properly in this context. Do you know a better way to share the Recorder across all other components? Will it be better to ini... |
The following is an implementation of fixed-length sequences that makes very exotic (and hopefully fun) use of Swift 2.2 types. The question is what exactly is the cost of having the type checker guaranteeing sequence length in this way on safety? performance? readability?
protocol CountType {
static var count: Int... |
This may be rather basic, but I wanted to experiment and learn with some of the upcoming CSS3 techniques. I wasn't able to come up with an HTML/CSS only solution, and I had to work longer than I'd like to admit to get to a point where this menu works as intended on desktop or mobile.
The main lesson I learned is forget... |
I am looking for some useful feedback on my programming. I'm only three days in and trying to improve.
Here is the code:
#include <iostream>
using namespace std;
const double SECT_A_TICKPRICE = 20;
const double SECT_B_TICKPRICE = 15;
const double SECT_C_TICKPRICE = 10;
double getSeatsA();
double getSeatsB();
double ge... |
I've recently made a test. There were four tasks. One of them was to improve following code:
public class FooFileProcessor
{
public void ProcessFile(string filename)
{
Stream fileStream = File.OpenRead(filename);
Console.WriteLine(ReadAllContent(fileStream));
fileStream.Close();
}
... |
I recently took a test. One of the questions was to find problems in the following code and suggest refactoring which can provide adding new formats of data:
public class FileProcessor
{
enum FileType
{
Html, Text
}
public void ProcessFile(string fileName)
{
StreamReader fileStream... |
This code performs integer factoring using the GMP library, and can also use OpenMP for parallel computation.
I compile it using: gcc -lgmp -fopenmp and whatever optimization flags I wish to try.
#include <stdio.h>
#include <gmp.h>
void next_prime(MP_INT *x) {
MP_INT r;
mpz_init(&r);
if (!mpz_probab_prime_... |
Given a URL like this:
localhost:3000/sell-residential/house-apartment-penthouse-size-30-any-for-0-100000-in-miami%3b+orlando%3b/list-1?numRooms=2&numBaths=2&numParkingSpaces=1&misc=photo-only&interiorFeatures=heating%2Clift&exteriorFeatures=garden%2Cbalcony
I would like to extract some values using RegEx. What I have... |
Here is my approach. Unique element means that element should present only once in the array.
import java.io.IOException;
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.Map.Entry;
public class Unique {
public static void main(String[] args) ... |
This is quite a simple function, but I just wanted some opinions on it, like is this the correct way to run a function and check if an element exists or not?
const button = document.querySelector('.js-brand-video--thumbnail')
const iframe = document.querySelector('.js-brand-video--iframe')
function playVideo () {
if... |
This is my challenge using JavaScript -> Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays.
My code works, but I think that it can be better.
function diffArray(arr1, arr2) {
var newArr = [... |
I have a challenge, which is to create a JavaScript function that turns a given number into the string representation. For example:
console.log(inToEnglish(15)) should print fifteen
console.log(inToEnglish(101)) should print one hundred one
and so on...
This challenge covers Non-Negative, greater than zero Integer numb... |
I've made integration tests for a major part of my application. I test my dependency injection is set up correctly, creating controllers with it's dependencies going all the way to the database (using localDB) and returning the response. I'm looking for what could be improved.
Here is the general concept of my tests:
p... |
I have this generic "matrix" holding elements of arbitrary type. It supports any horizontal or vertical rotations (of any step size) in \$\mathcal{O}(1)\$. See what I have:
package net.coderodde.util;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.ev... |
I wrote a 3D bin packing algorithm but I am still not sure if it is correct or not.
I did not follow any code or pseudo-code that's why I would like to know if it is an efficient algorithm for the 3D bin packing problem or not.
each container has a length, height and breadth
each item has a length , height and breadth... |
I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular format to view the clustering of a hashing function. This code works, however, it looks horrible. Is there a better way to create tables?
for (int i = 0; i < arraySize; i+=3) {
Sy... |
I have started learning Java recently and was looking into some easy algorithms.
I found the Boyer Moore voting algorithm here.
I am trying to get better at writing good code for my solutions. Please give me your suggestions.
import java.util.Scanner;
public class MajorityVoteAlgorithm {
public static void main(S... |
I am making a multiplayer platforming game, and currently there are server performance issues once I have about 7+ clients connected. I was told earlier last week that I should investigate socketserver since previously I had been writing my own server using merely socket.
Well, after 6 hours of implementation I've got ... |
Am trying to create a minesweeper game, I have the following code which has to many nested ifs, I want to change the code to take out the nested ifs and make it better to read. But I am stuck on how to change the nested ifs. Any help would be great. thanks
/*method to check cells around a cell and set its value.*/
... |
Problem
Given a square matrix of size N×N, calculate the absolute difference between the sums of its diagonals.
Input Format
The first line contains a single integer, N. The next N lines denote the matrix's rows, with each line containing N space-separated integers describing the columns.
Output Format
Print the absolu... |
I have the following function and I was wondering if anyone could come up with something more efficient.
It just has to split both the content and the search string and determine how many words are required to be matched before being true.
For example,
"A dog can run.".ContainsV2("Red Dog Run", 4) = false
"A dog can ... |
I'm writing a Matrix class, and I want to be able to construct a Matrix in two ways:
Supply a 2D array that the Matrix can use internally
Supply the dimensions of the Matrix, and the value to fill each cell with.
In most languages, the obvious solution would be to overload the constructor, having 1 version of it that... |
I have a query against an MS SQL database that takes the resulting dataset and stores it in an Oracle database table which then gets joined to another Oracle table using the column LABEL_YYYY_MM_DD_HH24_MI varchar(32). I have converted the MS SQL datetime column q.InTimeStart as per below.
Is there a more efficient wa... |
I'm currently reading the infamous K&R C book and trying to solve Exercise 1-20. My solution looks kind of too simple, but it works. I've searched the web for different solutions, but they all are much longer, although I didn't see any improvement compared to my code. Do you see anything which might compromise my appro... |
I'm trying to create a function to return a DataTable with the results of a MySQL query where the program doesn't know the names of the queried columns until run-time.
How can I improve the readability of this function? Is concatenating strings like this an appropriate way to generate MySQL queries?
public static DataT... |
I've started using the following Error configuration for some simple libraries I've been working on:
pub mod err {
use std::{error, fmt, result};
macro_rules! from {
($t: ty) => {
impl ::std::convert::From<$t> for Error {
fn from(e: $t) -> Self {
Error::B... |
I've implemented a rather straightforward octree, but I don't feel that good about the coding style or some of the implementation. In particular, I use some nasty void pointers and extra news because I couldn't figure unions out, and I'd like to have that replaced (I'm thinking maybe templating can solve it, but any f... |
A robot can move in one step from cell X to cell Y if and only if the distance between the centers of the cells X and Y measured in meters is equal to the sum of integers contained in X and Y. It then returns the index of the cell which the above condition does not meet which is the index only [0, 1, 4] and its value ... |
When a UITableViewCell has subviews with background color set, when setSelected(_: animated:) gets called, all the views are made transparent.
This issue is also discussed here
I'm trying to solve this issue by extending UITableViewCell
extension UITableViewCell {
private func backgroundColors(views: [UIView]) -> [... |
This is just a simple class that you can you use to send requests and get the HTML code. I would like to get feedback on this.
For your request you can set:
URL
Request method: GET or POST
Request parameters: if you need to pass parameters
Request cookie
As a response you will get:
HTML
Response cookie
Request
clas... |
I'm teaching myself Java and I had some basic questions on how well I am writing my code for readability. I feel like sometimes I'm just writing code that works, and I'm not that proud of myself when I have finished. I'm not asking you to rewrite my code; I'm just asking for some pointers on how optimize my code for re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.