instruction stringlengths 71 71.9k |
|---|
I have just been informed that the following code written by me is extremely poor. I have absolutely no idea why. It is memory efficient, and looks clean to me. But still the feedback is very poor. I have no clue on why. If someone can put some comments, I will be highly grateful. I have to pass file name from command ... |
I am currently developing a chess game but have made the mistake of putting all my Java code in one .java file.
I need help cutting up my code into more manageable chucks. Could someone show me how to take out all the piece movements and put them in a separate file which then links back in to the main file? I have trie... |
I have been doing this test task for C# Developer role at UBS.London recently and have been rejected. No reason stated yet. Was wondering if you can take a look and provide feedback on what I can do to improve solution. The task description is below and solution itself is on GitHub. Also attached code for two main clas... |
Is there something as "they have too little in common to use a superclass"?
In my case, doing iOS programming, in a project, every screen has the same background. So I created a superclass which only has:
.h
@property (nonatomic) IBOutlet UIImageView *backgroundImageView;
.m
- (void)viewDidLoad {
[super viewDidLoa... |
No specific question here. I am beginning with Java and here is an exercise. The rules of game:
You roll two dice. Each die has six faces, which contain one, two,
three, four, five and six spots, respectively. After the dice have
come to rest, the sum of the spots on the two upward faces is
calculated. If the su... |
I have the following working script which I use for my database connection for a multi-user webapp. I use a different database for the login, this script is called only after the user is successfully logged in. The login uses PDO.
I would like to know what I can do to
make this more secure
harder to fail
include('.d... |
I am going through coding challenges and I would like to get feedback on one of them.
I am not sure if i can post the link to the challenge but here it is. CodeEval Challenge
Outside of your window, there's a wire between two
buildings. Bats love to hang there but you notice they never hang
closer than "d" centi... |
There are many C++ implementations of the Euclidean vector. I.e., a vector in what is typically a 3- or 4-dimensional space. Something along the lines of
struct vec3f { float x, y, z; };
It can of course also be a much more advanced implementation. Since we don't have a standard implementation, nearly every library pr... |
I'm trying to create a very simple jQuery plugin in the object-oriented way. Now, I'm not sure whether the code I produced is correct and efficient OO programming. The plugin's aim is to change the navigation ul li based on the clicked country.
jsFiddle
// Widget container
(function($) {
// Widget container plugin
... |
Problem Statement:
Create a class diagram and Java code for the following system and
scenario, taking into account the possibility of future extensions.
"The system is a command line utility that prints a short 'quote of
the day' on the user's terminal when run. To begin with the quote is
selected randomly f... |
In my Node.js applications, I often find it helpful to have an application log so that should something go wrong in production, I can have more information than I get from a crash stack trace to track down problems.
To facilitate this, I use a global instance of Winston which is set up as one of the first things in my ... |
Back on track with my C++ saga:
The standard deviation of a list of numbers is a measure of how much
the numbers deviate from the average. If the standard deviation is
small, the numbers are clustered close to the average. If the
standard deviation is large, the numbers are scattered far from the
average. Th... |
Another more simple project from my CS1 class that I didn't upload while I was sick last week:
Write a program that computes all of the following statistics for a
file and outputs the statistics to both the screen and to another
file: the total number of occurrences of characters in the file, the
total number of... |
Continued from Playing "craps" for the win
You roll two dice. Each die has six faces, which contain one, two,
three, four, five and six spots, respectively. After the dice have
come to rest, the sum of the spots on the two upward faces is
calculated. If the sum is 7 or 11 on the first throw, you win. If the
su... |
I recently watched a video in which the speaker said that Haskell is not suited for real-world tasks, such as copying files from one folder to another.
So I tried to write a program that copies a given file system tree to a new location. The usage of the program is
copy_tree <source path> <target path>
If the target p... |
This table simply contains date information. I went ahead and used what I currently have since this is a one-time operation. However, since I only recently started working with Oracle, I would like to learn about all its different features and such.
The code is trying to establish if it is a business day or not while i... |
I'm reading Real World Haskell, and this is my first try with the language.
This is the result of the exercises of chapter 3:
Consider three two-dimensional points a, b, and c. If we look at the angle formed by the line segment from a to b and the line segment from b to c, it either turns left, turns right, or forms ... |
I have JSON object response returned from the server which is similar to this one:
{
"id": 123,
"from_id": 234,
"attachments": [
{
"type": "audio",
"audio": {
"artist": "Van Halen",
"title": "Eruption"
}
},
{
... |
I wrote simple TCP Client Server application, I was wonder could you please review my code. I would be grateful for any hints and tips regarding to logic of app, coding style or naming convention.
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;... |
Continud from Playing “craps” for the win v0.2
You roll two dice. Each die has six faces, which contain one, two,
three, four, five and six spots, respectively. After the dice have
come to rest, the sum of the spots on the two upward faces is
calculated. If the sum is 7 or 11 on the first throw, you win. If the
... |
Right now I have this messy method to collect the deck statistics while building a window that will display those statistics. These statistics are things like the type and mana cost of the card. I know that this method is too large, so I would like to get some advice for how to make it smaller.
The challenge is that ... |
Yesterday and today I've been working on an auto-update system for a game project. I've just pushed the server-side script to the server, and it seems to work great. Since this is public-facing code, though, I certainly wouldn't mind a few more eyes on it before I actually deploy it and changes get exponentially more p... |
I have a really basic image carousel that I just wrote.
Basically I'm trying to keep it as small and light weight as possible, but I get the feeling that I've gotten way off the beaten path of how these things normally work.
function hide(element, index, array) {
if (index > 0) {
slides[index].setAttribute('st... |
This review is in continuation with Part I mentioned in query.
As part of the assignment given in Part II from this link, here is the solution:
Ocean
/* Ocean.java */
package Project1;
/**
* The Ocean class defines an object that models an ocean full of sharks and
* fish.
* @author mohet01
*
*/
class Ocean {
... |
This is my first cut at separating the data access layer out of my very old spaghetti codebase.
I have tried to keep this as simple as possible, it is for a small project, so I am not really interested in learning Spring or Hibernate or other framework, and I don't mind writing a bit of SQL.
I basically have a 1-to-1 ... |
Problem Statement:
Create a class diagram and Java code for the following system and
scenario, taking into account the possibility of future extensions.
"The system is a command line utility that prints a short 'quote of
the day' on the user's terminal when run. To begin with the quote is
selected randomly f... |
I want to learn Haskell and figured the best way to do it is to write a simple TicTacToe implementation. However the result feels very inelegant and I think it might be the best playground for your rants and give me an opportunity to learn some lessons.
{-|
TODO: -filter symmetric states from game tree
|-}
module Tict... |
Currently I'm overriding create and write to copy the fields onto the partner, is there a cleaner way of updating the partner on save?
@api.multi
def create(self, vals):
if vals.get('allergy_ids'):
self.add_partner_allergies(vals.get('allergy_ids')[0][2],
vals.get('partne... |
I am trying to implement the Dijkstra algorithm in C++ that finds the shortest path for a graph from a text file. The text file contains a matrix that represents a directed graph.
What I am trying to do in this code is use every vertex as the source. I finished the code but I am still very skeptical if my code is righ... |
I have an interface IFilter and more types of filters: Filter1, Filter2, Filter3; that I want to call one after the other and if the result of one is empty, then I want to stop the process. For this I have thought of:
class FiltersSequence
{
private:
std::vector< IFilter > m_filters;
public:
FiltersSequence();... |
I have completed working on my own pure JavaScript Slider library and would like to get some input from other developers. I would like to know how you would improve the code in any way.
( function( window, undefined ) {
function Slider(el, opts) {
/**************
GLOBAL VARS
***************/
var that = this;
//co... |
I am using Java to modify remote files in different machines by ssh. At the same time, only one thread is allowed to modify the file in one machine.
I implement the logic like this:
public boolean executeCmd(String ip, String command, String file) throws Exception
{
final String file = ip + " " + file;
final S... |
In my application, we have a number of pages which provide an advanced search capability, with a large number of potential search options (some pages have as few as 3, some as many as 150).
The HTML for the page is generated with a standard .aspx page, and the search criteria themselves are stored in a DTO which is the... |
I will like to improve my code in Java involving creating simulations and games. This is a problem-solving code so far in interest and percentage calculations.
import javax.swing.JOptionPane;
class interest {
public static void main(String[] args){
String name = JOptionPane.showInputDialog( "Item" );
... |
I have a data set returned from an SQL database contained below, as you can see all data remains the same apart from one property, "name_alt".
[{
"language_id": "tly",
"language_name": "Talysh",
"speakers_native": 800000,
"total_speakers": 912000,
"name_alt": "Taleshi",
"country_main": "az"
}, ... |
I have a NodeJS stream.Readable, ArticleReader. Its job is to read articles, Meantime I have to give it a date to signify the date of the articles, say the default date is today, now I start reading with .on('data') event, and the stream ends. Later I want to change the date and start reading yesterday's articles. In w... |
Is it good to have this:
if(DataHolder.i().getLoginParamInfo().equals(LoginState.stateLoggingIn)) {
getView().findViewById(R.id.login_button).setEnabled(true);
}
else {
getView().findViewById(R.id.login_button).setEnabled(false);
}
or this:
getView().findViewById(R.id.login_button).setEnabled(DataHolder.i().ge... |
I'm using the script below to import a large .csv file to my database. If the table is empty the process takes about 5 minutes to finish on a local machine. If I'm using the file to update existing values on the same table it takes more than 15 minutes to finish. My .csv file contains about 35,000 rows.
How can I speed... |
I came up with this TSQL for SQL Server 2008:
DECLARE @TimeWindowInSeconds INT
SET @TimeWindowInSeconds = 10
IF OBJECT_ID('tempdb..#Temp') IS NOT NULL
DROP TABLE #Temp
CREATE TABLE #Temp
(
Class INT,
DT DateTime
)
INSERT INTO #Temp (Class, DT)
SELECT 1, '2014-11-05 10:55:00'
UNION ALL
SEL... |
def factorial(t,n):
if n == 1 : return t
else: x = (t * (n-1))
n = n-1
return factorial(x,n)
print factorial(6,6)
I can't seem to figure out a way to just stick to requiring one parameter input while keeping the program small. I also want the function to remain recursive (trying to work on my rec... |
I wrote an application which runs correctly, but I just want to have some feedback on it. Is there something unnecessary, or could there be something more pythonic, or did I write some code which Django could cover in particular cases?
views.py
from program.models import contract, cert, user, rdp, server
from django.ht... |
How can I refactor my code to remove the label and the need for it? I am aware that a loop with label is "forbidden". But I can not find a way to rewrite this without the label.
private List<myList> sortLinks(SegmentType s, Set<myList> LinkSet) {
List<myList> LinkList = new LinkedList<myList>();
String... |
GUI-based pseudo-random password generator. Modification of this app, improved according to suggestions from Code Review users. Additional feature: calculation of time to crack password on average desktop PC, which is determined as time to go through all possible combinations of characters.
Ideas for further improveme... |
I work quite a lot with file reading and writing in C/Win32 and I started wondering if my code is completely ugly and how I can improve it. I wrote two simple examples of reading a file, and I wonder how these functions could be improved. Are these methods bad - and how they can be improved? I use MSVC so the code migh... |
I'm going to be opensourcing some code I'm working on. I don't need help with the code, I just want to make sure my code is readable and my comments make sense. I have a knack for the esoteric. This code is to control GE G35 Christmas lights using a Netduino controller. Due to the .NET overhead, I've written a custo... |
I have the following working code to send search results via e-mail. Since we have segregated domains that cannot talk to each other, the program needs to support multiple SMTP servers.
private static int[] _SMTPport = new int[2] { 25, 587 };
private static string[] _SMTPserver = new string[4]
{
"smtp.domain1.local"... |
I would like to have a class which supports outputting bits into a file. This is what I came up with but I fear there are many poor decisions. Should I inherit from a std::ofstream instead of keeping it as a data member?
class OFBitStream final
{
static const std::size_t bitset_size = 8 * sizeof(unsigned long);
... |
If you work with a database that you only have access through a web interface, this one is for you. You probably don't have access to any programming languages other than VBA through MS Office, which I 95% guarantee you do have.
Since we will be controlling an external instance of Internet Explorer, you will need to r... |
I written a Tic Tac Toe game, which allows you to play against another person or the AI (The AI can also play against itself, which should always result in a tie).
The AI uses the Minimax algorithm to pick the best move. I'm not very experienced with Python, so I'm wondering if my code uses any bad practices and styles... |
I decided to make a program that calculates change, based on an input. My code is extremely long, and I would like to know how I can fix this.
def make_change(amount)
values = []
coins = []
hash = {}
if amount >= 50
coins.push(:H)
values.push(amount / 50)
amount = amount % 50
if amount % 50 >= 2... |
I have finally been able to create my little navigation plugin in an object-oriented way that reads the li from a JSON file.
Now, is my code efficient? Especially, the click function within getRegion function?
Is this the correct way to handle the click events in OO?
Here's is working version: PLNKR
'use strict';
if (t... |
I don't use constraints or IB to create views so it's easier to create rects this way. Does it wrong totaly?
@interface Client ()
@property (nonatomic, strong) UITextField *name;
@property (nonatomic, strong) UITextField *phoneNumber;
@property (nonatomic, strong) UITextField *address;
@property (nonatomic, strong) UI... |
I'm looking for some general feedback on my solution to Project Euler challenge 3
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest
prime factor of the number 600851475143 ?
let p3 () =
let rec primeFactors n i primes =
if i > n/2L then n::primes else
let quotient, remain... |
How can I improve this main game loop that monitors and displays frames per second?
public void run() {
running=true;
initengine();
initgame();
//Initialise game loop
long looptime, difference=0,timetaken=0;
int frames=0;
fps=0;
//Main game Loop
while(running){
while (tim... |
I am trying to apply certain random deduction pattern to different lists - different in items but having the same numbers of items. I wrote this code - I know it is pretty messy- but it seems it does the work. Please help me to make it better. To explain, better the base list changes each time the random pattern applie... |
I'm doing a challenge on TalentBuddy that requires you to find the powers of multiple array pairs. Since I got the solution right, but not fast enough, I decided I'd ask for help here.
def fast_power(a, b)
pairs = a.zip(b)
pairs.each {|p| puts (p[0] ** p[1]) % 4211}
end
a1 = [long array with 5000 elements]
b1 = [L... |
Implementation:
string Add(string a,string b)
{
int maxLen = Math.Max(a.Length,b.Length);
a = a.PadLeft(maxLen+1,'0');
b = b.PadLeft(maxLen+1,'0');
int[] arr1 = a.Select(x => int.Parse(x.ToString())).ToArray();
int[] arr2 = b.Select(x => int.Parse(x.ToString())).ToArray();
int[] sum = new int[a... |
This is what I came up with:
Version 1:
static double Integrate(Func<double, double> f, double low, double high, double delta)
{
return Enumerable.Sum(Enumerable.Select(Enumerable.Range((int)(low / delta), (int)((high / delta) - (low / delta))), c => f(c * delta) * delta));
}
If I'm allowed to use a helper-method ... |
I have a form that submits to a registration Servlet, which inserts a new user to the database when they sign up to the web application. Depending on the erroneous user input, the Servlet will sendRedirect() to a result page, telling the user what went wrong.
Servlet: doPost()
protected void doPost(HttpServletRequest ... |
How could I improve this working Perl script, which changes my desktop background to the next available one, without opening a terminal? Specifically, how could I iterate over my .fehbg and walls/ lazily, without reading them into arrays? I couldn't find a way to do that; I need the for loops.
Other than that, are t... |
I've written a minimal unit test framework. The goal was to allow assertions of booleans, for equality and catched exceptions. Two things are bugging the most. That assertions have to rely on macros and using a function pointer type instead of one of the more modern C++ ways. Are there ways to further minimize? What C+... |
When sieving primes up to some 64-bit number n I need to determine an upper bound for the greatest potential factor of n, which is the greatest integer that is not greater than the (true) square root of n.
Computing this as std::sqrt(double(n)) is fraught with pitfalls. The standard IEEE double has only 53 bits in its... |
In JavaScript we can write callback definition in many different ways:
Definition after usage:
var fs = require('fs')
fs.readFile('movie.mp4', finishedReading)
function finishedReading(error, movieData) {
if (error) return console.error(error)
// do something with the movieData
}
Definition before usage:
var fs ... |
Here is a program for converting Impute2 files into MaCH format (related to genetics).
Source files include one xxx_haps file and one xxx_samples file, for example:
// chromosome21.gen_haps
--- rs62224609 16051249 T C 0 0 0 0 0 0
--- rs62224610 16051347 G C 0 1 0 1 1 0
--- rs143503259 16051453 A C 0 0 0 0 0 0
--- rs192... |
My girlfriend and a friend started a Kiwanis club around here, so I figured it would be a good opportunity to try coding my first website. I'm pretty new to coding still and it's pretty basic, so I'm just looking for general pointers or any bad practices I may be doing.
GitHub
<!DOCTYPE html>
<html lang="en">
<head>
... |
For our Cardshifter Project we wanted to be able to load card definitions from file.
A card is defined as:
Having an unique id.
Having a set of resources, which are integers identified by a string.
Having a set of attributes, which are strings identified by a string.
In the implementation every card gets mapped to an... |
I'm writing a Java Servlet application where the users must enter information about a business. I'd like to prevent as many duplicate entries in the MySQL database as possible and I'd appreciate people's comments on the logic of the process.
When the user fills out the form and submits it, the business name and addres... |
I'm wondering if this is good design, or if the definition of the __init__, __call__, and __repr__ methods should be inside of mesh_class_meta itself instead of inside of the factory, mesh_class.
If it is better to for them to be defined inside of the metaclass definition, please explain specifically why? Or is there ... |
My friend wanted me to send her a list of songs from one of my iTunes playlists, so I exported the playlist within the app itself. It comes as a plain text file, where each field is separated a '\t' and each line is separated by a '\r'. Since there is so much extraneous information, I decided to write a Python script ... |
I have a question about using an IDisposable object in the ThreadStart function. I have a class that derives from ServiceBase:
public class ServiceTest: System.ServiceProcess.ServiceBase
{
private System.ComponentModel.Container components = null;
private System.Threading.Thread m_cProcessThread;
p... |
Given an array of numbers and another number k, how can I find the number of 2 elements such as their difference is equal to k?
def pairs(n,k)
n.combination(2).select{|x|(x[0]-x[1] == k) || (x[1]-x[0] == k)}.count
end
I ran a test where n was an array of 8000 different 10 digit numbers.
However, this took about 30 s... |
I've got a Backbone.Collection which looks like this:
define([
'background/mixin/collectionMultiSelect',
'background/model/searchResult'
], function (CollectionMultiSelect, SearchResult) {
'use strict';
var SearchResults = Backbone.Collection.extend({
model: SearchResult,
mixins: [Coll... |
I made another markdown parser. (original, this one on github). Look, I'm not crazy (sorta), I just like making markdown parsers…
String.prototype.replaceAll = function(find, replace) {
if (typeof find == 'string') return this.split(find).join(replace);
var t = this, i, j;
while (typeof(i = find.shift()) ==... |
I've come up with the following code to generate a list of all dates between two given dates:
def generate_all_valid_dates_in_range(_start_date, _end_date) when _start_date <= _end_date do
(:calendar.date_to_gregorian_days(_start_date) .. :calendar.date_to_gregorian_days(_end_date))
|> Enum.to_list
|> En... |
As some of you know, I have been working with Gray codes and am trying to design a good gray_code class in modern C++. I will end up posting several parts of the implementation, but what I want to be reviewed is mostly the addition function. Anyway, here is the code of the class essentials:
template<typename Unsigned>
... |
A more up-to-date version of this control can be found on GitHub.
One UI control that has always been mysteriously missing from Xcode's interface builder is some sort of checkbox. UISwitch is available, but this isn't always quite the feel you might want. It's particularly mysterious that any sort of check box is mi... |
Today is the first time I've used Linq, so I wanted to get a code review on this and make sure I'm going about it correctly.
I'm filling text boxes and dropdown lists from a table row.
protected void Page_Load(object sender, EventArgs e)
{
using (DBContext da = new DBContext())
{
... |
Motivation: for whatever reason, some of the available 3rd party logging libraries don't really deal with programs that get fork'ed/exectuted well. For instance, boost::log creates some static state that can cause deadlocks if the program using it gets forked.
This class attempts to be a simple logger for programs th... |
My teacher often tells me that I don't take full advantage of Python capabilities, I would like to know if my implementation of Quicksort is good enough and how could I improve it, aside from doing it in-place
def quickSort(l):
if len(l) > 1:
l,iPiv = partition(l)
return quickSort(l[:iPiv]) + [l[iPi... |
I wanted to try using CRTP (also new for me) to try making the loading of shared resources implicit. (Specifically I'm using it for loading OpenGl shader programs)
This will also help separate some of the boiler plate setup code (combining shaders into a program) from the more specific setup code (assigning locations f... |
Question:
Given two users say user1 and usern, print True if there was a chain
of tweets such that user1 tagged user2, user2 tagged user3 .....
usern-1 tagged usern or viceversa.
Input Format
The 1st line and the 2nd line contains the two users. The 3rd line of
the input contains the filename in which the datase... |
I'm trying to design a model for purchasing amounts of products in F#, following the ideas for designing for correctness (source). The idea is to use the type system to capture the different legal states, making it impossible to represent invalid states as defined by your requirements.
Since I'm not too experienced wit... |
I'm trying to show a table, for each ID, to see if there is data available. In this case, its measurements. If there's no data, that means the logger isn't doing its job properly.
I currently have two tables: data and times. data contains id, datetime, sensor_id, and value. times contains id and value.
Times is filled... |
I've been reading up on different design patterns, mainly MVP and different adaptions of this design pattern / architecture.
Now, I've decided to have a little play with my own ideas, the main outcome separating the user view, from the actual modelling which does all the data changes.
The example is simple, the user is... |
I want to replace the fifth space in a sentence with a new line. Sample input:
"Hi this is empty string. This should be in new line!"
Expected output:
"Hi this is empty string.
This should be in new line!"
I'm getting the expected output with this code, but I need to know, is this the optimized solution or there ar... |
I have a map whose values are case classes, and I want to access one parameter of that case class with a default value if they map doesn't contain the provided key.
myMap.get(myKey).map(_.valueParam).getOrElse(defaultParam)
intellij-scala suggests that this is a "simplifiable operation on collection” -- is there a mor... |
My code in my main background async task is a mess. Everything is everywhere. I'm afraid of moving things around without something breaking but I definitely think it needs work.
What I can do to make it more condensed, cleaner and refactored?
Here's the bulk of what I want to have judged as code review/ refactoring: ... |
I am trying to optimize my Java code where I am parsing an address field.
Address fields have the format:
full_address;phone; full_address;phone; full_address;phone;
where full_address = addresstype^street^city^state^zip
and where street = street1;street2;street3;street4;
So my string is
final String string = "Billi... |
I feel like there is a code smell in this. Can someone help me to refactor/optimize it?
protected TimeZone resolveTimeZone() {
IUserPreferences preferences = userProfileService.getCurrentUserPreferences();
if (preferences != null) {
String timeZone = preferences.getPreferredTimeZone();
if (timeZ... |
I've made a simple game for testing math facts (think practice for elementary school-age kids). It displays a random addition, subtraction, multiplication, or division problem, and feedback on if the right answer was entered.
For now it works interacts with the user via prompt(), but I plan to add a GUI later. You can ... |
I've added the code for an abstract thread class and 2 sub-classes. The structure and job of the threads (sub-classes) is identical except one difference: ONE of the sub-classes, RefreshData does not need the client parameter. I've overloaded the constructor in the sub-class but I'm not sure if the abstraction makes se... |
I'm trying to run the method below against a very large corpus and I need to optimize/reduce the run time for this method as it already takes up about 6 seconds to execute.
Requirements:
Check the word only consist of alphabets, hyphen and apostrophe
First character of word must be alphabet
Last character of word must... |
Given the code below, I'm curious to know if you'd have better naming suggestions for types:
VegetablePresentersFactory
VegetablePresenterFactory
It bothers me a bit that their names only differ by a single character ('s'), and that this character is located in the middle of the name.
class VegetablesApp {
priva... |
I know my question sounds strange but I have a situation in which I have Parent Data which can have 'N' Childs and each child can further have N-Childs and so on.
So its Like.
Parent
a. Child
i. Child
ii. Child
b. Child
i.Child
I hope I've made myself Clear. So here is a snapshot of the Database Table:... |
I have this JavaScript function which checks if the format has 'yyyy' and replaces 'yy' with 'y':
function validateDateFormat(format) {
if(format.indexOf("yyyy") != -1)
return format.replace(/yy/g, 'y');
else return format;
}
I feel like it can be simplified further. Can someone help me to refactor/opt... |
I figured this morning that I wanted to learn how to use SASS, so I decided to rewrite an existing project's CSS using SASS. The project itself isn't complete so this is just a rough draft of the final code.
What I'm looking for here is to know what I'm doing well and what I'm doing wrong. If I know what I'm doing wel... |
I currently am making a small application where a user will enter their ID which needs to be in a certain format. When entered in the wrong format, different output errors are produced.
I currently output errors like this:
public void errorLogger(string error)
{
errors += error + Environment.NewLi... |
This won't be released publicly, but that doesn't mean I want to have bad coding habits. I was not too far into this before realizing I could make it better. One of my main concerns is finding an alternative to the if statement halfway down. The toast message is temporary as I was having trouble with something earlier ... |
You give this function a pointer and how many bytes you want to extract as a decimal and it returns it.
long long
byte_extract
(void * source, size_t bytes)
{
long long num = 0, m = 1;
size_t i;
for(i = 0; i != bytes; i++)
{
num += (((unsigned char*)source)[i]*m);
m<<=0x8;
}
ret... |
I have a set of views and view models in my project. There is a one-to-one mapping of views and view models, so each view requires a particular view model. I'd like to instantiate a series of views given a collection of view models.
Here's what I've come up with:
public class OverlayBundle : DrawingVisual
{
private... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.