instruction stringlengths 71 71.9k |
|---|
It is my second day into software testing and I am currently testing my database, handlers, and functions. I am wondering if I am taking the right approach as this is the first time testing my web app. I'd love to get some advice or feedback to improve my tests!
Below is the code for data model.
class Post(ndb.Model):
... |
I just implemented the balanced parentheses problem in JavaScript. For those of you who are new to this problem, a statement of it would be:
Give a string of parentheses (including braces and square brackets),
check to see if they are opened and closed in order. The last opened
parens should be closed first befor... |
In short, the input is an ordered list of numbers, and we have to sum the numbers from index a to b quickly. For example, assume array[] = {1, 2, 3}. Please sum from array[0] to array[2] (1 + 2 + 3).
Because the input array can have as much as 200,000 elements, I used a Fenwick tree to save time, but the time limit is ... |
The question is that in a given integer n you have to sum its digits. For example, the sum for 111 would be 3.
Though I managed to solve the problem, I have a good feeling that this algorithm can still be improved.
public static int digit(int n){
String numbers = n+"";
int sum = 0;
for(int x = 0; x < number... |
During an interview, I was given this Hackerrank question to solve within 15 minutes but at that time I was interested in solving this without performance in my mind. I know a similar question has been asked Hackerrank Insertion Sort - Java and probably a lot in CR.
Problem Statement
Given a sorted list with an unsort... |
Here is the code I'm working on. I'm trying to find the optimum alpha value to get the minimum MAE/MAD. With scipy.optimize, it works quite well. However, when scipy.optimize achieves the optimum alpha, it also achieves the forecast values that essentially I'm trying to get to. Is there a way to return or access and st... |
This is a calculator for F = MA. (Force = Mass * Acceleration)
I would like a review of my code. I believe that I have gotten better since my last time.
package ufvnik;
import java.util.Scanner;
/*
* @author: Sean
*/
public class tfci {
private static Scanner keyboard;
public static void main(String args[]){
//ca... |
This file handles the player "stopping" in space, trying to find whoever is ahead or behind (also stopped) and joining everyone into each others stopping -rooms. I'm not too sure about the whole "each others rooms" - but I can't think of a sane way to have these N players sit in the same room that's created at differen... |
I am currently developing a web app that lets users submit posts and replies, and they can have their own profile which lists all the submitted posts and replies. I am also using X-AppEngine to fetch the location of users and I'm storing the information into the database. Posts, replies, and user information are stored... |
I am creating my first android app. It is going to be a quiz.
There are 40 different question categories and each category has its own database table.
I am writing all questions into a sqlite database like this:
private void addQuestions() {
// Category 1 (ACE) Questions
// First Question
String aceQuestion... |
This is a tool I needed for some other things (it's incomplete, but almost done) which is essentially just a text-editor that has two text-boxes: the left being the binary view / raw bytes, the right being the text when the bytes are decoded with the specified Encoding.
The only features it doesn't yet have that I need... |
I wrote this code a while ago, which is an excerpt of a payment service library:
# recover a transaction details from the Wirecard API
module Wirecard
module Elastic
class Request
class Transaction < Base
attr_reader :merchant_id, :transaction_id, :payment_method
def initialize(merchant_id... |
I created an OAuth 1.0 signature generator using Ramda based on this.
I'm just getting to grips with it, so was wondering if someone more familiar with Ramda and functional programming would give me review.
const R = require('ramda')
const hmacsha1 = require('hmacsha1');
// For RFC 3986 Compliant URI Encoding.
let enc... |
This program is based on as old retired Google interview question where you're supposed to create a program that will split a string into space-separated words, if the string is composed of valid words.
I've implemented two approaches, one that uses a normal array as the dictionary, making the implementation pretty si... |
List.h
#pragma once
#ifndef GUARD_LIST_H
#define GUARD_LIST_H
#include "List.h"
#include <stdexcept>
#include <iostream>
template<typename T>
class List
{
struct Node
{
Node* prev;
T key;
Node* next;
Node(Node* p, T k, Node* n): prev{p}, key{k}, next{n} {}
};
public:
/... |
User has number in head, the program must guess the number.
public class GuessingGame extends JFrame{
JButton newGameButton, highButton, lowButton, correctButton, exitButton;
JLabel initialTextLabel, enterLabel;
JTextArea commentTextArea;
JScrollPane scroll;
private int guess, high = 101, low = 0,... |
I have written a Boggle board solver in Python 3. I would like comments on readability and structure. Thank you!
Boggle
Boggle is a board game with a 4x4 board of squares, each of which has a letter, in which you score points by finding words on the board. This is an example Boggle board:
c a t c
a t c a
t c a t
c a t ... |
Check me:
Model should do everything. That's where all functionalities and features are accommodated. It has some properties, that I can access and use. Theoretically, it could work as a standalone app (used via command prompt).
View does nothing but looks (like a monitor: you always look at it, whereas the real work d... |
I'm trying to replicate the attributes text that appears in File Explorer, for files and directories.
I can't just use the enum names, as the summary text uses a single character for each set flag, and that character isn't always the first character of the enum member. I'm also not using the reserved FileAttribute.Devi... |
The purpose of this function is to turn a 2D array of sorts into a single-dimensional array by reading it in a spiral fashion.
In the array:
1 2 3
4 5 6
7 8 9
if it's a clockwise spiral it will read 1,2,3,6,9,8,7,4,5first going right, then down, then left and then up repeatedly until it's at a dead end.
The code I wro... |
This was my C# implementation of Parzen Window Density Estimation.
The following is my implementation of the same in Matlab:
parzen.m
function [retval] = parzen (matrix, dataPoint, variance)
[r c] = size(matrix);
A = ones(r, c).*dataPoint;
sub = matrix - A;
up = sub.^2;
dw = 2 * variance;
firstP... |
I created a directive that solves my immediate problem, but I'm trying to find ways to make it more reusable.
My immediate problem was, I have a table and needed to fill in one of the columns with data from an http request. I passed an object (dir.provider.resource) and a string (attr) into the directive, made a GET r... |
I'm a scientific C programmer moving my way over to using Modern C++. I found myself needing a HyperLogLog implementation, and I wanted to use this for practice.
I plan to move a number of these functions over into an accompanying header file, but I do find it convenient at the moment to only need to include it (esp. i... |
I've written a program that calculates all of the palindrome numbers in the given range, but the code is slightly slower than needed. I've tried to improve algorithmic complexity to the best of my abilities, but still overhead over passing solution (1 second). Is it possible to improve the runtime performance (in time... |
I am studying the book Realm of Racket.
On chapter 5, there is a challenge:
Find an image of a locomotive. Create an animation that runs the locomotive
from just past the left margin to just past the right margin of the screen. Next, modify your program so the locomotive wraps around to the left side of the screen afte... |
The original question is to write a Fortran program to compute the sum of the first 20 terms in the exponential equation (for x=1,2,3,4,5):
$$\sum_{n=0}^\infty \frac{x^n}{n!} = 1 + \frac{x^1}{1!} + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!} + \ldots$$
My original approach was:
PROGRAM Exponentia... |
I have a list of objects where one of the properties on the object class is an enum.
The program below simply loops through each item in the list, checks an int value, then checks the enum value for that item, then adds the item to another list when the condition is met.
I am using if-else statements, I attempted to us... |
I am working through Chapter 10 of Haskell Programming from First Principles.
I've gotten the code to work, but I am uneasy about the fact that a few of my functions - namely, extractUTCTime and extractInteger - are not total functions. There is valid input for which those functions are bottom. I've added the code bel... |
I've just started learning C# using Rob Miles' C# Programming Yellow Book and some related lab exercises from his website. I did one of them and produced a solution that works. In Miles' book, he says that nesting if and else brackets is clumsy and introduces the switch. But switch apparently doesn't work with Boolean ... |
What can be improved?
#!/usr/bin/python
import random
def board():
board_size = int(raw_input("Board size: "))
board = []
for i in range(0,board_size):
board.append(list(range(board_size)))
for parent in board:
for child in parent:
parent[child] = 0
return board
def che... |
I am still in the process of learning modern C++, and decided to write this dummy program for actually benchmarking copy semantics vs. move semantics:
#include <chrono>
#include <iostream>
#include <cstdint>
using std::cout;
using std::endl;
class List {
public:
void push_back();
List() : sz{0}, head{nullptr}... |
There are already many other TicTacToe implementations but most of them are missing some features like if duplicate input is entered exception and immediate termination of the program occurs board is not updated and so on I tried my level best to bring the proper one
/* SWAMI KARUPPASWAMI THUNNAI
... |
I'm porting a 2-D Terrain Generator from Python to C++ as Python is too slow due to the number of features that have been added.
I'm new to C++ and would like to know of any criticisms that you can make of the code at this time before I continue with the simpler parts of the generation. Right now I'm interested in mai... |
This code is working fine and I would like for it to be reviewed. Am I using extra objects and variables to store values?
LinkedList
package lab5;
public class LinkedList {
public static void main(String argsp[]) {
List ob = new List();
ob.addAtStart("y", 6);
ob.addAtStart("w", 4);
... |
The aim is to have any strings with integers within to be reorder by these integers.
Let's say you have the following string:
re5 Forty1 cash2 Man3 Booker4
The aim is to have the string order by the integer contained within the string:
Forty1 cash2 Man3 Booker4 re5
I created this function:
def reorder(wordchain):
... |
I have a buffer - int array with defined length. I want to read and write values into this array in parallel. For instance, 5 readers and 3 writers with different intervals. Additionally, I want to block waiting readers and waiting writers until a specific operation (read or write) is available.
Buffer:
public class In... |
I have designed a quadratic Equation Calculator with Java FX. It is divided into four separate classes:
GUI.fxml to design the UI
Logic class with the all the logic formulas and code that runs the program
Main class which brings all the different components together
Controller class
Any input is appreciated.
GUI.fxml... |
I created plugin for MySQL Workbench that allows you to export an ER Diagram to RoR migration files. I would like to know if any other developers appreciate it.
export-rails-4-migrations_grt.py
# -*- coding: utf-8 -*-
# MySQL Workbench module
# <description>
# Written in MySQL Workbench 6.3.6
from wb import *
import ... |
I'm learning Rust so as an exercise I'm trying to write a datatype wrapping the builtin BTreeMap to allow it to store duplicates. Like the STL multimap type. The functions I have:
fn insert_dup<V>(map: &mut BTreeMap<i32, Vec<V>>, k: i32, v: V)
{
if map.contains_key(&k) {
map.get_mut(&k).unwrap().push(v);
... |
I've made a little colour conversion app, and below is my JavaScript.
The app converts HEX values to RGB values and vice versa, as well as using a simple colour picker to get colours and convert them to both HEX and RGB.
Here is a picture so it is easier to understand what the code does. Basically you enter a HEX or RG... |
I'm working on learning Python, and this is my second GUI project using PyQt. I've played it a few times to test it and it seems to work. It isn't anything clever; the computer just picks randomly. Any feedback would be quite welcome.
import sys
import random
import time
from PyQt4 import QtGui, QtCore
class Tic(Qt... |
I've written my first program in GO, a command line tool that parses JSON containing events from a file or from STDIN and outputs the upcoming events in sorted order. Please critique it!
package main
import (
"encoding/json"
"io/ioutil"
"fmt"
"os"
"time"
"github.com/urfave/cli"
"strconv"
... |
This is a design data structure and movement for a tilt maze. For example, this one.
My major idea is to divide into Ball, Maze, HorizontalWall and VerticalWall classes. Ball is the core class which operates on Maze, HorizontalWall and VerticalWall.
I feel my code is a bit inefficient since each time, I need to enumera... |
As an exercise, and in an effort to avoid wrapping callback APIs in every node library it seems, I threw together a resource pool class. The intended usage is the following:
const pool = new Pool({
createConnection() { return ... Promise<MyConnection> }
destroyConnection(c: MyConnection) { return ... any }
})
cons... |
Can someone please review this code and provide comments?
Please comment on error handling
Is it right to do like this in method LinkedList::InsertFront()?
Node *node = node->CreateNode(key);
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
class LinkedList{
public:
LinkedList(){
head = NULL;
... |
I made the following bash script for extracting a group of ECG signals from ECG files. I would like to know if there is any mistakes and/or weaknesses. I have experienced difficulties in integrating bash parameters to it as a function because of AWK part.
I think it would be better not to use so much different separate... |
Suppose each node of a tree has maximum n children. I want to serialize and de-serialize for a tree. My current solution is doing pre-order traverse, and using # to represent None child.
I'm wondering if there are any better implementation method. My current concern for my code is if the tree has too many None node (ki... |
I solved HackerRank Nikita and the Game. The implementation is correct as program passes all test cases.
Nikita just came up with a new array game. The rules are as follows:
Initially, there is an array, A, containing N integers (1 ≤ N ≤ 109), with 0 ≤ Ai ≤ 109.
In each move, Nikita must partition the array into 2 n... |
I am automating a login page. I am using the page object design pattern Selenium with Java. What should I improve on in my code?
package Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
publi... |
I'm new to coding and have cobbled together some code to run an automated test against a web application. The code works but I have some complexity rule violations (CA1505, CA1502 and CA1506) and would be grateful to anyone with insight on how to go about improving the code.
The code logs into the UI, makes sure the u... |
I made a on-off switch to be more fluent in React and added touch functionality to it.
The idea is to have it independent of the state management library/logic, and be easy to import into a project, regardless of the state managing being used.
My question is: is the touch implementation (and overall React logic) corr... |
As the subject suggests:
Loop recursively through folders
All files are XLSX
Remove all non ASCII characters
Save as a CSV
Can it be improved with regards to speed? Would using openpyxl help?
import os
import xlrd
import csv
for subdir, dirs, files in os.walk("C:\Users\Alan\Downloads\Knowledge"):
for file in fil... |
I would like to get some performance improvement suggestions to a simple project I made using Bash in Linux.
The target is to read all the *.desktop files, and extract Name, Exec, Icon and Comment entries. Then will be displayed in a GTK yad List.
I have built the code in two versions. Both versions works OK, but are v... |
I have created a BeautifulSoup vacancies parser, which works, but I do not like how it looks. Therefore, I'd be very happy if somebody could give me any improvements.
from urllib.request import urlopen
from bs4 import BeautifulSoup
page = urlopen('http://rabota.ua/zapros/python/%D0%BA%D0%B8%D0%B5%D0%B2')
soup = Beauti... |
Here's my attempt to draw Koch snowflake. My initial state is a line instead of an equilateral triangle so that I am able to fit maximum detail in a mobile phone window.
My thought process was:
Start with two points A, B separated distance r.
Draw three points between them, P1, P2, P3.
P1 at distance r/3 from A on l... |
I'm using MongoId in a Rails project. I need to select some products which contain some SKUs which has an embedded document. The models are respectively Product and Sku.
The point is I want to keep it DRY and the conditions I apply to those subdocument already exist as a scope of the model. My working strategy so far i... |
I have a Winforms project in which I have a screen which loads a questionnaire. It restores answers the user has previously entered by restoring the saved results from the database to a single list (see code below).
The answers the user fills in are saved in my SQLite database table 'Results' with a result_id, assessme... |
I'm using the following code to unzip file which is working OK.
I'm getting file with the request (express) and unzip it in specified folder
_unzip: function (req) {
return new Promise((resolve, reject) =>{
var noOfFiles = 0;
let filePath = path.join(req.file.destination, req.file.filen... |
I have written this code and I am wondering if the code could be optimised.Please review.
public class Anagram1{
public static boolean check(char[] c1,char[] c2,int l1,int l2){
/*if the lengths of the strings are not equal,they cannot be anagrams of each other */
if(l1!=l2){
return false;
}
... |
I have two lists of coordinates,
lat = [-23.23, -44.23, -12.23]
lon = [-21.23, -14.23, -62.23]
and I generate a tuple of lat long pairs with zip:
latlon = zip(lat, lon)
and that gives the expected result. Now there is a very common pattern of generating lines with the points. It is common to do something like
li... |
I'm a beginner who wants to learn properly how to write code. The following code takes initial RGB values and gradually changes them (shade by shade) to targeted rgb values, scroll by scroll. The code works, but is there a way to clean this code, and get the same gradual result?
//GRADUALLY CHANGE BACKGROUND COLOR WHIL... |
I’ve written a script for automatically backing up my Goodreads data. This mimics the Export function on the Goodreads website, which returns a CSV file – but this doesn’t require going through a website, and provides JSON instead of CSV. The idea is that I could run this on a cron job, and have regular backups of my u... |
I recently started replaying Final Fantasy XII. One of its optional bosses, Zalera, has, among others, the following mechanics:
His attack sequence is Lv. 2 Sleep, Lv. 3 Disable, Lv. 4 Break and Lv. 5 Reverse, affecting characters whose levels are divisible by 2, 3, 4 or 5, respectively, and then Prime Lv. Death, whic... |
I decided to make a small program for filter design, to practise C++. I intend to also add a GUI, later on (Qt, most probably), so I thought that the way the program would go in the main() should be very modular and flexible, to be able to be used by widgets. I also thought I should be able to call only a filter at a t... |
Here is my solution to Programming Exercise 15-7 from Stephen Prata's C Primer Plus, 6th Edition. This problem asks the reader to:
15-7
Write a program with the same behavior as described in exercise 6, but
use an unsigned long variable to hold the font information and
use the bitwise operators instead of bit me... |
I made a method that takes 2 DateTimes as a parameter, a startDate and a stopDate.
The routine should return a list of DateTime ranges by checking if the range in the parameters is above one year TimeSpan. If it is, it should separate the range into smaller ranges of one year, starting form startDate and adding a year ... |
I'm looking for a code review on the following C++/STL graph implementation:
Edge
#ifndef edge_h
#define edge_h
template <typename T>
class Edge
{
public:
Edge(const T &weight): weight(weight) {} ;
const T& getWeight() { return weight; };
private:
T weight;
};
#endif /* edge_h */
Vertex
#ifndef vertex_hp... |
I'm looking for ways to optimize a function that I wrote as an answer to this problem in Python:
You and your rescued prisoners need to get out of this collapsing death trap - and fast! Unfortunately, some of the prisonners have been weakened by their long imprisonment and can't run very fast. Their friends are tryi... |
I like to use timeit to measure performance of small, and sometimes big, functions. However it can be uncertain as to what the 'actual' time to execute the function is. It also doesn't clearly show trends in function execution times.
Originally I wanted to measure the difference between list comprehensions and using ap... |
I am making a program that lets a user manipulate a database (a text file).
In the code I am posting, I show only 2 of the menu choices, namely "createdb" and "deletedb", and a few functions I made to desperately make the functions more compact. But my problem is that the pattern is similiar for all the other menu opti... |
I've been trying to fix this performance bottleneck in my web app for a while now.
Here is what the data looks like on my web page:
Here is how I get this data in the controller:
var allCategories = categoryRepository
.Categories
.Select(x => new
{
... |
I'm in the process of improving my coding style and performance hence I decided to delve into bit manipulation on Hackerrank. I thought the question was straight forward but on large input, my solution's performance declines. How do I improve it? Any smart tricks to solve the below question is welcome as well.
Below is... |
A followup question to this: IQueryable Extensions working on expression for collection property
I am working on a project for a family member which involves the use of a database and a repository, and I have set up a fairly complex (possibly too complex, but I don't have a ton to go off of so I'm trying to make it ver... |
I randomly decided to write a program that tests the Birthday Problem/Paradox.
The gist of the problem/paradox is that if you have a group of people in a room, how many people are required for there to be a 50% chance that 2 people will have the same birthday? Near 100% chance? It turns out only 23 people need to be in... |
I wanted to create a grid overlay for my browser that I can use when building websites. I decided on HTML5 canvas because it allows me to create lots of lines without adding loads of elements to the DOM.
The code is below and you can demo it on GitHub pages here. I'd appreciate your guys feedback on the following area... |
Can this be improved, or made more concise?
type Government = {
Id : Id;
Name : string;
Abbreviation : string;
ParentId : string option;
}
let govList =
[
{Id = "1"; Name = "United States"; Abbreviation = "USA"; ParentId = None}
{Id = "2"; Name = "California"; Abbreviation = "CA"; P... |
I have written a simple app that adds gitignore files to the current working directory - it does this by reading files hosted on GitHub and then saving them (currently Go, Python and Visual Studio gitignores).
I am a relatively new programmer and mainly code in C# and have written this app in Go. I would be very gratef... |
How can this be improved?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pdf_merging_70112016;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPag... |
I've came across this question https://stackoverflow.com/questions/11760420/what-is-an-optimal-way-to-find-duplicate-files-in-c and there are two answers for it both the answers convey that it is bit difficult and other suggested C++ is not suited for this purpose so as a student I am interested to test my C++ skill on... |
This problem is from INOI 2014 , where I have find out the maximum cost of traveling through the cities but taking the minimum possible route cost , here is an excerpt from it,
Indian National Olympiad in Informatics 2014
Nikhil’s slogan has won the contest conducted by Drongo Airlines and
he is entitled to a free tic... |
This is a design data structure and movement for a tilt maze. For example, this one.
My major idea is learned from abrarisme's smart idea of using two boolean matrix to represent wall. Please refer to this link for abrarisme's smart idea (Data structure and movement for tilt maze).
I need to (1) design the data structu... |
Here is a simple implementation of generic method that get value from array in class and cast it to a type.
private T GetReferenceFieldValue<T>(ReferenceRow referenceRow, string fieldName)
{
var referenceField = referenceRow.field.FirstOrDefault(x => x.name == fieldName);
if (referenceField !=... |
I have a piece of code to migrate data from an old app to a new app. The data represents the user's websites.
In the old app the user only had one section for websites, on which you could add any website, even social links.
In the new app, the user can add personal websites, social links (only Facebook, Twitter and L... |
The code adds up numbers from two different text files. It opens an input file 'DEPTH.dat' and reads the numbers after some headers as follows:
SCALAR
ND 3
ST 0
TS 1000
1.0
1.0
1.0
SCALAR
ND 3
ST 0
TS 2000
3.3
3.4
3.5
SCALAR
ND 3
ST 0
TS 3000
1.7
1.8
1.9
It then adds to them numbers which ... |
This program is meant to read a moisture sensor attached to an Arduino UNO board via USB to a Raspberry Pi3 which broadcasts it over MQTT.
I am looking for any constructive criticism.
import serial
import time
import RPi.GPIO as GPIO
import paho.mqtt.client as mqtt
def main():
try:
while 1:
se... |
Here is code for check null in object:
public static TResult IfNotNull<TInput, TResult>(this TInput obj, Func<TInput,TResult> expression)
{
if (obj == null || expression == null) return default(TResult);
var value = expression(obj);
return value;
}
The above code is best pratice of chec... |
I was given the task of finding those unused procs/functions in our SQL 2012 database.
Initially my plan was to use the table sys.dm_exec_procedure_stats. I could set up a job to check the table once/day and then summarize over the course of a month or a quarter.
Two problems with this: it wouldn't catch the functions... |
Here's my first serious attempt at writing Go code. This program counts the number of days until a certain date and displays that in the system tray.
To do that, it first reads the target date from a file — containing, for example, Dec 25, 2016 — and counts the number of days inbetween, then writes that number to an ... |
I want to write my C# code in a way which makes effects (state, I/O, etc) explicit in the type signature. I have started to understand monads, and have some acquaintance with algebraic effects, though not deeply so. I have attempted to implement a monad for working with algebraic effects in C#. The purpose is to allow ... |
I'm refactoring some "old" Swift code using deprecated UIAlertView and delegates.
I have a UIAlertController with an input textfield inside (and two buttons, OK and CANCEL). The user should insert his email address, then I should validate it anytime he enters a character: when the mail address is valid, the UIAlertCont... |
Is this thread safe?
I have a program that executes an SQL command on a number of files (selected by the user).
Here is where I create the threads:
var allThreads = new List<Task<bool>>();
if (fileList != null)
{
foreach (var file in fileList)
{
var fileName = Path.GetFileName(file);
if (File.E... |
This code is to guess_file type searching its content for known signatures. It is intended to be used both from command line (searching entire media for mismatched extensions) and from code to determine and validate type of uploaded files which will be stored in a database (and eventually downloaded by someone else and... |
I've been reading more on PHP JSON and APIs I wanted to play around and pull a user's tweets so I wrote a function that requires the TwitterAPIExchange wrapper.
The code:
ini_set('display_errors', 1);
require_once('TwitterAPIExchange.php');
get_twitter_json();
function get_twitter_json() {
$username = 'foob... |
I was solving a problem on codechef (online judge and contest organizer). I was writing my code in Java and was getting TLE at last testcase where as I wrote the same code in C++ and it was accepted. Now I know C++ is faster then java but If anyone could help me optimize my Java code ?
Here is the question
Chef has fi... |
I want to remove the extra spaces without using a regular expression. I'm using two while loops.
How can this become better / more elegant?
String str = "Hola caracola ";
char[] src = str.toCharArray(), dest = new char[src.length];
int i = 0, j = 0;
while (i < src.length - 1) {
while (i < src.length - 1 && src[i... |
I've been toying with the idea of making a simple game. In game development, it is good to do things in a more struct-of-arrays style rather than arrays-of-structs style, due to cache locality. However, I wanted to fool around even more, so my class puts all the data in one contiguous block of memory. It was my first t... |
Is the following class well-built and secure or am I missing something? Any improvement ideas welcome.
/*
* This class is for generating and using one single save session.
*/
final class Session {
private static $name;
private static $force_ssl_cookie;
private static $destroy_unset;
private static $... |
The problem consist of finding the longest contiguous subarray with a sum less than a given integer K.
The input data are:
K - the max sum
array - an array of integers
The algorithm I developed:
head = tail = 0
- while the tail is less than the length of the array
- increment the tail and update the sum
- if... |
Background
I want to send emails with a rendered template (django template, that is) but I also want to be able to control the QuerySets, and context provided.
The goal is to make a task whose run method is the same (because sending an email isn't the interesting bit) for each implementation but allow the user to provi... |
I wrote a Angular filter to use filters based on properties that handles some specific properties differently.
Is there a way to improve or use some built-in Angular filter to avoid extra code?
Usage:
<div ng-repeat="item in items | myObjectFilter: { someProp: user.uid, pending: true }">
Code:
angular.module('app', []... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.