instruction stringlengths 71 71.9k |
|---|
I'm learning Java at the moment and I'm currently trying to make a GUI using Swing. I've done some reading and people usually prefer and advice to use composition instead of inheritance of e.g. JFrames.
I'm trying to code the GUI by hand instead of using the GUI builders, since they all generate a lot of code and I wan... |
I have file which contains a lot of boards from TicTacToe 5x5.
First line says how many boards this file contains (n*5x5).
We check the winner in Horizontals, Verticals and Diagonals lines.
Player A or B win, when has streak of minimum 3 letters (can be 4, 5) on the board. for example:
ABABA
AABAA
AABAA ABABA AABAA
D... |
The following is my code for my "drawer" to be display or hidden on the basis whether it has been clicked or not. I want to make this better as personally its messy. Any tips?
//Checks if the page loaded is of specific type
if(window.location.href.indexOf("home.php") > -1) {
//Handles the displaying of the si... |
This was written as an experiment in performance, based on another question here on CodeReview. Input into the algorithm is the number of squares on one edge of the chess board, the point of origin, the destinat
ion and the type of slicing (imposing restrictions on the search to allow it to complete in a reasonable fin... |
I made this game for my computer science class.
Here is my professor's requirements:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when the left and right arrow keys are pressed using the translate and rotate methods.
When the spacebar is hit, create a torpedo that... |
I have a site where a friendly hacker says they have accessed my admin area. I am not able to see how this is possible so any help would be greatly appreciated. I am using PDO prepared statements to connect to my MySQL database.
Login Page (this is where the user logs in):
<?php
require_once('inc/constants.inc.php');... |
I'm learning OOP and totally new to this way of coding. I've always scripted PHP the procedurial way. Now I've written a working class, which creates a database connection and has the method to create a query which is impossible to SQL-inject by hexing the non-integer data. (I know how to use prepared statements, but i... |
I have created a program that turns a decimal into a fraction:
package main
import (
"fmt"
"github.com/retep-mathwizard/utils/convert"
"github.com/retep-mathwizard/utils/input"
"math"
"strings"
)
func main() {
fmt.Println("Input your decimal")
num := input.Strin... |
Short and Spicy question is that If input is how are you and output should beyou are how.
public class ReverseWord {
public static void main(String[] args) throws IOException{
String input;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter th... |
I've asked question on SO how to rewrite jQuery code to Angular. Because I got no answers I've tried to create something by my own.
This is my version of code:
(function() {
'use strict';
angular
.module('misiu.directives', [])
.directive('console', ['$rootScope', function($rootScope) {
return {
... |
I have been writing a small particle plugin since I want to learn how physics works for games. Now I have tried to get this as clean as I possible could but It feels something is missing. Am I repeating too much code? Could this be improved in any way such as in performance?
https://jsfiddle.net/zdufwLv6/
new explod... |
I have written the following code, and it works great, but I'm not satisfied. I really love the book "Clean Code" by Uncle Bob and I try to apply all his principles when coding, but I'm having a tough time cleaning this abomination. I call it an abomination because I'm sure everyone new to this method will spend more t... |
I am willing to get a linear output of a product in a ring Z/nZ
For that I have successfully implemented a code that does a Product in a modulo
However, it is not optimized to output the steps smoothly:
/* Product of n1 x n2 x n3 modulo M */
var numbers=[n1,n2,n3];
var modulo= M;
var AProd=1;
var BProd=numbers[0];
... |
public async void Execute()
{
var mongoClient = new MongoClient(connectionStringBuilder.ToMongoUrl());
var db = mongoClient.GetDatabase(connectionStringBuilder.DatabaseName);
var jobInfoDocuments = db.GetCollection<JobInfoRecord>("JobInfoRecords");
var encryptedKeys = new[] { "AccountKey", "PrivateKey"... |
I have three primary tables:
Customer
Product
Order
Relations:
Many to many between product and order.
CREATE TABLE Customer (
CustomerId int NOT NULL AUTO_INCREMENT,
CustomerName varchar(50) NOT NULL,
CustomerMail varchar(50) NOT NULL,
CONSTRAINT Customer_pk PRIMARY KEY (CustomerId)
);
-- Table `... |
The following code performs breadth first search on a mockup tree
# some tree
# A - LAYER 0
# B C - LAYER 1
# D E - LAYER 2
# F - LAYER 3
def get_something(x):
if x == 'a':
return ['b', 'c']
if x == 'b':
re... |
I have a rails4 app. When a user comments on a post it should send a notification to all the guys who commented on the post and to the post creator. I have a working method in the controller, but it's kinda ugly and I'd like to refactor it.
Could somebody tell me what the rails convention for refactoring this?
Comment ... |
In a recent project I started passing dependencies to classes as constructor arguments, instead of using local instances. This makes unit testing straightforward (with mock objects), but manual instance creation can be quite tedious if you have more than a handful of objects.
I created a small class that's capable of a... |
In an effort to teach myself Node.JS and truly delve into its communication capabilities, I elected to recreate a previous chatting project. It took a bit of forethought to acclimate code to the asynchronous nature of node, consider the implications of sending files for access and get in the habit of using callbacks.
I... |
This question was moved from StackOverflow as suggested by some users.
I developed a function that aims to (should) provide a simple and effective method to transform a polygon <path> from relative to absolute. The purpose of this function is to replace similar SnapSVG function from my code, since I'm not processing an... |
I recently created my first directive based on jQuery plugin and I asked for review here: Angular console like window - first directive
I've edited my directive so now instead of $rootScope it uses provider.
Below is my code:
(function() {
'use strict';
angular
.module('misiu.providers', [])
.provider('sim... |
I'm starting to learn Lua and in one part of the book I need to convert a "Maze Game" that uses goto to another one that doesn't use goto.
The maze is the simplest ever made, starting from room #1:
---------
| 1 | 2 |
---------
| 3 | 4 |
---------
This is the original version using goto from the book:
goto room1 -- in... |
I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and will not intrude or collide with other files, then concat/minify them for production as one file; basing some concepts off ... |
I am trying to learn AngularJS as a start to my revival of learning, I think that I am getting the hang of it so far, but would like to see what I can do differently with some super simple applications, hopefully I can see what I need to work on this way.
First thing is first, a basic calculator.
This is a super basi... |
Javascript newbie here. I built a total cost of ownership calculator to calculate the cost of a business over 5 years. It has a lot of repeating script and prob way more congested than it needs to be so I was wondering if y'all could give me an idea of how I could go about writing this in a more DRY way. Below is a liv... |
This code calls the iControl REST API provided by BIG-IP LTM. Trying to get the list of the pools, it's current status and the pool members associated with the pool.
My code works like this, based on three calls:
Get the pool names (/mgmt/tm/ltm/pool)
Based on the pool names (path), get its status (mgmt/tm/ltm/pool/~p... |
I have just finished a simple python script which uses this module to call Zenoss API for getting live events. What the script does:
connects to zenoss
reads a file which has one phone number on each line
sends a message to each number by POSTing some data(first of all it authenticates) to a specific URL with the foll... |
I have written this "Polyfill" for Chrome's Promise object and I have some concerns about the implementation;
Does it actually work as designed? It seems to work but I'm not sure if there are any "edge cases" I am not accounting for.
Is there a better way to do it? The inner function way seems a bit odd, as I don't li... |
I am busy creating a file processor that needs to get some files from an Ftp client download the file and save the data into the database. I have a two part question.
How can i refactor the code to look a bit cleaner? Feels like the
method ProcessFiles is doing a bit much. I can extract some of the
methods but... |
I've refined a lot of the code from my previous question, and have also decided to include the logic that interprets a given text file. Any advice on how to improve the actual algorithm that solves the maze would be appreciated! I'd also like to figure out how to store the full path to the exit in a queue.
Here's the f... |
I've written an ES6 function using the new fetch() API and returning a new resolved promise with a data object or a rejected promise with an error subclass.
I'm pretty new to both ES6 and Promises, and it looks a little unwieldy, so I'm wondering if there's a better way. I'm also wondering about how this relates to the... |
I am getting a compiler warning when running my code analysis. It is CA2202. It is saying that I have not properly disposed my dataset through all exception paths. Here is the code:
private System.Data.DataSet MyDataSet()
{
DataSet dat_set = new DataSet();
using (SqlConnection conn = new Sq... |
I started learning Go a few months ago and am trying to shake the rust off after a project took me out of the Go world for several weeks. I'd appreciate a code review on this flood fill algorithm I wrote for practice.
Specifically I'm looking for points on any code I've written that is unidiomatic in Go, and of course ... |
I have been using a particular pattern over and over again when I want to keep my jQuery apps more safe from XSS. I do something like this. (It uses ES6 template strings)
function doSomething ($el, user) {
var $html = $(`
<div>
<img src="${user.img}">
<div class="username-text"></div>
<div class="descri... |
I wrote a function to find a specific file, or all the executable files with a given name and accessing flag, and I want to make sure it is as cross-platform as possible. Currently, I'm using the PATHEXT environment variable to get the extensions for files that the operating system considers executable.
import os
clas... |
I've started to learn very interesting concept of DI, IoC and related stuff.
I have decided to learn it using simple application, very tiny calculator (only basic functions: add, subtract, multiply & divide), because it's very conveniently to learn any new stuff with elementary application.
My question relates to the d... |
I am writing a very simple Prolog intepreter in Haskell. It's a class assignment and I really want to do it right.
I was able to (quite quickly) write a parser for the language. Today I borrowed a copy of Programming in Haskell by Graham Hutton and I decided I would rewrite my code to a more function-oriented style, us... |
I'm currently using a make shift INSERT on DUPLICATE UPDATE function that relies on a DB raw query from eloquent. I'm looking to improve the quality of the code and the speed. Please take a look
function bulkInsertBookTable($data)
{
$inserts = [];
foreach ($data as $item) {
$inserts[] = implode(', ', ['... |
I'm writing a simple Android app with a database and am trying to make the right architecture for accessing a database.
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setC... |
I'm trying to get a little more comfortable with using classes as they're meant to be used, instead of using them to decorate my code to make it look more legitimate. Can you see anything glaringly wrong/could be improved/possibly different implementations?
import random
class Player(object):
def __init__(self,pl... |
As a project I have written a graphics library for educational use to allow kids at my high school to make Java games without directly dealing with to the Java graphics API. I'm in the final stages, tweaking mainly for performance and readability, and I would like some input on how I handle transformations.
The idea of... |
This script counts how many matches were won by the team with a first half, second half, and full game time of possession differential advantage.
The data is stored in a pandas data frame:
Points H1 H2 Total
0 36 46 50 96
1 -5 16 18 34
2 47 12 65 77
3 12 79 13 92
4 ... |
I'm trying to practice and learn design patterns, and I decided to create a weather app using the revealing module pattern. How can I improve on this, and what mistakes did I make?
Main.js
import '../styles/main.scss';
import {weatherModule} from './weather';
import {dateModule} from './date';
dateModule.getCurrentDa... |
I frequently want to filter and select elements from a long (10,000s to millions of elements) vector in R. Often, this vector is a column in a data.frame. I am usually interested in rows of the vector that "match" any one of a separate list of 10 to 100 query values. However, since these are experimental data (mass ... |
I'm trying to smooth the movement of a cursor which has a set acceleration and max speed. I wrote this function to calculate the stopping distance of an object given its speed and acceleration, and it works, but it seems a little ridiculous.
function getStoppingDist(speed, accel) {
var dist = 0;
while (speed > 0)... |
Following Nadeem Afana's article about how to include internationalization into an MVC application, I have introduced i18n into one of my MVC applications.
These are my goals:
Use strongly typed resources
Allow to easily change existing resources strings without application redeployment (i.e. at runtime)
Easy to use... |
Write a Compress class defines two static methods, gzipFile(), which
compresses a file using GZIP compression format, and zipDirectory(),
which compresses the files (but not directories) in a directory using
the ZIP archive and compression format. gzipFile() uses the
GZIPOutputStream class, while zipDirectory(... |
I think this code is not optimized:
function changeSalesStage(value){
var $form = $( getProductsForm() );
if( typeof(value) == 'undefined' ) value = $("#sales_stage", $form).val();
// Failure
var cause = $("#causes_failure", $form);
var notes = $("#failure_notes", $form);
var seconder = $("#s... |
I need to check that a user is allowed to save/retrieve contacts to/from the database by calling a web service, and return an HTTP403 with an explanation if it is not the case.
So for the sake of factorizing the code, I decided to use a boolean method that "never" returns false and is there only to check this, and thro... |
I'm working on the following DP which finds the optimal way to allocate a resource. At each time step I can either allocate (0.2 resources) at cost C or not in which case the storage is reduced by the demand. The cost C depends on which time step I do the allocation.
I need to add quite a few more complex features, but... |
I wrote a Python 2.7 script, which plays tracks from the SoundCloud Top 50.
import atexit
import os
import shutil
import subprocess
import requests
if not os.path.exists('.tmp'):
os.mkdir('.tmp')
@atexit.register
def cleanup():
shutil.rmtree('.tmp')
class soundcloud_top50_player:
def __init__(self):
... |
Currently, I'm working on a project where I needed to run some code every time the page is hidden.
I searched high and low and found this question: Is there a way to detect if a browser window is not currently active?. The accepted answer did an amazing job, but it only sets a class, doesn't run a function.
So, with th... |
I'm writing a project, and the part I'm doing now is getting bloated real fast. How can I remove this nested if statements, but still have the same behaviour?
It would be nice the the resulting code was succinct, and extra local flags weren't required. This might not look so bad now, but I'm planning on writing more me... |
I'm creating a dictionary app using Win32 API. I stored the word meaning in a file called dictionary.dic in the following format:
Word Meaning
A The first letter
B The second letter
... and so on
As my window is created, I load the dictionary file into the std::map object using this code:
std::map<wstring, w... |
I'm new with JavaScript and need your advice. The idea is to show/hide text field depending on select option. I have a working code, but I believe it could be more readable and better. What have I missed?
<script type="text/javascript">
<!--
function showHide(){
var selectedValue =document.getElementById... |
I am making a data drive system for creatures, abilities, items, etc. Considering my ability objects I need to create "templates" from the these since parsing them in real time is too slow. I am trying to find a way to just reference these on my creatures instead of a copy of the reference for each ability.
The thing i... |
Problem description
Given a text \$T[0..n)\$, a pattern \$P[0..m)\$, and a nonnegative
integer \$k\$, report all positions \$j \in [0..n)\$ such that \$ed(P,
T(j - l..j]) \leq k\$ for some \$l \geq 0\$, where \$ed\$ is the
Levenshtein distance between two input strings.
Question
I am comparing two algorithms: the trivi... |
I have written a Java class that parses Shoutcast 2 stats XML. It uses JDOM to parse the XML. I have only basic knowledge of Java and I wrote this class in about 3 hours. It works, but I don't know if I've done everything right, or how efficient it is. I intend to use this class in an Android app I am working on. You c... |
I have written a program to read HTML file, find particular text, write text from that particular text to next particular text in a newly opened file. I am interested in code review. I am very new PHP.
<?php
$FILE = "testing.html";
$count = 0;
$directoryName = explode('.',$FILE)[0];
$TAG = "/x-berschrift-1--nur-f-r-He... |
This is from the Resin codebase. It is fast at lookup but I could use some help making it faster at buildup. Loaded with 210K words, it looks up pretty much any node and its descendants in zero time. Buildup takes 3000 ms.
using System;
using System.Collections.Generic;
using System.IO;
namespace Resin
{
public cl... |
I've been trying to learn Python for a bit now. I've taken a few courses, but I've found that I've been going about them wrong and had allowed them to "hold my hand" too much. I'm trying to build projects on my own and thought I would start off small. My third or so project was this Pig Latin translator and I wanted to... |
I want to get the first argument as a number, if there is any. This does not feel quite right, but I don't know yet what the Rust way would be.
I'm not searching for a args-framework or something, I just want to get a grip on doing stuff with Rust.
fn limit_from_args(args: env::Args) -> i32 {
let args: Vec<String> ... |
A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, which is the pivot point of rotation.
function findminimum(a, start, end){
if(start>end || start == end || a[start]<... |
This is a follow up to this post I uploaded a few days back on my alternative account about a circular buffer in C. I'm confident that I fixed most of the warnings and even added an iterator.
circularBuffer.h
#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H
#include <stddef.h> // max_align_t in source
struct cir... |
I am working on an iOS project and I'm in charge of testing most parts of it. As I write some tests, I often have the need to wait for an asynchronous method to finish, and then test that something did not happen.
For example, try to login with an invalid username and password, wait until the network communications are... |
This is code that handles pushing data to an analytics API, and IMO it feels too much like Java.
logActivity is a method that uses Dispatch to POST the data to this API. I am worried that an exception could occur and that is why I wrapped the methods in a try/catch block. However, this feels very Javaesque.
Do I even n... |
This was an experiment to take any text and wrap it to a given number of columns. It also wraps
the text in just one box, lets you box multiple blocks of text, and also lets you limit the number
of boxes per line. The main paragraph tested was one that I found on Yahoo that I thought was
really fun to use as a test. Wo... |
I'm a novice regarding both C++ and Qt. This class is used in my project to get an image from a web service.
If a new call to StartDownload is made before the previous has finished, the old one can safely be discarded as it won't be needed any more. This is because a new request is made for each resize event, as one of... |
I want to write a class that returns a Stream of permutations of an int[].
public class Permutations {
public static Stream<int[]> of(int[] array) {
return permute(array, array.length);
}
public static Stream<int[]> permute(int[] array, int n) {
if (n == 1) {
return Stream.of(Arr... |
I had a task to create a program to simulate a simple card game.
Given an input file with number of players, the players and finally a list of cards played, I had to change the game state accordingly (I believe card-action relations are clear enough from the code, so I won't go into detail here).
The task was not inten... |
Consider a 3x3 square surrounding a cell (marked @) on a grid:
0 1 1
1 @ 0
1 1 1
I need to find the number of groups of open cells (ones) surrounding the center cell. In the above example, there are two groups of open cells. All cells have the value 0, closed, or 1, open.
Here's what I have:
{
// x and y coordinat... |
This script is very basic: it does one thing. Connect to it's root and it will log your IP if it has never seen it before. Connect to /logs, and it will show a list of unique IPs within the server storage. I can't take 100 percent credit for it. I grabbed it off of Stack Overflow, modified it to actually run on App Eng... |
I got inspired by Stack Overflow to build a simple state machine which can test if a sequence contains 0,1. I have two questions:
How can I get rid of line | _ -> (function `q0 -> `q0 | `q2 ->
`q2 | `q1 -> `q1)
How can I improve that code?
(If it is matters, I came from Python and many things in OCaml seem unusual to... |
So I have a file with a list of dates that are to be redirected as input to stdin and what the program does is it searches for valid dates, appends them to the output file and then appends all the dates in the input file to the output file. In other words, at the end of the program there would be a list of all the vali... |
This is literally the first time I've ever used JavaScript so I know it's really bad and how to improve it just not how to implement it. Basically, I need to loop through all the elements instead of manually checking and updating each one. Any suggestions on how to do that, and other recommendations?
<!-- Kalenpw -->... |
I created a function to add and return the average rating.
Rating Function
// Adding AddRating
final function AddRating($rt_target_id, $u_id, $rt_vote,$moduleName){
$error = 0;
if(!empty($moduleName) && $rt_target_id != 0 && $u_id != 0){
$tableName = '';
switch ($moduleNam... |
I created event delegation like concept which is present in jQuery. AFAIK, event delegation is used to register an event for an element which is supposed to be added dynamically. So, in jQuery we do the following:
$(document.body)
.on('click', '.main', function(){ /* code here */ });
.on('click', 'div.main', fu... |
(See the next iteration.)
I have subclassed java.util.ArrayList in order to be able to "rotate" it in constant time simply by moving a finger index. See what I have:
RotableList.java
package net.coderodde.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
i... |
One of my university assignments asked us to create a program using struct in order to create a simple event scheduler. This program is for a single day only, not multiple days.
Sample Input / Output
For a few reasons, I've opted to create a .GIF to display the sample input / output:
An example save file:
8 30 denti... |
Problem (Rephrased from here):
The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$.
We shall define the triplet of positive integers \$(a, b, c)\$ to be an abc-hit if:
\$GCD(a, b) = GCD(a, c) = GCD(b, c) = 1\$
\$... |
I've created this 3D vector class and would like it to be reviewed. I wonder if there are still some improvements that can be made. This is a header only implementation.
#pragma once
#include <string>
template<class T> class vec3
{
public:
union {
T f[3];
struct {
T x, y, z;
... |
I have started learning Java recently and was looking into the challenges on sorting on Hackerrank.I solved the following problemHackerrank on Insertion Sort.
The challenge was :
In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an entire unsorted array?
G... |
I have a situation, where I want to add many classes as instance variables of another class, plus perform some action on each class. The purpose is to have an 'app' with many 'views', to represent PageObjects.For instance:
class App
attr_reader :login_view, :list_view, :create_view
def initialize
action([Login... |
First time I write the tests before the actual code.
All fit in the same module.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from os.path import join as path_join
from xmlrpclib import Fault, ServerProxy
XMLRPC_URL = 'xmlrpc/2'
class Model(object):
def __init__(self, host, db, uid, pwd, model):
sel... |
I have just decided to get into programming as a hobby (and possibly a job in the distant future). After learning the basics of Python, I made Tic-Tac-Toe to apply what I've learned. I would appreciate any and all feedback on my code and the way I set up the logic of the game. I would like to avoid picking up bad co... |
I was wondering if you can help me out. I wanted to know if there is an easier way to do the following. My code works but I feel like there is a lot things going out with multiple loops and wanted to see if anyone can help me condense the code i have attached to make it clear.
In my code I have created 3 subroutines (i... |
The getDynamicTeacherCount function is generating number-based reports from the table that I have in database and the getDynamicPercentage function generates percentage for these reports; then I am calling the getReports function from the related controller and pass the getReport returned array to the Laravel View and ... |
This include was written for a Jekyll site I'm building. It generates nested HTML unordered lists to a given depth dynamically by parsing page urls. It works fine, but the code feels messy and it takes Jekyll upwards of 20 seconds to build the site (up from ~3 seconds before this navigation was implemented).
Basically ... |
I'm not used to Python.
The script opens serial communications with an Arduino unit and send commands to and receives information from the Arduino. It is intended to run indefinitely until the system is shut down or pulled out of field deployment/laboratory testing.
The time.sleep() calls with offsets are assurances th... |
I'm a C++ newbie and so far have written my code mostly in an not OO way. Since this is getting confusing I'd like to start creating libraries for some of the functionalities that I've implemented. The following program basically issues callback functions depending on a counter. It's made to detect the duration of a bu... |
In Service.Insert(), I call DeviceRepo.Insert() and in Service.Update(), I call DeviceRepo.Update(). All my other code is exactly the same.
I'm thinking I can make one method that do the same thing update. I want to update and insert when I will insert a device.
The methods respectively insert a new or update an existi... |
I am using CTR mode (it is a cipher in itself) in this code. I just wanted to see what you thought about it before I finish it.
(Yes, I know that the plaintext length and key length must be highly specific. I will take care of that with padding later.)
I just wanted to know if you thought if this code was cryptographic... |
Within my app i have a UIButton (avatar button which shows a profileVC) within a UICollectionView this button shows up in about 4-5 other views. I'm currently adding the target within cellForItemAtIndexPath in each view controller and pushing the view from a public function pushNewViews. I was wondering if they was a b... |
I have this Excel macro I created to highlight all instances of a number if at least one instance is already highlighted before running the macro.
Sub highlightXIDs()
Dim prods As Object: Set prods = CreateObject("Scripting.Dictionary")
Dim lastRow As Long: lastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp... |
I have this Java class for producing rotations of an input string:
StringRotator.java
package net.coderodde.util;
import java.util.Objects;
/**
* This class implements a data type for rotating strings.
*
* @author Rodion "rodde" Efremov
* @version 1.6 (Mar 24, 2016)
*/
public class StringRotator {
/**
... |
This is my first time using semaphores and I was wondering if I implemented them to the best of their abilities in my code....
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include<semaphore.h>
#include <math.h>
#define NR_THREAD 2
int sum=0;
unsigned int seed;
sem... |
I have the following code that makes use of the DiskArbitration framework to mount a disk to its default location:
#import <CoreFoundation/CoreFoundation.h>
#import <DiskArbitration/DiskArbitration.h>
void MountCallback(DADiskRef disk, DADissenterRef dissenter, void *context);
int main(int argc, const char *argv[]) {... |
I have created a brainteaser, which I called the "impossible problem" (see this video I made). The aim is to create a valid 3-digit subtraction which uses every digit from 1 to 9 once. Here is an example of one of the solutions: 873-254=619.
After finding it hard to come up with answers I created this program. What it... |
Just wanted to get a bit of feedback on this simple cache. My use case is to store this data on an Android client to avoid making a high volume of network calls for lookups.
I feel like maybe I should just extend HashMap with the small amount I've added, or change up my thinking and do some type of static implementatio... |
I have created a pretty bad (just being honest) Golang library. I will take any and all advice, as long as it's helpful. Sorry it's so long. Also, I easily forget some things, so many functions in convert are just light wrappers around strconv, etc.
GitHub
Convert
package convert
import (
"github.com/retep-mathwiz... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.