instruction
stringlengths
71
71.9k
Below comes a Value Object to represent UserId in ASP.NET application. It implements Value Identity, so equality is defined by matching of the state calculated at the moment of comparison. It depends on public interface IAuthenticator { int CurrentUserId { get; } // may be impersonated int Intera...
This fairly clunky looking VBA script successfully pulls names of countries from an Array, but could it be made shorter? Mass of text from Column C onward in each row may contain the names of countries, which I want to pull into the corresponding cell in row A. What I have so far is not pretty... Sub PullCountries() Di...
I have implemented a filter for filtering a IEnumerable of a specific type. To accomblish this goal i have created three classes: FilterOption, Filter and the FilterManager. FilterOption.cs public class FilterOption<TFilterOptionType> { private bool _isSelected; public bool IsSelected { get { retur...
My code is very slow to run, and I am trying to find a way to make it more efficient. I know there must be a better way than to write each modulo operation. The goal of the script is to find the smallest possible number than can be divided by numbers 1 to 20 without a remainder. def divide (2..Float::INFINITY).each d...
I have been trying to write a BrainF*** program that prints the Fibonacci sequence numbers repeatedly. I was wondering whether this is the most efficient way to do it. I basically repeatedly duplicate two cells into a third cell, and shift one cell forward and repeat. +++++[->----[---->+<]>++.-[++++>---<]>.++.---------...
The following is my first try at this classical interview question. It is quiet different from the solutions Gayle Laakmann provides in her book, and in another question on stackoverflow, someone initially mentioned there are better ways to do it. I think my solution should run in O(n) time and use O(n) space. Would b...
This class is for fast and small footprint buffering made specially for network I/O. It is similar to so-called circular buffers, but is not circular. #ifndef _IO_BUFFER_H #define _IO_BUFFER_H #include <cstdint> #include <cstring> #include <cstdio> namespace net{ template<size_t CAPACITY> class IOBuffer{ public: ...
I would like to use the following routine in my submission script for GAMESS calculations. I am not entirely sure if this is the optimum way to go. This function would need one of the messaging routines, message, to function properly, but I decided to put echo in front of it, since this is basically what it does any wa...
I execute the following SQL statement to get back an data object into a variable. try { $getUser = $db->query('select * from user where user.user_id = '.$user_id); } catch (Exception $e) { echo $e->getMessage(); die(); } from this I print out the information on the page where necessary e.g. the foll...
(See the newer version here: CodeReview question markdown downloader) As an adjunct to From new Q to compiler in 30 seconds, I've created a Python script to automatically download the markdown from any question on Code Review and save it to a local file using Unix-style line endings. For instance, to fetch the markd...
I created an application from 3 layers, DAL, BLL, and Representation layer in ASP.NET Web API. In DAL i have 4 Classes: - DatabaseContext.cs, UnitOfWork.cs, GenericRepository and UserInfo. In BLL i have a class called UserRepository that implemnet the IUserRepository interface. In the Representation Layer i have a co...
As an introduction, I would like to have my inputs validated with the built-in validation HTML5 attributes, e.g. use pattern for text input. So this is my sample code that implements that. Is it considered best practice while handling event, to access event.target, which is the original DOM, and do something with it, r...
I've been writing code for a little while but I'm a little slapdash. I'd like to get better so I've been having a glance at best practices, other peoples code and reading a whole lot. I'd appreciate it if you could read through my code and make some suggestions and explain why. You'll find some of my code below. I want...
Role based security does not work for me well in a multitenant app, as I need to query DB to decide on permission allowance. Here is the solution I came to. All implementations of this interface will be auto registered in IoC container (note covariance/contravariance support): public interface IResourceAuthorizer<out T...
So currently I have this basic little chat bot that can read commands and can timeout users if their message contains a banned word or phrase. I was wondering how I can improve on this bot to be able to !add "word" to the set of banned words and overall general flaw improvements. import string from Read import getUser...
So, yes, I know that "you shouldn't derive from std containers" but by now it's more of philosophical rule in my mind than a technical one. I've googled again for the one fundamental reason one should never-ever-ever-ever-do-that-ever-ever-ever-or-you-die but couldn't find it. So, if there's nothing fundamentally wrong...
I am faced with a design issue that has been discussed on SO several times, the most similar question being this one. Essentially, I want polymorphism for a CUDA kernel in the form of a "generic" kernel that can apply a "user-supplied" function to every element in an array. In C++, one could achieve this design by usi...
I have made a simple static parser for a bigger program. This parser takes a string that has comma deliminators and I need to separate the strings in to a vector for handling in a different section of the code. I would like this to run as fast as possible so the rest of the program isn't tied up separating strings. I a...
I've written a simple demo for Conway's Game Of Life for self-practice. How can I improve the code, especially the processLife() method which traverses and updates the next state of every element in the matrix. The complete code is down below; For those whose eyes are tired of looking at code here: Gist Link public cla...
I'm working on a program that generates a maximal geometric progression of at least 3 integers when given a number that the greatest value shouldn't exceed. My current code works, and it's quick(ish) with small numbers, but anything past 100 takes far longer than I'd like, as I need to calculate numbers in ranges from ...
I've implemented a templated DBSCAN for general use. At the moment, it's going to be used on Android through the JNI. I used Wikipedia's pseudocode and a little bit of the DBSCAN paper for reference. It's pretty naive, so I'm wondering how I can speed it up, and what I can do to make it perform reasonably well on a pho...
As an effort to teach myself Swift as well as to get familiar with machine learning algorithms, I've been trying to implement common algorithms, starting with a Random Forest. This is, for the moment just one of the tree, but I have been trying to implement it just from the theory, without looking at pseudo-code, in or...
The Node.JS HTTP and HTTPS modules only provide .get shortcut function, unlike AngularJS's $http which provides them all. I went about creating a function that returns one of these shortcut functions: 'use strict'; var http = require('http'); function httpF(method) { return function (options, body_or_cb, cb) { ...
Can somebody please try and help me speed up my code? The file is ~12MB (you can download it here). It takes around 500-600 milliseconds to run on my i7 4790k. import java.io.FileInputStream; import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.Files; impor...
I wrote a JavaScript source which regrouping by new key i.e. following JSON to the other: { "items" : [ { "company" : "A" , "name" : "Prod_A01" } , { "company" : "A" , "name" : "Prod_A02" } , { "company" : "B" ...
Forgive me if this is too simple, but I'm a beginner trying to learn and understand. I came across an exercise to create these three basic functions, and this is what I came up with. Any glaring errors? This program defines three functions: sum(x,y) range(x,y,step) rangeSum (start, end) sum will give you the sum ...
My son just started high school and in Math, he was asked to do some stats homework. The exercise was to count all the vowels in a passage of text, then answer some questions about frequency. Out of curiosity, I wrote a quick Python script to count the vowels: text = "Australian Rules Football is a ball game played by ...
How do I improve the following? List<int> list = new List<int> { 1,2,3,0,5,7,0,6,0,0 }; list.Reverse(); list = list.SkipWhile(l => l == 0).ToList(); list.Reverse(); The goal is to trim trailing zeroes.
I'm making a a simple labyrinth. I want to make it so that I could hit a wall, and if I did hit the wall, I wouldn't cross it. from turtle import * from time import * speed(0) for a in range(0,401,20): sety(a); forward(400); #write(a); forward(-400); home() left(90) for a in range(0,401,20): setx(a) forward...
I'm logging data from an embedded platform over UART. This gets saved to a log file and I want to process the saved log with Excel. I have no idea whether what I did was even remotely a good solution. My VBA experience so far consists mainly of code only used once. However, since I'll have to use this for every measure...
Formally, a deterministic finite automaton is a 5-tuple \$M = (Q, \Sigma, \delta, q_0, F)\$, where \$Q\$ is the set of all possible states \$\Sigma\$ is the alphabet \$\delta \colon Q \times \Sigma \to Q\$ is the transition function \$q_0\$ is the starting state \$F\$ is the set of accepting states Basically, each DF...
Here is a puzzle: U2 has a concert that starts in 17 minutes and they must all cross a bridge to get there. All four men begin on the same side of the bridge. You must help them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either ...
Is there any smart way to compress the following code: def __total(self, x, y): count = 0 for x_offset in range(-1, 2): x_index = x + x_offset for y_offset in range(-1, 2): y_index = y + y_offset if 0 <= x_index < self.Size and 0 <= y_index < self.__Size: ...
Problem: Find all the pairs (a, b) whose product is equal to the sum of all numbers in the sequence [1..n] excluding both a and b. I have made code for one program and need refactoring for code to get execution in less time. I am currently getting 13 sec for 500 number range. def get_correct_array(n) beginning_time ...
Since the deprecation of C-style for loops in Swift 2.2 (and the removal in Swift 3), several questions about the possible replacements were asked on Stack Overflow. In most cases, a for .. in loop is the appropriate replacement: for i in 1 ... 5 { /* ... */ } for j in 10.stride(through: 0, by: -2) { /* ... */ } for el...
I just finished creating a fancy checkbox and am hoping for some tips to help improve my code, as I am still learning. $(document).ready(function(){ function checkbox(){ var y = $("#yon"); var n = $("#non"); var cx = $("#chex") var cbx = $("#checkbox"); var chval = false; $(".cspan").click(f...
I'm working on an experiment to parse speech out of an emote in a text roleplaying game (MUD) so that if you can't hear it correctly, or if it's in a different language, you won't understand it. This works correctly, but I was just wanting to make sure it was as clear and efficient as possible. import java.util.Scanner...
I am writing Rijndael for academic purpose, following wikipedia's description. https://en.wikipedia.org/wiki/Rijndael_key_schedule I would like to know, if up to this point it is correct, both from pragmatic programmer and strict cryptographer views. class KeyExpander { private static final int COLUMN_SIZE = 4 ...
The input is read in line by line from stdin. Input Format The first line contains an integer, T, denoting the number of test cases. The subsequent lines describe T test cases, and the input for each test case is as follows: The first line contains an integer, N, the number of (x,y) pairs in the test case. The ...
I would like to get some advice on WAI-ARIA markup I have added to my paginated post navigation. Does this look correct, am I missing anything? Should anything be added/removed to the current page link (#2)? Also, curious on my "Page Count" and "View All" sections what if anything can be added to make it more ARIA-fr...
Sometimes we need to map a .NET type to some custom nice looking text and resolve it back to the type latter. We could use it while implementing polymorphic behaviors in JSON API, or persisting/rehydrating class hierarchy. Sometimes we need something more complex than 1:1 mapping. Let's say that we backed up part of ou...
I'm working on writing tests for a rails application using cucumber and capybara. I have a scenario for a user editing a post, and making it invalid. The scenario looks like this: Scenario: I edit a post and make the data invalid. Given I have 1 post And I view my 1st post Then I click "Edit" And I fill in the ...
I'm writing a Direct2D game in c++ / WinAPI. I need to render things 60 times every a second using fixed time step. __int64 time_before = 0; __int64 time_now; __int64 frequency; __int64 time_elapsed; double frameTime; if (QueryPerformanceFrequency((LARGE_INTEGER*)&frequency)) { frameTime = (double)frequency / 60; ...
I have made my first game in Python. My program can determine when there is a winner, however I am unsure what to do if the board is full and there is NO winner (a cats game). import cTurtle import random import sys def DrawTicTacToeBoard(t): #Vertical Lines of board t.pensize(3) t.up() t.goto(.5,-.5) ...
I am solving a coding challenge whose objective is to print the right diagonal of a matrix. And below is my code to do that. package basics; import java.util.*; /** Problem statement : Print right diagonal of a matrix. Example: For input : a b, c d ; the right diagonal is b c **/ public class PrintRightDiagonal{ p...
I am writing a Tetris program in C# for programming practice, and I've got it working. This will be the first post in a multi-part series. Future posts will cover the TetrisBoard (the game logic), the WinForm, the AI, and maybe a graphical board and sounds that I will code later. Design Some design decisions worth ment...
I have one class Number (base class) and two child class Fraction and Integer. I am suppose to provide the functionality to add and compare two Integer obj, two Fraction obj, One Integer One Fraction obj by operator overloading. Below is what I have come up with. Can someone kindly review it. I am trying to avoid memor...
Here is problem to be solved TradingAlgorithm employs a trading algorithm which, based on the prices it receives, will return a trade to execute. The trading algorithm must implement the following interface: public interface TradingAlgorithm { Trade buildTrades(Price price); } A Price is made up of a p...
I used to write a bit of BASIC years ago, and recently found an old book called "Fun Mathematics on your Microcomputer" with some mathematical games in. I'm learning Python and have tried to implement one of the games, called "Treasure Hunt," which I played as a kid on a ZX81(!). This is the first project for me where ...
Here is my approach. Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. import java.io.InputStreamReader; import java.util.Scanner; public class Query { public static void main(String[] args) { Scanner scanner = new...
isPalindrome :: Integer -> Bool isPalindrome n = reverse x == x where x = show n is3x3 :: Integer -> Bool is3x3 n = any (\x -> cond1 x && cond2 x) [101..999] where cond1 x = n `mod` x == 0 cond2 x = length (show $ n `div` x) == 3 main = print $ head [p | p <- [999^2,999^2-1..], isPalindrome p...
I'm working on updating a GitHub project that I use at work, but I think the person abandoned the project as there is a pull request for it since 2014. At work we use a Repository pattern with NHibernate and mappings and so forth but this project they use Entity 4.? I had to update the project to use .Net 4.6.1, and be...
I need help to enhance the performance of java source code. The code take txt file that has name, amount and date in form (name) (amount) (date yyyy-mm-dd) separated by spaces. After reading the file the data will be (name) (amount) (date dd/MM/yyyy). public static void main(String[] args) throws IOException { ...
I decided to play around with doing my own super-basic animation. For a previous Javascript project, I needed the ability to flash an element. The code below is the result of me attempting to generalize the main animation loop function, and learn Typescript at the same time. What I'm looking for suggestions on: The na...
I started learning C# and this is my first "project". Its main purpose is to calculate the equivalent value of two resistors or capacitors connected in either series or parallel. I just finished it and was wondering if you could review it for me. I'm open to learning what's bad, what's good (if it even has any in it) a...
I'm making a photo marker application and need to make a factory pattern for marker. I think it is not very flexible and overall not good. Would you check my code and suggest what could be improved? import Foundation enum MarkerType: String { case Shape, Image } enum MarkerError: ErrorType { case ImageNoExis...
I am making a GIF editor in C#, and I am currently working on the eraser tool. I am not sure what I can do to make it more efficient, because when I make the thickness (diameter) more than 30 (pixels) it starts to get a bit slow. if (click && eraserSelected) { new Thread(() => { ...
I'm working on a simple dice roller for a Python IRC bot. The particular game this roller is for uses six different kinds of dice, which I've defined using a simple base class, and created six instances of it, passing a string array with the possible values of each dice. class DiceBag(object): def __init__(self, di...
I decided to start working on the Euler project exercises. I'm doing fine for now but the seventh problem is running quite slow and I can't think of anything to make it work faster. It takes around 1300-1500 ms to finish which doesn't satisfy me while I know it can be done in maybe 20-30 milliseconds. int index = 1; Li...
A simple algorithm that can be run by two processes to ensure mutual exclusion for one resource.Shared variables are created and initialized before either process starts. The shared variables flag[0] and flag[1] are initialized to FALSE because neither process is yet interested in the critical section. The shared varia...
I am writing a Tetris program in C# for programming practice, and I've got it working. This is the second post in a multi-part series. My previous post covered the TetrisPiece. You can view the TetrisPiece code and critique here. Future posts may cover the WinForm, the AI, and maybe a graphical board and sounds that I ...
I have been programming for a long time, but nobody has given me any feedback if my code is good or not. Please review it, and give me feedback where I could be better. The source code is also on GitHub. GameEngine.java: package com.marcellelek.sudoku; import com.marcellelek.sudoku.view.sudokugrid.GameGrid; import an...
I needed to do transformations on a data stream, not on an element-by-element basis, but on subsequences. This is what I've come up with: https://github.com/peterjoel/rust-iter-replace/blob/master/src/lib.rs I am relatively new to Rust, and would love some feedback on any areas of the code: style, design, memory/perfor...
I have made this small quiz with 10 question and 40 JRadioButtons. One question and 4 JRadionButtons for each panel. So I had to create an array of JRadioButtons and JPanels, and for all I need to call setText. Can this project be done with only four JRadioButtons, so when someone clicks on next question, the radio but...
Question Link to the exercise : https://projecteuler.net/problem=11 I'm currently working on the Project Euler exercise's and I just finished the eleven exercise. It's working fast enough it takes around 15-25 ms to calculate the output, the volume of the code is probably bigger than it should be.I barely used any math...
I'm building a Django (1.8.12) application that parses a .bc3 file (Standard Interchange Format for Databases of Construction and Real State) and loads all the data into the database (PostgreSQL 9.3.9). A .bc3 file looks like this, and a common one has more than 2000 concepts (those records that start with ~C). To sum ...
I am writing a 2D game engine library that I can use for simple future games, and I've been told that it is written very procedural rather than objected oriented. I was wondering what I should do to fix this, or how other game engines are usually written. My engine is very laggy, and I think this is why. Here is the ma...
Please review my balanced parenthesis string checker code below. I would love to know how to improve my algorithm and if you have any other feedback. // comments inline function validateParenthesisString(inputString){ if(inputString.length === 0){ // empty string is as good as a valid string console.log('Strin...
I wrote a Python script that, given a literary work in text file format, takes it apart, makes a word list, counts how many times each words appears in the literary work, and then checks if it follows Zipf's Law by performing the chi-square test. For those of you who don't know Zipf's Law, put simply, it is a law that ...
Please review my Secret Santa random pair allocator written in JavaScript. Random pairs will be generated every time you run the code. Input data is hardcoded for now (line # 41). I would love to know if you have any suggestions on improving the algorithm or any other feedback that you might have. function getSecretS...
I have two these methods. Their loops are pretty similar. I'd like to refactor it to avoid duplicate nested loops. How could I do that? @Override public boolean isValid() { for (final FormSection formSection : getFormSections()) { for (final Component fieldComponent : formSection) { boolean isFi...
I wrote the code to fetch the JSON Data. For that I tried to do this in 2 projects. First Laravel project which has API code for database interaction only. Sample code in API controller class CountryAPI extends Controller { public function AllCountries() { return response()->json(['CountryList' => \App...
I have written a small Python function to extract version info from a string. Input is of format: v{Major}.{Minor}[b{beta-num}] Eg: v1.1, v1.10b100, v1.100b01 Goal is to extract Major, Minor and beta numbers. import re def VersionInfo(x): reg = re.compile('^v([0-9]+)([.])([0-9]+)(b)?([0-9]+)?$') return reg.fi...
We have about 14G files and each is about 150k. I'm writing a script to upload them to Azure Blob storage and would like to run an upload() function (each with own file to upload) in 5 threads. Here is how I realized it and it looks like it works - but I still have doubts about how correct this code is. ... class Loade...
Would this be secure enough to hash passwords? /** * Creates a SHA-256 hash * @param string $salt Salt for hashing algorithm * @param string $string What is getting hashed * @return string Returns a hashed string */ public function hash ($string, $salt) { $crypt = crypt($string, '$5$rounds=5000$' . $salt . ...
Method.create(domain_id: domain.id, type_notification: type, message: title, url: url, owner_id: self.user.id) How can I reduce this line to 80 ?
The following code has begun to smell, but I have not yet decided with what to replace it, other than, obviously, a database. I made a very unsatisfactory workaround for my attempt to make relationships among tuple members as I assigned them. How can I modify a piece of code like this that contains some hostnames or a ...
We have a requirement for a script which polls an SQL database for scrape commands which need to be run. These commands are added to the SQL database on an ad-hoc basis. The scrape commands themselves are in the form of psexec commands, and need to be run by the listener script which is constantly polling the database ...
Just for fun I tried to write a chess game in Haskell, in the hope that it would eventually be good enough to beat me. It's not perfect at the rules (it doesn't know about promotion, castling or en-passant yet) but it does manage to make legal moves, and they're not always totally stupid. I've tried to make the code ne...
Here is a code file (I use it as a stand alone header file to be included in my projects) that contains macros to generate ANSI encoded strings that when printed are colorized. Also, the module contains useful string functions that are found in PHP standard library: strpos, stripos and substring functions: substr, sub...
What could I do better in my code or logic? Wikipedia Search $(function(){ $('.search-input').keyup(function(data){ var pesquisar = $('.search-input').val(); $('.box-logo').fadeOut(500, function(){ $('header').css('padding','12px 0'); }); $.getJSON('https://en.wikipedia.org/w/api.php?format=json&actio...
I made a simple text-based UNO game in Java. It lacks some features of the original game, but it's good enough for now. I'm new to Java, so I would like to receive as much feedback and suggestions as I can on my code. The Unocard class: import java.util.Random; public class Unocard { public String color; publi...
This is in ASP.NET MVC, but that shouldn't make a difference. I have a large number of rows in my database for Songs. var songIndex = Context.Songs.ToList().FindIndex(x => x.Id == 500); var songs = Context.Songs.OrderBy(x => x.Id).Skip(songIndex).Take(10); However, the ToList() and OrderBy seem pretty heavy just to ta...
I decided to learn JavaScript and what better way than wrestling with a Sudoku solver. I'm guessing there are (many?) optimizations that I missed. I'm thinking of adding a generator also, but this for another time. Thoughts? <!DOCTYPE html> <head> <title></title> </head> <body> <form action="" method="post" acc...
I am using this code in an MVC application to manage objects that should only have one instance per request. /// <summary> /// Manage all the resources that we want to scope to a single HTTP request. /// </summary> /// <remarks> /// This class should not be directly referenced in many places. /// In general, infrastruc...
I'm arguing here with a colleague over two implementations of how to handle a processing logic: VERSION 1: public class SomeManager { private readonly Dictionary<Type, Action<IData>> dataHandlers; public SomeManager() { dataHandlers = new Dictionary<Type, Action<IData>> { {typeof(DataTypeO...
This is a correct version, for computing a small matrix multiplication: C += A * B, where C is 12 * 4 in non-transpose setting, A is 12 * k in non-transpose setting and B is k * 4 in transpose setting. Computation is scheduled k number of matrix rank-1 update. 12 and 4 are choose to best use available register file. On...
This is my code that interprets my own golfing and esoteric language, Fuzzy-Octo-Guacamole. It has 2 stacks to store information in, and various operations can be performed on each stack, or both at once. This is also my first real project using classes, so any advice on how I did would be much appreciated. #!/usr/bin/...
I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one. I already have this working solution for my problem, but it seems a bit too much code for me so maybe you have a better idea :) HashMap<T, Integer> s...
how to make this algorithm to display palindrome that was done with fewer permutations ? #include <bits/stdc++.h> using namespace std; #define M 26 bool isPalin(string str, int* freq) { memset(freq, 0, M * sizeof(int)); int l = str.length(); for (int i = 0; i < l; i++) ...
My question has to do with : (a) Can this be made more secure? (b) Are there best practices in relation to setting timezone? (c) What best approach should be taken defining use of utf8? $my_success = 0; $my_message = ''; $my_id = 0; try { # declare & set variabl...
Recenlty I have finished this primitive console string calculator in C. I need your balanced criticism, I'd like to know what I have to correct, remake and learn. Permitted operations: + - * / ( ) ^ Sample input string: 11 * -10 + 15 - 35 / (35 - 11) + 2^2 = main.c #include "stack.h" #include <stdio.h> #include "calc...
Requirement Validate two inputs (from and to). Input can be either Number or String (value hast to be date in UTC format) "from" and "to" both cannot be empty or null but one of them can be empty or null. Pre condition : Use only Java 7 My simplest validation logic. Please let me know if I can optimize this code. Ig...
I'm working on figuring out what the current 'business' day of the month it is. For instance, if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month. Is there a better way of doing this? var first = DateTime.Today.FirstDayOfMonth(); var businessDayOfMonth = 0; for (var i = first; i <...
I've been to C++ lessons a long time ago and now I want to create a simple console program for switching Steam accounts. Please help me analyze my code and find my mistakes or better ways of doing something. Main #include "stdafx.h" #include "functions.h" using namespace std; bool getNumberOrQuit(int &num, const int ...
I have the following controller with a couple of database queries and I'd like you to review it. I've tried to make it clean for other developers but the communication with the database can be improved (more effective). The exception returned when nothing is found, so I'm not sure if it's the best way to do it. public...
This code basically allows you to provide a collection and a lambda and have the lambda operate on each value iterated even allowing modification of the data if you wish. I would like to be able to reduce the calling of my template advfind to something more concise along the lines of what I could do if I used std::find...
I have the following code which produces successive generations of Conway's Game of Life: life =: 3 : '+./ (>(($ y) $ 1);y) *. > =&(+/ (>,{ ;~(1 0 _1))|. y) each 3 4' Usage: RR =: 5 7 $ 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 NB. First five gens of RR life^:(i.5) RR NB. in ASCII ' *' {~...
This is my first time using password_hash and password_verify in PHP. Would this be the correct usage of password_hash and password_verify to log the user into the site? Is there anything I could do to make this function more secure? /** * Initiates User Login * @param mixed $data Post data * @return mixed Checks i...
Here are a few questions on my mind: What improvements to the above code can you think of? I want to say new UnionFind(x) where x is a Set[T] (I emphatically don't want to say new UnionFind(x.toList). Is Traversable[T] (and .toList inside the UnionFind) the right choice for that? Note that the union method requires an...