instruction stringlengths 71 71.9k |
|---|
I've made a userscript that oneboxes links to GitHub repos, issues or pull requests in Chat after seeing the request One-box repositories, issue tickets and such on GitHub in the chat on Meta.
It uses the GitHub API to get any relevant information and displaying it in a onebox-like manner. It uses MutationObserver to c... |
I'm learning Dynamic Programming, following the topcoder guide. I just solved the AvoidRoads challenge. It passes all the test cases, but I don't have much experience, so I don't know if it's good.
Challenge Description
Linked description contains images and better illustrates the problem.
You are standing at the corn... |
Most of my programming experience is in PHP, and I have always been a bit wary of JavaScript.
I have a JavaScript class to manage executing, caching and displaying search results.
class Search
# @property {string} The previous search term.
@previousSearch = undefined
# @property {HTMLElement} The element ... |
This code determines which index for a given string if that character is removed will produce a palindrome string.
For eg
s = "baa"
After removing b the string "aa" is palindrome.
Here this is what I have written until now. Due to time complexity problems, it exceeds 2ms. How this can be made faster?
#include... |
I am trying to make my code as legible as possible, and today I wrote the following snippet and I'm unsure as to whether it can be improved in an obvious way. There's always room for improvement, of course.
private Date extractTestRunDateFromLog() {
Matcher testDateMatcher = Pattern.compile(regexes.getTestDateRegex... |
I am trying to implement graphic objects that can be either Sprite, Base, Point or some others, but not very many types at all. That's why I do not make separate classes. All types exist in 1 class due to unions and few short switches. I use directly objects, not pointers, and no virtual methods.
The question is also, ... |
I made this simple addition calculator in Java and I'm wondering how I can improve it.
package com.craftxbox.main;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
int inInt1;
int inInt2;
int outInt;
@SuppressWarnings("resource")
Scanner... |
(See the next iteration.)
I have this adaptive counting sort for integer arrays. Basically, it maintains a doubly-linked list of nodes. Each node knows its integer \$a_i\$ and contains the counter describing the number of \$a_i\$ encountered so far in the range. As you might know, the running time of counting sort is \... |
For a recent project I was in need of excessive bit manipulation. Specifically, I had to write to or read from a variable number of bits up from the least significant bit towards the most significant bit.
I created the following helper class since I had spare time and wanted to learn something. I made it work but feel ... |
I'm writing code to generate artificial data from a bivariate time series process, i.e. a vector autoregression. This is my first foray into numerical Python, and it seemed like a good place to start.
The specification is of this form:
\begin{align}
\begin{bmatrix}
y_{1,t} \\
y_{2,t}
\end{bmatrix}
&=
\begin{bmatrix}
... |
Since I'm new to HTML and CSS, I was wondering whether my HTML layout is correct? Before I used div id for everything and everything seemed to work fine, however I recently heard about the use of span and div classes, so I've attempted to make use of them on a page from my website.
The issue is I have no idea if I've u... |
I wanted to get some eyes on some code that I wrote, and see if anyone can help improve what I did. Just looking for some constructive feedback to help make my code more performant, and more elegant.
From a high level my code needs to accomplish the following:
Create a function that takes an array of objects that eac... |
I recently added this CubeMap class to my engine to make handling skyboxes easier. I would like to ask if my OpenGL coding semantics are good, and if I could improve this class in any way.
CubeMap.h:
/*
* CubeMap.h
*
* Created on: Aug 9, 2015
* Author: mattmatt
*/
#pragma once
#include <GL/glew.h>
#include... |
I have two lists List<Person> list1 = new ArrayList(), list2 = new ArrayList(); (Not the same size), of the class Person:
public class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
... |
I'm currently converting a PSD to a web template and attempting to overlap content and I'm running into a issue with the 3rd section because there is more padding than the first overlap and using the CSS style background-color covers wherever there is a block element but if there isn't anything in the pace a image tak... |
I am retrieving data from Postgres (jsonb type) and I need to return an OrderedDict that has a predictable order for human and machine consumption. There are some common(ish) keys that should be used to direct precedence of values of common types (based on a predefined order and if sort_order is defined). Otherwise, ... |
My solution for the topcoder ChessMetric challenge seems really slow. I feel like there should be a better way, but I'm not sure.
Challenge Description
Suppose you had an n by n chess board and a super piece called a
kingknight. The kingknight can move either one space in any direction
(vertical, horizontal or dia... |
I have a little applet that I wrote in Python and Tkinter, and I was wondering what a good way would be to make it public, or open source or whatever.
I think it's quite fun. You can add players, add singles games, add doubles games, and then it gives you a table of recent games and ratings with a bunch of stats (game... |
I'm new to Ruby and don't know all the methods, so I was thinking there would probably be and easier way to do something like this. I'd love any input on how to refactor this.
define_singleton_method(:delete) do |id|
revised_words = []
@@words.each do |word|
if word.id() != id
r... |
I've posted an excerpt from my Nginx configuration with the hope that someone can give me advice on anything I've done wrong or could do better. Please note that the below config works, but has been edited for brevity.
The area I'd like you to focus on is TEST1 and TEST2.
TEST1 is redirecting any requests to /folder/... |
I built a calculator in C# with WPF for the UI. I'm still a beginner at WPF and C# in general, and I'm just looking for some constructive criticism.
XAML
<Window x:Class="Calculator.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/20... |
I have 10 large (34 million cell) 2D gridded vectors storing doubles. When written they are over 200 MB in size. I use an ofstream object to write them to a text file (.csv format), one element at a time, using two for loops (one for my rows, one for my columns). They take way to long to write. Is there a faster way to... |
The user will input two numbers, say 19 and 5. We need to equally divide 19 equally into 5 groups and output the start index and the end index of each group (using zero-based indexes). Example:
Grp 1: 0 1 2 3
Grp 2: 4 5 6 7
Grp 3: 8 9 10 11
Grp 4: 12 13 14 15
Grp 5: 16 17 18
The output should be... |
Telling the time based on the "set theory principle", the Mengenlehreuhr consists of 24 lights which are divided into one circular blinking yellow light on top to denote the seconds, two top rows denoting the hours and two bottom rows denoting the minutes.
As a morning exercise I have been writing an implementatio... |
I have the following tables:
val postTable = TableQuery[Posts]
val postTagTable = TableQuery[PostTags]
val tagTable = TableQuery[Tags]
One post can have multiple tags and postTagTable just contains the relation.
Now I could query the posts and tags like this:
val query = for {
post <- postTable
postTag <- post... |
Sometime back I came across a bug where a particular object was leaking but it was very hard to identify the root cause. I knew that it was due to a cyclic dependency (which usually indicates a bug in the design), but couldn't get a clue where the design went wrong.
I wrote a small utility class view on github to help... |
This is an extension method to get a string that is truncated to a maximum length.
Any comments?
public static class StringExtensions
{
public static string WithMaxLength(this string value, int maxLength)
{
if (value == null)
{
return null;
}
return value.Substring(0... |
I have this iterator class that expects in its constructor two directed graph nodes, source and target, and upon each next() generates another possible directed path from source to target, that was not generated previously.
What comes to algorithm, it is basically a depth-first search. Since the nodes store their child... |
I would like a review of the RAC implementation for the function setGist()
I've posted the code on GitHub for easier reading.
Description:
You create an instance of GistService()
let gistService = GistService()
Then use public functions .resetGist() -> Bool and .setGist(string: String) -> SignalProducer<(URL: String,... |
I'm currently taking Harvard's CS50 course via EdEx.org, and we're learning about sorting algorithms. More specifically, we're studying bubble, insertion, selection, and merge sorts.
Just for kicks and giggles, I went ahead and decided to write a program that compares all three. Basically, what it does is takes arrays ... |
A new diagnostic has seen the light of day! This one will alert you when you have a string.Format() call where the formatting placeholders are in the wrong order. The right order is defined as:
For each placeholder with index N, its value should be higher or equal to the placeholder at index N-1
If you want a more el... |
I'd like to get a review for the function build_list() which reads a file containing words (separated by spaces) and returns a linked-list of words:
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct ListNode {
char* word;
struct ListNode *next;
} ListNode;
typedef struct List {
Lis... |
I've completed a program as a learning experience to make sure I've got the concepts down. I found a practice project online and decided to try it out. The program compiles and runs exactly how it should with no problems.
The program is a game called Artillery. You have to fire a cannon at one enemy at a time until you... |
I wrote a Python sort function that uses shell sort:
# shell sort
# ignore the comments
def shell_sort(sequence):
# shell sort needs an increment sequence
# the increment sequence used here is 1, 2, 4, 8, 21, 56, 149, 404, 1098...
# the sequence is defined by the following equation: round(e^(n-2)) + 1
... |
Whilst developing a game I needed a delay routine capable of doing delays
ranging from 0.5 sec to just a few msec. The obvious choice was to use
the BIOS delay function 86h on int 15h. In a true real address mode environment
it works correctly but I saw that an emulator like DOSBox messes up things.
Tons of illegal rea... |
Warning: This implementation is obsolete, because it doesn't meet the standard. Specifically, while the standard guarantee any pointers and references to elements to remain valid after insertion or erasure at the front or the back element, this implementation doesn't. This issue will be discussed later.
In fact, entire... |
I've always found coding UIs in Java very inefficient, and hopefully this is because of my misunderstanding. Here's a great example.
I have a UI class which is returning the String "Hours", which is effectively going to be a CSV file containing opening and closing hours of a business, Monday through Sunday. Each of the... |
I started following Harvard's CS50 (Introduction to Computer Science) on edX, and as part of their Hacker edition set 1 was the following assignment:
I am supposed to write a program (in C), that takes as input a long long int from the user and proceeds to check whether the entered number is a valid credit card number.... |
Is the following helper idiomatic ASP.NET MVC? All the built-in DropDownListFor helpers only accept IEnumerable<SelectListItem>. If the Model doesn't have this list, but an IEnumerable<SomeEntity>, avoiding this conversion in the Razor template seems to require some more of its helpers.
namespace CompanyName.ProjectNam... |
A friend of mine asked me to write a script for showing the most used tags in her Tumblr blog in the last days. I saw it as a great opportunity for learning JavaScript and accepted it, as it seemed simple enough while being useful.
I "chose" the requirements to be:
Simple basic usage, not requiring JavaScript knowledg... |
This function returns a lambda expression based on the parameters sent. I am sure there is a better way to do this.
[NonAction]
private Expression<Func<ScheduleItemDto, bool>> Where(Guid siteGuid, Guid? eventGuid, MonthOfYear month, int year, bool? closed)
{
Expression<Func<ScheduleItemDto, bool>> n... |
I created an Excel AddIn that has a function called SLOOKUP which can replace INDEX MATCH combinations in an easy and smart way. For more info please visit my blog post. I would like you to optimize this further if possible.
Function SLOOKUP(database As Range, lookupCol As Range)
' Description: Excel UDF that implemen... |
Please review my answer for this interview question:
Merge k sorted arrays, using min heap.
import java.util.*;
public class MinHeap{
public static class HeapItem implements Comparable<HeapItem>{
int[] array;
int index; // the index of current element ... |
If I'm creating an immutable class from an existing class, should I override methods that mutate the property or have an instance of it and write my own methods to read from the property?
I have an existing class Set which is basically a fancy array. There's a few more methods in the class but for the purposes of this ... |
I didn't write the login code yet.
Main
static AccountLogin objAccountLogin = new AccountLogin();
static AccountRemover objAccountRemover = new AccountRemover();
static AccountCreator objAccountCreator = new AccountCreator();
static Accounts objAccounts = new Accounts();
public static void main(String[] args) {
... |
I have some functionality that allows the user to create a Meter, which counts your gas, water, and electricity usage.
A Meter has one or more Counter objects, which keeps track of your usage for a certain date via CounterReading.
Once a Meter is created, you can edit it by adding a new Reading.
This is the caller:
Cre... |
I made this Primitive class recently for my OpenGL engine. It basically wraps all basic primitive shapes, like cones, toruses, and cubes, which the user can use for various things. I would like to ask your advice on improving my class design in any ways.
Primitives.h:
#pragma once
#include "alpha/Mesh.h"
#include "alp... |
Select one of two number selection strategies and select two numbers
using that strategy.
The strategy is selected using an enum implementation of the strategy
pattern.
Strategy one: Ordered Numbers are selected sequentially. The last
number selected is persisted in the database and the next two numbers
are se... |
Problem Statement:
Samu had got N fruits. Sweetness of ith fruit is given by A[i]. Now
she wants to eat all the fruits , in such a way that total taste is
maximised.
Total Taste is calculated as follow (Assume fruits sweetness array
uses 1-based indexing) :
int taste=0;
for(int i=2;i<=N;i++){
if (A[i]-A[i-1]... |
I wrote up a Treap implementation to serve as the base class for a bunch of augmented data structures (interval sets, plane (2D) sets, order statistic trees), replacing my RB-tree base.
Some profiling for performance compared against std::set:
4 times faster insertion (for all cases; random, in order, reverse order)
... |
I'm currently learning Java. I'm trying to get a good grasp on determining what becomes a class. I've started translating old games in to simple Java programs.
I'm looking for any critique of use of objects. Pretty much any advice as to what could make this better in the long run.
(This code has no input error c... |
I have this script which is for a news feed. A button click will grab more data from the server if there is any and then add it to the box. It doesn't allow any more than 10 pages of results currently and how to properly store that page counter is what this question is about. loadMoreFeedItems() is the function attach... |
So I've been confronted with a rather simple problem in the Java chat on Stack Overflow. It's about doing a median filter with a sliding reference window.
For the purpose of the task we can assume the window used for filtering is always an odd integer between 3 and 21. The sliding window does not wrap around the array ... |
This is my revised solution to Problem 42 from Project Euler, based on suggestions in this original post Project Euler 42 - Finding triangle numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Collections;
using System... |
Since I was having some difficulties to debug the next step for Scrolly - A (very) simple infinite mouse "scroll", I've decided to make a console-like class that allows to add messages to it.
This allows you to show some messages. It also allows to pass any object you want, but it will be converted to string. You can a... |
This question is a follow-up. The original question was itself a follow-up to an older question by @LokiAstari.
The idea is to provide a compile-time integer range.
This version incorporates almost everything from the answers and comments to the previous iteration of the review (except the handling of corner cases s... |
This is the answer to this challenge:
Description
Thanks for that list you made me, my thoughts are way more organised!
I've got a few problems though that I thought you might be able to
help with? Sometimes I put the wrong information in a list item. Maybe
to prevent this I'd be able to modify/update the list item? T... |
I have implemented an Integer to Roman Numeral converter that converts any number in the range \$[1 \le x \le4999]\$ to its Roman number equivalent. Any comments on improving my code style or organization?
#include <string>
#include <iostream>
class Solution{
public:
Solution () : IntVal {1,5,10,50,100,500,10... |
I recently started toying with SIMD and came up with the following code for matrix multiplication.
First I attempted to implement it using SIMD the same way I did in SISD, just using SIMD for things like the dot product for each particular entry, which was actually slower (still trying to figure this one out).
After gi... |
I wrote a Perl script that implements the algorithm described in this
article to generate terrain height maps. The idea is to raise a random hill \$i\$ of size \$r_i\$ centered at point \$(x_i, y_i)\$, such that the height at point \$(x, y)\$ is
$$ z = r_i^2 - ((x - x_1)^2 + (y - y_1)^2) $$
The resulting terrain is th... |
In an attempt to learn better functional programing I've attempted to convert some Python to idiomatic Clojure, but I'm not sure how well I did with parts of it.
One thing I found myself doing a lot was destructuring a map into a list and then converting it back into a map as in the following example that takes a map o... |
This program detects whether an expression is balanced or not. I would like to know how I can make this more efficient.
#include<stdio.h>
#include<stdlib.h>
struct Stack{
char data;
struct Stack *next;
};
void push(struct Stack **top,char data)
{
struct Stack *new_node;
new_node=malloc(sizeof(struct S... |
Both of the following code give the same result. But I'm not sure where should I put the raise statement.
def bisection(f, start, stop, eps = 1e-5, max_iteration = 100):
for __ in range(max_iteration):
half = start + (stop - start)/2
if abs(f(half)) < eps or half - start < eps:
return half
if f(ha... |
I'm trying to create a program that converts infix expression to postfix (using stack) and evaluate the result of the postfix expression. I already have a solution that works, but I feel that it's ugly and that there must be a better approach.
(Note: the program must be able to accept digits greater than 9 and decimal ... |
I've implemented this skip-list yesterday, and I'd like suggestions on how to improve this code, and my coding practices.
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class SkipList<T extends Comparable <T>> {
List<Node<T>> levels;
public SkipList(){
this.levels ... |
I have refactored the graph path enumerator. DirectedGraphNode was not changed, so refer to the link above in case you want to have a look at it. The node type is not of a big concert for me, however, I just need something to find paths through. Now, all five points made by Misha, except the second one (deferring the p... |
I am developing an online game and my code is getting pretty hard to work with. I would appreciate any suggestions how to clean it up or make it simpler to work with. Thanks for any suggestions.
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import serv... |
I made an animation of the Microsoft logo. It's available as a CodePen doodle, also. Would anyone be so kind as to check my style and say if there is anything I could've improved? (I am sure there is.)
$(document).ready(function(){
$(".logo").click(function(){
$(this).toggleClass("turnOffAnimation");
... |
I am using C++ to code the following logic:
An Array is given we have to traverse the array such that sum of array elements to its left must be equal to sum of elements to its right.
BTW this is hackerrank Problem.
Here's the code , but this is giving me time-out, that is my code is too slow for very large input, I w... |
I created a method for finding the most common character in a string (using HashMap):
public static char getMaxViaHashmap ( String s) {
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
char maxappearchar = ' ';
for (int i = 0; i < s.length(); i++)
{
... |
The task:
There is an AccountManager that makes transfers. It receives 2 arrays of the same size: accounts and sums. They need to be transferred to the accounts correspondingly.
public interface AccountManager {
public boolean transfer(Account[] accounts, int[] deltas);
}
There is also an Account interface:
public... |
I'm writing a Python parser for OpenFoam mesh files. When the mesh is big, I face performance issues.
Here is the format of the file describing the points:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\... |
I wrote an STL allocator which uses boost::pool to allocate the memory for std::vector container.
This is my first time I implement an allocator and while working on this class I found that STL containers (std::vector for example) copy, destruct, create many times the assigned allocator during their lifetime. For examp... |
This is my program currently to calculate sum of following series:
$$\frac{x^2}{2!} + \frac{x^4}{4!} + \frac{x^6}{6!} \dots$$
#include <iostream>
using namespace std;
int main() {
int fac = 1;
float x, sum = 0, p = 1;
cout << "\nENTER x: ";
cin >> x;
p = x;
for(int i = 2; i <= 10; i++) {
... |
At the moment, it gets the first page worth of data and then each subsequent page when the user scrolls down to the bottom of the page.
My JavaScript/jQuery level is fairly weak, however I have managed to cobble this together and would like to know how I can improve my code.
var page = 1;
$(function() {
getUser... |
I've found that it's a huge pain to have to write the boilerplate code for each Project Euler problem I write (timing code, main method, what about running every problem instead of just one?). So I decided to create a program to run the problems for me.
Main.java
package projecteuler;
import projecteuler.autorun.Execu... |
I'm currently going through some lessons on Codility. I've just spent a couple of hours with GenomicRangeQuery, which is intended to demonstrate the use of prefix sums.
The task description is here. Broadly, the idea is that given a string and a set of arbitrary cut points one should be able to return the lowest value ... |
See also the next iteration.
This snippet is a counting Bloom filter supporting removal of elements as well. Instead of a bit vector it maintains a vector of "bucket counters". Also, the API supports well taking your customised hash functions.
Inserting: Just compute all hash values and increment all counters indexed b... |
I'm starting C as my first language and am just under halfway done the book I'm using. However, I commonly hear about 'bad' programmers and 'bad' code whenever I encounter any sort of programming related discussion on the internet.
I've done some examples that do work as they should but, I want to make sure that when I... |
I'm trying to do a recursive implementation of the problem mentioned below.
The code works, and takes care of a corner case with only 1 element in array (in which case I should return 0 - (element[]). Could there be improvements to this solution (like say not having to pass 4 arguments or anything like similar).
Also,... |
I have written the following class to allow me to uniquely identify classes in C++, and I was wondering if there are any better ways of going about it.
#ifndef _TYPE_IDENTIFIER_H_
#define _TYPE_IDENTIFIER_H_
typedef std::size_t Identifier;
class TypeIdentifier {
public:
template<class T>
static Identifier get... |
Firstly, I got the solution for this question in CodeChef, but I noticed one thing which still confuses me. This was the code which was accepted as correct.
#include<iostream>
using namespace std;
int main(){
int testCases,count=0;
cin>>testCases;
unsigned long int a,b;
while(testCases--){
c... |
I have made an implementation of the Euclidean algorithm in Java, following the pseudocode shown below.
As far as my knowledge goes, I can't find a way of making this more efficient.
I have looked into other peoples implementations of this algorithm and there are a few which are slightly shorter, and some that use recu... |
After reading Designing a coffee machine, I decided to implement the same problem as an exercise to get to know Guava and Lombok.
I used the problem statement from the given question:
Design a coffee machine which makes different beverages based on set ingredients. The initialization of the recipes for each drink sho... |
I have a program which solves Project Euler problem 60:
The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowes... |
I'm reinventing std::future from scratch (for an upcoming talk). I'd like to incorporate as many of the latest and most likely-to-succeed proposals as possible, and then also at least one additional feature that I haven't seen in any proposal yet: cancellation of tasks.
The idea is that if I spawn a chain of tasks via ... |
I made a commandline tool for renaming files, similar to the rename command in Ubuntu. Here is the code:
import scala.collection.mutable.Map
object Main extends App {
val usage =
"""
|A commandline tool for renaming files (written in Scala)
|
|Usage:
|
| screname [-a] [-t] -s searc... |
I have an array to have a maximum of 10 elements. Whenever I add a new element, if it already has 10, it would remove the first and push a new one.
I made this:
Array.prototype.pushMax = function(value,max){
if (this.length >= max){
this.shift();
}
this.push(value);
}
Which seems to work fi... |
Folow up of diary-applications-with-accounts
Diary Class
AccountLogin objAccountLogin = new AccountLogin();
AccountRemover objAccountRemover = new AccountRemover();
AccountCreator objAccountCreator = new AccountCreator();
Accounts objAccounts = new Accounts();
Exit objExit = new Exit();
public static void main(String[... |
This is my solution to Project Euler #4, which asks for the largest palindrome that can be made from a product of 2 3-digit numbers. I have done a brute force method, but it takes around 10-20 seconds to run. It works by looping through 2 variables, finding its product, and converting it to a string to check for palind... |
I made what started out as a web browser but now is a scanner for open ports. I wanted to know if you think this is a realistic or a unreliable tool for port testing. I found some open ports on my computer and was able to send data through them.
#include <windows.h>
#include <winsock2.h>
#include <conio.h>
#include <st... |
My attempt at this challenge., incorporating lessons from this question, which turned out into a much bigger project than I anticipated, but it works. I'll definitely be refactoring most of this in the future, maybe going the MVC route. I tried a lot of new things here and am curious which are good and which are far re... |
As part of a larger Java application I'm working on, I have to retrieve emails and parse the data for the emails' content (subject, date, text, attachments, sender). In the method below, I pass a Message as a parameter, which is the Javamail abstract representation of an email. The details of the Message are recovered ... |
I'm creating a WPF application with a DataGrid. I'd like some advice on the code I've written:
<DataGrid Margin="0,10,10,10" LoadingRow="DataGrid_LoadingRow" Name="user_view" EnableRowVirtualization="False" Grid.Column="2" CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserResizeRows="True" CanUser... |
I have written a simple program in Java 7 to write the .gitignore of different file types:
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Scanner;
public class Oye {
private static final String HELP_TXT = "help.txt";
private static final String DATA = "gitignore";
... |
I'm working on a 3D-project with three.js and webGl. I've written a function to check for 2 objects to be near each other and thus "snap" to each other.
The objects don't move on the Y-axis, so I only have to check the 4 sides of each object against the side of all other objects in the scene. At the moment I'm doing th... |
We are using an outdated 3DES algorithm for encryption and I have been tasked with writing a new implementation using AES with a 128bit shared secret.
I would like to know if there are any security holes in my implementation and if there is any way to optimize the code. Please note that I have removed the code for impl... |
I have an Android application that is using an EventBus architecture with publishing and subscribing events. Usually this is from Controllers (Activities) to a "Manager" class that handles all the subscriptions.
Here is an example:
Controller Class
public abstract class EventBusActivity extends Activity {
protecte... |
The problem:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
The solution in Swift:
import Foundation
var number = 2520
var found = false
while found == false ... |
I previously asked about my implementation of the Sieve of Eratosthenes algorithm here.
After looking at all of the feedback, I have reworked the code to make it significantly more efficient. However, I'd like to know whether it can be made more efficient still.
I have tried to follow pesudocode for my implementation, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.