instruction stringlengths 71 71.9k |
|---|
I have implemented an ArrayBlockingQueue (put and take) on the lines of LinkedBlockingQueue i.e using two locks so that my take should not block my put.
For more information please see this Stack Overflow question. The code is also available at GitHub.
Please review the code for any race conditions.
import java.util.c... |
The brief is to be able to generate links to artwork files and PDFs easily and quickly without having to use a browser.
I have added an image box which shows the user the image upon clicking one. The links are taken from a dir listing in Google Drive. There is then some conversion to change the folder location to the G... |
At work I have a Microsoft Access database of employees with fields such as employee's manager, employees email, and employee ID. My duties include updating this database and validating entries generated. Biweekly when I run the VBA script to validate records, I am faced with between 25K and 30K of employee records in ... |
The problem is that I am trying to modify the code to invert the image in C and optimize it to make it run faster than the original by any method I could think of. After tried to use blocking and loop unrolling, it still does not seem to speed up. Maybe I did it in a wrong way as I'm not really fully understanding thes... |
I have used animate.css and jQuery as external libs. Is there a better way of doing what I have done with jQuery?
DEMO
$(document).ready(function () {
$('#test li').on('click', function () {
var className = $(this).attr('class');
$('#test2 > li').each(function () {
var prodName = $(... |
I am into building functional prototypes, but also for outputting CSS and JS, which means we have 2 times we build out our code, once as a demo with HTML files (we are using assemble.io) and another, where we are building out the files to be uploaded to production (an Enterprise CMS).
Most things about the build are th... |
Is it OK to mix different lifetime of ISerializer and ICacheProvider in this case? I am using Unity DI. In this case, whenever ICacheProvider is needed, Unity will always give the same instance (singleton) but ISerializer will always be a new instance. I am not sure if it would be OK to have ISerializer as a singleton ... |
Right now I'm studying OOP with javascript/jQuery and so far upon reading tutorials over the internet and with the helping hand of google, I come up with a way to do it based on my own understanding.
So far, I tried to create a plugin where I could make a custom twitter bootstrap panel with some options like close and... |
I have tried to make modification in below specified code by removing synchronized and replacing Integer with AtomicInteger .
Is it correct and going to ensure that code does not run into synchronization issue?
/**
*
*/
package com.ciena.ems.server.system.dataManager.layer1Connection;
import java.util.Hashtable;
i... |
How can I imrpove the performance of this T-SQL statement?
SELECT Code, Description
INTO [DBApps_Pulse_WarehouseAreas].[dbo].[Tbl_Partmaster]
FROM SYSDataBridge.dbo.View_Pulse_Partmaster_Synchronized
ALTER TABLE [DBApps_Pulse_WarehouseAreas].[dbo].[Tbl_Partmaster] ADD PRIMARY KEY (Code)
|
I am designing a new asp.net MVC4 application. I know that context class generated by EF is Unit of work and Dbset is the repository class. I am just avoiding the extra abstraction. I want to know whether I am following the correct pattern or not.
Entity
public partial class ProductMaster
{
public long ID { get... |
I have the following checkbox as depicted by the image below:
The checkboxes are in 3 groups. Confidentiality, Integrity ad Availability. When the first in is clicked, the Confidentiality turns Red for High, Orange for Medium and Green for Low.
This is a lot of work to be done as you need to create a subroutine for ea... |
I would like to display a 3...2...1 countdown on my iOS app (before to take a picture) but I didn't find an elegant solution. I don't want to make a Countdown app with an NSTimer. For me the important is to keep all code in the same method, use a system like Block.
self.infoLabel.text = [NSString stringWithFormat:@"3... |
We've been reviewing some legacy code and have found differences in the preferred approach to how to write tests using Mockito.
Both the following tests pass but which one is better and why?
@Test
public void verifyObjectSaved() throws PersistQueueException {
final UserTokenVo userTokenVo = new UserTokenVo();
... |
This currently does what I intend:
import Control.Arrow (Kleisli, runKleisli)
import Control.Applicative (WrappedArrow(WrapArrow))
import Control.Lens.Traversal (preview)
nested :: Request -> Maybe Response
nested = runKleisli . unwrapArrow
$ WrapArrow (Kleisli (preview (prefixed "/name") >=> app1))
<|> Wr... |
Any suggestions on improvement are welcome.
(ns cina.prime-circular)
(declare least-prime-divisor-from-primes
least-prime-divisor
prime
primes)
(defn least-prime-divisor-from-primes
"Find the least prime divisor of an integer n. Instead of checking every integer less than n,
use the po... |
Normally, you would change the LSB of the RGB channels in a pixel, they would represent the bits you are storing in the image. My method differs in that I represent my bits as either odd or even numbers stored inside the image channels ARGB. So an odd number represents a 1 and an even number represents a 0.
I also can'... |
I have the following code which is responsible for the validation in our app (just an example).
Based on the particular tab where user can add person to the database we need to perform additional validation (more fields in each tab).
Fields that always should be validated are name and surname so we provided an abstra... |
Below is the solution:
def approx_deriv(fn, x, dx=0.00001):
return (fn(x + dx) - fn(x))/dx
def improve(update, isdone, guess=1, max_iterations=100):
def recur_improve(guess, i):
if i > max_iterations or isdone(guess):
return guess
else:
return recur_improve(update(guess), ... |
I wanted to create an example of developer-friendly, maintainable, expandable, reusable understandable module that could be used by other programmers even though it won't. Thus, I started developing a simple terminal program engine.
This terminal engine reads a file, where each line is a separate command with its argu... |
I am trying to learn Golang.
This is a problem from Robert Sedgewick's Algorithms book:
You have a mixed pile of N nuts and N bolts and need to quickly find
the corresponding pairs of nuts and bolts. Each nut matches exactly
one bolt, and each bolt matches exactly one nut. By fitting a nut and
bolt together... |
I have this script on top of all pages to check if user is admin otherwise we kick him. The problem is that I don't know if I am using double resources with a double query and results. Can I make this code to be only 1 query and 1 result? Please read the comments in code to understand:
<?php
session_start();
$identific... |
I am doing the following about 10 times with other strings, so the code is duplicated. How can I refactor this?
queryWhere is a Dictionary<string,string> that contains parameters that will be passed to a query.
string account = string.Empty;
if (queryWhere.ContainsKey("account")
&& queryWhere["account"] != null
&&... |
This code extracts marks of all students in class and stores the result in a file results.txt, using BeautifulSoup. I'm looking for code review and suggestions.
from bs4 import BeautifulSoup
import requests
file = open("results.txt","w")
for roll in range(1,60):
if roll in range(1,10):
rollstr = '0'+s... |
Here's a quick extension for [String: AnyObject] dictionaries in Swift. The output needs to be in the following format (order and spacing don't matter):
{"key": "val", "keywdict": {"anotherKey": 100, "Key2": "Val2"}, "strings": ["string", "another"]}
I am wondering if there's a better way, or if this can be improved.
... |
Wikipedia uses Infoboxes for many of its articles. They contain basic information in a structured form about the topic. Take for example the articles about Stack Overflow and donkeys.
Their structure is something like:
Title
Icon or Image
One or more sections
Each containing on or more key value pairs
or a text
Wi... |
I am wondering if the following is a good concideration.
There might be several links on a page with a data-rel attribute that could be static or dynamically added with javascript. Instead of adding an eventlistener to each of those I am thinking about adding an eventlistener to the document. I don't want to use jQuery... |
I'm trying to transform the following string "joe-smith" to "Joe Smith". I have the following code which seems to work okay, but is there a faster, better way?
var prettify = function(str){
var temp = str.split('-'), i, pretty;
for(i = 0; i < temp.length; i++){
temp[i] = temp[i].charAt(0).toUpperCase() + te... |
I'm teaching myself Python and wanted to share this problem as my current solution feels inelegant but I'm not sure of the best way to refactor. If this sort of question isn't appropriate, leave a comment and I'll remove it.
I'm writing a generic library to handle web API requests. The aim is to have a generic core tha... |
I am just getting into front-end web development and to practice, I made a dropdown selector that allows for more styling than the regular <select> element.
Please let me know what I can improve on (examples are appreciated, but not necessarily needed). I am mainly looking at the JavaScript, but if I am structuring th... |
I have a query that returns an array or associative arrays of ids and years. It looks like this:
[{"id":8,"year":1950},{"id":9,"year":1950},{"id":8,"year":1951},{"id":9,"year":1951},{"id":8,"year":1952}]
There is a fixed number of ids, but they each have many years associated. I wrote the following script to turn the ... |
The purpose of this program is to write a code that will give a user a list or menu of choices that show colors and their values according to some data and prompt them to enter input to determine the value of a resistor. I have completed my source code for this program and it runs perfectly, but I would like some feedb... |
I'm trying to make a market depth chart with data from a exchange and a Google JS chart.
The good news is I got it working, but the bad news is the code to prepare the data to be used by google charts is just bad. I know there should be far better ways to do this but I can't come to a proper solution.
The original data... |
My code is too slow, it does the desired, but not in \$O(\log n)\$ or faster.
Explanation of the auction system:
For simplicity we will assume that all orders are for a single unit of the traded item. The
double action system operates as follows. When a new buy order of $x arrives it is simply
stored for future use if ... |
I am currently working on Project Euler problem #2 which requires you to print the sum of all even fibonacci numbers below 4 million.
I just recently learned about generators and from my understanding they are used to decrease memory consumption by generating values on the fly (and not storing them in a huge list).
Doe... |
I have multiple (1000+) JSON files each of which contain a JSON array. I want to merge all these files into a single file.
I came up with the following, which reads each of those files and creates a new object with all the contents. I then write this new object into a new file.
Is this approach efficient? Is there a be... |
EDIT: This question was followed up by this question, with improved code.
I have a set of pretty large files (>2 GB, over 30m rows) containing intraday data in the following format:
TIC, Date, Time, Bid, Offer
AAPL, 20090901, 09:45, 145, 145.5
AAPL, 20090902, 09:45, 145, 145.5
AAPL, 20090903, 09:45, 145, 145.5
I al... |
I've been struggling with registering a plist into NSUserDefaults and I've finally got it working, though I'm not sure that its written properly. I'm hoping someone here can shine some light on this process.
My intention with this code:
I want to be able to set all of my values in a plist and essentially use that to "... |
public static <T> void heapSort(
T[] array,
Comparator<? super T> comparator) {
int length = array.length;
int start = (length - 1) /2; //right-most parent node
//build heap
while (start > -1)
maxHeapify(array, start--, length, comparator);
//move max to end, and rebalanc... |
I am working on a new MVC web application, so the project is in early stages. I have created 4 projects.
Let me explain what they do:
Common --> contains all my DTOs, enums helpers, ViewModels etc.
Web --> simple MVC application
Business --> This contains providers which have an interface and implementation for dep... |
This is a problem from Robert Sedgwick's Algorithms book:
Write a version of bottom-up mergesort that takes advantage of order
in the array by proceeding as follows each time it needs to find two
arrays to merge: find a sorted subarray (by incrementing a pointer
until finding an entry that is smaller than its prede... |
I'm looking to get this cleaned up.
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BaseHexW... |
I am implementing, in my SinglyLinkedList class, an interface where I redefined linked list. I am trying to learn data structures. Please, let me know what I can approve upon in my code.
public class SinglyLinkedList<E> implements LinkedList<E> {
private class Node<E> {
public Node<E> next;
... |
I recently wrote some code to handle parsing of URLs, even if those URLs might not be one hundred percent perfectly well-formed. (This constraint made using Java's URL class impossible.)
The resulting, relatively short library is presented below.
(ns fuzzy-urls.url
(:require [clojure.string :as string]
[c... |
I recently challenged @Hosch520 with writing a query as such:
Find first questions with answers posted within 24 hours
And he did great. I figured I would have a go at it too. Turns out I learned valuable things about data subsets, so here I am seeking review.
I did not specify whether to return only the first answer... |
LiveDate has the ability to display the current date either by asynchronously fetching the time from a server or by just using the client system date. It's only as accurate / reliable as the source being used.
It's pretty much finished, but before I definitely considered it that I'd like to get a full review of it.
Spe... |
I have been using Python to learn programming, but I am just recently beginning to utilize classes. I have a basic game below. Please review and let me know what I should improve on.
import random
class Game:
def __init__(self):
self.winningNumber = random.randint(0,100)
self.humanGuess()... |
I'm trying to have a main App view with references of all my views to manage and call transitions between theses views. But, I have circular dependencies.
app.js
define([
'jquery',
'underscore',
'backbone',
'views/viewOne'
], function ($, _, Backbone, ViewOne) {
'use strict';
var AppView = Bac... |
Inspired by this question and my answer to it I told myself I could try an optimized version for a 4x4 puzzle. There are only \$16!\$ possible states, so the state fits into a single long. However, representing the state as a primitive is ugly and precludes generalizations to bigger puzzles.
Before reviewing please not... |
It's about two months since I posted this question on CodeReview. I've been working hard to improve the code posted there and came up with the following.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned long long ull;
int main(void) {
ull start=1, stop=100,cnt;
register int t,len;
... |
I'm looking for feedback on a repository I set up based on a blog post I read here.
I have just recently got more into .NET within the past year, so any feedback and/or best practices that can be thrown my way would be appreciated.
The branch I am working in can be seen here if interested.
IGenericRepository:
public in... |
I hope the extension methods ThrowArgumentNullExceptionIfNullOrEmpty and ThrowNullReferenceExceptionIfNullOrEmpty are straightforward.
I have a property in my class called ConnectionString. I can set this property through a method called SetConnectionString.
public static void SetConnectionString(string connectionStrin... |
The purpose here is to make it easy to use sensitive data that is already in the form of a SecureString (example) without converting it to a String object and risking more leaks than necessary.
SecureString isn't about total security, but it is about reducing attack surface. For example, when you call SecureString.Appe... |
I've written a script to automate the entry of laboratory instrument data into an Excel spreadsheet using pandas and win32com.
I've got the script functioning correctly, but it is painfully slow. In an attempt to profile the code, my acfmp_ToExcel function seems to be the culprit. I've pasted the profiling data for thi... |
What follows is an implementation of the java.util.Map interface with weak values. This means that entries should be removed from the map when their values become weakly reachable, in the same way that WeakHashMap removes entries whose keys have become weakly reachable.
It is intended to fully implement the contract of... |
I have this painting app called JPaint in Java and I'm wondering if it could be improved. The variable declaration seems repetitive and long, and I think it might be able to be improved.
public class JPaint3 {
private JFrame frame;
private JFrame startFrame;
private DrawPanel drawPanel;
private LineBor... |
I am trying to iteratively turn a tree into a list.
For example:
c1
c11 c12
c111 c112
The tree above should return:
[
{'value': 'c1', 'children':
[
{'value': 'c12', 'children': []} ,
{'va... |
The following code is complete and works perfectly. What I want to do to is make it more modular in a way where I can use the code again - similar to an api. I also hardly ever code in javascript, and I think my code looks disgusting, I feel like there are cleaner ways to write what I've written but I just don't have ... |
I was trying to solve the problem where given a larger string and an array/list of smaller string, we need to make the determination whether the larger string contains each of the smaller strings. I realized one way to do it would be to create a suffix tree for the larger string and then look for each of the smaller st... |
I am learning Java through Stanford CS106A and I'm wondering how the code for this early assignment looks. I've worked in a proprietary scripting language before and so I'm trying to get the right programming form down for Java. It works but am I doing anything in the wrong way? Am I declaring and initializing my va... |
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()) == 'string' && typeof(j = replace.shift()) == 'string') t = t.replaceAll(i || '', j || '');
return t;
};
function html(input, re... |
I would like to offer for review a simple tkinter GUI window in Python 3 to be used for data entry into an SQLite database table. As a noob, this is my first attempt at OOP and my first experience with tkinter, therefore, I was hoping for a thoughough review before I got too carried away.
The script below builds a s... |
I have created a virtual piano that turns the home row (excluding 'g' and 'h') and the top row (excluding 'y' and 'u') of the user's keyboard in a piano's keyboard.
The home row is used for white keys and the top row is used for black keys.
The keyboard's keys bind to piano's as shown below:
a - C
w - C#
s - D
e - D#
... |
In my journey to learn Clojure I recently decided that I would like to write a chess engine, which is kind of funny because I don't really know chess either. ;-) My goals are to learn Clojure and chess, and write something that is fairly easy to understand.
Currently I'm working on board representation and basic movem... |
I am currently reading Eloquent JavaScript and am trying to solve the exercise problems. One of the exercises in Chapter 18 asks to emulate Conway's Game of Life using checkboxes in JavaScript.
Before looking at the official solution, I like to solve the exercise on my own and then compare it with the author's solution... |
Here is my implementation of the suffix array construction algorithm which follows this paper (specifically, pages 4 and 6).
#!/usr/bin/env python3
from math import ceil, log2
def sufar(txt):
txt = txt + chr(0)
N, tokens = len(txt), sorted(set(t for t in txt))
equivalence = {t: i for i, t in enumerate(... |
In an MSSQL database, I have automatically increasing IDs for every entry.
Is it safe to acquire the ID of the newly inserted entry like this? I am worried that, if at the exact same time another entry gets inserted, I could end up with the wrong ID.
string query = "INSERT INTO subscriptions (polygon,...) VALUES (@pol... |
I have wrote the following code in C++ for the n-body problem. This code is sequential as later on I am planning to parallelize it using OpenMP. I want to know whether I have wrote the correct implementation, if there are some errors or bugs, or if this is an invalid approach.
#include <iostream>
#include <ctime>
#incl... |
I'm moving on to graphics, picking Pyglet and Cocos2D. This is my first program in Python with GUI.
Introducing:
Two distinct high definition button sprites
Satisfying high quality button pressing clicks
Conveniently positioned counter
Fully functional exit button
Detailed error logging techniques to support software ... |
Let us define prefix-function(string)[i] as the length of the largest prefix of string, which is also a suffix of string[1..i], and z-function(string)[i] is the length of the largest prefix of string, which is also a prefix of string[i..].
Unfortunately, there is very little information on them in English, but I found ... |
I am using the following technique for simulating mixins (or Traits) using Java and would like to know whether this is reasonable or just confusing to future developers. Also, I believe a good naming scheme is the best documentation, so if it would help to change the nomenclature, please provide suggestions.
/** A mix... |
I was thinking about splitting a string based on certain categories, for example alphabetic and numerical, lower and upper case, and even the 3 lines of the keyboard. I wrote a generic function for this but it seems unreadable, so I ask you for better modularization and improvements to readability.
import doctest
def ... |
This is router I created for use, however, I wish to refactor this code and make this more robust. I would really appreciate anyone who can:
Point out how to make this code more robust, clean and flexible in terms of reusability where the user of this module can easily alter the configuration, etc to his/her needs wit... |
I'm new to C++ and SDL, and I've written a Texture manager class whose purpose is to help me manage sprites and other textures. I have a dispose method which unloads all the textures from a map container. It works correctly but I'd like to ask if I am not causing any memory leaks, or other pointer related issues.
Textu... |
I got my JWT generation working with X509 and wanted to ask if you would recommend any changes in respect to:
Signing certificate storing / handling.
Publishing for anonymous access public key
Background info on service:
Generating JWT with refresh token
Expiration set in DB
Certificate (*.cer) x509 is stored... |
I have function that convert binary number to unary number based on a Markov algorithm. In what ways can I improve the code?
The algorithm goes as follows:
Replace all 0l with 0l
"|0" -> "0||"
Replace all l0 with 0ll
"1" -> "0|"
Major Step 3: Remove the 0
"0" -> ""
public List BinaryToUnary(List value)
... |
Von Neumann extraction is a technique to remove bias from a source of entropy. You extract an unbiased array of bits from a biased one by comparing pairs of consecutive bits in the array and returning the first one when they are different, or nothing when they are the same. The extracted array will be smaller than the ... |
I implemented this peak finder for practice. I have tested it. Everything looks pretty good to me. Please let me know if there is any improvement I can make.
Peak Finder
Let input be an array. input[i] is a peak if input[i] >= input[i + 1] and input[i] >= input[i - 1].
Implement a recursive algorithm of time complexi... |
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that only one letter can be changed at a time and each intermediate word must exist in the dictionary. For example, given:
start = "hit"
end = "cog"
dict = ["hot","dot","dog","lot","log"]
One... |
I wrote a simple neural network simulator (the biophysical kind) from scratch, and was hoping to get some feedback on how I can speed things up, or any C++ / compilation best practices that I can improve on.
The code is at this repository.
Main Problem:
OpenMP doesn't seem to be conferring speedup.
The performance-crit... |
I've been toying around with some code I wrote a while back, in an attempt to make it "cleaner" based on what I've read. Does anything stand out to you as bad conventions here? What are your thoughts about doing some conditional checks as separate variables at the top of the function? I thought of putting those into th... |
I am developing a chat bot with Node.Js. I am trying to find efficient way to parsing sentence.
what do you think about humanity
-> ba bla bla.
what do you think about cats
->I love cats
Right now I am using the intersection technique, but I don't think it's efficient:
var sentence = sentence.split(",")
var inters ... |
How can I simplify this?
if ((principal == null || principal.getName() == null)) {
boolean isValidInputData = true;
if ((!reCaptchaBean.isValidCaptcha(recapchaResponse))) {
model.addAttribute("captchaError", messageSource.getMessage("СaptchaError", null, LOCALE_RU));
... |
I've written this method to replace an older method that was much simpler, but used the regex split method and couldn't tell if a comma was in quotes/brackets/etc. and didn't read double quotes as single. I was hoping to cover most of the most used possible CSV formats except where a tab is used as a separator rather t... |
I have a render function:
render: function(playerId) {
this.getTotalPoints(playerId);
// and some other code after this;
}
This render function may be executed with or without a playerId.
This is the getTotalPoints function:
getTotalPoints: function(playerId) {
if (playerId) {
this.allplayers[pla... |
I have implemented simple tree class as follows:
public class MoveTreeNode
{
public MoveTreeNode Parent
{
get;
set;
}
private List<MoveTreeNode> children = new List<MoveTreeNode>();
public IEnumerable<MoveTreeNode> Children
{
get
{
return children;
... |
I'm using a levenshtein matching algorithm to match a title to a filename (for anime). I either use the main show title for matching or its alternative titles (flexget_titles).
For that I have the following snippet of code.
public function matchFilenameToShow($filename)
{
$shows = $this->shows->getAll();
$short... |
This is a relatively simple script (basically it's a dictionary containing information on how to edit the input text), but I'm trying to learn to write stuff properly. The commented bit at the top seems a bit messy, but I'm not quite sure how else to demonstrate all the functions in action.
Function names are also not ... |
As a follow-up to this blog post and this question, I wanted to post my idea of replacing the IUnitOfWork with a factory pattern. It seems to me that in the case of this blog post the IUnitOfWork seems to be a type of sudo-factory pattern with each repository type and their accessors hardcoded. So my goal was to come u... |
Is the following an effective way to implement the Levenshtein Distance with Haskell vectors?
import qualified Data.Vector as V
levenshtein s1 s2 = levenshteinV (V.fromList s1) (V.fromList s2)
levenshteinV p1 p2 = lev V.! l1 V.! l2
where
lev = V.map levi (V.enumFromN 0 (l1 + 1))
levi i =... |
Where should you store state and how should it be managed in a ClojureScript application? Take the following code for example - it's a "game" where you travel either down or left.
(ns cljsfiddle)
; initialise the state
(set! (.-x js/window) 0)
(set! (.-y js/window) 0)
; state modifiers
(defn inc-x! [value] (set! ... |
I have the following code which uses EntityFramework to reach out to a DB and retrieve data to populate into a Winform application gridview.
I am still quite new to C# and especially abstracting code out of code behind/writing loosely coupled code.
Could the following code be reviewed and feedback given on the methods ... |
In the Windows operating system, some system events are notified via broadcast window messages. DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE are good examples of this. To receive and process these notifications, one need to have a window with an associated window procedure. Given a non-GUI application, this is a burd... |
Here's the first, straightforward version of BF interpreter:
def run(step_limit, memo, m_i, code):
""" Runs valid BF code. """
if len(code) == 0:
return
i = 0
for step in range(step_limit):
cmd = code[i]
# Switch - case
if cmd == '+':
memo[m_i] += 1
... |
Can you please review this code to determine if it's good or can be improved?
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int h = 20;
int bl = 1;
while (h != 0) {
for (int i = 0; i != h; i++) {
cout << " ";
... |
I'm implementing my own time unit class. This class provides a function for fetching a specific time value (milliseconds, seconds etc.). In order to prevent defining several get() functions for each time unit, I tried to implement a single function to serve this purpose.
typedef unsigned char u_char;
typedef unsigned s... |
I have a function that takes two separate wordlists and searches a third list, which is a text formatted as a list of wordlists.
The function finds the proximity between words in word_list1 and word_list2 by taking the difference between their indexes; (it takes one over the difference, so that larger numbers will ind... |
Purpose:
I've on occasion required a method for changing a (or a set of) Display names (formats, order, etc.). The problem was I'd have to push to production just to change something as simple as display name of a column. To fix this, we decided on storing this metadata information into the database (or really anywher... |
I have the following snippet of LESS code to generate CSS. I have some different classes which I apply to different elements, and on hover or focus they should change color.
.social-icons {
color:#bbbbbb;
// Material design palette, 500
.blue {
&:hover, &:focus {
color: #2196F3;
}
}
.red {
... |
I need help in improving this script that I have written to parse a URL and check it from an array.
This is what I have done till now: (fiddle)
This is working fine. Was this done correctly? What exactly I need is to search URLs in a list (ul) (which will be a domain specific), and then match if the URL is found in an ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.