instruction stringlengths 71 71.9k |
|---|
I've coded this class that lets me search through an ArrayList displayed into a RecyclerView. This is the class:
public class SearchActivity extends AppCompatActivity {
ArrayList<Accordo> chords;
RecyclerView rv;
SearchView sv;
ArrayList<Accordo> filteredList;
@Override
protected void onCreate(... |
Recently, I wanted to change my vim colors to something new. So I went to the vim colors website and then I decided that I wanted to download ALL the colors.
So I wrote this simple Python script that will download all the files from: Vim Colors
I'm still learning Python and it would be amazing to get some feedback / s... |
For a set of 2D or 3D points \$\{\mathbf P_0, \mathbf P_1,\cdots,\mathbf P_n\}\$, their parameters \$\mathbf T = \{t_0,t_1,\cdots,t_n \}\$ could be computed as follow:
$$\begin{align}
t_0&=0\\
t_i&=\frac{\sum_{j=1}^{i}||\mathbf P_j- \mathbf P_{j-1}||}{\sum_{j=1}^{n}||\mathbf P_j-\mathbf P_{j-1}||} \qquad i=1,2,\cdots,n... |
This program is basically a rhyming dictionary. It makes use of Sphinx's groups phonemic dictionary of English which includes a lot of words broken into their respective phonemes, and if we assume that, at least for most cases, anytime the two last phonemes match, the two words rhyme, then it's very easy to whip up a p... |
I have a JSON file like
{
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "RESOURCE_NAME",
"Type": "A",
"TTL": 60,
"ResourceRecords": [{
"Value": "RESOURCE_HOSTS"
}]
}
}]
}
where I need to repl... |
This is in continuation from the project posted here: Making a report from payroll details part II
Basically, based on the user input in columns F, G, H, the macro generates a varying string in column I.
Eventually this spreadsheet is combined together in a mail merge in Microsoft Word (if anyone knows how to do that i... |
I have written a program to generate a pascal triangle of predefined size.
Code
#include <stdio.h>
#include <assert.h>
#include <pthread.h>
#include <gmp.h>
#define N 50
#define SIZE(x) (((x) >> 1) + 1)
#define NTHREADS 8
int min(int a, int b) {
return (a < b) ? a : b;
}
mpz_t row[2][SIZE(N)];
typedef struct ... |
I have a very simple directive <my-card> that lists out some data.
Example Usage
my-card(ng-repeat="item in parentCtrl.items" item='item')
The only main functionality I have is a button that toggles some additional data.
Here is my directive/controller definition. Should I use the link function instead of creating a c... |
Inspired by a previous question, I was looking into converting a table to a sorted list (ascending) -
Resulting in this -
I used a very simple bubble-sort, but I don't know how efficient that would be with larger data sets, either in records or if I wanted to sort on more than one condition. Basically, this was an ex... |
This is a follow-up review request to the first one for this same utility/file/script. The first review can be found here: Cross-platform file hash sum generator in Python
I'm back with the modified version of this script/utility, looking for some more follow up on the original review.
This iteration of my hash sum ... |
I was doing a programming challenge and the object was to validate an email address, I wrote a simple little email validator and would like some input on how I can make it more efficient.
How it works, it has two validations, one with a regex, and one validating the length (most email addresses are over 12 characters, ... |
Recently, I was burdened with the task of finding a bug. It turns out the problem was strings from different systems containing different newlines. Comparing two strings with different newlines (but same "text") still are not equal. E.g. "new\nline" (Unix flavor) and "new\r\nline" (Windows flavor) are not equal.
Since ... |
I am updating a class in legacy code and having some issue with my calcPressure method. I want to make it nice and clean but there is some convolution in the process.
Namely the calcPressure method I have does this:
computes a value from existing values
writes that value into an in-class parameter
returns the value ... |
I wrote a bash script for the Raspberry Pi 3 (Raspbian) which has the main task of setting up a LAN to WLAN router. In addition it makes some things nicer for the intended users who have Windows background only. It will be used on a Pi 3 with built-in WLAN and the official 7" display only.
Preconditions to run the scri... |
I'm doing Python programming challenges and have come across one where the object of the challenge was to create a script to change passwords. The script must validate that the password contains, one upper, one lowercase, and one number. After everything has been validated the script should save the password to a text ... |
This code copies files to our Test server and places the executable on a file share for the tester to access. I'm new to Powershell, so I'm sure I'm not doing this in the most efficient way. Any criticisms would be appreciated.
# the destination that we are copying TO.
$codeToDeploy = "\\deployment_server\App-Shares\... |
Can someone please take a look at these recursive functions, offer some advice on the code, or just critique my attempt into thinking recursively?
Problem:
We’ve seen that % (the remainder operator) can be used to test whether a number is even or odd by using % 2 to see whether it’s divisible by two. Here’s another w... |
Preface
I was trying to review this question on the same topic, but in the end many points I wanted to make were excellently explained by @ferada so I felt that posting my code and explaining the concepts around such changes would just be repetition.
Instead I am questioning whether my approach is over-engineered consi... |
I receive a weather forecast for 5 days, but in 3 hours intervals.
This classes represent the weather forecast:
public class Forecast : ILocation
{
[JsonIgnore()]
public string City { get; set; }
[JsonIgnore()]
public string Country { get; set; }
[JsonProperty("list")]
public IList<WeatherTimePo... |
In an attempt to hide from the sun outside, I gave the community challenge "Rainfall" a try.
Code here, specific questions below.
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.stream.Collectors;
public class RainfallChallenge
{
public static void main(String[] arg... |
I'm writing C# applications that store their data in MS Access databases, (I'd rather use a different type of database but currently have no other option).
The applications are in use by multiple people at a time and so when there are multiple connection attempts (or someone mistakenly opens a table), some of them fail... |
I'm making a program where I need to check if files in the directory are correct (46 files and all 11 chars).
I've got two methods to do it but I don't know which one is better.
Using opendir/readdir:
int checkfiles()
{
DIR *dir;
struct dirent *dp;
int count = 0;
if ((dir = op... |
What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the [provided] 20×20 grid? [source]
This solution works, and works effectively instantly.
The algorithm is \$ O ( n ) \$, as it loops through the entire field a total of four times.
However, it seems ... |
I have put together a stored procedure to load and parse the Stack Exchange Data Dump into a relational database (akin to Stack Exchange Data Explorer). Each site has 8 XML files like these:
The stored procedure below performs the following steps:
Fetch the Badges.xml file for the target site from the local file syst... |
I'm trying to pass my logger to a Logging Aspect that I've created with PostSharp. I have one logger per job run (because I need to send each job's logs to different folders), each job runs in different threads using BackgroundWorker. This is the code that I have:
[Serializable]
public class LogExecutionTimeAttribute ... |
The task is to provide a function that returns the earliest time point when a worker is allowed to start duty.
The function uses two parameters:
Time stamp when the rest starts
The number of local nights which is necessary according to a table
I wonder if there is anything wrong with void convertTimeStructToLocalTime... |
I'm working on load/save application sessions functionality, and came up with this code:
public class SessionManager
{
private static ISessionStorage storage = new DbTableSessionStorage();
private static StudySession session;
public static StudySession Current
{
get
{
if (ses... |
I'm fairly new to python and decided to build something useful (I believe). So I made this script to track changes in user's files with DB with ability to "Accept changes", so end-user might track which files were removed/added/changed. This db then is being used in Django project.
Any help will be greatly appreciated,... |
I calculate the moving averages of a specific measure. However, multiples threads can access this class in order to compute the average.
public class AvgUtils {
/** The alpha. */
private static final double ALPHA = 0.9;
private double avgOldValue = 1.0;
public synchronized double computeAvg(double p... |
The task at hand was to ensure that certain columns in the database are encrypted in case the database data is stolen. I have a feeling that a lot can be improved here (naming, DSL, encapsulations) while keeping the functionality as simple as it is. Let me know what you think, I'd appreciate any suggestions and ideas!
... |
Is there any way that I can improve the performance of my x12_reader? The main functions that seem to be the bottlenecks are read_line() and get_element() they are both called upwards of millions of times.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
n... |
This is a list class which allows users to "turn" the list while keeping track of the current position.
For efficiency, the list is not actually rotated on each rotation, but instead an offset keeps track of where the "0" in the list is. However, this makes addition and multiplication less efficient as these operations... |
I've implemented a VHDL program that sums up the positions of switches and shows it on a 7-segment LED, but I've had to use lots of temporaries and a division. Is there a better way?
library ieee;
use ieee.std_logic_1164.all;
entity light is
port(
LEDR : out std_logic_vector(0 to 9);
LEDG : out std_l... |
This file contains the main functions of my tool, rac. In particular, I care a lot about the Shannon function.
Would you please give some hints to make the file cleaner? I have a perversion for concise and good indented code.
#include <math.h>
#include <stdio.h>
#include "headers/utils.h"
double ccount(char * foo)
{... |
I am using SharePoint 2010 and get values from a list using the code below.
It might be called like this: getValueFromList("addresses", "secondName", "city", "manhattan");
It will return the "secondName" of the first entry that has "city = manhattan". Is there a way to make it more efficient?
private string getValueFro... |
I have implemented the Gabor Filter of which I provided the source code as bellow.
The code is deadly slow.
Applying the filter on a grayscale image of Lena 512x512 takes 7577 milliseconds.
And the filter bank (12 filters) freezes and doesn't even display any value.
Source Code:
Gabor kernel,
public class GaborKernel... |
While trying my hands at the beginner codechef problem I came across this . So basically doing that problem with Dynamic programming is an overkill but why not try that and get some DP practice.
Nice, I almost solved that problem in minutes but the problem is this takes too much memory , and ends up with a Segmentation... |
I have the use case of needing to find the parent path of a sub path for which I have written the following function:
#! /usr/bin/env python3
from os.path import sep
def pathbase(main, sub):
if main.endswith(sub):
parent = main[:-len(sub)]
while parent.endswith(sep):
parent = parent[... |
Some context: I have some existing code to populate network header structs from istreams. A motivating excerpt:
struct l2_eth_frame {
using mac_address_t = std::array<std::uint8_t, 6>;
mac_address_t dest, src;
std::uint16_t type;
std::uint32_t vlan;
};
template<typename StreamLike, typename T>
void rea... |
This time, I have rewritten my radix sort implementation from C++ to C:
integer_sort.h:
#ifndef INTEGER_SORT_H
#define INTEGER_SORT_H
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
void int32_sort(void* base,
const size_t num,
const size_t size,
... |
I am looking for suggestions of improving this function to check whether a memory address is appropriate or not.
def isweird(addr, cpu_name):
"""Check if a memory address is weird
Args:
addr (str): a memory address
cpu_name (str): cpu name
Returns:
bool: True if the address is weird
... |
Can this if-else statement be simplified and/or cleaned up?
var path = require('path')
var express = require('express')
var app = express()
app.get('/*', function (req, res) {
var page;
if (req.params[0] === '') {
// if requesting root dir, add `index.html`
page = path.parse(path.join(__dirname, 'index.html... |
I've got some experience with Laravel but for fun I started a small project (basically a CRUD with also Google Maps) without a framework because I considered that is oversized.
This is the directory structure.
+---assets
| +---css
| +---img
| \---js
+---classes
+---inc
| +---templates
| \---views
| \---... |
I recently posted a program that I wrote that would change a password after being validated, the program can be found here.
I have rewritten this program, it has a couple new features:
Usernames
Decryption
Program related errors
How it works. At the beginning of the program you asked to make a username, that username... |
I wrote a function that will pixelate an image using the average color of each 4x4 cell.
The function will "split" the image into 4x4 cells, and find the average color of each pixel in the 4x4 cell, and set the 4x4 cell to the average color.
I'd like some help optimizing my function so it can pixelate an image as fast ... |
Let’s say we copy some file using retry strategy (it might be blocked, etc.):
class Processor
{
public void CopyData() =>
CopyData(Try.Slow);
public void CopyData(Try loop) =>
loop.Execute(() =>
File.Copy(@"c\a.txt", @"c:\b.txt"));
}
What do you think about names chosen for the fo... |
In this code, I tried to integrate my little knowledge of (and great fascination towards) functional programming. I'd like to make this code more functional, and faster, if that's possible.
'use strict';
var insert = require('./insert');
const STEP = 50;
const WIDTH = 200, HEIGHT = 100;
var ptr = [[0, 1, 0, 0, 0, 0,... |
Suppose I have a string with a length always a multiple of four:
'CodeReviewSE'
My goal is to create a permutation. First, I arrange the string into a matrix (where each row has a length of 4):
C o d e
R e v i
e w S E
And then I simply read down, starting from the top-left corner. I get four segm... |
I'm making an experimental Java algorithm that translates binary data from a file into a (very large) base ten integer. I am using BigInteger since this number may have millions of digits. I am trying to translate this number into a sum of powers of 2.
I tried this code, which theoretically works, but is sluggishly slo... |
I have an algorithm for generating permutations in Python
from collections import Counter
def permutations(A):
def permutations(A):
if len(A) == 0:
return
if len(A) == 1:
yield A
else:
for i in range(1, len(A)):
for p in permutations(A[i:]... |
I was inspired to throw this class together by an SO question and thought I'd subject it to some welcome criticism here.
The class is basically just a wrapper around the shell utility dir, and is intended as a replacement for the built in Dir$ function. The rationale for replacing the function is that it has many mo... |
I'm trying to measure the time taken to copy a std::vector<someObject>. Would like to know if this is a correct approach. I tried to do some trivial computations on the copy to prevent the compiler from optimizing out the copy. Should I explicitly write a copy-constructor?
#include <iostream>
#include <new>
#include <c... |
I've been trying to look for a better way in which a user has up to 5 inputs in which they can search for results in a database.
I have 2 EditTexts in which the user can have alphanumeric values and 3 Spinners. As you can see in the code, it's badly designed in the way it consists of if or else if statements which is j... |
I wrote a simple console application that reads contents from a CSV file, and using that input, checks a database table to see if the contents are within it. If there is a match, then the program will output the name of the file that the input is included in to a text file.
I feel like I should break this application u... |
I made a small program that tests numbers against some properties:
Welcome to Numbers!
Is it odd? 4
No
Is it a multiple of 18? 38
No
Is it big? 100
Yes
That's basically it :)
My code is:
import System.IO
import Text.Read
askUser :: String -> IO Double
askUser str = do
putStr str
num <- fmap readMaybe getLine
... |
I recently posted this script:
VIM colors downloader in Python
But since I'm not allowed to update the code there, I wanted to get an idea on this version, that uses multiprocessing:
import os
import json
import requests
from bs4 import BeautifulSoup
from multiprocessing import Process
class Spider:
def __init__(... |
I am trying to apply this simple macro to merge two big sized sheets (around 30000 rows each), but the process is too slow and never ends. The macro works perfectly with smaller sheets. Could you give me any advice for the optimization of my code please ?
My Macro consists in an Userform :
Public listChoice As String
... |
I recently was playing around with the idea of having an image appear when the user scrolls and came up with the following. Is there a better or more efficient way to do it?
var pastScroll;
jQuery(document).scroll(function () {
var currentScroll = jQuery(document).scrollTop();
if (pastScroll == currentScroll) ... |
Two quick notes: I'm targeting 4.5, and the server already has newtownsoft's json library. I'd prefer not installing anything additional on the server.
using Newtonsoft.Json.Linq;
using System;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Thread... |
I have been tinkering with various ways to clean this up and I was wondering if it is more ideal to break this into small methods or way to accomplish this on a single line?
def run_counters
@num_attempts ||= 0
@num_attempts += retry_attempt
@all_attempts ||= 0
@all_attempts += retry_limit
end
|
I am picking up a code smell from this code and I am not sure of the best way to rid myself of it.
I have a validation class that has a function that returns a list of IValidationRule<T> implementations (RuleOne, RuleTwo, RuleThree).
public interface IValidationRule<T>
{
ValidationRuleResult Validate(T instance);
}... |
So someone challenged me to write FizzBuzz using CSS only. This was the best I could come up with, but I think the "divisible by 5, not divisible by 3" CSS rule is a bit clunky. So I'm looking for advice to provide a more readable and maintainable solution.
ol li {
list-style-type: none;
counter-increment: listCo... |
There are frequently things I miss when using C; one of them is a nice error-handling (exception-like) system. After trying Rust, I realized I could implement something similar in C itself. So here's my attempt at writing a Result type in C.
The idea of the Result type is similar to that of an Optional type: if the val... |
This is a bot for Twitter where you can upload an excel file with text in as many rows as you want but in a single column and it posts every row as a tweet every certain time.
It stores the credentials in another Excel file, I know this very insecure but I couldnt find a better way to do it, if anyone has a suggestion ... |
Previous version
Now supports async operations and cancellation.
Let’s say we copy some file using retry strategy (it might be blocked, etc.). App code comes bellow:
class Processor
{
public void CopyData() =>
CopyData(IOTry.Slow);
public void CopyData(Try loop) =>
loop.Execute(() =>
... |
This is probably my final submission to Code Review regarding this making a report from payroll details series. Basically, working in the human services sector, the funding agency requires A) Weekly documentation of services provided and B) Monthly documentation of general progress for each of 60+ developmentally disab... |
I would like to know if this is a good way to make sure the user enters a valid number.
#include <stdio.h>
#include <ctype.h>
void clear_stream(FILE *in)
{
int ch;
clearerr(in);
do
ch = getc(in);
while (ch != '\n' && ch != EOF);
clearerr(in);
}
float retreive_input()
{
float input = 0;
... |
I am developing WPF application keeping MVVM and using Prism. Here is simplified scheme:
I need to invoke model logic in UserControlResult when executing command in view-model of UserControlButtons. Real case: UserControlButtons contains buttons (and one of them triggers start of data processing), while UserControlRes... |
First, I'm adding words entered into a search field to an array. Then, I'm getting results from a stored procedure on SQL Server using Database First approach with Entity Framework.
Finally, for each word in the array, I'm filtering the results using this query:
products = products.Where(item => (item.basedescription.... |
Before I begin using this code in vital systems, I wanted to quadruple-check that it was soundproof. I plan to implement this as part of a larger program, obviously not by itself. Are there any clear flaws (output is incorrect) or optimization issues in this code?
#include <iostream>
using namespace std;
int main() {... |
I developed a program that creates and displays a Newton fractal based on a complex polynomial.
For example, the complex polynomial:
$$z^{3}-1$$
which is what is given as input in the code, will produce an image similar to this one:
Basically what happens is that the program finds the function's derivative, uses it to... |
This is my first time making an Office 365 Addin and wanted advice on my current form structure.
I'm particularly looking for advice on best partices for constructing directives and how to properly separate logic into app controllers. I feel that my single controller below and various redundancies could cause issues in... |
I asked this on Stack Overflow and got some good ideas, but was advised to post here instead. There are obviously several ways to code this, each with a drawback and a benefit.
A person works a number of hours and can bill for the work in one of three ways:
Hourly: the number of hours worked * hourly rate
Dual: (for s... |
I've been working on Project Euler, here was my solution for Problem #1. It gave me the proper answer, but it's egregiously slow. How can I implement this more efficiently? My math skills aren't top-notch, sorry.
package main
import (
"fmt"
)
// Problem1: find the sum of all the multiples of 3 or 5 below 1000.
//... |
I'm going through a beginners exercise for writing a small program in Java. My task is to print out (i.e. find an algorithm) the following output:
XOOOOOOOOO
XXOOOOOOOO
XXXOOOOOOO
XXXXOOOOOO
XXXXXOOOOO
XXXXXXOOOO
XXXXXXXOOO
XXXXXXXXOO
XXXXXXXXXO
XXXXXXXXXX
I have figured out how to do it but the code I wrote seems r... |
How is this designed so far?
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <memory>
#include <iostream>
template <typename T> using ptr = std::shared_ptr<T>;
template <typename V>
class LinkedList
{
private:
class Node
{
private:
V data;
ptr<Node> next;
public:
Node() : n... |
I have created this method to do all my WebRequests.
Generally my question is, if this could be improved in any way.
As a side question, I would like to know if it be better to create methods for each type (PUT, POST, GET, UPDATE, DELETE) of a request separately?
/// <summary>
/// Test-Method
/// </summary>... |
There has been talk recently of how we should be handling the lifetime of the System.Net.Http.HttpClient.
This article http://byterot.blogspot.co.uk/2016/07/singleton-httpclient-dns.html says that we should use it as a singleton, but we need to be careful about ensuring the connections are properly closed otherwise DNS... |
I wrote a program to copy directories in Windows 10. I have tested copying a directory (696MB) in 3 different ways:
xcopy: time taken - 52 seconds
ctrl+c: time taken - 78 seconds
My program: time taken - 193 seconds
What can I do to improve the performance of my program to be as fast as xcopy?
#include <stdio.h>
#inc... |
Find the fractions for, all positive numbers, all negative numbers and zeros in a given set of integer array.
I wrote the below program. If you see any improvements required, please feel free to point them out.
Sample input:
6
-4 3 -9 0 4 1
Sample output:
0.500000
0.333333
0.166667
Here is my program :)
public class... |
Let's say we've two parallel galaxies with same amount of stars. What I want to do is to find the nearest neighbour of GalaxyA in GalaxyB. But if that particular neighbour is shared by other star(closer to another GalaxyA star) then look another nearest neighbour. This way we will get unique nearest neighbour for each ... |
Vogel612 and I decided to take a shot at the StackSTV challenge in Haskell. This is part of the CRitter Collaboration challenge. Except I don't know any Haskell. So let's try a FizzBuzz first!
I'm quite pleased with the readability of the following code. Let me take a shot at trying to explain how it works.
main = mapM... |
I inherited this code that saves data to a sharepoint list.
This method saves the data to the list.
In other parts of the application a list is presented and can be paged through.
You then select an item and it loads all the columns and you can modify them and save them.
It's taking roughly 25 seconds to save data.
Any... |
I have the following java class which has many private variables and methods:
package gui;
import java.awt.Color;
import java.io.File;
import java.util.*;
import java.util.stream.Stream;
import javax.swing.*;
import messages.Message;
import net.miginfocom.swing.MigLayout;
import utils.*;
public class FileCopyManager ex... |
A book1 that I'm reading states Goldbach's conjecture as follows:
Every even integer > 2 could be represented as a sum of two prime numbers.
Every integer > 17 could be represented as a sum of three unique prime numbers.
Every integer could be represented as a sum consisted of maximally six prime numbers.
Every odd i... |
I put together a little tool for finding where people have suppressed warnings, and to see if they have commented why. Its in Haskell for fun and some practice. Its split into two files, the thinking here was to keep all of the IO functions in one place and the pure parser code in another.
My immediate concerns are:
... |
By default, QSlider move his thumbtrack by a value belonging to the singleStep() prop on mouse click. To make thumbtrack jump directly at the mouse click point, we need to create a new class inherited by QSlider.
Header file (.h):
#include <QWidget>
#include <QAbstractSlider>
#include <QSlider>
#include <QMouseEvent>
#... |
I designed a Python3 webservice which gets a file name, looks for this file in a local folder, converts it using an external software, then sends the converted file to the user.
For this example, the input and output file types are respectively PNG and JPEG, but they're actually proprietary formats.
Here is my code:
#!... |
I'd like to know if this piece of code is thread-safe. I'm learning something about threads, queues and synchronization, and I'd like to make sure this is correct, before moving forward to next step.
The code is very simple. It just runs two threads (producer and consumer). Producer reads data from stdin (until "0" is... |
public static DataSet execute_query(string query)
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection();
con.ConnectionString = DataAccessLayer.Properties.Settings.Default.cn;
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(query, con);
da.Fill(ds);
... |
I am currently in the process of completely rewriting an older Chess project and have written the main recurring function in the AI:
//Finds and applies the best move for the ai.
function aiTurn() {
//Recursive function. recurBoard is the board array passed to the function.
//Colour is either -1 or 1, -1 means it's cal... |
I created a simple little script for the people I work with, what it does is copy information to the users clipboard for escalation approvals. It's pretty simple and not very exciting but I want to know if there are ways to do this better:
from Tkinter import Tk
import getpass
import os
import time
class ClipBoard(ob... |
I have a function that will take an image and then return that image in 8-bit color. Almost all of the code was taken from MSDN.
The code is quite short compared to all of the other methods I've seen for converting an image to 8-bit color. I'm just curious as to if this is the most efficient method?
private static Imag... |
This is a follow-up to the previous question: Implementation of the linked list data structure in C++
I've tried to improve the design of the previous code by fixing some indexes that could go out of range and cause the dereferencing of a nullptr, and minor changes for compactness and elegance. However, I'm not sure ab... |
I am running a simple OCaml program which opens a CSV file with a pseudo dict-reader and hashes "key" + "value" (where key and values are strings). Then some counts are evaluated on the hashes (but it is not really relevant for what follows).
After a quick look at the default OCaml profiler (gprof), I noticed that my p... |
I have a table that looks like this
Directory nvarchar(max)
Extension nvarchar(10)
Length bigint
I also have another table that provides the type of file (lookup table)
extension nvarchar(10)
FileType nvarchar(50)
That being said I have a correlated subquery I wanted to migrate to a sproc that takes in the levels from ... |
I am making a snake game and I'm almost done but I want to make my code more organized so people can understand so how to do it.
# -*- coding: utf-8 -*-
import pygame
import random
import time
import thread
##########################Functions############################################################################... |
I created this regex in Javascript that returns a boolean for Domain validation that meets the criteria to allow IP addresses and ascii domain name. The assumption is that the TLD should be atleast two letters.
/^((([0-9]{1,3}\.){3}[0-9]{1,3})|(([a-zA-Z0-9]+(([\-]?[a-zA-Z0-9]+)*\.)+)*[a-zA-Z]{2,}))$/
I used the follow... |
I am working on a Simon game using python and tkinter, just now it is incomplete, but I don't know if I am doing it right because it looks messy, and I would like to have a check on my code for corrections and suggestions on how to improve it.
This is the first game I'm making, and I don't have to much experience in pr... |
In a very specific application I have, I needed the ability to easily convert between different data sizes. I.e. when I give an input of 1,048,576KiB, I needed it to say 1GiB, etc.
So, I built a struct for it.
It's pretty robust, includes operations for subtraction, addition, multiplication and division, == and !=, IsS... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.