instruction stringlengths 71 71.9k |
|---|
I have problems with dealing with derived classes that inherit from the same base class.
I have 2 types of songs:
Songs with lyrics that have: Title, Tags (sad, happy etc.), lyrics (one line), writer.
Instrumental song: Title, Tags (same as lyric songs), instrumentals (a string), performer, BPM.
I thought it would be... |
I have been reading the chapter 15 of "Introduction to Algorithms" (3rd edition) by Cormen, etc. The chapter 15 is about dynamic programming, and the first example they show us is the "rod cut problem".
Now, I have spent some time trying to understand it, but mostly trying to understand the pseudocode, and why it real... |
I have a piece of code where I have string pairs (eg. 'a' and 'AA'), where both have their own unique ids. Id for first object is configured by user and second id is received at some point during runtime.
Example code:
http://repl.it/BE5N
Is there smarter way to load/save second ids from/to a file?
It feels somewhat un... |
Here is my Python code for Project Euler #2:
Each new term in the Fibonacci sequence is generated by adding the
previous two terms. By starting with 1 and 2, the first 10 terms will
be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not
exceed four milli... |
Reverse engineering old games is something I do every now and then. This time, I took a shot at this old RPG called Darkstone.
The bulk of the game's data is stored in archive files with the .MTF extension (not related to the Microsoft Tape Format). A partial description for this file format can be found here. The form... |
I'm new (to CR and to programming in general). I wrote my first VBA on Monday. This is my first working project. It Takes a bunch of financial data from a company called Financial Analytics and a bunch more from a number of webqueries, and puts it all in a nicely formatted table for external consumption.
It's a kludgy ... |
After writing a rather long document in Markdown and using pandoc to convert it to a PDF, I found, to my dismay, that many of the images were out of place, and that they all had their alternate text proudly displayed underneath them as captions. My document is rather instructional, so this rearrangement was harmful to ... |
While reviewing Sending templatized e-mail to a million contacts, I wrote this implementation to illustrate an alternate approach. It is designed to be the fastest possible way to generate templated text repeatedly. Is it?
I used the in-memory Java compiler featured in this Stack Overflow answer.
I think that the str... |
I have an openwrt router (TP-Link MR3040) and on boot I have it check the slider (AP, WISP, 3G/4G mode). The goal was to have it execute the current "slider status" vs the old one, or do nothing if it's the same (before reboot). I just want a critique on making it more elegant.
#!/bin/sh
test=$(cat /root/logs/sliders... |
The following class BackgroundExecutable is to be used to take a function f and return a function f' where f' asks iOS for background execution. f takes a completion closure which it uses to end the background execution.
class BackgroundExecutable {
var identifier: UIBackgroundTaskIdentifier
let f: (() -> Void) -> ... |
Write a function called answer(document, searchTerms) which
returns the shortest snippet of the document, containing all of the
given search terms. The search terms can appear in any order.
Inputs:
(string) document = "many google employees can program"
(string list) searchTerms = ["google", "program"]
Output:
(st... |
This is my current RowDataBound function. I think this functionality is a bit horrrendous really and it winds up with an extreme amount of LINQ SQL queries being passed around (which makes for big server load etc).
What I'm wondering is, is there any way that I could pull all the data in the first select statement, pu... |
I was in the mood for some data structures and I decided to code up an ordered map using AVL tree. I will post only map.h and map.c. The demonstration driver may be found here.
See what I have:
map.h:
#ifndef MAP_H
#define MAP_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct map_entry... |
I have a WPF application that gets data from a web-server.
It contains two Views
LeftView
RightView
three Models
LeftModel
RightModel
CentralModel
and two ViewModels
LeftViewModel
RightViewModel
I will show only LeftView, LeftViewModel, LeftModel, and CentralModel (too much code). You can find the entire pro... |
I wrote (as part of a greater work) a Boost.Spirit grammar that would parse string literals, including support for the various escape sequences known from C/C++ (\n, \x7f, \341, \u017f, \U00010451).
At some point I encountered some problems, mostly due to my lack of understanding either Boost.Spirit or Boost.Phoenix to... |
I was just wondering if my code contains defects or if there was a more efficient or general way to convert string to DateTime object. In the input, I have a string in the UTC format.
public static DateTime ParseDateTime(string dateString)
{
DateTime dateTime;
if (!DateTime.TryParse(dateString, Cult... |
So, I had a go at re-writing my Workbook_Open event based on The advice from my previous question. Thoughts?
Private Sub Workbook_Open()
Dim strTableTitle As String
Dim StrTodaysDate As String
Dim StrThisDay As String
Dim StrThisMonth As String
Dim StrThisYear As... |
I have a C# type to generate Layer SubLayer:
public class Layer
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; }
}
And simulated a list with a Db class:
public static class Db
{
public static IList<Layer> GetLayers()
{
return n... |
I have a JSON API where a user can update a post and related details to that post. To simplify the process the user just fills in one hash and we don't expose our architecture. What I did here works but I would like to know if their is a better way. This smells to me, but I don't know why...
def update
params['blog... |
I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong.
Stack.h
#pragma once
#include <ostream>
template <class Type>
struct Node {
Node(Type data, Node<Type>* next)
: data(data), next(next) {}
Node* next;
... |
POSIX version:
^((00)*|(11)*|((10|01)(\2|\3)*(10|01))*)++$
Emacs version:
"\\"^\\(\\(00\\)*\\|\\(11\\)*\\|\\(\\(10\\|01\\)\\(\\2\\|\\3\\)*\\(10\\|01\\)\\)*\\)+"+$"
(in case you were too lazy to add backslashes)
I am absolutely sure that the language of binary strings of arbitrary length with a requirement of even num... |
I wanted to scrape all the wallpapers from the Bing wallpaper gallery. This was for personal use and to learn about webscraping. The gallery progressively gets images using javascript as the user scrolls down the page. Then you can download the high-resolution image with a few clicks. I actually succeeded in scrapi... |
I wrote a snippet of code to help me memorize text out of files and was hoping to get some feedback on the code, since Python isn't my strongest language.
You can see the code on GitHub, but I've pasted it below as well.
#!/usr/bin/python
# coding=utf-8
import argparse
import codecs
import random
import sys
parser = ... |
I'm making a text simulation game in C# and I've made the calculations and all. But I know there's a better, faster and more efficient way of doing this.
Basically, the first calculation is that there's a 5% chance that there would be a 80-100 yard gain and so on.
public static class Program
{
public static Random ... |
This is an implementation of a segment tree with lazy propagation. Could you please review this code so that I can improve my Go language skills?
package main
import (
//"fmt"
)
var array []int; // Array to store initial input like: [1,2,3,4,5,6,7,8,9,10]
/*
This is Node structure
val : aggregate result (s... |
I'm writing and app in AngularJS and am learning about writing RESTful services. I also want to make sure that I'm understanding the MVC pattern correctly. In my code, this is my take on how I'm implementing MVC.
I have two services that get JSON data from the server. The JSONController then calls these services, an... |
I'm writing a sub which is going to determine which type of business is being detailed on a particular line of data. It's going to use column positions to check if the data exists, and then output the corresponding string if it does.
I've decided that the best way to organise a group of my arguments is using a 2D array... |
I just started JavaScript about a week ago. For my first project, my goal was to use my knowledge of basic JavaScript to create somewhat of a "thinking computer brain," so to speak. I wasn't focused on the looks of it, as seen by my only using the basic prompts and alerts. I just wanted to get used to writing coherentl... |
Let's say I have a bunch of Widget, where a Widget is
class Widget (sku: Int, label: String, name: String, description: String)
And I have 2 sources of Widgets:
List[Widget] wInventory = getWidgetsInInventory()
List[Widget] wCatalog = getWidgetsFromCatalog()
I want to use the name & label from the Catalog to overri... |
The following is a function that takes an area as an input and outputs some resulting calculations.
I thought an object was useful for creating multiple instances with different custom properties overwriting the defaults to make comparisons easy.
The getter and the setters are there so when one property is updated th... |
The application leverages the bitcoinj library to generate a vanity bitcoin address. A vanity address is simply a bitcoin address that contains a personalized string. I would like some critical feedback, specifically code correctness, code smells, and my usage of futures
Sample Invocation:
java -jar vanitas-1.0-SNAPSH... |
The title is a joke on how some people take a lot of selfies pictures
Recently, in The 2nd Monitor, there was a brief discussion on selfie answers, starting with this post.
At one point, a user said this:
I don't know how many selfies I have :s
I immediately thought: this is the perfect opportunity for an SEDE query!... |
This is horrendous.
I'm using lodash's templating engine for this table. Here's the template for an individual record's row. I've got 5 different table and record-types and a view and edit mode for each row:
<script id="individual-template" type="text/template">
<div class="individual<%= typeof isParent !== 'undefine... |
I was working through a programming challenge I found on Reddit and it seemed easy enough:
Find all numbers less than \$10^n\$ where the number and its reverse (the reverse of \$123\$ is \$321\$) are both divisible by \$7\$ and then sum them all together.
def challenge_229(power):
numbers = []
for x in range(... |
I'm hoping for some input on if my code is DRY or how I could have made it more efficient. I am pretty new in terms of jQ/JavaScript and this took me far longer than I care to admit. I will post the CodePen and also the entire JavaScript (Unsure which is better in terms of formatting.)
Forked CodePen so new changes won... |
I just wrote an advanced CSV parser that translates CSV to SQL(SQLite Compatible) statements, which are then inserted into the database. It translates variable names in the CSV to values defined in the script.
Example CSV
0,1,An empty black tile,${ASSET_PATH}/BlackTile.png
1,1,Grassy Tile,${ASSET_PATH}/Grass.png
2,1,La... |
This code checks to make sure a directory is hidden and if not hides it. Then if hidden it will prompt for password and if password matches it will un-hide it. There is also an argument to open un-hidden directory too.
#! /bin/bash
DIR="path/untitled"
DIR2="path/.untitled"
password="Z2FsdGVkX18vy4f4QRB3qnb5vIWR0x+... |
I am an electrical power engineer with some programming skills. My boss asked me to make a program which could analyze very large data, make some calculations and give the result.
The task looks like this:
I have an Excel file with a list of objects (Number of object, Name, Power, Switched on state decimal fraction, S... |
This is my implementation of a binary tree in Scala. How can this be made better?
abstract class BinaryTreeNode[+A]
case class MyBinaryTreeNode[A](var data: A,var left: BinaryTreeNode[A],var right: BinaryTreeNode[A]) (implicit ordering: Ordering[A]) extends BinaryTreeNode[A] {
override def toString = data + " " +... |
I am using MVC+Angular. In MVC, I created partial views for search, listing, etc. I show them using:
@Html.Partial("_Search")
@Html.Partial("_Featured")
@Html.Partial("_Listing")
Previously each partial view had an ng-app and ng-controller.
Now I combined them all into one ng-app. I added ng-app to master page, and ... |
from itertools import izip_longest
def partition(n, iterable):
p = izip_longest(*([iter(iterable)] * n))
r = []
for x in p:
s = set(x)
s.discard(None)
r.append(list(s))
return r
print partition(2, range(100))
I saw it from a recruit and the company said there were potential problems,... |
I haven't used regex a lot and I needed to set up a script that can gather a list of file paths that should adhere to a strict formatting convention, so I thought that sounded like a good opportunity to use them.
To explain a bit, there's a set of sequence folders inside a root folder, and in those sequences is a set ... |
I have no much experience with C++, so it is about time to start actually doing something about it. All in all, I coded this tiny unit test library:
assert.h:
#ifndef ASSERT_H
#define ASSERT_H
#include <iostream>
#define ASSERT(CONDITION) assert(CONDITION, #CONDITION, __FILE__, __LINE__);
#define REPORT as... |
Everything is evaluated in compile-time. You will need a C++14 compiler. The compilation time is quite long, and with a bigger list input, you'll get some error messages like constexpr evaluation hit maximum step limit.
#include <iostream>
#include <limits>
#include <initializer_list>
template<typename T>
class List
{... |
I'm dealing with a searching query where the user will pick from menus and checkboxes the variables-criteria I'm passing to the toWeb method and a list will be returned. This works fine but I'm going to add two more variables and it's already hard to follow.
public List<newEvent> toWeb(string name, string egk, string ... |
I'm solving Project Euler problem 7, which says:
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number?
Here's the code I've written:
def primes(n):
primes = []
attempt = 3
while len(primes) < (n-1):
for i in range(len... |
I've been implementing a custom internal server error page in ASP.Net MVC which will check if the current user is either an administrator or accessing the page from localhost, and if so, show them a whole bunch of details about the error to debug it with, otherwise just send them to a basic HTML error page.
So far, it ... |
I made the layout for a new project which will allow you to subscribe to periodic emails about your favorite Stack Exchange site (I'm not very happy with the SE-provided one). Since I'm horrible at design and in essence new to HTML/CSS/Javascript, I figured I'd get started with that so the hard part is over.
Below is t... |
Why am I not just using a Pivot Table / Database?
a) I've never ever used either before. And I don't have time to learn how before this project needs to actually be finished.
b) The final output is going to be a report for the Company Directors. As such, the flexibility of choosing which bits of data to output in wha... |
For some background, I am learning from the following Stack Overflow question that I asked regarding creating the this code.
I was playing around with different combinations of whereKeys and queries, and I found a solution that seems to be working. I'm not really sure if this is the correct or most efficient way to ha... |
The purpose of this code is to search the entire database for duplicate records and produce a script that a user could then run to delete all of the duplicates.
The stored procedure takes the following parameters:
@DiscludeTables varchar(max): a string of Table Names separated by semicolons. These tables are not in... |
Working through CodeEval's Interrupted Bubble Sort, I have a working algorithm, but there's a speed issue. I'm trying to do this with Ruby and I keep getting an error that it's timing out after 10 seconds. I'm not sure what else I could be doing here to speed things up.
def bubble(arr, interrupt)
i = 0
while... |
Floating point inaccuracies are really annoying. I understood that in its true sense while developing the next version of Point (this time I'm actually foolproofing my code). Before I upload it for review, I want a class that I wrote, called Numbers to be reviewed.
Numbers.java
package library.util;
/**
* This class ... |
I have written nested while loops to read in some of the columns in a text file that looks like this:
comp id subreddit created ranks recorded_at rank_length
0 3ckf7b pics 1436373189.0 [1, 1, 3, 5] [1436392502, 1436396101, 1436399701, 1436403301] 4.0
0 3csv79 UpliftingNews 1436538581.0 ... |
I have a JavaScript (jQuery) 'init' file with various variables/event handlers and functions that are currently written in no particular order. I've read that it's good to organise these by declaring variables at the top of the file, using an init function and binding event handlers etc.
Here is the file in its full an... |
I have an index page which gets passed $_POST['timestart'] and $_POST['timeend'] variables. In addition, I have a cart page that has variables passed to it from the index page, and it passes variables back (with header) to the index page depending on what is done. In order to retain the initial $_POST['timestart'] an... |
This game works out the basic of a Tic Tac Toe game. I am looking to see if this can be redone in any way to make the code more smaller since this is really big.
private string player = "x";
private string cpu = "o";
public Form1()
{
InitializeComponent();
Buttons();
Grid();
}
private void Form1_Load(obje... |
I have written a couple of macros (? and ??) for performing unit tests, but I'm having some difficulty with modifying it, so I was hoping to get some feedback on how to tidy up what I have written so far.
Yes, I know that unit test frameworks already exist, but I'm trying to learn by doing.
Here is an example of usage:... |
I just wrote a utility program in C that converts numbers of different bases to 'standard' well-known bases (hex, dec, oct, bin). I called it repnum, short for "represent number."
You will notice a 'template' that I like to employ when writing C programs. Any suggestions?
repnum.h
#ifndef REPNUM_H
#define REPNUM_H
#if... |
After receiving some awesome feedback in my first post yesterday, I was able to grasp the "building block" method of creating javascript in chunks and putting them together to create coherent/straightforward code.
I've done quite a bit of refactoring and am fairly pleased given my initial goals for this project, but I ... |
I am trying to generate JSON from a query. All this seems to be too much grinding it out.
string function getJSON() output="false" {
var result = "[";
var myrow = 0;
for(var row in this.qryLocation) {
myrow++;
result &= "["
& row.LocationID & ','
& ... |
I created a generic version of IDA*. I am attempting to create the following code with exceptional quality and performance. I'm hoping to try and create short code tutorials regarding. However, the quality of my code may not be up to standard for a tutorial on the subject. I attempted to closely follow the pseudoco... |
I've been working on this project to learn networking and concurrency as well as C++11 practices. I'm just looking for a general code review.
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <WinSock2.h>
#include <iostream>
#include <string>
#include <vector>
#include <thread>
#include <mutex>
#pragma comment(lib, "w... |
Been working on a BMR calculator on and off for a while now. Created an interface and been over different ways to store user input, different ways to calculate BMR/TDEE etc.
I created another class called User for the calculations (as suggested by someone). This way I can pack the data of a user together with any metho... |
I designed a simple drop-out stack a while back. Basically, I just want to get a few opinions on whether or not this is a good implementation and whether I am understanding the concept of a drop-out stack correctly. I know there are other / better ways to implement a stack, but I'm interested specifically in doing it w... |
I have some code that allows for SQL reuse for C#. I'm pretty happy with it, but the fact that I can't find anything similar on the web makes me think I'm going about it the wrong way. I have a GitHub repo with a Visual Studio solution, and the code is repeated down below.
Here's the use case:
I'm working on a fairly s... |
I want to check a text for consecutive repeating characters. For example, with a minimum of 3 consecutive chars, this should match:
Okeee
OOOkee
Alsoook
This should not match:
No not okee, oh no
This is my code:
public static bool HasConsecutiveChars(string source, int sequenceLength)
{
if (str... |
How well is this Tic Tac Toe code written? Where may I improve it? This is meant to be a platform for a machine learning algorithm.
The code is written so any player may play first. Once a player plays first and starts the game, the code enforces turns. Overwrite protection is also enforced.
#! /usr/bin/python3
class x... |
I am building a simple REST client in Swift 2. The methods the client offers can return errors. Every method returns the same errors (network problem, unauthorized, etc...). But each method can also return "specialized" error, than are needed only for the method itself.
I am trying to "extend" my ErrorType enum to matc... |
I am still working on basic data structures for C. Now I came up with a hash map:
unordered_map.h:
#ifndef UNORDERED_MAP_H
#define UNORDERED_MAP_H
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct unordered_map_t unordered_map_t;
typedef struct unordered... |
I've seen tutorials about node promises and such but not using bind. I feel like I can do lots of things this way and keep everything clean:
Updater.prototype.generateLocFieldForDocs = function(docs) {
console.log('list obtained')
async.eachLimit(docs, 10, this.generateLocFieldForDoc.bind(this), this.generateLocFie... |
I came up with this during English lessons many years ago to kill some time, and just decided to try code it. It's basically a 3D version of Connect Four/Noughts and Crosses/Tic Tac Toe, but the grid can also flip itself, which means the people good at spacial awareness have a chance against people good at planning ahe... |
I'm learning about using LESS and wanted to get anyone's input on if I'm using the concepts, syntax, etc. correctly.I know this might seem subjective and not the correct place to post, so please let me know if there is a more appropriate place to do this.
LESS code
.centered(@position: inline, @width: 100%){
marg... |
Motivation
const_cast is a beast that I seldomly encounter. But when I do so it is mostly a bad experience.
Nobody knows what most of the C++ programmers do but so far I only ever had one use for const_cast: to cast away a const from a type. For this task const_cast is too verbose:
const std::vector<int> constVectorOfI... |
Here I have a simple algorithm to percent-encode any string.
(Specification from Wikipedia; note that this is not compatible with URLEncoder.encode())
Is this an efficient solution to the problem?
Using a StringBuilder should be efficient, but it doesn't seem great since every character is added to the StringBuilder ... |
I want to extend the Closeable-Interface so that I can add Listeners, that get notificated when the resource is closed.
The CloseListener-API is rather simple and straight forward:
public interface CloseListener {
public void objectWillBeClosed(CloseableObservable closeable);
public void objectClosed(CloseableObse... |
I'm wrapping ui-select in my own directives to pre-configure and style it, as I need it for my app in different select widgets. They appear on many pages, for example accountSelect, countrySelect, contactSelect and so on.
What I really dislike is, that I'm mostly copy-and-pasting the directive's code and then just chan... |
I'm a newbie in Tkinter and I've managed to make the "Lights Off" puzzle using Tkinter with Python 3.
The game starts by presenting 9 buttons arranged in a 3x3 matrix. The text of the button will be either 0 (which denotes that the light is off) and 1 (which denotes that the light is on). Clicking on a button inverts t... |
I have a session class that needs to be setup based on different needs of the client code. Sometimes a new session needs to be created, or continued, or resumed (loaded from database after a user has saved their progress and came back).
Right now the client code has to ALWAYS execute Start(), Continue(), or Resume() af... |
Now I have this d-ary heap data structure. Note that for d = 2 this is a binary heap. The client programmer specifies the value of d when constructing the heap. See what I have:
heap.h:
#ifndef HEAP_H
#define HEAP_H
#include <stdbool.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct h... |
More refactoring based you guys' great feedback. This time around I worked on using global/local variables properly and efficiently, putting return values to use, renaming variables so that the code is more understandable, and simplifying functions so that they serve one main purpose.
My main concerns/focuses now: I'm ... |
I want to model this scenario in object oriented language:
A hospital has number of patients
A patient can have zero or more medical conditions
A medical condition is identified by name and date
Please review my code and tell me:
What can I do to incorporate object oriented fundamentals like reusability and extensib... |
The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname.
This is what I ended up with but I'm reasonably confident it should be able to be improved (I haven't spent much time thinking about it yet).
Any improvements/suggestions are welcome.
#!/bin/sh... |
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also too many little tasks getting started; not great.
I have written a class designed to manage these updates in the view ... |
For my application, I've opted to use Integrated Security with Windows Authentication to access the SQL database. I've created AD security groups for each role and given them GRANT permissions on the tables and views they need to do their job.
To further keep the end users from getting to the controls I'm checking the ... |
I made some code to check that e-mails given apply to the right format, and I'm sure there must be a better way to do this.
import javax.swing.JOptionPane;
public class MailTest {
public static void main (String [] args){
String email="";
int at1=0,at2=0;
int dot1=0;
boolean at = fa... |
This question is a followup to Simple RPG skeleton, Part 1 - The Character.
This is the second "part" of my development of this skeleton, and it now includes two new classes, Entity, and SpecType. The Entity class essentially serves as a base class for any character-like object, and has the following attributes and met... |
I felt nostalgic recently, and decided to install a Commodore-64 emulator. C-64 BASIC 2.0 is the first language I ever programmed in... some 20 years ago (yes, C-64 was already well beyond deprecated by then).
Implementing a simple fizzbuzz in such a limited language, and un-learning pretty much everything I learned in... |
I don't feel that my code is secure, and would like some help in using prepare statements for the following;
$track = "INSERT INTO resources_record (name,email,stage,format,topic,max_cost,mentor,total_cost,duration)
VALUES ('".$fullName."', '".$email."', '".$stage."', '".$format."', '".$topic."', '".$cost."',... |
I've writen a C# JSON parser, but its performance is not as good as JSON.NET.
Running the same test, my parser takes 278 ms and JSON.NET takes 24 ms. What should I do to optimize it? It seems that the dynamic type slows down the lib.
I know this parser doesn't support floats and negative numbers, but it doesn't matter.... |
I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, like a List<String>, where at a later point I can perform various routines such as counting and sorting words, and so on.
... |
This program is supposed to determine the day of the week for 2015. Could someone tell me how I could shorten my code?
#include <stdio.h>
#include <conio.h>
void findDay(int , int);
int main(void)
{
int jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec;
for(jan=1; jan<=31; ++jan)
{
printf(" 01/%d/201... |
I am using this R function to web scrape data from the google play store. Is there a way to increase its efficiency using R? This code takes about 4 seconds for 14 urls with my machine/internet connection.
library(rvest)
library(RCurl)
library(foreach)
library(doMC)
registerDoMC(4) #insert number of your real Core... |
I'm using Java 7.
private Long difference;
public Long timeDifference(String weboutput) {
try {
Calendar calendar = GregorianCalendar.getInstance();
Calendar today = new GregorianCalendar();
Date inputTime;
if (weboutput.length() <= 11) { // for data fetched for current date.
... |
The goal here is to, add a credit card image, and remove all other credit card images, of a certain input field.
I had a even larger code, with a lot of addClass() and removeClass()... then, I shrink it until I have this.
Still, I feel it's still a huge block of code.
The point here is to short things up, but NOT until... |
I have inherited some legacy code that I'm now trying to clean up.
I feel like the 2nd null check is redundant, see comments:
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof ArrayOfColumn)) return false; // Here is first check if ... |
I use Groovy to write business rules into big, long term Java software. Use Groovy in object way, that is not as groovy Script, but every elementary groovy source overrides some Java API class.
i.e. AtLoginScript, PreparePaport etc.
I had an idea to clone in very little scale IDE functionality: generate class from, or ... |
Challenge Description:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Source
I want to receive advice on my code.
total_sum = 0
for i in range(1000):
if (i%3 == 0 or i%5 == 0)... |
Problem 11
Largest product in a grid
What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20
grid?
import numpy as np
initial_max = 0
candidate_max1 = 1
candidate_max2 = 1
candidate_max3 = 1
S = {}
S[1] = "08 02 22 97 38 15 00 40 00 75 04 05 07 ... |
In order to save memory space. Strings inside an embedded device are stored in a particular way. Each 32-bit location holds up to 4 chars instead of only 1 char in the usual case.
I wrote a function that convert an encoded string back to its original string. I am new to Python, so I would like to know whether or not I ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.