instruction
stringlengths
71
71.9k
I have a solution but it fails the performance for two tests. How can I speed it up? def palindrome?(str) str.reverse == str end def parse(str) return -1 if palindrome?(str) str.length.times do |i| before = str[0...i] after = str[i+1...str.length] return i if palindrome?(before + after) end end t...
I speedily wrote a bunch of crappy checks, to check whether strings are empty, in order to build a query string. StringBuilder SB = new StringBuilder(); SB.AppendFormat("{0}guide/search.aspx?", root); root is a const, containing the website address. It's like this because we have test servers. if (!String.IsNullOrEmp...
ReSharper has a very handy feature that's particularly useful when coding against abstractions. Since coding against abstractions is something that can also be done in VBA, the next release of rubberduck is going to include that functionality as well: The click handler for the code pane context menu simply calls the ...
I've developed my shopping cart further. This is related to my earlier post: Securing PHP shopping cart In addition to those functionalities, I've proceeded to make integration to Paytrail payment gateway. This post will add option to handle customer's personal data and to send that data to payment gateway. All credit ...
This is a little net health monitoring project I made in NodeJS. It pings Google every second and stores the result (true/false) along with the date in a database (MongoDB). I've collected enough data and I want to represent it for the past week. I created a 2x2 array of 7 days and 24 hours each. I go through each reco...
What about the following meta-predicate "fixed point"? fixedpoint(P_2,X0,X) :- call(P_2,X0,X1), if_(X0 = X1, X = X0, fixedpoint(P_2,X1,X)). fixedpointlist(P_2,X0,[X0|Xs]) :- call(P_2,X0,X1), if_(X0 = X1, Xs = [], fixedpointlist(P_2,X1,Xs)). The implementation is based, in part, on if_/3 and reified term e...
I am implementing my own UnitOfWork for an EntityFramework-DataContext. I want to call SaveChangesAsync and when this succeeds, clear a list. Is my approach with ContinueWith correct? public async Task<int> CommitAsync(int? commandTimeout = null, bool ignoreCustomLogic = false) { try { return await Dat...
This code gets request status based on request type and some mapping info. I'm wondering if there is a way to write nice conditional expressions in if statement. Expression should test if request.IsInvalid property equals null or false. It'd be nice that one can see just from looking at the expression that request.IsIn...
I need to pass a programming exam in order to graduate but I'm having a hard time passing it because most of my programs are too slow. Can someone give me some tips on how to make my programs faster please? Below is an example of a question we had in the last exam and the code i wrote. My code passed the first test cas...
I have a program that will get all possible permutations of a certain equation: A + 13 * B / C + D + 12 * E - F - 11 + G * H / I - 10 == 66 Where A, B....I is a value 1-9, and where each digit is used only once in the equation (So if A is 1, no other variable can be 1). There are 136 different solutions for this. usi...
I am dealing with a huge time taking with primes. I hope you know they are pretty random and that's why create many problem. Both are using the same logic/methods. /* * The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all * the primes below two million. * http://projecteuler.net/problem=10 */ ...
I'm developing a JavaSE-1.7 Swing application that displays XML files as a JTree. This will be the base for further work, e.g. filtering nodes. My questions, as a beginner in Java & Swing & MVC: Design: How would you refactor this into Model/View/Controller? (Doing the doc/tree model stuff inside of the GUI thread isn...
I am always surprised by JavaScript and how simple and elegant JS code can look. I have a piece of code below that simulates a finance calculator. Please share your thoughts, critiques/feedback on how the code can be improved. jsFiddle The calculation is just a simulation, so please ignore. Also please ignore the way I...
By profiling my application, I found that the bottleneck of my application is the function below. In particular it will be executed by a lot of entities (monsters) in a game, that will go onto a smartphone. The graph is the model for this type of grid: (the final one is 25x45) Also, each cell has an array of 4 pointer...
I was building a rails web, and used form object to separate the validation logics per form. I had to find_referral_code twice in order to store the user_id of referrer. I wonder how I can improve it. after_sign_up_form.rb def get_referred_by_id User.where(referral_code: referer_referral_code).first.id end def va...
I have a JSON file: { 'Document':[ [{'fields': {'name': 'js/main.js', 'content': 'hello'}, 'pk': 284, 'model': 'Document'}], [{'fields': {'name': 'css/main.css', 'content': '2'}, 'pk': 287, 'model': 'Document'}], [{'fields': {'name': 'about_us.html', 'content': 'again hello'}, 'pk': 306, 'model': 'Document'}]], 'Pa...
I have this example data : var objects = [ { title: "Parent Area", code: "P", areas: "B,C", child: [], selected: 0, remove: 0 }, { ...
When I want to try a new language, I first try to write a fairly basic sieve of Eratosthenes project in said language. This is a very simple algorithm, with predictable results, and can even be optimized somewhat to compare versions of different languages' compilers. I've done this in (chronological order) python, ru...
I wrote a PHP connector that will allow me to communicate with a REST API. This is the first time I am trying to make my code as clean as possible. I want to help myself learning how to better code. I have done everything I can think of to make my code clean and easy to read, but I would like to get feedback from the e...
/* * The following iterative sequence is defined for the set of positive * integers: * * n -> n/2 (n is even) n -> 3n + 1 (n is odd) * * Using the rule above and starting with 13, we generate the following * sequence: * * 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 It can be seen that * this sequen...
I'm new to Perl and have successfully written a merge sort program. I'll paste the entire program below, but would like mostly a review of the subroutines mergeSort() and merge(). I tried to use pass-by-reference as much as possible to make as it as fast as possible. Is there ways I can make this better/more optimi...
I have several tabbed views with a Unity scene in them. What I do between scene is hide the elements in that scene, then render them if the right view is shown. The method below is the method that renders all the lines previously drawn in my view. The lines can be lines, angles, points, etc.. private void RenderLine...
I am trying to make an inputin() function to take all the parameters input for the first time with exception and for individual parameter for the runtime proposition. I am thus looking forward to reducing code size or being a more efficient coder with more pythonic procedures. ""This code is well executed and tested fo...
I have a string like this : val content = "some_text{macro1}another_text{macro2}text" I want to replace the {macro1} and {macro2} with macro1 and macro2, i.e. just to remove the { and }. I wrote some piece of code which works fine, but for me it seems very hard to read: val Pattern = """\{(.*)\}""".r Pattern.findAl...
I've been working at speeding up my web scraping with the asyncio library. I have a working solution, but am unsure as to how pythonic it is or if I am properly using the library. Any input would be appreciated. import aiohttp import asyncio import requests from lxml import etree @asyncio.coroutine def get(*args, **k...
Is there any improvement possible in this implementation? #include<iostream> int search( int array[], int N, int key ) { int first_index = 0; int last_index = N - 1; while ( last_index >= first_index ) { int middle_index = last_index + first_index / 2; if( array[ middle_index ] == key...
My last question had a lot of views (over a 1000) so I decided to apply what I learned from the previous question and revamp the program. I learnt a lot from posting that question (functions, how to do a menu without using using a lot of printf and learning to not repeat code etc). So here's the updated program: #inclu...
I've written a simple script, that takes a 0, 0 style co-ordinate input, following the pattern of: $$0 \le n \le 9$$ Tacked onto the end of the output program, is a simple script that runs through all iterations of 0,0 - 9, 9. Below is a gif of that. Note: This code DOES not map multiple, I am not asking how you can m...
A string is said to be complete if it contains all the characters from a to z. Given a string, check if it complete or not. Input First line of the input contains the number of strings N. It is followed by N lines each contains a single string. Output For each test case print "YES" if the string is complete, else ...
I've recently started switching from JQuery to Angular and it's awesome at making my HTML expressive and easy to read but every reusable module I make has its own script which leads to a massive script loading area. I suppose I could closure compile them or something but is there a better way? <!DOCTYPE html> <html> <h...
I'm mostly curious if there's a faster or more efficient algorithm I could use. I created this for a unique side project, as well as for an issue at work, so what the function does (e.g., return a negative int) isn't what I'm focused on. In short, can I make this faster or more efficient? // GetBufferLength returns the...
There was a suggestion in this StackOverflow question to move this question here. I added some more information and restructured the question a bit. I'm trying to parse the following file which contains information in the following format: TABLE_NAME VARIABLE_LIST_OF_COLUMNS VARIABLE_NUMBER_OF_ROWS (Seperated by a ...
I have an if else statement like this deciding the pattern to be followed based on type or department of employee. The if else block goes like this. I am planning to simplify the if else block to a better format. public static Pattern decidePattern(Employee employee) { try { if ("individual".equals...
I have a group of four inputs, the first three are required, the fourth is optional. $fieldA $fieldB $fieldC $fieldD #Optional So to validate the inputs, I just use this: if($fieldA === '' || $fieldB === '' || $fieldC === '') { #error } That works pretty well, except there is a special case: If all four inputs ar...
I've used encountered this exercise from a tutorial: Create a function that takes a string as a parameter and returns True if the initial word of the string passed is an article (“The”, “A”, “An”) and returns False if it isn't an article. Be careful, if the string starts with “There”, it does not start with an article...
Please give feedback on all aspects of the code, whether it be the commenting, usage of methods, semantics or anything that can be improved. This code looks flawless to me, so any suggestions for improvements will make a difference. // Imports packages for AWT, Events, Scanner, File, PrintWriter, // exceptions and S...
I am trying to create a Sudoku game in F# and I'm having a bit of trouble with the file reading and writing. But since I've also just started programming in f# I would like to check if my thinking is truly functional or if it have any obvious flaws. The Sudoku game is made up of 5 parts, Logic.fs with the game board: l...
Beginner here, trying to make a small program that sorts three numbers from smallest to largest only by using ifs. Any thoughts on how to improve this? #include <iostream> using namespace std; int main () { int num1, num2, num3; int smallest, middle, biggest; cin >> num1 >> num2 >> num3; cout << endl;...
This PHP class connects to and queries the database MuSKL. I am a novice, and I ask you to comment on the approach and style of code. <?php class MysqlAccess { private $dsn = 'mysql:dbname=bid;host=127.0.0.1'; private $user = 'bid_root'; private $password = 'e1e2e3e4e5er'; private static $_db; pr...
I have managed to get this to work but I am sure there is a better/more polished way to write this can anyone guide me to some shortcuts? https://jsfiddle.net/zrpgvoL7/4 /* move the products down in the categories for the opening of filters/sort by aswell as slide down the filters or sort by sections */ var filterHeig...
I am working on some coursework for a simple Java EE web application that records blog comments. On the add comment page there are two fields: name and comments I am using a RequestDispatcher to pass control to an acknowledgement.jsp if the fields are not empty, and an error.jsp if one (or both) are empty passing a rel...
I have a method for generating a report in Python. I want to organize the section about the date into a separate method so I can repeat the report for different dates. What's the best way to organize this? Should I create a method using just *args or **kwargs where I can dump in all the various dicts...etc.? Does it...
I need to intercept a URL and go outside the WebView if the URL contains MAPS or DOCUMENTS constants. I must also go outside if url does not contain the value of DOMAIN and LOGIN_SALES_FORCE. This is working nice, but seems ugly for me. Any ideas? if ([request.URL.absoluteString rangeOfString:MAPS ].location != NS...
I am going through some PHP array exercises on w3resource because I want to get to grips with all the different functions PHP offers for arrays. I have just done this one: Write a PHP script to sort the following associative array : array("Sophia"=>"31","Jacob"=>"41","William"=>"39","Ramesh"=>"40") in a) ascending o...
I need to create a JavaScript Promise that will not resolve until a specific HTML element is loaded on the page. I don't have any way of knowing when this element will be loaded, other than to simply poll the DOM for it. It seems there should be a more concise way to accomplish this task. I don't want anything that's ...
I'm trying to solve one simple task and on first look it's working. Any advice on how I can optimize this code will be appreciated. A quick description of the task would be: You have a file from which you read the integers. The first line has two values: The array width The number of test cases The second line has ac...
I am writing a program that will take a binary bar code and convert it to a zip-code. I need to validate the bar code. A valid binary bar code contains no more and no less than two 1s in any position per five digits. This is what I have for the validation part so far and would like simplify this code. #include <iostrea...
I have an assignment for my Java programming class that is kind of an expanded FizzBuzz-like question: Write a program that iterates through numbers from 0 to 113 using a loop. Print the numbers, one number per line. As you print each number, say x, also print the following when appropriate, separated by commas: ...
I am going though some PHP arrays exercises on w3resource. I have just completed the following: Write a PHP script to calculate and display average temperature, five lowest and highest temperatures. Recorded temperatures : 78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 75, 76, 73, 68, 62, 73, 72, 65, 74, 62, 62, 65...
For asynchronous requests, I use Alamofire. I have created one method for requesting async data. func requestData(method: Method, urlString: String, onSuccess: (AnyObject) -> Void , onFailure: (NSError) -> Void, sender: UIViewController, postParams:AnyObject? = nil) { let AFmanager = Manager(configuration: seesio...
Today I tried to code up a generic graph abstract data type in C++. Precisely, I implemented the adjacency list data structure for a generic graph type. I think it seems to work with different type according to the test cases I have tried :). Through this post I would like to know what kinds of optimizations can I make...
I am writing a jQuery plugin which, among other things, inserts a stylesheet in the head. Additionally, I also require vendor prefixes. A lot of values are derived from variables in the script, and I'm unsure how I can write this in a maintainable manner. Now I just list everything, but maybe there's a better way for v...
What I'm trying to do is bind the controls generated by a ItemsControl.ItemTemplate to a new instance of my ContactInterface class that is created whenever I run my query function. ContactInterface.cs class ContactInterface : INotifyPropertyChanged { public string Type { get; set; } private string firstname; ...
I'm working on a programming assignment which simulates network traffic between two hosts. My task is to implement the transport layer, the code for the other layers, GUI etc. is already provided. I have managed to do this and the code works according to the specifications listed below. My concern is that the code feel...
My goal was to replicate Ruby's each_cons and each_slice: (0..5).each_cons(3) {|a, b, c| print a, b, c, "\n"} 012 123 234 345 I made two functions, for_each_cons, and for_each_slice. They work similarly to their Ruby counterparts, except the slice is always passed to separate arguments. The slice size is deducted from...
This is a fun little program I made of a fruit machine gambler, aka "slot machine". What mistakes am I making? How can I make this better OOP programming, less spaghetti? var spin = false; var value1, value2, value3, value4; var holdFirst, holdSecond, holdThird, holdForth = false; var first, second, third, forth; ...
This is a program I wrote in Python using the BeautifulSoup library. The program scrapes YouTube search results for a given query and extracts data from the channels returned in the search results. I'm just looking for some tips on how to make my code look (and function) better. I removed most of the redundancies but ...
This is a simple User class that I'm using throughout the application for anything related to the users. To tell if a user is logged in or not, I check the presence of the userID in the $_SESSION. When I'm logging in the user, I simply set the $_SESSION["userID"] equal to the ID of the user. class User{ protected $pdo...
I solved the Girlfriend's Demand challenge on HackerEarth. In summary: Input: First line of the input contains a string S. Next line contains an integer Q, the number of queries. Each of the next Q lines contains a test case consisting of 2 integers, a and b. Output: If S is repeated infinitely, would string positio...
Using the async and child_process modules, I can create true "parallel" processing. My question is, how can I ensure that it is running on multiple cores? var cp = require('child_process'); var async = require('async'); async.parallel([ function(callback){ console.log('1'); var k = cp.fork('./doOt...
I am building a list of Python objects that I use fairly regularly that have a length property, (len, 'len') and I was trying to determine the best way to simplify the type/class formatter that the object uses. For example: type([]), returns "< type 'list'>" and type(collections.Counter()) returns "< class 'collectio...
This is my first time implementing a merge sort (just getting started with algorithms & data structures). Are there any obvious things I have done wrong? I am also worried that I have overused recursion, as both the merge & the sort function are recursive. function sort(array) { var len = array.length; var middle ...
Given a Integer, find the maximum number that can be formed from the digits. Input: 8754365 Output: 8765543 private static int largestNumber(int data) { int num = data; int[] times = new int[10]; while (num != 0) { if (num == 0) { break; } int val = num % 10; ...
I have a relatively long method, and I'm wondering: How readable is it? Is a method this long okay, or will it be bad later on? Note: This method enables users to select from a console menu - UpArrow and DownArrow change option, and LeftArrow and RightArrow change amount. Here is the method (from here): public st...
I am currently working in a Zend Framework 1 project. In the project we needed a sort of logging module, and Monolog was requested. Now since I'm quite a beginner with PHP, I'd like to know if I'm doing this right. I feel like I'm missing the whole prospect of Monolog: Custom Handler: <?php use Monolog\Logger; use Mon...
I've written a piece of code, where a pair of checkboxes and a textbox are generated N amount of times. Depending on what's in the DB, the checkbox/textbox may have a default value or are left empty. I've pasted the code below, could anyone take a look to see if I haven't created an abomination? <td> @if (singleIt...
The question - A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is ...
I have the following code, which draws a overlay image onto video for each frame: video.addEventListener( 'play', function() { var $this = this; // cache (function drawCurrentFrameToCanvas() { if ( ! $this.paused && ! $this.ended ) { drawImage(); requestAnimationFrame( drawCurr...
I'm learning about time structs. Without assigning either in code or input routines I want the current time. Please help me refactor this, if it should be. This code just tries to make a time struct with the current UTC time. How am I doing? // better_current_gmtime_struct_builder.c // compile with : // gcc -Wall -g b...
The application is a web application that consumes a REST service. Web config has the REST URL along with the parameters. REST URL and the values are passed as IDictionary and in Repository I convert the same as meaningful REST URL using BuildCompleteUri(). I use RestSharp to consume REST service. I am trying to learn...
The point of this method is to emulate Java hashCode(). In order for this to work the project must have arithmetic overflow allowed under: project --> compiler options --> advanced. Public Shared Function GetHashCodeStr(value As String) As Integer Dim finalCode As Integer = 0 For i As Integer =...
In the code below, noisy data points with unique errors are created. From this, an exponential function is fitted to the data points, and then doubling times (10 unit windows) are calculated. I'm uncertain how to show the unique errors in the data points in the fitted function or doubling times. Output: from scipy imp...
I made a GPL project to read Shogi Western Notations that I made public in GitHub. The project works perfectly on Ubuntu. Please check README.md to check requirements. All this code works quite well. The basic idea was fragmenting each notated move with a long regexp, which I think is the best way to optimize the proce...
I'm just going through some array exercises in PHP on w3resource. I have just completed: Sample array : $Color = array('A' => 'Blue', 'B' => 'Green', 'c' => 'Red'); Expected Output : Values are in lower case: Array ( [A] => blue [B] => green [c] => red ) Values are in upper case: Array ( [A] => BLUE [B] => GREEN [c] =...
I need to produce a list objCollector with some results: objCollector = [] allRows.each () -> obj = source: self.source url: '' host: '' currentTag = $(this) links = currentTag.find('a') getTextFromSpan = currentTag.find('span.lnk').text() ex...
I'm writing to some serial comm port with specific bytes set into buffer. My protocol for write buffer is written below. Platform is Windows and IDE is Visual C++. Byte 0 will have message type indicator (Byte) Byte 1-4 will have message number (Uint32) Byte 5-8 will have unix epoch time (Uint32) Byte 13-14 will have...
Today I made a clumsy update without WHERE. Yeah, I know. I have backups but I found a way to fix it without loosing anything. It implies a SELECT and a loop of 50.000 updates, not a fan of this approach. Maybe I can merge the SELECT and the UPDATE so it's only a big query, witch in my head seems like a better approach...
I present my solution for Project Euler problem 23 written in Python (2.7). The problem statement is: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a ...
I have a form with 11 inputs that relate to each column on a table, which is displayed above. Each input has an id that matches the a class in the table based on the column name. I want all the inputs to be droppable, the logic for all of them is identical to below. $(function() { $( "#dest_city" ).droppable({ dr...
Is there any way to improve the performance of local report or even an alternative if not? I have been looking for a solution for quite some time but the general consensus seems to be that it's just slow. public byte[] genReportBytes(int id, string fromm,string too,string filetype) { reportDetails repD = new report...
I am creating unit tests but the class uses objects that have long JSON. What can I do to improve the readability of this? In tests, only insert those JSON really needed for the test. The class I tested is responsible in turn that JSON in a modified spreadsheet (xlsx) and it seems difficult to maintain the code. @Test ...
I'm working on a client proxy for my WebAPI. I've looked at WebApiProxy but I feel DTOs are unnecessary in my scenario. I made an ApiProxyBase class that supports basic Get, Post, Put and Delete functionality using generics. Using this base class I've setup an implementation as follows: public sealed class MyProxy : Ap...
I am writing a (multi) filter that is created when the user enters in the data through wordpress. There can be anywhere between 2 - 10 filters so I need this to be as dynamic as possible. My first approach was to write out a boolean for each possible filter being created and check if it is there or not. Inside the bool...
I got tired of following Android-SQLite's transaction idiom, briefly documented here. It requires too much boilerplate code, IMHO, especially when you add the obligatory null checks. So I came up with this pattern, inspired by the Objective-C library FMDB: // Inside the class that manages the database interface Transa...
I've created a PHP script which take an array of filenames as a comma-separated parameter and concatenates them, serving them as one, single JavaScript file. I've also built a caching mechanism into it - each time, it checks if any of the individual JS files have been updated and, if one or more of them has, it updates...
I'm working on a singleton object to manage size changes in the viewport, I wanted it to be a singleton because there may be different unrelated objects that need to be notified when a change in viewport dimensions has occurred. So I came up with this solution based on the singleton design pattern found in here. var C...
I have recently been working on my first game with an isometric perspective. For those who don't know, an isometric perspective is a pseudo 3D view created from 2D tiles. I am working off of this tutorial about isometric graphics. I believe my approach is fairly clean and efficient. I have tried to do things in an ob...
I'm working on a tile-based game, and am looking to improve the efficiency of my code to slightly improve framerate. I call this method on every tile, every frame, so it is very performance critical. What optimizations can be made? public bool OnScreen(Vector2 point) { Rectangle rect = this.Rectangle; return (...
My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. import subprocess,time,threading, winsound, sys, basepipe commands = '' def alarm_checker(alarms): """This will be the main threaded process, and will be the meat of the program.""" global commands hours = [int(a.s...
This uses the Stack Exchange API to quickly batch replace tags in questions. I still need to fully comment and make the Wiki, but are there any glaring mistakes in it? I have tried to use try: except: wherever I can to prevent any errors, and have attempted to make it compatible for Python 2 and Python 3. # -*- coding:...
The point of this is to concatenate a vector of std::strings into one string starting at an index of the vector. std::string vectorSubstr(std::vector<std::string> vec, int startPos, char seperator) { std::stringstream ss; for (int i = startPos; i < vec.size(); i++) { if (i == startPos) { ...
I'm doing some exercises from another good website aimed at a similar problem - exercism.io, and my 1st C++ problem was to pass a certain test suite. Here is the README for relevant information: Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a quest...
Here is the code that I wrote to give me sum of prime numbers between n and m: class TestClass { final static int MAX=1000000; final static boolean[] isPrime=isPrime(); public static void main(String args[] ) throws Exception { BufferedReader keyboard= new BufferedReader(new InputStreamReader(System...
I have finished a really short and small import / export script using Python 2.7, and now I would like to structure it using classes and methods where possible. Could anybody give me some advice on what would be the best approach for this? I haven't used any OOP because I would also like somebody to give me some best p...
I recently put in a submission for a small coding challenge using Angular. The challenge was to get a token and array of values using a GET request then make another GET request passing the token and sum of values within the url. I'm still getting to grips with promises and want to know if the flow in the service and c...
To append data I am using parent() method five times in the code and I think it seems like an ugly way to do this. $("div.commentItem a.showReplies").on("click", function(){ var jqData = "i am so eE"; $(this).parent().parent().parent().parent().parent().find('div.commentItem span.repliesholder').append(jqData);...
I was assigned a task to fix the SQL injection flaw reported by a code analysis tool. I am not the original author of the code. I am fairly knowledgeable with SQL. public int ExecuteNonQuery(string query, SqlParameter[] parameters) { using (SqlCommand command = CreateCommand(query, parameters)) { i...
function RequestValidation() { $(".RequestTrigger").on("click", function () { var selectedButton = $(this); var arr = []; if ($(this).data('multiple') == true) { var ids = $('input:checkbox:checked.check-box').map(function () { var value = $(this).data('entityid...
I have written a small function to generate an array of page numbers for displaying a pagination. The inputs to the function is an active page number p, and the max page number. The function will return an array of 5 possible page numbers available near the active page. Example input, output: pages(1,10): [1,2,3,4,5] ...
I'm working through the Assembler assignment in the Nand2Tetris course (chapter 6). The suggested implementation contains 4 modules: Main, Parser, Code, SyntaxTree. Today I wanted to get some feedback on my implementation of the Code module. The book specifies a general API in order to allow students to use whichever ...