instruction stringlengths 71 71.9k |
|---|
Problem:
There are \$n\$ pigeons and \$m\$ grains. Pigeon \$i\$ eats a single grain every \$x_i\$ seconds. Find the time until all the grain is eaten.
Input:
A line with the integer \$m\$ giving the number of grains, followed by a line with \$n\$ integers \$x_1, x_2, \ldots, x_n\$ giving the time taken by each pigeo... |
The purpose is to attach a tooltip-element to arbitrary HTML-elements.
The tooltip appears when the user hovers an element. Follows the mouse-pointer while moving over the element.
/**
* Attaches a tooltip to every element in the result-set.
* @param { string } selector - An CSS-selector.
* @param { number } hor... |
The code's purpose is to call to some function async given some condition was true. I've using the following code which is working as expected. Is there a way to write it better, maybe by not using the promise push array?
var _run = (req, res, oModule, oConfig, urlPath,action) => {
var aPromises = [];
//reques... |
I have created a rationalnumber class and used operator overloading function of C++.
My questions are:
Have I implemented the class and < operator correctly?
Objects of class can now inserted in map and set. Is that part done correctly?
#include <bits/stdc++.h>
using namespace std;
class RationalNumber {
int nu... |
Write a program to implement stack which implements min a method
which gives the minimum element below the top element in the stack.
const items = Symbol('Stack items');
class Stack {
constructor() {
this[items] = [];
}
pop() {
return this[items].pop();
}
push(data) {
this[items].push(dat... |
I've been developing a small screen sharing project for the last months, it's a desktop application, pct protocol based. I'm going to show the logic and the code and I hope to get reviews. I would like to hear every suggestion.
First of all, I'm using a service called Desktop Duplication API. Here's the C# implementati... |
I wrote a method that will confirm email with token send to user emails. It will also send different email depending on the condition for the registered user. If anyone would write the same method, how would you write this code snippet?
[AllowAnonymous, Route("confirm-email", Name = AccountControllerRoute.GetConfirmEma... |
Please let me know your feedback around handling ADO.NET connection and transaction, especially when it comes the catch block. Any way I could improve?
public static bool FileBulkLoad(string filePath, string tableName, string fieldSeparator, int numberOfSourceColumns)
{
using (var connection = new SqlConnection(Get... |
I'm currently trying to learn the idiomatic way to write F# code. The code simulates a basic calculator with only binary plus, minus and unary minus.
I'd like to know if there is a better way to group union cases than the way I did it. Should the Add/Sub/MinusExpression be cases in the Expression union? Is there a bett... |
I need to shorten/simplify this code:
require "time"
def parse(timings)
validdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
hours = {}
if timings.include?("Open everyday from")
validdays.each do |day|
open_close = timings.gsub(/.*everyday\s*from\s*(.*)... |
I've started learning C and as an exercise I decided to implement some basic functionality for a bloom filter. This is my first C project, so I wanted to see if I was doing things appropriately (project structure/organization wise). Also, I was wondering how to turn this into a shared/static library, since I tried ini... |
I have this program on Excel VBA, that implements a userform in order to simplify input and to create control charts from the data input analyze the data and send emails if certain conditions are met.
My problem is that everything works properly but after running line by line I noticed that when filling up the correspo... |
I recently started to learn Haskell in order to write some small tools for me. Currently I'm working on a program which calculates how much steam a (railcraft) boiler of a given size outputs per tick.
In the console the user inputs a string of the following format: S | L | BL-Size | BH-Size, example BH-3x3x4
I then use... |
These couple of functions solve (or attempt to solve) an arbitrary Euler square. In this case I will refer to it as the colored tower puzzle and explain it that way:
Given an n by n grid of tower bases of different heights (0 to n-1) which each base height occurring once in each row and column as well as n sets of n t... |
I had to jump through some hoops to get a localized enum working. I went through dozens of SO articles that never actually answered the relevant conundrum with a working solution. So I made my own:
I have two resource files: LocalizedStrings.resx and LocalizedStrings.es-MX.resx
With two corresponding lines:
GENDER_FEMA... |
I have a data scraping script that runs and scrapes records, saves into the following table:
For the records already existing in DB, I need to update the old records if it is not updated for the past 2 days.
My table has fields scraper_run_inserted (DATETIME value when record is inserted) and scraper_run_updated (DATE... |
actualarray = {
'single_open_cost_1':{
'cost_matrix': [
{'a': 24,'b': 56,'c': 78},
{'a': 3,'b': 98},
{'a': 121,'b': 12121,'c': 12989121,'d':16171},
]
},
'single_open_cost_2':{
'cost_matrix': [
{'a': 123,'b': 1312,'c': 1231},
... |
I am writing a program in an environment that makes use of cgroups to identify and group processes together. I want to parse the CPU utilization of each cgroup by sampling /sys/fs/cgroup/cpuacct/.../cpuacct.stat over a 1 second interval a few times and then averaging them. It also calculates the overall CPU utilization... |
I've been working on an ANTLR grammar that defines some tokens in terms of Unicode character categories (fileformat.info page). The Unicode Consortium makes a full data tab-separated-values .txt available at http://www.unicode.org/notes/tn36/Categories.txt.
The below scripts work together to take Categories.txt and tu... |
I have made one architecture on my project and want to know. Is it good or bad?
events = {
init: function() {
for (var callback in this.events){
this.bind(this.events[callback].selector, this.events[callback].event, this[callback], this.events[callback].params || {})
}
},
eve... |
I've written the following codes in Scala and Java to solve cryptarithmatic problems.
E.g. For SEND+SOME=MONEY, assign the digits 0 to 9 such that the equation holds true.
The algorithm I've used is backtracking without pruning.
Scala Implementation:
package recursion.flavors.decisions
import scala.language.dynamics
i... |
I'm very much used to enumerations a la Java, where each value in an enum is a distinct object. You can call functions on these objects, and they're generally treated as most normal objects.
Except ActionScript 3 doesn't have enumerations. So... I had to create my own.
My hard requirements:
Compile time type-safety ch... |
I want to return an iterable collection of all q-grams of a provided string. This means all sub-words of length Q. Let Q be 3 for example:
normalized as an already whitespace-stripped and upcased word or string. PREFIX3 and SUFFIX3 are constant strings ^^ and$$ that are put surrounding the string before splitting. That... |
The puzzler:
This was sent in by a fellow named Dan O'Leary. He came upon a common
one-syllable, five-letter word recently that has the following unique
property. When you remove the first letter, the remaining letters form
a homophone of the original word, that is a word that sounds exactly
the same. Replace ... |
I implemented a function that prints all the numbers from the Fibonacci sequence until max_num. The minimum value allowed is 0 (so, fib(0) prints 1). It works until 92, and I want to know how to improve the code, in general.
void fib(unsigned int max_num)
{
unsigned long fib_num = 1;
unsigned long fib_temp = 0;... |
I have a Django site where users upload and have the option to delete files. There will be a lot of files that will have the same logical name so I append numbers to them:
foo/bar/file.mp3 foo/bar/file2.mp3...
I needed a method that would return the lowest file number not currently being used. I have a working examp... |
Suppose my milestone is this:
milestones = [ {state: 'unavailable'}, {state: 'arrived'}, {state: 'completed'} ]
I want to remove all the unavailable state from the list of hashes except the last one. My function works pretty well but I need some help to re factor it even further, and will appreciate any comments you c... |
Can the following function be improved in terms of performance?
I am calculating millions of such hashes.
The long array represents a record from data table where all values are encoded as long values. Usually in one calculation stream all arrays are of the same length but in some rare cases this rule does not apply.
T... |
This is a small function I have written to equalise the height of groups of elements. Useful for when titles or content will end up being odd length and throw out the visual flow.
To use it you just add the data-equalize attr to two or more element you would like equalised. Can have multiple groups working on one page.... |
After dipping my toes in PowerShell for over a year i think it is time for creating a real cmdlet. My first mission was creating a regular PS script to take in a .csv and create a wifi account using the Aerohive REST api.
Although it works, i find the script bloated and ugly, and want to swap large code block for prope... |
I implemented a tcp socket server using the Microsoft IO Completion Port Model, which is basically an asynchronous model where WSAXXX function return immediately and you use a worker thread to handle actual completion of the operation and handle data received or sent.
There is quite a bit of code in tcpserver but not m... |
This is for heapsort and am wondering about the heapifyDown method. Here it is for review. I included relevant helper methods.
The heap is stored in array starting at index 1.
/*swaps node at i with biggest child if larger*/
private void heapifyDown(final int i) {
while(!isLeaf(i)) {
//find biggest child
... |
Today I wanted to find a program that I wrote a while ago. I knew that it contained a certain regex, but I couldn't for the life of me remember the file name I saved it under. I knew I could use Windows search, but it takes more time then it would for me to write a Python program to do the same.
The main two things I u... |
I wrote a recursive function to uncheck all menu nodes. It works well, but I need to know if it is right to leave empty block inside if (nodes[i].children.length === 0) base case.
Is there a better design choice?
The function:
function uncheck_all_tree (nodes) {
var i, n, n_dom_el;
for (i = 0; i < nodes.length; i... |
I am new to the whole Data Structures thing and I want to get better at writing efficient code. So, I have been practicing some problem sets. The questions is - Replace characters in a string using iteration and recursion approach. I am still learning the whole recursion approach. But I tried to design an algorithm usi... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Youtube Iframe load on thumb click</title>
<style>
.youtube {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
... |
I've recently wanted to make a "Loading..." display in C where the dots print one at a time in order and then reset:
Suprisingly, there isn't much on the internet for doing this well, so I figured I would make a simple program for it.
#include <stdio.h>
#include <time.h>
int main(void)
{
int msec = 0;
const i... |
Let's say I have a struct…
struct Person {
let isMale: Bool
let name: String
}
and an array of Person structs. I want to trim all the men (isMale == true) from the start and end of the array (similarly to how you'd trim whitespace from the start & end of a string)…
func trimMen(people: [Person]) -> [Person]
... |
I created a class that is able to generate a Sudoku board.
The following board generation steps are made:
Create a valid board with numbers on all squares, row by row
Basically I always generate the sequence 1 to 9 and I shift the elements on the cells. The shift amount depends on the row index.
Shuffle the board
Nothi... |
Update: Based on Mike's inputs, a better version of my code can be found below (search for "better version", to skip the ugly version)
The dataset I obtain after performing a table join in the database is this:
RestaurantID RestaurantName OutletID OutletName Address Phone Latitude Lo... |
I solve this problem in Swift. I am looking for a code review, thanks!
Given a non negative integer number num. For every numbers i in the
range 0 ≤ i ≤ num calculate the number of 1's in their binary
representation and return them as an array.
class Solution {
func countBits(num: Int) -> [Int] {
var ... |
Although C11 introduced aligned_alloc( alignment, size ), there is no support for aligned reallocation (AFAIK). The memory_resource structure that follows and its related functions provide such functionality.
I wanted to provide something with as little overhead as possible, which is why there's close to no error check... |
I've made this extension but I'm touchy around NSAttributedStrings, keenly aware that Swift refuses to use the traditional notion of integer lengths on Unicode Strings, what with their graphemes that can compose and overlap. Also, it feels odd to convert to String to check for the newline. I'm not worried about \r beca... |
I managed to send video feed over tcp socket using code and decode of string64. My problem is that the video feed is kinda laggy, and it's probably because of this time between coding and decoding.
Is there a simple way to improve this?
C#
private void enviar_data()
{
string data = "";
stri... |
I have the following C# code for deleting files from a folder (and from its sub folders) excluding a list of files specified in an Excel file. The code works fine.
The deletion is happening one-by-one in a for loop. Is there a way to improve its performance by reducing the time taken for deletion?
class Program
{
... |
The task is to create a website which allows the admin to create classes, students and teachers. He/She should be able to assign students to classes and one teacher. The admin should also be able to register students attendance using a register. Classes should have specified dates as to when they are running.
The teach... |
This code implements an FTPManager class and is designed to be a place to insert file data to be sent later, without having the program wait for a potentially very slow file operation to finish.
This code is designed to work around some issues that I've been noticing when having multiple threads use FTPWebRequest simu... |
Background and Example
This code simulates the Enigma machine, minus the plugboard. Here's some test code that illustrates how the machine's construction and use:
>>> r1 = Rotor("VEADTQRWUFZNLHYPXOGKJIMCSB", 1)
>>> r2 = Rotor("WNYPVJXTOAMQIZKSRFUHGCEDBL", 2)
>>> r3 = Rotor("DJYPKQNOZLMGIHFETRVCBXSWAU", 3)
>>> reflector... |
I am certain there is a better way to flatten the array with an optimized approach for the solution.
Example:
[[1,2,24],[12,1241,122],[3,2],[7]] => 1 12 3 7 2 1241 2 24 122
public class flattenArray {
public static void main(String args[]) {
int inputLists[][] = {{1,2,24},{12,1241,122},{3,2},{7}};
flatten... |
The goal is to write a generic doubly linked list program to handle.
Header:
#include <stdio.h>
#include <stdlib.h>
struct list {
struct node *head;
struct node *tail;
size_t element_size;
int element_count;
void (*printFunc)(struct node *);
};
struct node {
struct node *next;
struct node *previous;
... |
Uuencoding is historically used to encode emails. Instructions for creating a Uuencoder are:
Start with 3 bytes from the source, 24 bits in total.
Split into 4 6-bit groupings, each representing a value in the range 0 to 63: bits (00-05), (06-11), (12-17) and (18-23).
Add 32 to each of the values. With the addition of... |
I tried to refactor my code with entity framework configuration, splitting in multiple private methods, one per entity, each responsible for configuring things related to that entity and only that entity. But I feel like Version 2 can still be improved.
What do you think?
Version 1:
protected override void OnModelCreat... |
I wrote a small piece of code for observing changes on JSON object. Whenever there is a change in Object, it should trigger all the handlers with simplistic information about data change.
I am looking for improvements in the code. As I am struck with this pattern, could not think of better ideas of it. Please help.
How... |
I was refactoring a quite large WPF project and I found some pieces of code where it can leads to error.
Ive got some services in the form
public sealed class CurrenciesService : ContainerServiceBase<Currency>, ICurrenciesService
{
public override Currency GetItem(int id)
{
return GetItemInternal(x =>... |
I have written a script that turns an asn file into a hpp file, but it look very dirty even though I have made changes based on pylint.
I think I make use of too many lists, for-loops and try except blocks.
I would like to get a review of my code, and I am particularly interested in making my code look more organized ... |
Recently I was going through this codechef problem while practicing for the upcoming zoc.
The problem asks to calculate number of combinations of the given numbers where the sum is less than another given number.
Previously I had a bruteforce algorithm which gave the correct answer but took a lot of time, in some cases... |
I wrote this function for string concatenation some time ago.
Jo() stands for "Join". The name is shortened on purpose, because this function is used very often.
It offers a stream-like functionality: Jo("i = ", i) = cout << "i = " << i
and returns a const char * to internal buffer.
const char * is used instead of std:... |
I've done a practice session on cyber-dojo and would like someone to review it.
Main question - is my solution too complex for such a simple task?
For example, I decided to split out printing and generating logic into ChainPrinter and NumberGenerator classes. This in my opinion conforms better with Single Responsibili... |
Given a 2D matrix find the largest area of identical elements.
Here is my first implementation:
using System;
using System.Collections.Generic;
namespace ProgrammingBasics
{
class MaxArrayArea
{
static void Main()
{
// target matrix
int[,] matrix = new int[,] { { 1, 3, 2, 2, 2, 4 },
... |
I was wondering if there was a way I could shorten this code that gets input from the user about the state of their 2×2×2 Rubik's Cube to solve it. I want it to still be informative so any user knows what to do, the thing is the method is pretty long.
static public int[][] scanCube(){
int counter0 = 0;
Scann... |
How can I improve upon this code to apply logic based on the user's response to a SaveAs Dialog Box 'do you want to overwrite existing file' question:
Sub SaveFile(fName As String)
cancelSave = False
Retry:
saveAsFileName = Application.GetSaveAsFilename(InitialFileName:=fName, FileFilter:="Excel Files (*.xlsx), *.xlsx... |
I just finished working on a coding challenge for learning Python 2.7. Essentially, I'm a function that if it is fed a string such as:
"The man drank the drink and ate the bread and forgot the drink"
I get in return:
{'and': {'ate': 1, 'forgot': 1},
'ate': {'the': 1},
'bread': {'and': 1},
'drank': {'the': 1},
'dri... |
I'm trying to implement a heap using list data structure. I'd also like to keep track of the position of elements in the list in order to enable easy deletion. My implementation involves looping through the entire list to update the positions after an insert/delete combo. I'm afraid this raises the time complexity from... |
I have written a basic binary file handling program and have used goto, so I want to know how to improve this program by replacing goto with another function
#include<fstream>
#include<process>
#include<string>
#include<stdio>
#include<conio>
using namespace std;
int opt;
class housing
{
int hno,income;
char nam... |
jQuery plugin for a form. Looking for constructive criticism on my code. Thanks in advance!
// form.js
// splashinn
var Form = function(options) {
options = options || {};
this.url = options.url;
this.$fields = $(options.fields);
this.$status = $(options.status);
this.$submit = $(options.submit)... |
I'm working on a fluent interface builder that takes:
an array of strings, each of which becomes a key to an object that is a function that follows the fluent interface pattern
a terminator function which when called breaks the chain and does something else
I'm looking for some advice on how to improve this.
var Twit... |
I've got a function that I mainly use while web scraping. It gives me the ability to throw in a multi line address and clean it or a name field with unwanted characters and clean those, etc.
Below is the code and I would like to know if this is the best approach. If I should switch to recursive or stick with the while... |
I am copying data, that is one long list, into an excel sheet and I want to use a macro to organize it visually. The problem is that the data I am copying has empty cells that are unnecessary and will inhibit my code later in the macro and I want to get rid of them. This is what I came up with, but I am hoping there ... |
I've been learning Sass recently and I've made a small project to master key concepts. I've tried to use placeholder to make different styles of boxes. I have a few questions:
is the project generally correct (metodology, semantics, sass
structure)?
is it right to use nested style in placeholder (.icon in %feature-box... |
*** PS_HOURS.3_1
July |1 |2 |3 |4 |5 |6 |7
Name |Total|Total|Total|Total|Total|Total|Total
Abram, John |1.00 | | | |3.00 |3.00 |3.00
Agara, Hara |2.00 | | | |2.00 |2.00 |3.00
Alsi, Idria |2.00 | | | |2.00 |2.00 |2.00
Amon,... |
I am wondering how to optimize the following OCaml simple code.
#load "unix.cma";;
open Unix;;
let time f x =
let start = Unix.gettimeofday ()
in let res = f x
in let stop = Unix.gettimeofday ()
in let () = Printf.printf "Execution time: %fs\n%!" (stop -. start)
in res ;;
let syracuse x =
let... |
For a while, I have worked with the Nuget Epplus package to export MVC models to fresh Excel documents. While the code I show below works correctly, I have a feeling that either I can make this code better or perhaps that there is a coding pattern of which I am unaware that could simplify what I am trying to do.
The m... |
At my work, I need to use multiple versions of Java, depending on which project I work on. I've made a batch script to take care of this. There are several different actions that you can perform with the script.
You can change the current value of your JAVA_HOME from a version in your file. You can add new Java instal... |
I wrote a method early of our development last year about getting the content of a webrequest where it contains an xml data that we need to process and insert to database. I wanted to improve this, so I'm asking a feedback on these code snippets.
public async Task<BulkStatusCode> AuthenticateConnection(string url, stri... |
This is in reference to the following kata:
Item Unit Special
Price Price
--------------------------
A 50 3 for 130
B 30 2 for 45
C 20
D 15
I am still trying to learn F#.
Thus, I have the following code:
module Checkout
(*Types*)
type Type = A | B | ... |
As my go to first project for a language is a Mandelbrot, I had to implement one in Rust. I'm particularly annoyed by invalid_arg_count, as I feel like there has to be a way to add the arg length checking to the match. I also wish to find a way to multi-thread this in the future.
extern crate image;
extern crate num;
... |
I have a simple task that comes up often my work. I need to create a dictionary for an id key to a list of data associated with that key. I'm wondering if there is a better way to do this than the one I am using. The pattern is so common that I feel there must be better solution.
value_list_dict = {}
for line in f:
... |
I've been learning Haskell from LYAH for quite some time, and as a first practice for Chapter 7: Modules, I decided to make a simple numTimesFound function: it returns the number of times an element is found in a list.
Here's my working code:
numTimesFound :: Ord a => a -> [a] -> Integer
numTimesFound _ [] = 0
numTimes... |
I have implemented few functions of a linked list. Feedback is welcome.
Please note I have specifically avoided using pointer to pointers.
#include <stdio.h>
#include <stdlib.h>
// Node data structure inside the linked list.
struct node {
int data;
struct node* next;
};
struct node* BuildOneTwoThree(void);
void... |
I would appreciate critique and comments in regards of thread-safety on a basic type I'm trying to create.
In C#, the Lazy<T> type is initialized only once, and only when needed the first time.
My type, called Snoozy<T>, is similar, but differs in one important aspect:
The value can be reinitialized when necessary (but... |
I like to overcomplicate things, this is fairly simple though but I would like to keep it simpler without lowering readability. Not just to improve my code but also my self.
private String checkTrailingSlash(String website) {
if(!website.endsWith("/")){
website = website + "/";
}
return website;
}
|
I have a class which contains a reference to a parent of the same type( or null if it has no parent).
class MyObject{
private MyObject parent;
public MyObject getParent(){ return parent};
…
}
I have a list of MyObject, and need to order it so that every object comes after its parent in the list (the pare... |
I want to create a modular website with no frameworks or CMS nor server-side language.
Also, I am doing simple use of the hashchange event to help the navigation.
The structure would be as follows:
A basic container HTML page with 3 main areas: header, content, footer.
Individual HTML files - one for each page - which... |
Well, I'm writing a piece of code that will take a list of file names and should search a local drive for each file, determine if it's there or not, and return an array of all the paths found.
Right now I'm using a function that searches for one file and I call this function for each file in the list:
Public Function D... |
Currently, I am interested in programming. I have programmed a calculator in C. Everything works, but I do not feel completely confident in my solution.
Are there any logic or efficiency issues with my code?
Supported operations: \$+\$, \$-\$, \$*\$, and \$/\$.
Algorithm: Flowchart
main.c
#include "practice.h"
int ma... |
This is an algorithm that I wrote to get the nth Fibonacci number using bottom-up dictionary. How can I make this better/more efficient?
memo={1:1,2:1}
f=0
def Fib(n):
for i in range(3,n+1):
memo[i]=memo[i-1]+memo[i-2]
f=memo[n]
print(f)
return f
Fib(15)
|
import tornado.web
from selenium import webdriver
import sys
import psycopg2
from selenium.common.exceptions import NoSuchElementException
class LevelHandler(tornado.web.RequestHandler):
def __init__(self, application, request, **kwargs):
super().__init__(application, request, **kwargs)
self.conn_... |
I recently found an Objective-C extension on NSData that encodes and decodes data with AES-128. I made an attempt to port this code to Swift 2.2:
NSData+AES.swift
extension NSData {
struct AES {
static let privateKey = "DefaultPrivateKey"
}
func AES128EncryptedDataWithKey(key: String = AES.privat... |
I wrote a utility class called ObservingCache, which receives a task in the form of Supplier<T> and an interval, computes the task every [interval] millis and allows its result to be queried via the getItems() method.
I'm using for making sure that outside resources (such as configuration files or DB tables) are always... |
Any suggestion to improve this, they ask me to input characters that should be an invalid input and ask you again to input the number of process without crashing the program.
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
int bt[20],wt[20],avwt=0,i,j;
int n;
cout<<"Enter total n... |
My problem is related to data manipulation: on the basis of the existing variables in a given data set, I would like to create new ones. Bonus points for performance as well as code readability.
Let's consider a reproducible example for the famous "iris" data set. My goal is to create a new variable, which can be descr... |
Following my previous unbounded prime generator and a followup by Martin R, I've tested the waters in Kotlin by making an unbounded sieve.
To quote Martin R's wonderful explanation of the base algorithm,
The interesting thing about that algorithm is that the prime generator needs a list of "base primes" which are cre... |
I recently had the need to implement Luhn's Algorithm in a Java/Kotlin application. I needed a function that would add the check digit to the string of a number like a credit card or IMEI. It could be easily modified to check if the last digit is valid.
At first, I had a code of around 20 lines in Java, but by using ev... |
RESTRICTION: jQuery 1.6.4 only, no other library, or version can be used.
My goal is to use jQuery to allow two input checkboxes behave the same.
For example: If 1st checkbox is checked, 2nd will be checked. If 1st is unchecked, 2nd will be unchecked. And vise versa. When either of the checkbox is checked, I will add a... |
I have a shell and batch script to make specific calls to a MBean on a JMX server. The shell input args are not working in windows because windows handles " differently than linux.
Assuming this is a bean name : bean = "hostName=\"localhost\",name=\"foobar\"\""; and the whole input args on linux is something like this:... |
This is an algorithm to find the item with the minimal value in a sequence. I've written a function called minimal to implement this algorithm.
Here is my script:
def minimal(*args):
"""Returns the item with the minimal value in a sequence. """
if len(args) == 1:
sequence = args[0]
else:
... |
# unit tests for the /brands endpoint
from flask.ext import restful
import unittest
import os
import json
import sys
# tells sql_models to use the testing database
os.environ['API_TESTING'] = '1'
sys.path.append('/opt/backend_api/')
import api
from models import sql_models
from config import settings
class TestBran... |
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
public static void Main()
{
ThreadPool.QueueUserWorkItem(() => {
Thread.Sleep(10000);
PressAnyKey.Cancel();
});
Console.WriteLine("Press Any Key or don't...");
PressAnyKey.WaitOne();
}
}
internal ... |
I have made a simple pagination algorithm. It shows "next" and "previous" buttons when appropriate.
It also limits the amount of buttons if the page amount exceeds a certain amount, e.g. 1 2 ... 15 16 17 18 19 ... 99 100.
It works fine, but I feel it can be simplified.
function appendTruncateButtons(buttons, pageCou... |
I have two classes:
country
country_name
Country.java
public class Country {
private Integer ID;
private String ISO;
public Integer getID() {
return ID;
}
public void setID(Integer ID) {
this.ID = ID;
}
public String getISO() {
return ISO;
}
public void... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.