instruction stringlengths 71 71.9k |
|---|
Is there a more conventional / standard / easy-to-read way of building an index of tuples from an iterable than this:
# -----------------------------------------------------------------------------
def build_index(itable_tup):
"""
Return an index for an iterable container of tuples, all the same length.
The... |
Being that I needed a min-heap implementation for a project, I implemented one. Now that it's finished I though about having a review for it. I'm interested in all aspects: readability, performance, naming, comments, everything.
I'm planning on extending it afterwards with other features like the possibility to choose... |
In my attempt to help improve Using Array to store calculations in VBA, I figured a good way to do it would be to create two dictionaries of values to lookup.
So this was my attempt at creating two dictionaries from two sheets and then gathering data from a third sheet into an array and looking up the items in the arra... |
I have a class which inserts a list of tweets to a database table and also inserts the tweet's key with the associated filter's key to a many-to-many table. I am testing the sole public method of this class:
class TweetByFilterDatabaseRepository {
private final DatabaseFacade database;
private final Mapper<Tw... |
This is meant to be a bidirectional flow BidiFlow that works exactly as BidiFlow.identity, except that it completes the stage as soon as one of the Flows (in1 -> out1 or in2 -> out2) is completed.
This can be useful to automatically close a connection fully when one of the two sides is closed.
There are a few tricks to... |
I have created a function that parses a directory tree, and returns a list of lists that groups specific files within for later program specific parsing. I feel like it could be done better, considering I've used dummy variables, and was hoping some of you could help.
def get_output_files(path) -> list:
"""
Th... |
Hear this problem: Write a C/C++ program that reads all the values from the "BAC.TXT" file and determines which are the two largest three digit numbers that are missing from the file using a time-efficient algorithm. This is the code that I wrote and it returned good values for all the input sets I tried:
#include <io... |
I had the following piece of code for populating a list of currently running processes in an IT Self-Help application :
var proclist = ProcessHelper.GetProcList();
var i = 0;
var j = 0;
foreach (var process in proclist)
{
if (process.ButtonText == "") continue;
var button = new Button();
if (i < 7)
... |
I am designing a database and I am just wondering if I am doing it correctly. I have tables for things like State with all the states in them and then I reference the ID in other tables. But should I just handle this in my UI and then store it as a string or is this the correct way?
The goal of this database is to hand... |
About
I'm trying to implement a simple virtual machine. Now it supports only three operations:
ADD(reg0, reg1, reg2) -> reg0 = reg1 + reg2
LOAD(reg, value) -> reg = value
EXIT -> finish process
It has 8 registers and no memory (for now).
Source code
main.rs:
use std::process;
mod opcodes;
mod utils;
const REGISTERS... |
I have the following javascript code that I'm trying to modularize using ES6:
import $ from 'jquery';
$('.select-element').change(function() {
const $this = $(this);
const $nextElements = $this.nextall();
const $nextElement = $this.next();
$this.val() === 0 ?
$nextElements.addClass("hidden") :
$nextE... |
I wrote the following code for a coding challenge I was given and it received the following criticism: it was quite a beginner attempt using Angular.
<body>
<div id="view" ng-view ></div>
<script >
angular.module('myapp', ['ngRoute']).
config(function ($routeProvider){
$routeProvider.
when('/',{ ... |
I have the case of repeated very similar logic that is used to check if a boolean value was changed from the initial value and prevent it from changing back, or to summarize multiple boolean return values like:
bool SomeMethod()
{
bool endResult = true;
foreach(var obj in objs)
{
bool result = obj.M... |
I have a problem similar to the baseball elimination. Given some teams, the number of wins they have and the number of games they have left between each other I have to find for which team it is still possible to win. I am using the maxFlow algorithm to solve it. First I build a graph without the team I am currently ch... |
I'm currently having a go at some past Google Code Jam problems to help me practice my programming skills.
One of these problems is Problem A ("Googol String") from Round A APAC Test 2016. Here is the problem for reference (you can find the details via the link):
Problem
A "0/1 string" is a string in which every chara... |
Here is my personal implementation of the clustering k-means algorithm.
from scipy.spatial import distance
import numpy as np
import random
# (x,y) coordinates of a point
X = 0
Y = 1
def get_first(k, points):
return points[0:k]
def cost(cetroids, clusters):
cost = 0
for i in range(len(centroids)):
... |
My code works perfectly, however, I know my approach isn't best practice practice. I would appreciate the effort of anyone who tries to explain in details on how I could refactor this code using either(presenters, decorators or poros) - I have no deep understanding of either yet.
Here is the code below:
In my events c... |
Here is what I'm trying to accomplish: Suppose you are trying to control an embedded system with several external hardware resources/components/devices. Naturally, you are concerned with the issue of sharing these resources, locking them. Also, the control flow of the overall program must not be unnecessarily impeded b... |
From the Project Euler challenge series:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
The brute force method runs in 1.8s per loop on my machine:
def get... |
I am trying to convert a tri-gram containing 3 characters of type wchar_t to an integer type (an uint64_t at the present time).
It's been quiet a while I've been working with shifting and squeezing bytes. Here's what I've come up with so far and it - at least the few test cases in the tri-gram list - seems to work so f... |
I'm working on a simple LRU cache for C++. There's nothing spectacular or unusual about it, but I would like it to be thread safe.
(I'm going to be using this for instructional/benchmarking/entertainment purposes in a blog post, not in production, so mostly I just want to avoid embarrassing myself or causing undue har... |
I would like to use Haskell to do some image processing so I have been writing small programs to test performance. I wrote a program to batch convert PNG images from color to greyscale. I compared the performance of the program below with a Python script using PIL. I found when compiled with -threaded -O2, the Haskell ... |
I would like to ask your advice on my simple code to login and registration sessions.
In the User class, login function:
public function login($username, $password){
$this->db->query("SELECT * FROM users WHERE username = :username AND status = :status LIMIT 1");
$this->db->bind(':username', $username);
$... |
The following is my first successful running C# program.
The lessons that I personally learnt through this include:
The value of asking for help after having tried several times
The advantages of being adaptable about one's methods of reaching an end
The (a?) proper placement of functions in relation to a main program... |
I have been working on a Project Euler: 125, which took me ages to solve. The problem and source are cited below
The palindromic number 595 is interesting because it can be written as
the sum of consecutive squares: 6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 +
12^2.
There are exactly eleven palindromes below one-thousan... |
This is my first TDD Kata I've done and I'd appreciate it if someone could review it.
String Calculator
Create a simple String calculator with a method int Add(string
numbers)
The method can take 0, 1 or 2 numbers, and will return their
sum (for an empty string it will return 0) for example “” or “1” or
“... |
I wrote a script that you can use to open the file explorer from command line like
e db --> opens my Dropbox folder (e.cmd is the name of the script)
e bin --> opens my script folder
(I’m not very happy with the way I define the relationship mnemonic <--> folder.)
Remarks, anyone?
@ECHO OFF
SET "target=%~1"
if "%targ... |
I'll define template <typename...> class VariadicTree with the following example:
VariadicTree<A,B,C,D,E,F,G,H,I,J,K,L,M,N,O> is a binary tree whose type for insertion, removal, searching, etc... is A. But it will also accept insertions, removals, searches, etc... of objects
of type B,C,D,E,F,G,H,I,J,K,L,M,N, or O as ... |
I've written a script that recursively goes through a directory tree and looks for folders containing folders with NOT INVOICED in the folder name. If it finds one it prints the name of the containing folder and the names of any folders inside it with NOT INVOICED in the folder name.
The output is:
FOLDER 1
NOT ... |
I have a library which is being used by customers and they are passing DataRequest object which has userid, various timeouts and some other fields in it. Now I use this DataRequest object to create a URL, then make an HTTP call using Apache HttpClient for which my service returns a JSON response which I use to create a... |
Here was my first, simple C fizzbuzz:
#include <stdio.h>
void main() {
for (int n = 1; n <= 100; ++n) {
if (n % 3 == 0) printf("%s", "fizz");
if (n % 5 == 0) printf("%s", "buzz");
if ((n % 3 != 0) && (n % 5 != 0)) printf("%d", n);
printf("\n");
}
}
I was messing around, trying to separate the trans... |
Rubberduck's Code Explorer was recently redesigned from scratch:
Anything from modern features, such as virtual folders (limitation of the VBE--it doesn't support real folders), to ancient features in the original VBE, such as printing.
Here are some of the commands I wrote that I'd like to get reviewed:
The Indent co... |
I'm using Microsoft SQL Server 2014 Express.
I found myself wanting to add the Columns CompanyNameChangeDate (1 through 10) and CompanyNameChangePreviousName (1 through 10) to a table in my database.
I wrote the following query to do it:
declare @i int
set @i = 0
Declare @nameChangeDatePrefix as varchar(255) = 'Compan... |
I wanted to put this out here and see if there were any security vulnerabilities that I'm not seeing. Also, if I can improve performance without sacrificing security, that's always a plus. Thanks in advance!
Typically, when you want to validate an e-mail address, you store an activation key and expiration date in the u... |
I am sharing a viewset between two types of routes in Django: one is a nested route (/users/:id/comments/:id/), and a regular route (/comments/:id/). The query set returned is either filtered by the user_pk or it's not. What is an idiomatic way of writing the following?
if(user_pk):
queryset = Comment.objects.filte... |
I have these scripts I made that work absolutely perfectly as I need them to. Is there any improvements that can be done to these scripts and make them more efficient for Mobile Platforms? Or even just combine them into one script?
These 4 scripts are just about identical except that each one controls a different obsta... |
Do you see any security issues with this authentication approach or have any suggestions?
WebAPI is REST-based. The user logs in by calling the Authentication Controller and expects a 401 if unauthenticated or a 200 with a session token in the header.
GitHub
Session session = null;
try
{
session = Models.User.Logi... |
Can someone please review this design I created for deck of cards in Java?
package prep.design;
import java.lang.reflect.Array;
import java.util.*;
/**
* Created by rohandalvi on 5/14/16.
*/
public class CardDeck {
private ArrayList<Card> cards;
CardDeck(){
cards = new ArrayList<>();
for(C... |
I am studying algorithms and I solved this problem under Dynamic Programming section:
Alice is a kindergarten teacher. She wants to give some candies to the
children in her class. All the children sit in a line ( their
positions are fixed), and each of them has a rating score according
to his or her performanc... |
I am developing a WPF component that can be used to create interactive tours for WPF applications. To further improve the API in terms of usability and intuitiveness, the input of other developers is needed.
The following feedback would be helpful:
Do you see potential to improve naming?
Do you like that organization ... |
The problem is as follows:
I have a matrix with impassable fields those are marked by the input. There is also a castle which reaches up the right side of the matrix. I have to find how many paths can there be in such a matrix, starting on the right above the castle and terminating on the right below the castle.
I proc... |
I have implemented a splash screen, to hold/pause the screen for few seconds and then launch the next screen. I am very enthusiastic to know if there is a more basic way to write the code.
public class SplashActivity extends BaseActivity {
private final int SPLASH_TIME_OUT = 2000;
@Override
protected void... |
I'm relatively new to C++ and am trying to learn good programming practices and habits from the beginning. The code I wrote finds the largest common subsequence between to strings (and output the resulting subsequence, not the length of the subsequence).
I was wondering if there were any improvements I could make to ma... |
I'm building WPF/MVVM application and I'm struggling implementing Unit of work pattern.
The part, about which I'm not sure is UnitOfWork class. Here is my thought:
It's coupled with my repositories and MyDatabaseContext. At first impression, it doesn't sound good. But, I think, UnitOfWork should be coupled with DbConte... |
This is the first program I've created without help from a tutorial. Written in Python 3.4, it gathers a specified number of media files and opens them in the default player (I use VLC on Windows 8.1). Python is my first language I have been learning mostly through trial and error. I am posting here to see what I can ... |
I always have enormous difficulty working out 2D grid addresses, so for me it is easier to work with the List functions. All tests pass and I'm looking for feedback on clarity, functional programming concepts, or extra edge cases.
Source:
class Board(values: Int*) {
require(values.length == 81, "Board must contain... |
I wrote a simple JavaScript SEO keyword counter. The user enters their SEO keyword in one field then enters their webpage text in a textarea field. It then calculates (in realtime, as the user types) how many times the keyword appears in the web page text. It also calculates the keyword density.
It works but probably i... |
I wrote code that chooses a random set of Chinese characters, asks the user what the characters are, and if they meet a certain criteria they level up (ex. get more than 50% correct). I want to know if there is a better way to have fewer lists, better organization, etc.
# -*- coding: utf-8 -*-
import random
allnumbers... |
I have a class called TicTacToeBoard that has a [3][3] array of TicTacToeBoardCells. Doc neck if board has a winner, I check if any of the 8 possible combinations have 3 of these are type.
Is there any way to make the check of the 8 states more elegant? I am not looking for optimizations like reducing number of checks... |
This project was made to replace the stock Android CountdownTimer class. It is more responsive when completing the timer and adds additional functionality such as lap counting and start, pause, resume, and stop methods.
However, I am not so familiar with threads and was wondering if I am doing it right and how it can b... |
I am in my first object-oriented project and wrote this method for updating the database. The PDO include is just for convenience, so I could work on a single file temporarily. I'm not entirely clear on how or why to use the __constructor for this particular situation.
<?php
include 'pdo.php';
class database{
functi... |
I'm scanning a CSV file to see which values fit inside of a given box. The CSV file has X and Y coordinates, and the arguments to the function are the perimeters of a box (i.e, top, bottom, left side, right side). I don't want to use any external libraries; part of the purpose of this is to learn how to speed up code m... |
I've created little block of code that should update a external program, but I've checked it through and have not seen possible error or warnings. There are no errors in my testing but I wan't to publish it so tried to make it as comfortable to many users as possible. I hope that someone could check it too and tell me ... |
For educational purpose I implement recurrent merge sort without recursion. The algorithm idea seems absolutely clear but my implementation appears to be really slow:
5 seconds to sort 10,000 values;
6 minutes to sort 100,000 values;
it was not able to finish 10,000,000 in several hours (while lib sort() function does... |
I would like to know if the below VBA can be streamlined to process faster, since it takes on average 9hrs to complete a sheet (800 000 lines), and I have quite a few to get through. Running on 3 computers already to get ahead of the work.
Sub Calculate_Sheet()
Dim orderSh As Worksheet
Dim wiroSh As Worksheet
Dim last... |
This code is a proof-of-concept which I intend to convert into a static utility / helper class. I'm looking at this review from a structure or performance viewpoint. Small detail such as whether it prints or returns something, or whether the output is well-formatted, don't concern me too much.
The purpose of this code ... |
I need help reviewing my code snippet copied below.
The below code counts the number of continuous ones in a given array of Size 11.
#define size 11
#define ONE 1
using namespace std;
#include <iostream>
#include "stdio.h"
int arr[11] = {1, 0, 1, -1, 0, 0, 1, 1,0, 1, 1};
int sequence_count = 0;
... |
So I have following piece of code which basically validates five date fields in angular service.
But the catch is that there may be one to five field(s) visible on the screen based on some other criteria.So the code checks if one datepicker is shown it will only validate one input.If three datepickers are shown it woul... |
Here is my Graph class that implements a graph and has nice a method to generate its spanning tree using Kruskal's algorithm.
I want to:
Make it pythonic
Improve readability
Improve the abstraction (but not changing the use of outer and inner dicts to represent the graph)
Performance is not a concern.
Code:
class Gra... |
I am brand new to Scratch (and animation in general) and have been playing around with various techniques I feel will probably come in handy. My project in question can be viewed here. It started as a basic, infinitely scrolling background and a sprite (in this case a dragon) with a fixed position. The scrolling of the... |
Edit: I found a potential solution. Changing all of the Dim as Long to Dim as Integer allows the scripts to run smoother. However, there is a potential that the number of rows in some instances will exceed 32767. Is there a way I can put a condition on the first few statements, to use integer only if there are less tha... |
This is a piece of code that implements an image-processing algorithm I came up with. I call it Dynamic Colour Binning. It's a fairly academic exercise that was more about providing a learning experience than about producing something useful, but here is what it does:
Input: A set of images with a limited colour space.... |
I just got some negative feedback on some code I wrote and I was not able to know exactly what was wrong with it (I tried). It is a program that verifies to see if a social security number is valid or not. The program is working fine.So I would really appreciate it if somebody could take a look and tell me if this can ... |
I have written a basic event emitter in JavaScript and I'd like some feedback on my design. I tried to make it as simple and minimalist as possible, as I'd like it to be understandable by anyone.
I have wrapped the code itself in a top-level "module" that adds it to the global namespace under the name events. I have al... |
Given the following code:
namespace AtBash
{
class Program
{
static List<string> letters = new List<string> {
"Aleph", "Beis", "Gimmel", "Daled", "Hei", "Vav", "Zayin", "Chies", "Teis",
"Yud", "Chof", "Lamed", "Mem", "Nun", "Samech", "Ayin", "Pei", "Tzadik",
"Kuf", "Reish", "Shin", "Taf"
... |
I am a newbie in this world of data structures and algorithms (returning to these topics after 5 long years). Can someone please check if the code I have written for Binary Tree is OK?
Test-case
10, 3,11,11,5,0
PrintInorder
3,0,5,10,11,11
PrintPreOrder
10,3,0,5,11,11
PrintPostOrder
3,0,5,11,11,10
using namespace std;... |
Next Saturday I'd like to conduct a TDD demo in our local developer meetup. For this purpose I want to implement the first user story of the BankOCR kata from the Coding Dojo Wiki.
Here is the solution I came up with. Any feedback is appreciated.
AccountNumberParser.java
package com.demo.bankorc;
import java.io.Buffer... |
I am working with this code to parse through HTML files stored on my computer and extract HTML text by defining a certain tag that should be found:
from bs4 import BeautifulSoup
import glob
import os
import re
import contextlib
@contextlib.contextmanager
def stdout2file(fname):
import sys
f = open(fname, 'w')... |
I'm trying to accomplish the following:
Start out with 1 interval on the real line. This interval is processed in some function and out comes an array of errors (size < 10 usually). The maximum element of this array is also stored and the interval is put onto a queue sorted by this maximum error.
Then we proceed by tak... |
This is a variant of the Manhattan Distance problem. The input is a 2D matrix of boolean with the true cells representing location of an ATMs(or anything for that matter). The output has to be a 2D int matrix giving the distance of each cell from the location of the closest ATMS.
Here's my code,
public class ManhattanD... |
This is my second attempt to make simple lock using extended assembly.
See https://stackoverflow.com/questions/37241553/locks-around-memory-manipulation-via-inline-assembly/37246263
The code:
static inline void atomic_open(volatile int *gate)
{
asm volatile (
"jmp check\n"
"wait:\n" ... |
I am working on a server for a smart house. This part of code is responsible for communication with client (separate application), sending requested data and ensuring everything is safe.
I've decided to use multithreaded version of Python socketserver in order to avoid bottlenecks (I want it to be flexible enough to ma... |
This script records audio from the computer's output and passes it to a C program that fingerprints it and queries the Gracenote database. If it identifies the audio then it offers options to look it up on Discogs. I made this because I wanted a way to identify tracks in DJ mixes that didn't involve using Shazam on my ... |
I am new to unit testing and I am unsure how to design classes that use third party libraries, so that I can easily test them. The example I'll use is with EPPlus-OfficeOpenXml (an Excel document manipulator). I have a class to import excel documents and validate them.
Here is a sample of my code:
Imports OfficeOpenXml... |
Given the task of having to return an array that alternately takes elements from two arrays, what would be most Ruby way of completing the task? As of now, I have this code, but it doesn't feel very elegant.
def alternateTake (a, b)
raise ArgumentError, "Unequal length" if a.length != b.length
build = []
(0..a.le... |
For a new project I'm going to need to be able to serialize random types to TSV or CSV files, so I write a class which can be used to serialize any object to a TSV, CSV or any other _SV file you can think of. (You could literally serialize objects to files with the letter "B" or the word "Rawr" as the column or row del... |
I wrote a prime number sieve in Ruby last year as part of a coding challenge, but lately I wanted to port it to Rust. I finally got around to it, but it's still intensely Rubinic.
Before I take the obvious next step and parallelize it, I want to make sure my code is as Rust-idiomatic as possible, so that I don't develo... |
I wrote this program to process the names and meanings from .txt files. From the while loops I wrote, I noticed they are very similar loops containing Scanners. I am wondering if there is any way to reduce the redundancy in the code.
Also, for this program my instructor only allows us to use Scanners, while and if/else... |
I'm currently building a node.js addon for libcurl. Right now I'm trying to correctly use v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory to update v8 on the amount of memory being allocated by libcurl, and to do that I need to wrap the above mentioned functions that libcurl uses, using curl_global_ini... |
To give you a simple background, I've been programming in C++ for about a week and decided I wanted to build a simple snake game.
I made one over the course of a day and this is the end result. What overall improvements can be made to this code? Are there any general advice on programming that might be relevant?
#incl... |
I recently stumbled onto a very old article about procedural dungeon generation on this site. Unfortunately, the author did not provide any code, only a description of the algorithm he used. Wanting to use this in my game, I tried to write my own generator following their algorithm:
local random = math.random
local fu... |
I'm doing this HackerRank problem, which asks whether an array of up to 100000 integers can be sorted in ascending order by exactly one of the following:
swapping two elements
reversing a subarray
doing nothing (i.e. it is already sorted)
I've written this code and it passes all the tests, but it seems very convolute... |
I had a test task for internship where the main part was in implementing fixed size caches with different displacement policies (LRU/LFU/FIFO). I did that task, but was refused afterwards. Now I am wondering how my solution might be improved?
Requirements for an implementation are:
Cache must be thread-safe
Operations... |
I have this code that fetches rates from a website called X-Rates, and outputs to excel the monthly averages of a chosen country.
The code runs quite fast, but I still think there's improvements to be done!
Apologies for long code, but if you help me I would be really grateful!
Option Explicit
Public Sub fetchCurrency... |
I've created a method to split a date range into a collection of date-arrays. These arrays consist of two timestamps.
Example:
System.out.println("");
System.out.println("*****************************");
System.out.println("Split 2.1.2004 to 26.3.2004: ");
for (DateTime[] date : TimeSpl... |
I've been reading up on Actions and delegates for the last couple of days, and I think I'm finally starting to understand, but I wanted to check that I was using them correctly, or at least using them in a way that isn't totally insane.
I'm using a text-based game (as such) as a platform for learning about what I susp... |
Is there any way to simplify this query? It's being run against a Progress Database via an ODBC connection.
The CustomerSalesperson table has a CustomerID, a SalespersonID, and a CreateDate. Each CustomerID could have many records, each with a different SalespersonID. I'd like to get a list of the SalespersonIDs with t... |
I have been writing a web crawler in F# that downloads pages with stylesheets and scripts.
Can somebody give me suggestions on improving this code, please?
Would appreciate any feedback that could improve it / prettify it.
open System
open System.Net
let log fmt =
Printf.kprintf (fun str -> // todo: lock | agent... |
For a while now I've been playing around with various ways of passing a logical predicate E.G. >= someValue as an argument to a function. (see: If ComparisonIsTrue(thisPost, ComparisonOperator.NotEqualTo, goodCode) Then Me.Answer and a global enum for comparison operators)
In the end, I've decided to build a CLS_Compar... |
The following is a full example to illustrate my question:
#define MAX_LENGTH 32
#define ITEM_COUNT 3
using namespace std;
void doSomething(char ** name, int items)
{
*name = new char[MAX_LENGTH * items];
strncpy_s(*name, MAX_LENGTH, "Oracle", 7);
strncpy_s(*name + MAX_LENGTH, MAX_LENGTH, "Apple", 5)... |
I'm fairly new to VBA, and this was basically a brute-force solution to a problem I was encountering. I wanted to take data that appeared in two columns, and pull it together into one.
The current code works, but is very slow with large datasets. I've been told to avoid using the clipboard if possible, but I'm not qui... |
I need to create an structure to control dynamically locks. For example, I have 100 threads running, and each thread will "process" a "key". Sometimes two threads could be processing the same "key", and if it occurs, a dynamic lock needs to be created and used by both, to process one at a time.
I create the following s... |
I wrote a small function that checks if an image or multiple images are loaded. For that purpose, I decided to use ES6 promises, but I'm not really sure if my way of handling errors is the best way.
const loadImg = function loadImg(src) {
'use strict';
const paths = Array.isArray(src) ? src : [src];
const ... |
So, I have written a code which calculates the number under n( 1 million in this case) which produces the largest Collatz Sequence in that range().
The problem is given in detail below:
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rul... |
I am using the below jQuery and HTML to read in and use an XML server status feed for a server widget. This is the code:
XML Feed:
<status>
<script id="tinyhippos-injected"/>
<serverinfo>
<hostname>harvey</hostname>
<external>
http://stats.pingdom.com/3tltrr03waho/1435422/history
</external>
</serverinfo>
<host>
<statu... |
Recently I was looking for some really simple modal/popup solution in vanilla JS, but nothing popped. So I wrote mine component. It works great so far, have all the options I need, but I don't know if I can improve the code itself.
JS:
/* A very simple modal component
You can close the modal either with `esc` key, hitt... |
I am putting together a couple code samples for prospective employers and would love some feedback. I am still pretty junior so I am not sure what constitutes a good code sample and the do's and dont's.
The code sample shows both the original version of the code which is currently in production (at my previous company)... |
I have already asked a question about a dynamic multi threaded lock, and the reviewer found a problem.
Here is the description of the problem that I need to solve:
I need to create a structure to control dynamically created locks. For example, I have 100 threads running, and each thread will "process" a "key". Someti... |
Recently, I came across this problem on Codility. I am aware there is a bit of similarity to this question and this question, but I am trying to achieve this in C#.
The problem is as follows:
A non-empty zero-indexed array \$A\$ consisting of \$N\$ integers is
given. The array contains an odd number of elements, and... |
I have a table with columns dated by week that changes dynamically each day. Currently, I am using the following php code to get the proper dates for the past eight weeks:
$currentDate = date('Y-m-d');
$weekOneStart = strtotime("-56 day", strtotime($currentDate));
$weekOneStart = date("m/d/Y", $weekOneStart);
$weekOneE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.