instruction stringlengths 71 71.9k |
|---|
I recently reinstated the unit tests in Rubberduck. Previously, our parser was a synchronous parser, with everything running in sequence, and we could just request a parse result. Now, however, it runs asynchronously and we can only request parses. As a result, I have to somehow perform a blocking call to the parser... |
I have the following. How best to refactor it:
def self.search(search, organization_id, is_admin)
if is_admin == false
where("record_no LIKE ?", "%#{search}%").
where("organization_id = ?", organization_id)
else
where("record_no LIKE ?", "%#{search}%")
end
end
Basically this means, ... |
Is there a better way to organize the methods within this program without compromising the clarity? Running through digits 0-9 with separate functions seems very bulky.
// Prototypes
void display();
void zero(int digit);
void one(int digit);
void two(int digit);
void three(int digit);
void four(int digit);
void five(in... |
While reviewing @Martijn's Distinct sums of integers (finding all combinations of positive integers that sum to a given number), I proposed the following solution:
/** List of non-increasing positive integers */
type Sum = List[Int]
def sums(n: Int): Iterator[Sum] = {
/** Prepends the head of the stack repeatedly un... |
I have written a simple Ruby program to model a transit card system which aims to address the following user stories. I wanted to see whether I could get any feedback on it. My main interest is understanding where I have made fundamental mistakes that violate OOP(SOLID) Principles with a real focus on Single Responsibi... |
I'm in need for clarity. I'm at an annoying step in my development of a website, and I have read a lot about semantic structure etc, but I'm a bit nervous for my current structure, so I would like to ask your expertise to see, if I might get problems with search engine bots with this setup.
<body itemscope itemtype="ht... |
I'm currently in the process of making a 2D tile based game. This game has an "infinite" world that can be traversed and modified as needed. I am creating the chunks with a mesh and I apply a texture to them. The chunks texture updates every time I set a tile with a new Sprite.
Each time I set a new tile, the surroundi... |
I have a Laravel project that has courses. I want to take the related courses from one.
Should I create the method in the model (the php class) or in the controller?
Currently I have this code in the model:
class Course extends Model {
public function relatedCourses() {
$all_courses = new Collection;
... |
This function produces a decoded string, decoded, for all keyspaces against a given cæsar cipher ciphertext. Punctuation is not changed and string.upper() is used to make working with ord() easier.
I am looking for a more Pythonic way to work with my decoded variable. I keep finding myself assigning empty strings or No... |
Everybody knows this river crossing puzzle solving game. I was playing a river crossing game in my cellphone and decided to try to implement every single game mode this app has.
In case by any chance someone doesn't know what this popular river crossing puzzle is about, here's an explanation:
A man once had to travel ... |
I am creating a few functions that wrap around jQuery's Ajax function to make it a bit quicker and easier to perform a request. For this I have this JavaScript file:
$( document ).ready( function ()
{
var ajax = {
url: "", type: "", success: "", beforeSend: "",
preform: function ( $url, $type, $succ... |
This script is used for gathering fragmented documents from your computer, and organizing them by extensions.
Here is the main things my algorithm does:
Search through path(s)
Stores documents' paths
Detects existing extensions
Copies documents by extension to categories in a directory created in the current working d... |
I've got the below SQL statement which runs in MySQL on a WordPress installation. I'm looking for meta data that matches certain criteria and was created after a certain date.
However, WordPress doesn't store the date that metadata was added to posts, so I've created the metadata itself (wpcf-post-likes), the date it ... |
Most of the VBA I write is to produce tabulated reports from spreadsheet data.
So, here is my attempt at creating a CLS_Data_Report class.
Properties:
a 2-dimensional Data Array
3 dictionaries to, respectively:
Map headers to column indexes
Map external (user-set) descriptions to data headers
Store number formattin... |
I've recently started playing the X-Wing Miniature game, and there is quite some math behind some of the dice rolls, as they are affected by many abilities and so on. Manually calculating these is quite burdensome, so I decided to write a simple C++ program to approximate the expected damage by running many simulations... |
I'm not sure if this is the right question but didn't come up with something else. I have this huge for{} loop which prints out some HTML Tables with some infos from some devices.
This code looked totally wrong to me and it had bugs. I tried to make it look as idiomatic to JavaScript as possible (started learning JS 4 ... |
I am interested in calculating odds of winning UK Lottery. The format is that 6 numbers from 1-59 are drawn. I am interested only (at this stage) in the odds of winning the jackpot (matching six balls). As an aside, I'm interested in the odds for a total balls count of 49, and 59, to see the change in chance of winning... |
There have been a few questions over on SO recently about securely storing credentials in Powershell scripts. Because ConvertFrom-SecureString uses DPAPI it makes the output only valid for that user, which makes creating credentials for service accounts etc. occasionally awkward.
I have had this script lying around for... |
I have a view that displays posts created by users that actual logged in user follows. It works, by I think the way I've done it isn't good.
BTW, UserProfile is my default user model.
UserFollower model
class UserFollower(models.Model):
followed = models.OneToOneField(UserProfile, related_name="followed")
foll... |
I got a problem I'm finding pretty hard to solve. I'm trying to generate calendar months for a datepicker but at only 12 months I see a perf of around ~4-7ms.
This doesn't sound like a problem but it becomes one on lower-tier devices such as smartphones that basically are 1/10th of the speed of a desktop (so double tha... |
I just wrote a snow animation in Python. I think this is fairly clean but I have a few things that I don't like.
from random import randrange
import time
# Snow animation
# Snow is simply the `#` symbol here. Half of the snow moves at 1 char
# per frame, while the other half moves at 0.5 chars per frame. The
# program... |
I have a database containing a high amount of data. I want my app to filter and select only some of it, and save it into a CSV file or JSON.
For the moment I have this method which takes the data from the database and puts it in a CSV:
void viewAllCounters (String tableName, long startDate, long endDate, Connection c) ... |
The code finds all the combination of alphabet with length 5 and saves it in a list(its ASCII value, minus 97). I want to optimize the code to reduce execution time.
from itertools import product
def permuteKey():
def pp(chunks):
return map(''.join, chunks)
k=pp(product('abcdefghijklmnopqrstuvwxyz', ... |
So I'm almost 100% certain I've done something wrong simply due to the inefficiency of what I've written, I'm entirely a novice to coding and am working on an assignment for my introductory programming course. The only way I could think to display the input from 4 check boxes was to go down 16 different branches to cov... |
Currently this is the store procedure I am working on, it is working according to some testing that was done. I feel that it could be improved though, could use some optimization, feedback or recommendations.
What is it supposed to do? For given policy id passed in, grab all coverages associated with the policy. For ... |
Solving the maximum subarray problem with added cases of finding non maximum non contiguous subarray as well. I used divide and conquer approach and tackled the 'all negative' case by keeping a counter for that and branching it.
#include<stdio.h>
#include<limits.h>
#include<stdlib.h>
// finding maximum non contiguou... |
I have written a series of Regex.Replace() lines to take an input like {"id":36} and convert it to id 36 and I was wondering if it is possible to combine all the calls I am making into one.
Results = Regex.Replace(Results, @"\{", "");
Results = Regex.Replace(Results, @"\}", "");
Results = Regex.Replace(Results, @"\""",... |
I made a simple scene manager in C99. I tried to make it readable, reusable and reliable. I would be grateful if you would help me to improve it. I want to use it for my upcoming OpenGL game. I think that code is sufficiently self-documenting for you to skip the comments.
The headers
scene_manager.h
// Defines client i... |
I wrote a Risk battle simulator that returned the odds of every possible outcome and put it up to be reviewed here. I used the comments to improve it, and am wondering if it can be optimized further.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;
class battle {
publ... |
I wrote a little A* implementation by my own and would like to have some feedback ;)
The code is in OOP way, thus we can use an other pathfinding algorithm easily. The "Base" is just the interface class, thus is should not matter here.
Before we look at the code, let me say one or two senteces about it behaviour and mo... |
I’m currently aiming to make my first app for the Universal Windows Platform (UWP) / windows 10. It’s a small app but should follow some best practices patterns (although I’m considering it as a first step on new grounds, as I am more used to MVC/ASP.net programming and a bit WPF some time ago). I’m using following fr... |
I want to post my tiny program here and hope to get feedback improving the performance of my code and understanding Python better. My main issue is the slowness of the program and the corresponding bugs due to incorrect image checking since the game has already advanced in that time.
It's a slow 2D game that I try to c... |
I'm playing with async/await, but I have yet to discover a standard method to safely cancel an intensive task. I have tested the following, and it works exactly as intended, though I remain unsure if a standard method exists.
abstract class PageLoader<TPage, TElement> where TPage : Page
{
private TPage page;
p... |
I wrote this Pin class as a part of a project to learn SOLID. What do you think about it and what can be made better?
Interface
public interface IAuthorization
{
bool Verify(object obj);
void Change(object obj);
}
Class
public class Pin : IAuthorization
{
private int _pin;
... |
I'm new to Java and is trying to solve the beginners problem of finding out the number of words in an user input string or a text file. I was just wondering if there are any alternatives to any of the steps that can improve efficiency as well as simplicity.
import java.io.BufferedReader;
import java.io.FileNotFoundExce... |
I usually write function-only Python programs, but have decided on an OOP approach (my first thereof) for my current program, a web-scraper. Here is the working code I wrote which I am looking to have critiqued:
import csv
import urllib2
NO_VACANCIES = ['no vacancies', 'not hiring']
class Page(object):
def __init... |
Purpose
This question comes from a HackerRank problem called Fibonacci Modified. I think I have coded a valid solution, but would like feedback about my approach, implementation, and of course, any errors / edge cases that I may have missed.
Task
Implementation
public class FibonacciModifiedImpl implements FibonacciMo... |
I'm trying to learn F# by creating a little web scraper that will do custom scraping based on the url domain. For this, I need to create and select the correct kind of scraper. I figure I would use a Factory that would determine the correct kind of scraper for me.
So here is the interface for my scraper
type IExtractor... |
I'm working on a program that is supposed to use alpha beta pruning to find the best move for a game. The game is basically a binary tree of degree of 40 and each node will have a different float value. The moves are only true or false. The goal is to score a positive score at the end. The professor gave us the Main an... |
I am creating a chat API for Android developers, but it's slow -- the chat app is getting messages a little bit late.
How can I improve the performance of my code?
<?php
require_once('config.php');
$sender_id = $_GET['sender_id'];
$receive_id = $_GET['receive_id'];
$response = array();
if($sender_id && $receive_id)
{... |
I decided to try out some named tuples by implementing Dijkstra's algorithm to find the cheapest routes in a file like this (where each line represents node_a is connected with node_b with a cost of n):
1 6 14
1 2 7
1 3 9
2 3 1
2 4 15
3 6 2
3 4 11
4 5 6
5 6 9
However, something that caught my attention is that some ... |
Here's the code I'm planning to use to power meta description tags for a site in header.php in the template. Is anything missing / incorrect / could be done better?
<?php
if (is_front_page() || is_home()) {
$description = get_bloginfo('description');
} else {
$description = get_post_meta(get_the_ID(), 'descrip... |
I wrote the following piece of code and want to hear your opinion, in this snippet I have a vector called aggregateFeaturesForML which has elements of Class with 3 fields: sourceip, key, value. what I want is to collect all the key-value pairs that have the same sourceip and form a nice histogram (for each IP the keys ... |
I've been writing JavaScript for a couple years but nobody's ever really looked at my code.
This is a small library I wrote to check code modularity, w/ input like avg-lines . -name '*.js' (the arguments are passed straight to find) you might get:
Checked 20 files (1615 LOC):
80% of files contain > 137 LOC
20% of f... |
I've been working on an app based on the MEAN Framework. I have got the app working but I just wasnt sure whether my coding structure and standard was good enough, meaning does it adhere to the programming standards in terms of structure, security etc.
So I'll explain my app:
A very simple app, it consists of a MongoDB... |
This video should explain how the game works, but in simple form, it's a game where you enter a number between 1 and 3, This number is than removed from 12, in doing so the computer will then pick a number between 1-3 based on what number you have picked, if you choose to remove 1 marble it should say that it has remov... |
I'm writing a 2d top down game where I perform a lot of "closest" searches between one point and all the rest of the points.
In this example, "me" wants to search for the closest visible house (Home) that I haven't visited yet, and if it is not found, return null.
protected Home getClosestUnvisitedVisibleHome(Person me... |
I am working on a PowerShell script which will loop through a directory containing SQL Server database backup .bak files; move the files to a different location; restore each of those files to the local SQL instance using OSQL.exe; output the SQL output to a log file.
This works OK, but I am willing to improve it.
$s... |
I've written a Universal Windows Application which allows you to select a folder and shows the icon and name of a random executable from anywhere in that folder. The intent is to be a Game Roulette, where if you install all your games in a certain folder, it will tell you what game to play.
MainPage.xaml:
<Page
x:C... |
I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below.
It is still a work in progress and uses some not-so-best practices. For example any consumer, that has an access to the event can fire it. Also you will notice, that the ... |
I've created a brief UserScript (GitHub repository) for TamperMonkey to stop Google from hijacking Search results URLs for tracking purposes when you click them:
// ==UserScript==
// @include http*://www.google.*/*
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
function handl... |
I pursued an according algorithm with an absolute best performance, the following class embodies the solution.
Any comment is welcome.
class TextCompressor
{
private const char Seperator = '\x20';
private StringBuilder builder;
public TextCompressor()
{
this.builder = new StringBuilder();
... |
I am parsing the responses from our Varnish load balancers in order to monitor the status of various nodes. One of the responses we get is text consisting of multiple blocks of data, one for each server in the load balancer.
This is one such block:
Backend web05 is Healthy
Current states good: 10 threshold: 8 window... |
On a shared host, I'd like to setup a cron which scans folders recursively for some base64 malware strings. Therefore, I've written the following script:
#!/bin/bash
if [ $# -ne 1 ]; then
echo $0: usage: ./findone folder_to_start_with
exit 1
fi
folder=$1
IFS=$'\n'
searchfiles=($(grep -r -F -n -f malware-stri... |
This is a port of a C# cache manager we use to F#. This is my first F# code, and I've tried to make it as idiomatic as possible. I would appreciate input on style, performance considerations,correctness, anything at all. The goal is to learn more about F# and functional programming. The purpose of the code is to abstra... |
This picture inspired a contest between a few of my friends to rewrite this code in more proper OO style.
This is what I have come up with.
Any thoughts:
public enum CoffeeKind
{
Black = 1,
Cappuccino,
Espresso
}
public class Coffee
{
//Measured in celcius
public int Temprature { get; set; } = 30... |
I am trying to get an Auth ticket from a 3rd party server. I am using FutureTask to perform the task. However, if I don't get response from the server after 10 seconds, I want to timeout the call. At the same time, I want to kill the Thread which was busy in fetching the Auth Ticket from 3rd party, but got stuck becaus... |
I would like to know if someone can think about a better solution for doing this stuff.
I have an array of raw bitmap data in 32bit format (RGBA). I need to transform and transpose this array into a 24bit format by eliminating the alpha component.
Additionally I need to transform the data by aligning the red component ... |
This is my attempt to implement the Pascal Triangle in C#. It is meant to calculate and return a pascal triangle of size n (which it takes is through the parameter rows).
static List<List<int>> GetPascalTriangle(int rows)
{
List<List<int>> result = new List<List<int>>();
for (int x = 0; x <= rows - 1; x++)
... |
This is a rags-to-riches of some recent "search word in multiple files" questions, such as this deleted question and this.
The idea here is to do a case-insensitive word (complete, not partial) search that can also report the line and 'column' number of the search result. For example, if the word is found as the first ... |
Imagine I have connection in which I have to write numbers, represented by this contract:
interface ISocket
{
Task WriteAsync(Byte[], Int32 offset, Int32 count, CancellationToken cancel);
}
There is one single thread calling this WriteAsync method.
Till now each caller to ISocket was buffering independently and kn... |
I need to show article's content based on this logic:
if article's content has to be truncated (e.g for preview)
if there's [read more] substring in the content
replace first [read more] with link to the article
truncate content to the first occurence of [read more]
else
truncate content to the first 500 chara... |
The following class is used for handling sessions:
class DBHandler implements SessionHandlerInterface {
protected $exists;
public function open($save_path, $name) {
try {
DBCxn::get();
return true;
} catch(PDOException $e) {
return false;
}
}
... |
I'm making a card game and I found useful to include a 60 second countdown timer. Here is my approach:
import java.util.Timer;
import java.util.TimerTask;
public class SecondTimer {
private Timer timer;
private int countDown;
private int secondsLeft;
public SecondTimer() {
timer = new Timer()... |
Could this code possibly be shortened, or even better be rewritten in the fewest lines of code possible?
import csv
import random
import math
import operator as op
name=input("What is your name: ")
print("Hello there",name,"Welcome to the math quiz, you will be asked 10 random questions on Addition, Multiplication ... |
I have a website which only needs to support IE11. It is a single page application, which has about 200 table rows and each table row has 5 child rows.
There is a pulsing function that updates the table as records come in. Table rows are skipped over if no update comes in.
However, when receiving large updates (which s... |
It's my first exercise involving the well-known binary search. The problem goes as follows: we are given a sequence of n numbers and we have to answer to t questions, each of which is: “How many numbers in the specified sequence are greater than the i-th element of the sequence?” For example, we have n = 3 and t = 3. O... |
I have a form component with multiple refs pointing to form inputs. On submit, those inputs' values need to be passed the into form callback, structured as an object.
Currently, it's achieved like this:
class MyComponent extends React.Component {
render() {
return (
<form onSubmit={() => this.on... |
In an RPG game I'm developing, after building a base Weapon class, instead of having many subclasses of Weapon, I want the weapons to be built upon dictionary parameters. Many of them will be simple static information (weight, value, etc.), but others will have conditionally defined parameters, with not only numeric/te... |
I'm making a scraper/web crawler using Kivy when I run the code it works but I'm not sure if what I'm doing is Pythonic because all the language I can find is about using the Kivy library. I'm unsure about putting the functions to bind the widgets to inside the build method. Is there a better way?
class MainApp(App):
... |
I needed a caching decorator, that could be used with methods and functions, that could take typed args and kwargs, and that was Python 2.7 compatible. Therefore I started with a backport of the lru_cache from Python 3.3. However, I also needed the ability to incorporate a shared cache (I am doing this currently via ... |
I find that I often have to maintain a singleton primarily to hold an array that is sometimes persisted between user sessions, that should have only one class of items, and that sometimes needs to be ordered. I got tired of writing the same boilerplate over and over so came up with this. I'd welcome critiques (particul... |
I made some games in Pygame, but I am still new to making games.
I made this RPG game, and this code is just a part of the game. The game executes different Pygame files for different levels of the game as it can be seen in this part of the code (this is for random battles):
if (mainCharacterCoordinates.colliderect(b... |
I wanted to make a button that goes to the top of the page but only appears when you're not at the top. There are probably libraries that already do this, but I wanted to make it myself and after some tinkering the following is what I came up with.
There is an occasional annoyance from quickly scrolling up & down with ... |
I inherited an application that uses some stored procedures. Here is a sample of one of the stored procedures used to insert or modify user data.
would like to get the group's opinion on the code. The SQL Server version is Microsoft SQL Server 2014 - 12.0.4100.1 (X64).
USE [MyDataBase]
GO
/****** Object: StoredProcedu... |
This query took 6 seconds to complete. How can I optimize it?
Total records in table is 166803.
SELECT ltrim(rtrim(CAST(cageID as nvarchar(max))))+ltrim(rtrim(CAST(trayNo as nvarchar(max)))) as _unique,*
from lf_transit_cage
where ltrim(rtrim(CAST(cageID as nvarchar(max))))+ltrim(rtrim(CAST(trayNo as nvarchar(max)))) ... |
I've been designing a dynamic graph to improve my understanding of C++11. The dynamic aspect means that it could represent the hyperlink structure of a chunk of the internet, with node deletion corresponding to removing dead links. I'd be grateful for a review of coding style/design patterns/optimization.
The main conc... |
Purpose
I came across this relatively simple question on HackerRank regarding finding missing values across two Lists. I took a fairly straight-forward approach, but is there a "better" / "slicker" way of implementing a solution?
Task
Strategy
Iterate throughList with complete data.
If Integer is in List with incompl... |
Rags.
Introduction
All too often I find myself wanting to allow only a certain list of characters to be written to stdin, and only recently did I actually bother to implement it. In Python, of all languages!
Essentially, this module provides a few APIs that allow a very tailored approach to reading characters from a t... |
My goal is to iterate over a datamatrix, calculate mean, standard error of the mean, and then have a bar plot representing the 2 groups of my data matrix in R.
My code below works as a for loop. However, my initial goal was to output each 8 plots in one .png file. To that end, I posted the question here.
One of the 'c... |
Previous topic: Large table updates using AJAX in Internet Explorer 11
For the functions included here, I have taken the advice of the previous answer and incorporated it in the restructure, but am still experiencing huge latency of about 2 seconds per computer record.
I am lead to believe that this is more an issue wi... |
I'm creating my own application exception types so I could catch them higher in the call stack and take specific action. I'm looking to get feedback on the latest exception I've written for two reasons:
I'm using the Exception snippet from Visual Studio 2013, and am wondering if it is any good and/or has potential pro... |
For following input string:
"VISITOR_INFO1_LIVE=USv90B-7CzI; LOGIN_INFO=e486e37a395be3f0e3b3237d090a6829c1oAAAB7IjQiOiAiREVMRUdBVEVEIiwgIjciOiAwLCAiMSI6IDEsICIzIjogMjAxMTk0MTMwNiwgIjgiOiA2MDgwMTg0NTEzNjQsICIxMCI6IDIzOTYyMTEyODczNH0=; PREF=f5=30;HSID=AHuJQBOVR0lQoRt_3; APISID=QaParXGsQcEPCzKg/A1smCfYrfMjxvfEPT; YSC=Vm3A... |
I'm a Java guy in a JavaScript world, and I'm used to certain things about Java Strings that just aren't there for in JavaScript. Some of this I can accept, for example Strings are freaking everywhere for some reason.
Now I realize this could be simply implemented with return this.indexOf(needle) === 0; (or, even more... |
The statement is as follows :
The sequence of triangle numbers is generated by adding the natural numbers.
So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1... |
[ This app is now on github !! ]
This is a small program I wrote to hide/show different windows on my Windows PC.
This is named LifeSaver because it did save my life several times, whenever someone stormed into my room unexpectedly. It does have some cool uses and some naughty uses, for all people.
Its structure is lik... |
I have written a small plugin for nagios to check a WebDAV server. It is supposed to connect using a username and password and upload & delete a test file
This is my code:
#!/bin/bash
#Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
FILENAME=/tmp/test_monitor
FILE=test_monitor
HOSTNAME=$1
USERNA... |
I'm displaying JSON data in a tabular format on a html page using jQuery.
In the function I'm looping the resp.DATA once to get the key names so it can be displayed as the headings in the table, and a second time to get the values of the keys for all customers.
Can this be done in a way that I only have to loop the re... |
This is a Unity3D script I wrote for my game to control a character. I don't consider myself a highly-skilled coder, so I come here to ask for suggestions. Is my code clean enough? How can I improve my coding style and pattern?
using UnityEngine;
public enum OnWallStatus
{
None = 0,
OnLeft = 1,
OnRight = 2... |
Inspired by this question, I decided to rewrite this code in Scheme, as I'm working through SICP right now. Any feedback welcome.
#lang racket
;assume cup, is-empty?, refill and drink are operations understood by the environment
(define (coffee cup)
(if (is-empty? cup)
(coffee (refill cup))
(d... |
I've got a service that loads data from a databasr and it performs almost the same operations in all methods.
private async Task GetProvenances()
{
try
{
var result = await commonRepository.GetProvenances();
if (result != null)
{
provenanceConta... |
I have a function which sets the text to a label displaying current active "products" and current active pages. The label displays "X products, Y pages/page" depending on the amount of products active in the template. Products is the same as rows really, the client wants to call it products.
The template consists of a ... |
I am working on an algorithm question in which I need to find out pair of number out of 2 sorted arrays which sum up to the given number. I need to print out the indexes of those pairs rather than number itself.
I have written an algorithm which does work but I am wondering is it the best solution or is there any bett... |
I am searching for some improvements, particularly in the regex, in the way I highlight specific words in a string.
I have keywords into my database stored without any diacritrics
The user comes with a string with diacritrics
I find the matches between the keywords and my string modified so that it does not contain an... |
I have a view which displays a list of items, in each row I'm going to have a link, a link in each row points to different location So base upon a property called CertificationType I have to generate an address, for example if the type equals to 'BirthCertificate' I need to fetch the address from a table called BirthCe... |
This code will copy data from a workbook and copy it to an existing (and open) workbook. At the beginning of the month this copy/paste works very quickly, but as the month goes on and the data also grows, this process slows down to a couple of minutes. Once we start hitting 200 rows of data, we see the performance slow... |
I'm working on some code right now where the goal is to take in a byte stream and grab the data from the body of a message. The data is 10 bytes long and is meant to be translated into hex. Specifically, the 10 bytes coming in look like 01000200030004000500 or 01010201030104010501 (with implied 0x in front of each).
Th... |
I wonder if I should divide this class into two, since it contains two "ifs" with different messages. Would breaking it down be in keeping with the "S" of SOLID?
internal class ValidDateApuration : IBusineeOfValidation<DtoFormGnre>
{
public MessageValidation Validar(DtoFormGnre obj)
{
var paymentDate = ... |
I have a slice with ~2.1 million log message strings in it that I am parsing for regular expression matches. For any matches, I add it to a local slice and then return said slice.
func Search(re *regexp.Regexp, logs []string) []string {
var lwg sync.WaitGroup
var lresults = make([]string, 0)
NumCPU := runti... |
I've written a programme to find Chen primes. A Chen prime p is a prime number where (p + 2) is either also a prime number or has two prime factors.
I've got it working to the best of my knowledge: the first few values are correct.
def isprime(n):
for m in range(2, int(n**0.5)+1):
if not n%m:
return Fals... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.