instruction stringlengths 71 71.9k |
|---|
For the code sample that I am asked to submit with most of my job applications (usually Gameplay Programmer), I created this console application in which I attempt to figure out what is the best loadout for a mech to win a match within the simple turn-based combat system that I came up with. Since I will submit this as... |
I have just started learning how to build websites, and I have been experimenting by creating a contact form.
Here is what I currently have - can anyone suggest and recommend ways enhance my current contact form system?
JavaScript:
$("#contactForm").submit(function (event) {
/* stop form from submitting normally ... |
I am writing code to do some numerical task using the routines of the book Numerical Recipes. One of my objectives is to calculate the second derivative of a function and have a routine that calculates the first derivative of a function in a nice manner within a specified accuracy. However, I would like to generalize t... |
Two integers a and b are relatively prime if and only if there are no integers:
x > 1, y > 0, z > 0 such that a = xy and b = xz.
I wrote a program that determines how many positive integers less than n are relatively prime to n. But my program works too slowly because the number is sometimes too big.
My program shou... |
I've been coding in a vacuum for several years and am trying to get up to speed on best practices, in anticipation of my eventual return to employment. I'm hoping this is the best forum in which to ask these types of questions. If not, please let me know.
My first question regards assigning the initial values of a UIVi... |
When a button is pressed, an animation loop is triggered. At the start of the loop, I create a new time object.
I also have a pause button. A problem was created when paused and then started as the Date object would be recreated each time.
The variable is global and not defined to be anything. I could set it to 0 an... |
I'm moderately new to programming in C and I'm not sure about programming practices with code; suddenly I have had fears that my code is messy and disorganized. I can read it when I come back a month later yet I'm still nervous if I'm doing anything that's considered taboo.
This isn't all the code that I've done with t... |
I am working on a project in which I am supposed to make synchronous and asynchronous behavior of my client.
The customer will call our client with a userId and we will construct a URL from that userId and make an HTTP call to that URL and we will get a JSON string back after hitting the URL. And after we get the respo... |
I was not sure if I should post about 200 lines here. I want to make this ant simulation faster. The bottleneck is at Ant.checkdistancebetweenantsandfood().
It would be great if you have some hints for some cleaner or more efficient code. I hope this is the right place to show this code.
import random
import time
impor... |
I have issues with dynamically typed languages, and I tend to worry about type a lot.
Numpy has different behaviour depending on if something is a matrix or a plain ndarray, or a list. I didn't originally have all these asserts, but I inserted them while trying to debug a type error.
from numpy import *
sigmoid = vect... |
Is there any way to reduce total execution time for the function getSilhouetteIndex? P.S. I am using weka SimpleKMeans for getting kmeans and ceval.
private double getSilhouetteIndex(List<ITSPoI> _POIs, SimpleKMeans kmeans, ClusterEvaluation ceval)
{
double si_index = 0;
double[] ca = ceval.getClusterAssignment... |
Based on the advice provided in my previous question, I would like to post the other source file that actually implements all the combat mechanics and also the actual evolution process.
As with the previous question, I am interested in all kinds of feedback — regarding design, implementation, algorithms, presentation,... |
The exercise is explained in the comments. Do you have any suggestion?
package com.atreceno.it.javanese.attic;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import ja... |
I am practicing my recursion skills as I think I am really weak in this area.
I have written the following Java class whose purpose is to reverse a string but to do it 'in-place' - i.e. no additional arrays. I have two implementations - one iterative and one recursive. Why would I choose one implementation over the oth... |
Visual Studio somehow optimizes the below code to be 20 times faster (release with optimization vs. release with no optimization). What could it be doing?
for (unsigned n = 1; n != units.size(); n++)
for (unsigned j = 0; j != (units.size() - n); j++)
{
unsigned sizesMap[11] = { 0, 0, 0, 0, 0... |
I've a application which runs with two threads. The main thread runs in one infinity-while-loop:
while (true) {
try {
ArrayList<Info> infoList = zabbixHandler.APIRequest();
handleInfo.handleInformation(infoList);
Thread.sleep(5000);
}
}
The second thread, which uses more than 50% of my CPU, mu... |
I am working on a haskell exercise where I have to compute the amount of people riding a rollercoaster in a day. I have the following data: the number of rides in a day, the number of seats, and the composition of the queue.
The queue is a list of groups. During each ride, the first few groups of the list enter the ri... |
I would like to test the following garbage collector code on a database of sessions.
It should be following the conditions below:
if 'remember me' is enabled by the user, then it should delete all rows which are not active within 2 weeks.
if 'remember me' is disabled by the user, then it should delete all rows which a... |
I've been playing around with inheritance in JavaScript and I'm wondering if there are any drawbacks to this method which tries to emulate classical inheritance from C-based languages.
Function.prototype.extends = function (parentClass) {
function temp () { this.constructor = this; };
temp.prototype = new paren... |
I have the following code to load an enumeration into a bound combo box, but am not quite happy with it.
I would prefer to store the actual enum value in the combo box and bind directly to it.
However, I can't quite figure out how to do so.
public enum HemEnum
{
HemNone = -1,
Hemsew = 0,
H... |
I have a class Creator which will execute a block code for a number of times. I'm not sure how to write this in a more elegant way in Ruby.
class Creator
attr_accessor :block
def self.create(&block)
@block = block
return self
end
def self.for(number)
0.upto(number) {
... |
I've written a small Game of Life module in Haskell, as well as a small testing application. I'm relatively new to the language, so any kind of comment about the code is welcome. The most important comments for me are comments about efficiency of the code, and of course bugs. I would also be happy to accept comments ab... |
As xts objects are arrays, getting apply functions to work is a little tricky if you want to preserve the dates. For example, take the xts object xx below:
xx <- xts(replicate(6, sample(c(1:10), 10, rep = T)),
order.by = Sys.Date() + 1:10)
Say we wish to apply a function to each column (to keep it simple s... |
So I wrote this function to convert a given number to its interpretation in the English language as part of the Project Euler exercises. It works fine, but I sense that it's rather sloppy and inelegant, especially for Python where many things can be done quickly in a couple of lines. Any feedback on how to make this ... |
I am working on an app: a virtual sandbox of sorts, a lot like Powder Game.
The problem is, when working with an app, you must deal with hardware limitations. Don't get me wrong, the speed isn't like 2 FPS or anything, but I would just like for someone to look over the code and point out any spots that could use optimi... |
I am working on building an UndoManager in C#. The concept is to store events and property changes in a Stack<Action<T>> instance. I believe it is working, but I am also looking for peer review.
What can I improve? Do you see any bugs?
public abstract class UndoManager<T>
{
/// <summary>
/// Adds an Event to ... |
Looking for optimization, smart tips and verification of complexity: O (log (base 2) power).
NOTE: System.out.println("Expected 16, Actual: " + Power.pow(2, 7)); is a typo. It correctly returns 128.
/**
* Find power of a number.
*
* Complexity: O (log (base 2) power)
*/
public final class Power {
private Po... |
I have a considerably large directive which is doing many things: First it renders a Google Map, then it adds a listener to check when the bounds of the map change, then it renders points on the map based where the bounds currently are, and finally it has a menu of options which allow the user to turn on and off variou... |
I am writing a program to factor stupidly large integers (5000 digits+), and performance is obviously critical. A currently TODO feature is to factor semiprimes, specifically RSA, which is why the cube root function is included. Don't tell me it's impossible. I'm trying to learn, not actually do it. Before I start on ... |
This is my first relatively big program. First it shows an askdirectory() screen to get the path. It gets all subfolders of that path and appends them to a list. It checks every folders' items if they are wanted file types by checking extensions and puts them into a proper sqlite table. After all files written to a dat... |
Not lock-free, but still only C++11 and no Boost. It also supports timeouts.
#pragma once
#include <cstddef>
#include <chrono>
#include <memory>
#include <queue>
#include <mutex>
#include <condition_variable>
template<typename T>
class blocking_queue {
public:
explicit blocking_queue(std::size_t max_size) :_max_s... |
I have a the beginnings of a class (in this case for a NeuralNet).
I'm not very happy with how I am initializing self.ws, seems a bit off.
What is the pythonic way to do this?
import numpy as np
class NeuralNet:
def __init__(self,layerSizes):
self.ws = self._generateStartingWeights(layerSizes)
def _ge... |
Looking for code review, optimizations, good practice recommendations etc.
/**
* This is utility class for operations on rotated one-d array.
*
* Note: a sorted array, reverse-sorted or a single element is array is not considered rotated sorted.
* Eg:
* [4, 5, 1, 2, 3] is condidered rotated.
* While.
* [1, 2, 3... |
I'm using C++11 and I have the following problem (pseudo C++):
template<typename T, R1 (*F1)(Args1...)>
class one_size_fits_them_all {};
template<typename T, typename U, typename V, R1 (*F1)(Args1...), R2 (*F2)(Args1...)>
class one_size_fits_them_all {};
template<typename T, typename U, R1 (*F1)(Args1...), R2 (*F2)(A... |
I have the following code to get the ID of a <a href="#ID"> </ a> and go to their respective div <div id="" />:
$('a[href=#certificados]').click(function(e){
e.preventDefault();
$("html, body").animate({ scrollTop: $('#certificados').offset().top }, 1000);
});
$('a[href=#team]').click(function(e){
e.preven... |
I need to parse the data coming from a URL:
haschanged=true
version=1
timestamp=1389562122310
DATACENTER=/pr/hello/plc
TotalNumberOfServers:4
primary:{0=1, 1=2, 2=1, 3=2, 4=1, 5=2, 6=1, 7=2, 8=1, 9=2, 10=1, 11=2, 12=1, 13=2}
secondary:{0=0, 1=0, 2=0, 3=1, 4=0, 5=0, 6=0, 7=1, 8=0, 9=0, 10=0, 11=1, 12=0, 13=0... |
I have used the Newton-Raphson method to solve Cubic equations of the form $$ax^3+bx^2+cx+d=0$$ by first iteratively finding one solution, and then reducing the polynomial to a quadratic $$a1*x^2+b1*x+c=0$$ and solving for it using the quadratic formula. It also gives the imaginary roots.
def deg3(a,b,c,d,g): #using n... |
In the first code snippet I am creating a generic class to hold configuration details. I am currently using it as a way to pass run time configuration options to plugins in a generic manner. The second snippet is a helper class that utilizes the class to provide the public methods for use which helps guarantee type s... |
Pretty printer in ABAP does not take care of all my aligning need, so I wrote a small JS script that tabulates/aligns with a custom string. It contains HTML, CSS and script in 1 file because this is a small tool.
Link : https://github.com/konijn/aligner
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=... |
I have a need to print the content of a jQueryUI Dialog to a printer, and I couldn't find anything to my liking. I developed the following simple jQuery plugin which prints one or more provided HTML elements, and am using it to print the jQueryUI Dialog DIV element. The code is below, and a live example is located he... |
Can I improve this markup? Is it SEO friendly?
<div class="bloc-contenu group" itemscope itemtype="http://schema.org/Hotel" itemref="logo nom-hotel">
<p><iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d89225.49873817024!2d-74.4423141!3d45.664941!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sfr!2s... |
I have fully working code, however I'd like to make it nice. I've got these three models:
User (can have both or either one)
user can have one trucker
user can have one owner_trucker
Trucker
belongs to user
OwnerTrucker
belongs to user
I'm not the only one working in the app, but it starts to annoy me how e... |
I'm learning JavaScript and I was trying to make a custom addEvent function that would care about compatibility (I don't want to use jQuery [nor any other library] yet, in order for me to "master" the bases of JavaScript).
I came across this code on github (https://gist.github.com/eduardocereto/955642):
/**
* Cross Br... |
I have an angle where I need to convert a 'normal' angle to an isometric angle (116 degrees), and I came up with this function. It works, but I was wondering if the math could be optimized/simplified, or if this is the way to go. It's for a mobile game.
public static inline var ISO:Float = 0.45378560551; // (116-90) /... |
Is this the best way to reverse a singly-linked list? Can it be done with two, or fewer pointers? Any other comments?
public class ReverseLL {
Node start;
ReverseLL()
{
start=null;
}
class Node
{
Node next;
int data;
Node(int newData)
{
next=n... |
This feels like a simple question, but I'm wondering what the best way would be to manage the elements of a private, fixed-size array.
Context: I'm making a simple particle engine, and my Emitter class will smoothly interpolate between up to 8 colors per Particle, depending on the Particle's Life value. I have that par... |
Looking for review, good practices, optimizations, clean code tips etc.
/**
* Flip the columns.
*
* Complexity:
* O(row * col)
*
*/
public final class Mirror {
private Mirror () { }
/**
* Given a matrix create a mirror image,
*
* @param m the input matrix
* @throws NPE if... |
Looking for review, good practices, optimizations, clean code tips etc.
final class Pixel {
private final int color;
public Pixel(int color) {
this.color = color;
}
public int getColor() {
return color;
}
}
/**
* Rotates an image by ninety degrees.
*
* Complexity:
* O(row * ... |
I have an array of Item objects that each have a string particular and a numeric amount. I want to put all particulars (separated by newlines) into a single string and the same for all amounts.
Here's what I came up with:
particulars = []
amounts = []
items.each do |item|
particulars << item.particular
amounts <... |
I have written this little tagging module to make it easier to generate small html snippets on the fly. The examples below show how this make things a bit easier. My question is about the handling of tags that contain either a single element like text or a list of other elements, like the tr element in the second examp... |
I want to create all possible combinations of points (0,0),(0,1)...(12345,6789) and then all segments from these points.
The code I have written is simple and with no optimization. Is there any algorithm to generate it in less time?
public static void main(String[] args) {
int m=12345;
int n=6789;
for(int... |
Depending on the width of the screen the JavaScript animates a node and then loops another animation.
I'm trying to understand DRY but my JavaScript skills aren't quite up to scratch to get this code as optimised as possible. I'm also wanting to implement $(window).resize(function() { }); to detect this change without ... |
I have tried to write code of Box stacking problem (mentioned here) in C++ .
Kindly give me some views on what mistakes I might have made and how I can improve.
It is running for the two inputs I have provided.
//============================================================================
// Name : Boxstacking.c... |
I wrote this unbalanced binary tree and would like to know how to improve the code and performance. If you can point out any situations that are not being handled appropriately, that would be great too.
It supports element insertion, removal, search, iteration, tree balancing and encoding/decoding.
bst.h
#ifndef BST_H
... |
There is a recommendation not to use an Exception to control the flow of execution. This gives me a reason for doubt when I do something like this:
public void initApplication(String input) {
try {
MyClass mClass = new mClass(input);
saveToDatabase(mClass);
updateSettingsThe... |
The question is very simple but also a bit theoretical.
Let's imagine you have a long jQuery script which modifies and animate the graphics of the web site. It's objective is to handle the UI. The UI has to be responsive so the real need for this jQuery is to mix some state of visualization (sportlist visible / not vi... |
I am quite new to event programming in C# specially in WPF. I have made a very simple core app which I am planning on extending.
It's very simple as its purpose is learning curve and doing things the right way that's why I am asking here for a review and not help on building as most of the building is easily researcha... |
I have to work with a 3rd-party API that allows me to define and execute "commands", using XML. Since I don't like seeing mixed abstraction levels, I managed to remove all the inline XML / string concatenations by creating a simple XmlCmdBuilder object - here is the C# implementation (I have one in VB6 as well, the C# ... |
I have one file with indexes. For example, they are:
1 Fruit
2 Meat
3 Fish
4 Salmon
5 Pork
6 Apple
And a dictionary, because I want to match entries that I choose:
similar = {'1' : '6', '2' : '5'}
Since they are on the same file, my program scans for the '1' on the file, and then re-scans... |
I used step 4 from the Angular tutorial to do some tinkering of my own. In that particular step of the tutorial, a option list is created that determines how a list is sorted (Alphabetically, by age). I tweaked the code to dynamically generate these sorting options from the data set.
Essentially, it takes the first el... |
The idea of the below code is that I feed back to a Gridview if the user has permission to view the property otherwise that property is not show.
The data is passed in via SessionParameters
USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE [dbo].[spSafeguardingActionPropertyByPermiss... |
After reading some texts regarding creation of files under Python, I've decided to create this class which creates a new file on a directory, and creating a backup on the other directory if the file already exists (and if it's older than x hours).
The main reason I opened this question is to know if this is a correct w... |
I've heard that Lbl and Goto use up memory that they don't give back. I've noticed clearing the RAM on my calculator frees up a lot of space and makes my programs run a lot faster. Any suggestions on how to minimize memory leaks here would be greatly appreciated. (This code does function correctly other than leaking me... |
Below is a pretty simple Python script to ingest some data, massage it as necessary, append a column, sort it, and then write it back to another file. Still learning all the Python best practices and APIs, so as always, any tips and tricks are appreciated! Feel free to be brutal with me if it's horrible. It's my fir... |
I just took a stab at creating a library for something I'm dubbing semi-synchronous programming (async + dependencies). It's rather dense, but I'd really appreciate a quick code review to ensure I'm not introducing any race conditions. Feedback on best practices, general improvements is also welcome.
from multiproces... |
The first thing I would like to say is that I do have a fully functioning script, but the script is ugly, and I am wondering if there is a way to optimize it.
The script looks to see if I have at least 6 news articles in my database.
If I have at least 6 news articles, it branches into a nested if statement.
If the to... |
I need to find the end of a loop or the length of the object. Some context on the code:
I obtain the txt var from the DOM (that's the only way I've got by now and can't change it) and it's a formatted JSON. Here's an example of the expected JSON output:
{"SE DIO AVISO A CENTRAL":true,"OTRO":false,"SE DIO AVISO A SEGU... |
I'm kind of new to Python. So, I wonder which method is better to use in a function to find an element in a list.
First:
def search_binary(xs,target):
count = 0
for i in xs:
if i == target:
return count
count = count +1
else:
count = count +1
conti... |
This compiler, implemented in C++, takes brainfuck code and produces a valid (but still obfuscated) C program, which in turn can be compiled to a native binary.
Expected usage is as follows:
Build the compiler
$ c++ -o bfc bfc.cpp
Compile a brainfuck program (example) to C
$ ./bfc ascii.bf
Compile the resulting C pr... |
I'm just getting into testing and wanted to see if someone can tell me if I'm writing tests correctly. I'm using C#, NUnit, & Should.
This is the class I'm testing:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Emit;
Using VM.Models.Comm... |
I am learning Java as my first programming language and have written a bit of code. I would love to read expert reviews on this code and suggestions to improve right from naming conventions to logic. Please let me know if there is any kind of mistake.
public class Sudoku {
public static void main(String[] args) {
... |
I have a Backbone.Collection which has some models in it. Each model has a boolean property called 'special.' Only one model should be special at any given time.
I've got the following to enforce this, but I'm wondering if it could be clearer or if there is a more appropriate way to enforce such behavior:
// Ensure th... |
I would appreciate it if someone experienced in F# and/or functional programming to look over my code. This is practically the first thing I wrote in the language so I'm sure it's filled with non-idiomatic stuff and unoptimized code.
I'm not interested in implementing a more efficient algorithm. Just implementing this ... |
Project Euler Problem 12 asks (paraphrased):
Considering triangular numbers Tn = 1 + 2 + 3 + … + n, what is the first Tn with over 500 divisors? (For example, T7 = 28 has six divisors: 1, 2, 4, 7, 14, 28.)
I have written the following solution. The code is calculates the correct answer, but the run time is appallin... |
I am writing a program that is based on the Travelling Salesman Problem. There are four cities in which the user determines its x and y coordinates. The salesman always starts at city1 and ends up at city1, so there are 6 possible routes. However, each route has an equivalent route, i.e route1 has the same distance as ... |
I want to see if I can make any improvements to the rendering methods that are currently written. I've noticed when profiling this project that the CPU was allocating a fair percentage of the time towards rendering and was wondering if there were any improvements that I can make towards it.
Note: Below is my somewhat s... |
I am working on a CoderByte problem in JavaScript. I have solved the problem below. Although I am trying to figure out if there is an easier way to do it? I am guessing RegEx will come up, although I don't have experience with that yet.
From CoderByte:
Using the JavaScript language, have the function SimpleSymbols(s... |
I have this class which is used as part of a game. It needs to generate Random Even values, which is done by generating random numbers until the result is even.
Is there a better way to do this?
Also, I currently have the methods implemented as private instance methods, but should I declare generateRandomNumber() and e... |
I want to implement a Type system for different representations of an angle value. Motivation to implement this as a type system comes from this question.
Angle can be represented using the following types:
Degrees (45.5)
Degrees Minutes Seconds, DMS (45*30'00")
Radians (0.7941)
It should support conversions... |
Please review the code for code cleanup, smart optimizations and best practices. Also verify my complexity: \$O(n^2)\$, where \$n\$ is the number of nodes.
/**
* This class traverses the tree and returns in-order representation.
* This class does not recursion and does not use stack.
* This code is threadsafe.
*/
p... |
Please review the code quality of this l33t Speak translator. Improvement suggestions are welcome. Here it is - http://jsbin.com/IHoFuQE/1
(function() {
"use strict";
// http://en.wikipedia.org/wiki/Leet
// http://www.catb.org/jargon/html/crackers.html
var alphabets = { // common
"a": "4",
"b": "8",
... |
As an exercise, I wanted to rewrite this toy Python code in Haskell:
def f(x):
return abs(42-x)**2
def improve(x):
newX = x + 0.1
return newX, f(newX)
def optimize(f, goal):
x = 0
err = f(x)
while not err < goal:
x, err = improve(x)
return x, err
print(optimize(f, 0.5))
Ideone
My... |
The following is a solution to Project Euler problem number 12: which is to find the first triangular number with more than 500 divisors.
The code takes far too long to complete (over 10 minutes). Is there any way to optimize the run-time and to make it more elegant?
#include <iostream>
#include <chrono>
#include <ctim... |
I needed smth that could send (scp/rsync) many files in parallel but that would not overload machine, firewalls on the way by starting e.g. 600 simultaneous uploads, so upload should be done in batches.
Most of the utilities like aria2c are download managers and I needed something to send many files in parallel from a... |
The following code works and does what I want, but I'd like to confirm I'm using this OOP concept correctly. I'm using the following class to get and set some configuration parameters for my program. It used $GLOBALS for this before, but I'm trying to use a singleton pattern for this instead.
Below is the Config class.... |
I need your help in OpenCV. I'm a student and am working on a project in which involves a little autonomous car. I use Python for the main programming language.
I have some problem with my meanshift. When I run the program, I want the camera fixed on an area on the floor and stay on this area. I would like for the ca... |
I create a binary tree, now I want to remove a node. I hope that you can provide me some input. The nodes are composed of characters instead of numbers.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BinaryTree
{
public class BinaryTree... |
This is a continuation of this:
Performance of BigInteger square root and cube root functions in Java
I've made most of the changes suggested, but since I'm loading literally the largest array possible on the computer, I'd like some review before I implement Sieve of Atkin.
Code follows, just over 300 lines, formatted... |
This seems like a pretty basic question, so bear with me...Say I have two (or many) methods in the same class that need a LINQ to SQL DataContext. Additionally, I am needing the DataContext in other classes as well. Does it make sense to create the new DataContext every time?
Should I be creating this DataContext in a... |
My application uses a simple Model-View-Presenter architecture and uses the following classes and interface:
Presenter:
public abstract class Presenter<V> {
private V view;
public final void setView(V view) {
this.view = view;
}
protected final V getView() {
return this.view;
}
}
... |
In MATLAB I have a set of 5393280 points in the form of a decimal-valued vector (x,y,z). How do I represent them in a way that I can quickly collect all the points within some rectangular x-y domain?
Right now I'm representing them as a 3-column matrix, sorted by x-values, and using the following code to extract a rect... |
Being curious to see which tags on this site get the most attention, I developed a Stack Exchange Data Explorer query:
WITH CanonicalTags AS (
SELECT Id, TagName, Id AS AliasId, TagName AS Alias
FROM Tags
WHERE NOT EXISTS (
SELECT Id
FROM TagSynonyms
WHERE... |
This was our old site that I am redesigning.
Someone else hardcoded with inline CSS and javascript in tables.
I wanted to make it dynamic, so I added Mustache and made this template:
{{#labs}}
<div class="lab">
<h4>{{{lab}}}</h4>
<p>
{{#stadt}}
<span><i class="fa fa-building-o"></i></span><spa... |
Preface: I'm starting to learn C# and I don't want to port any of my bad habits from other languages, so I'm following convention wherever possible.
Using the default Visual Studio code formatting, this relatively simple function requires 14 lines of code.
public void add(int[] values, Func<int, int> transform = null)
... |
I have the following code to log changes using Entity Framework 6.
At the moment it only logs changes to a particular table - but I intend to expand it to cope with any table. I'm not sure of the best way to extract the table name.
I call this code before Db.SaveChanges. Db is the DBContext.
private void LogHistory()... |
Fishstacks is a deadfish derivative based on a stack the stack can only hold four elements when a fifth element is pushed the bottom element is kicked out and eventually printed out to the screen.
I've come up with an interpreter in TI-BASIC for my calculator. However, I fell slightly guilty about using all four variab... |
I have an array that I want to enumerate using blocks concurrently. However, I'm having trouble making this thread safe. I am new to using blocks and locks, so I am hoping someone may be able to push me in the right direction for preventing this from crashing.
The point of this function is to loop over a number of fil... |
I am hoping to make this method run a little faster. I typically need to run this on a list with more than 100000 entries. Note that at the start and end of the list, I wish to weight the average so that it is closer to the start or end value, hence the smaller framesize.
public PointPairList GetMovingAverage(int frame... |
Code review for best practices, optimizations, code cleanup etc. Also requesting verification of the complexity: O(row*row*col).
/**
* Contains coordinates of the
* topMost left, of matrix, obtained by getRowOne and colRowOne
* bottomMost right, of matrix, obtained by getRowTwo and getColTwo
*
* @author javadeve... |
Which of these names is better: time.getHours() or time.hours()? And why?
public class Time implements Serializable {
private final int hours;
private final int minutes;
public static Time from(Calendar calendar) {
int hoursIn24HourFormat = calendar.get(Calendar.HOUR_OF_DAY);
int minutes = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.