instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I'm programming a checkers game in typescript.
I'd like to explain some important details to understand how the following code works.
In my game coordinates are a string, like "b4".
I want to get the neighbors of a piece coordinates, but only the neighbors that make sense depending on the player and if the piece in the... | stackexchange/codereview |
In jQuery, I have been reluctant to create a better form validation, and I feel the time has come for me to do so.
With that said, I have been using this particular type of form validation, and I would like to simplify it.
$('#saveSubmit').on('click', function()
{
var criteria =
{
company: $('#company').val(),... | stackexchange/codereview |
Here's the API my teacher assigned:
and here is what I came up with:
class MyMap:
def __init__(self,size=10):
self.size = size
self.internal_list = [None] * size
def _getHash(string,size):
total = 0
for ch in string:
total += ord(ch)
total = total % size
... | stackexchange/codereview |
I'm new to programming. I wrote the following code in python. It's a cmd based address book.
import os
from reportlab.pdfgen import canvas
from cryptography.fernet import Fernet
p_d_D = {}
d_D = {}
dd = {}
file_path = os.path.join(os.path.expanduser('~'), 'Desktop', str(os.path.basename(__file__)) + '__database.txt') ... | stackexchange/codereview |
I have implemented a piece table in Swift, based on a Javascript implementation. I don't have much experience with Swift yet, so I'm especially interested if I'm doing things "the Swift way". Any feedback is highly appreciated.
import Foundation
public class PieceTable {
private let original: String
private va... | stackexchange/codereview |
Hello I'm currently developing a FPS game for my portfolio and I made a weapon shoot system, and I would like to receive feedback about my code to make more cleaner and efficient. Thanks.
using UnityEngine;
[RequireComponent(typeof(PlayerGunController))]
public class PlayerGunShootManager : MonoBehaviour
{
priva... | stackexchange/codereview |
I am getting a segmentation fault on the below snippet, only when I go above a text file in the range of 80-100kb. It will read smaller files of text but otherwise segmentation 11.
int main(int argc, char* argv[])
{
FILE* file;
if (argc != 2 || (file = fopen(argv[1], "r")) == NULL) {
printf("Invalid com... | stackexchange/codereview |
I just did CodeChief's candy splitting task here and my code is working even with a lot of test cases and big numbers, but it uses way too much memory. When I checked my submission, it was 1342M, which is a lot.
import java.util.ArrayList;
import java.util.Scanner;
class Candies {
public static void main(String[] arg... | stackexchange/codereview |
Nowadays there are many malware which is a batch file (.bat) or batch file is directly or indirectly helps to download, execute malicious process/executable etc here is a single header and source implementation which checks and informs whether the batch file is safe to execute or not.
Here is the header implementation:... | stackexchange/codereview |
In my project I have an async method AnAsynWebServiceCallHere for calling a web service. I want to call AnAsynWebServiceCallHere twice in parallel and at the end I want to return the combined result. Will at the end of this method
public async Task<List<DesiredResult>> GetMyDesiredData(MyParamDTO dto)
{
List<DesiredR... | stackexchange/codereview |
I wrote this simple scoped thread to use it as a class member to ensure the the thread running on a class method doesn't continue running after the class has been destructed. Also to spawn threads from the main() function to ensure that I don't forget any running threads upon exit .
This can be achieved by calling joi... | stackexchange/codereview |
I'm trying to create a 2 way communication socket in python. The socket will listen for connections from the client until it gets the data formatted in string like this: 'PHONENUMBER|STATUS'. I will need to split that and convert it to json which will be sent via http request to a web api. When the api receives, it wil... | stackexchange/codereview |
Any suggestions are welcome.
package je3.io;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IDEA on 31/01/15.
*/
public class DirWalker {
private List<File> recursiveList = new ArrayList<File>();
public void walkDir(String pathname) {
File d = new File(path... | stackexchange/codereview |
I am making a website that takes a bunch of dining hall information and puts it all together in a neater (and hopefully more mobile friendly) form.
Here is the link:
https://googledrive.com/host/0By7Z_HHj2VhnWmlhbWl4aF8xdFU/nuEats.html
It's a little incomplete at the moment, but what it does is the bar up top shows yo... | stackexchange/codereview |
This was my code challenge for a Junior JavaScript Developer position.
The app is mostly running error-free, but I was rejected for the role, so I assume there were major issues with my code and have no idea what they were.
I know this is a long piece of code, but as it already runs, I'm not asking for a fix - more f... | stackexchange/codereview |
I found myself in need of a fixed size queue and decided to implement one using a ring (cyclic) buffer.
I have tried my best to match the API of std::queue with the addition of full() to test if the queue is full and unable to accept another element.
The code compiles cleanly with: -Wall -Wextra -pedantic --std=c++14 ... | stackexchange/codereview |
Explanation
I'm trying to get better unit test coverage of my server.
I needed to mock out some system libraries (I could not find anything that worked easily for C++).
Because I did not want to do this ad-hoc, I added some automated tools to my build scripts that do all the work.
In the test directory I have a Mock.de... | stackexchange/codereview |
Please can someone confirm if this code is the best way to build the following tree
0
/ \
1 1
/ \ / \
3 8 4 7
class Node():
def __init__(self, value, right = None, left= None):
self.value = value
self.right = right
self.left = left
... | stackexchange/codereview |
I did this code for somebody but need it to be double checked before I pass it onto them. Code seems fine but I need someone to confirm I have coded the crossover methods correctly.
Would be great if somebody that is familiar with genetic algorithms and crossover methods, could confirm that I have the correct logic and... | stackexchange/codereview |
I currently have an Android Activity that allows the users to select the startDate, endDate, startTime and endTime. Once they click the "submit" button, I will combine the startDate and startTime together, and then convert it to milliseconds. The milliseconds will then be used to set an alarm using the AlarmManager. So... | stackexchange/codereview |
Today I wrote a JavaScript module (with module pattern) which generate gradient texts using canvas tags. This is my first JavaScript "program" (I don't know how to call it) created for a real need.
I would like to receive opinions about:
The performance factor: Is creating canvas slow? Or is it acceptable?
The maintai... | stackexchange/codereview |
I've recently started playing the X-Wing Miniature game, and there is quite some math behind some of the dice rolls, as they are affected by many abilities and so on. Manually calculating these is quite burdensome, so I decided to write a simple C++ program to approximate the expected damage by running many simulations... | stackexchange/codereview |
This is from my project codecount I use personally that is very similar to cloc.exe or SLOCCount. The part that I am questioning is where I am calculating when I am in a comment block and have deep nesting, I basically am replacing the sections with blank. I would like to deal with fixed format files at some point (R... | stackexchange/codereview |
This program prints odd numbers by thread1 and even numbers by thread2 sequentially. Can this code be optimized or made more efficient?
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condition_var = PTHREAD_COND_INITIALIZER;
void *fu... | stackexchange/codereview |
In Python I know packages like click or argparse to implement command line interfaces.
However, I'm in search for something the other way round. Something like a commandline assembler.
I need to set-up some complex command strings in python before executing them using subprocess.
Currently, for every command line tool ... | stackexchange/codereview |
I have the following code:
const arr = Array.from({length: 5}, (_, i) => i + 1);
const finalArray = [];
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length; j++) {
finalArray.push(arr[i] + '-' + arr[j])
}
}
console.log(finalArray);
Which creates an array of range 1 => 5, and returns... | stackexchange/codereview |
I have a simple cookie popup where the component technically runs on every page, giving the user the option to accept all or essential cookies. Once they accept an option, the popup no longer shows. However, I keep wondering whether many of the variables need to be memoised because the CookiePopup component itself rend... | stackexchange/codereview |
I have a data set.
public class EmployeeRepository
{
public static List<Employee> AllEmployees()
{
var loc1 = new List<Location> { new Location { City = "Gretna", State = "VA", ZipCode = "24587" }, new Location { City = "Charlotte", State = "NC", ZipCode = "28012" } };
var loc2 = new List<Locati... | stackexchange/codereview |
I have one input that is needed in many forms, so I created a partial view for that. In the partial view I query the database and generate a drop down list.
I just want to make sure, this is the best way to achieve this.
The partial view looks like this:
@model long?
@{
var data = Utility.GetData();
}
@Html.Drop... | stackexchange/codereview |
From my previous question, I got great feedback which helped improve my code which I submitted. I went back and built upon that and came back to see if my code is an improvement.
try:
from tkinter import *
except ImportError:
from Tkinter import *
import time
import random
with open("NAME_FILE.txt") as f... | stackexchange/codereview |
I created my first java application for a college assignment. I tried my best to design my application using best practices of MVC design patterns. I have read about it on Stack Overflow and other sites. My question basically is: Do I follow the best practices? Every feedback is much appreciated. Below is my code.
View... | stackexchange/codereview |
This is my solution for evaluating postfix expression using a stack. It does work on multidigit numbers, the problem I was struggling with last time. Now it works completely fine.
This is the stack that I'm using:
class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return se... | stackexchange/codereview |
The original problem statement is here, here is the super short summary:
Your binary search tree iterator must implement the following interface:
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
struct BSTIterator {}
impl BSTIterator {
... | stackexchange/codereview |
I'm writting my Django website and I created a view function which let to filter data before filling my Django form.
It works pretty well but I would find a way to simplify this function. It seems really ugly and maybe it exists a way to do that.
My models.py file looks like this :
#-*- coding: utf-8 -*-
from django.d... | stackexchange/codereview |
I developed this code for a vertical debounce counter for the PIC micro (PIC16F57). The code is called every 512 microseconds. It takes 5 bits from PORTB and compares it to a last known debounced state. If an active input has been stable for 64 calls it is accepted as changed. Though it is sufficiently good for the cur... | stackexchange/codereview |
I'm learning C for mainly for fun and to get a better understanding of how things work under the hood (most of my experience lies with high-level languages). I've been following quite a few books and working through the exercises. For extra practice, I've implemented a linked list using the knowledge I've learned - I t... | stackexchange/codereview |
How to set in HTML/CSS a section just like in this picture https://snag.gy/mStL9H.jpg ?
I have tried something but am not sure if it's right.
#trd-banner{
background-color:#284c57;
width:100%;
height:50%;
margin:auto;
}
#list{
position:relative;
left:110px;
top:1px;
width:200px;
height:150px;
... | stackexchange/codereview |
I made a game in Python where you play Pong against an AI. As I am quite new to pygame, I would be grateful to hear any possible improvements.
This is my code:
import random
import pygame
from pygame.locals import (
K_UP, K_DOWN,
K_w, K_s,
QUIT
)
BG_COLOR = (255,) * 3
FG_COLOR = (0,) * 3
SCREEN_WIDTH = ... | stackexchange/codereview |
My girlfriend and I are making a goodies tracker to enable us to keep better track of our stamp/gift cards. Right now we've got a super simple Object with some fields of what a stamp card has, and no support for modifying its fields (yet). I want to get some tips on if this is bad or good code, if there are any glaring... | stackexchange/codereview |
In my web API, the client wants me to implement logic in order to control/block concurrent requests in a specific time period. I added RequestInterval which is 10 seconds in the appsettings of web config. I added the Authorization filter into my project. I tested, it looks working but I wonder if you can check and give... | stackexchange/codereview |
I want to calculate the Cartesian product of n copies of a small list, marker=[0,1,2]. I want to use these Cartesian product tuples as keys in a dictionary. The value per each key is to be a numpy array with n random floats between 0 and 1.
The only twist is that for each key:value pair in the dictionary, if the key ha... | stackexchange/codereview |
HTML
<div id="form-0">
form 0
</div>
<div id="form-1" class="add-form">
<a class="remove-form-1">X</a>
form 1
</div>
<div id="form-2" class="add-form">
<a class="remove-form-2">X</a>
form 2
</div>
<div id="form-3" class="add-form">
<a class="remove-form-3">X</a>
... | stackexchange/codereview |
I've implemented Excel's SUMIFS function in Pandas using the following code. Is there a better — more Pythonic — implementation?
from pandas import Series, DataFrame
import pandas as pd
df = pd.read_csv('data.csv')
# pandas equivalent of Excel's SUMIFS function
df.groupby('PROJECT').sum().ix['A001']
One concern I have... | stackexchange/codereview |
A guy at the company I work for needed a small application that would combine multiple text files into one, larger text file.
I wrote a console application for this. it seems pretty efficient, but I was wondering if there would be an even more efficient way of doing this.
It has 2 important functions, one that gets the... | stackexchange/codereview |
My method searches through an list of accounts which have the property "Name".
class Accounts
{
static internal List<Account> accounts = new List<Account>();
static internal bool findAccount(string name, ref int account)
{
for (int i = 0; i < accounts.Count; i++)
{
if (accounts[... | stackexchange/codereview |
Whats the best practice for calling a function with a complex set of arguments?
I've seen a 1 and 2 in most codebases, but I haven't seen 3.
Since it's almost impossible to search for **{ in codebases, does anyone know why this pattern isn't used more often?
I'm using Google's Sheet's API v4 as a demonstration, which... | stackexchange/codereview |
I'm practicing some python exercise and I have some doubts about the solution of reversing a number. Example, 42 -> 24, -314 -> -413.
The book has this solution:
def reverse(x: int) -> int:
result, x_remaining = 0, abs(x)
while x_remaining:
result = result * 10 + x_remaining % 10
x_remaining //= 10
r... | stackexchange/codereview |
From SICP
Exercise 1.3: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
Square is:
(define (square x) (* x x))
I know the code could be written using language features like lambda or let, but first to remain true to the exercise, I wouldn't use ... | stackexchange/codereview |
Problem :
Imagine you are a developer and get a job in which you need to create a program for a teacher. He needs a program written in c# that calculates the average score of his students. So he wants to be able to enter each score individually and then get the final average score once he enters -1.
So the tool should ... | stackexchange/codereview |
The following is my second attempt at a basic CSV parser in Ruby. I've addressed suggestions that I've got for my previous version here.
I have omitted all test cases - the code listing would be too long otherwise. You can look at the full code-base at GitHub if you want to.
As opposed to the last version, the current ... | stackexchange/codereview |
I am an amateur in OpenGl and for this reason I am seeking to learn only modern OpenGl the 4.x stuff. Once I had completed basic tutorials (rotating cubes, for example) I decided I would try and create a voxel-based program dealing solely with cubes. The goals of this program was to be fast, use limited CPU power and m... | stackexchange/codereview |
I want to generate a random seed based on a string value (which is ~32 characters long).
I don't want to use string.GetHashCode() since I may later will need a working implementation in another language (C++, Python, JavaScript) (Yes I will need to get rid of Random() too then and all other .NET classes).
I also want t... | stackexchange/codereview |
I am looking to see if someone is willing to take the challenge in optimizing this noob python script.
The purpose of the script is to:
Check if Google Drive File Stream is installed
Check if Google Drive is installed
Check if user's Google Drive folder has been renamed
Then the actions begin:
Install Google Drive F... | stackexchange/codereview |
I'm currently looking into the quickest way to sort an almost sorted array:
Given an array of \$n\$ elements, where each element is at most \$k\$ away
from its target position, devise an algorithm that sorts in \$O(n \log k)\$
time.
I've implemented a sorting function which "slides" through an input list, pushes ... | stackexchange/codereview |
I'm a new developer just starting out learning HTML, css and JavaScript. Below is my attempt at building a portfolio website.
I am finding it difficult positioning elements the way I want to and finding botched ways to do so when there's probably a more cleaner and efficient way of doing so.
Any advice or criticism is ... | stackexchange/codereview |
Given two objects with some food data, log the name of the recipe and ingredients names separated by conjunction "and". Please run the code I have attached to see the expected output.
condition - match RECIPES.rules.id with INGREDIENT.id and use INGREDIENT.name in the final output.
I was wondering if my solution can b... | stackexchange/codereview |
This is (the significant) part of an implementation of a logging mechanism for recording events in a real-time control system. The basic requirements are:
No dynamic memory on either side (producers or consumer),
Lock-free
variable length event entries
strictly sequential timestamps
multi-processor safe
tolerant of o... | stackexchange/codereview |
This code computes the function (3x^2-4x+16) / (5x^2+2x-4). I ran the program and it works, but I am fairly new to assembly language and am not quite sure how to make the most efficient use of the registers. Does this look ok or is there a better way to do it?
.text
.globl main
main:
ori $8, $0, 3 #put ... | stackexchange/codereview |
My task is ask this from the user:
Enter the number corresponding to the desired pay rate or action:
1) $8.75/hr 2) $9.33/hr
3) $10.00/hr 4) $11.20/hr
5) quit
If choices 1 through 4 are selected, the program should request the hours
worked. The program should recycle until 5 is entered. If someth... | stackexchange/codereview |
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 ... | stackexchange/codereview |
I have a PANDAS DataFrame that contains sensor data that is recorded every hour (sample included below). It is important to note that every hour is not necessarily in the dataframe, as sometimes the sensor is down and nothing is recorded. This data is going to be used as input into a predictive model, but before that... | stackexchange/codereview |
This is an inversion-of-control object store. It is meant to be for a multithreaded application where it can load components at start-up based on complex environmental setup,
Worker threads can retrieve individual components on demand.
Do I need 2 overloaded functions of registerInstance()?
#include <iostream>
#includ... | stackexchange/codereview |
I am reading the book The Linux Programming Interface and I have reached the exercise in which the implementation of the chattr command in C is required.
I would like to receive feedback on the implementation, to criticize my solution
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#inclu... | stackexchange/codereview |
I have this code that requests the graph API from Facebook to respond with a shared count for a particular URL (could be multiple on the page). Graph returns a full number (135934) and I take that number and abbreviate it into more friendly numbers (135K). Basically I'm looking for any help on improving the code to be ... | stackexchange/codereview |
I've written a simple accordion using zepto js lib.
Looking for advice on how to improve this better.
HTML
<div class="box">
<span class="learn-more"><a href="#">Learn more</a></span>
<div class="more">
blah<br>
blah<br>
blah<br>
<span class="close"><a href="#">close</a></span>
</div>
</div... | stackexchange/codereview |
I was working on one of the Hackerrank programs, Bigger is Greater, and it basically deals with finding the next largest lexicocraphic permutation of a string. I've implemented my solution, following an algorithm described here. I then store all the permutations in a vector, loop through it, and search for the next per... | stackexchange/codereview |
I have this code that helps me to paste data from an Excel file to a Datagridview:
If e.Control AndAlso e.KeyCode = Keys.V Then
DGVLookUP.Rows.Clear()
DGVLookUP.Columns.Clear()
Try
Dim Generar As Boolean = False
Dim N As Integer
For Each line As String In Clipboard.GetText.Split(vb... | stackexchange/codereview |
Problem:
Using the recursion approach, find a Fibonacci sum without repetition of computation.
def sum_fibonacci(n):
"""Compute the nth Fibonacci number.
>>> sum_fibonacci(35)
9227465
>>> sum_fibonacci(10)
55
>>> sum_fibonacci(0)
0
>>> sum_fibonacci(1)
1
>>> sum_fibonacci(5)
... | stackexchange/codereview |
This is a real live chatroom that I have made with Tkinter
I posted a question before about making a chatroom but the problem that I had with that one was that only one user could connect to the server so I restarted and have made this one. I just want suggestions on how I can improve it.
All suggestions will be greatl... | stackexchange/codereview |
The following code is intended to implement a LinFu DynamicProxy interceptor to lazy load given virtual properties from an Umbraco datastore.
My concerns:
Thread safety, Have I covered all the bases, Am I storing variables correctly?
Duplication - Getting the child type, am I safe to store a variable via my Lazy to us... | stackexchange/codereview |
I'm implementing a STL-like vector with the essential functionalities.
I would like to know what is good in this code and what is bad. In terms of everything (memory usage, functions implementations, naming conventions, etc,...).
The header:
#ifndef BVECTOR_H
#define BVECTOR_H
#include <memory>
static const int MIN_... | stackexchange/codereview |
I'm very new to Python, and far away from writing my own scripts. For my work with lilypond I needed a script that parses a text file, searches for a string and inserts another textfile before the match. I have been searching quite a lot for this kinda script and I did not find any. I ended up combining the snippets I ... | stackexchange/codereview |
I am modifying Volley for Android a bit and Findbugs complains about the data flow and I am a bit lost. First the code:
String userAgent;
try {
String packageName = getPackageName();
PackageInfo info = getPackageManager().getPackageInfo(packageName, 0);
userAgent = packageName + "/" + info.versionCode; // D... | stackexchange/codereview |
I made program for parsing CSV and XLS files, I just want to know if there is some space to improvement and is it all written good?
My goal is when I got CSV or XLS file to parse that file and got list of objects for specific class, besides of getting list I made metod to populate datatable and show data in DataGridVie... | stackexchange/codereview |
There are quite some questions and answers about how to make enum really type-safe and I didn't find a solution that ensures both type safety and valid values. So I took some ideas and extended it to my own generic solution, somehow resembling to enum classes used in some other languages.
My solution adds the overhead ... | stackexchange/codereview |
I've written a heapsort implementation. It's generic: generic comparators and sequences with elements of a generic type.
The implementation (follows closely chapter 6 from Introduction to Algorithms 3rd Edition and) consists of
heapify: establishes the heap property for an element:
template<typename BiDirIterator, typ... | stackexchange/codereview |
This is the "Popes" problem from UVa Online Judge:
On the occasion of Pope John Paul II's death, the American weekly magazine Time observed that the largest number of Popes to be selected in a 100-year period was 28, from 867 (Adrian II) to 965 (John XIII). This is a very interesting piece of trivia, but it would be m... | stackexchange/codereview |
I want to create algebra evaluator but I don't want to write my own parser because it takes much time to learn.
I don't like algebra expression in C# because it does not look natural compared to VB counterpart. For example, "x^2+1" in VB must be written as "Math.Pow(x,2)+1" in C#.
I am still a newbie in the world of p... | stackexchange/codereview |
Please review the code and suggest better algorithm to efficiently extract key/value from files using multithread.
Input : FormNGFAddTab:First add Tab control inside Tabs control.परीक्षण
Output :
Key : FormNGFAddTab
Value : First add Tab control inside Tabs control.परीक्षण
Separator : ':'
DataHolder/DataStructure : An... | stackexchange/codereview |
Here is a simple client for Wwitter that I wrote based on the twitter library in Python. The aim is to be able to read the feeds from different twitter accounts from the same place in a light way.
I should mention that the code does what I want it to do. Nevertheless, how could I improve it?
(It is available on GitHub.... | stackexchange/codereview |
A little bit about myself: I am 18 years old, a student living in Germany and currently working on an android app.
I would like if someone has the time to review my code. I am especially interested if this code has any vulnerabilities and if the efficiency could be improved. Thanks in advance :)
import javax.crypto.*;
... | stackexchange/codereview |
There has got to be a better way to do this. I have a method which returns either your standard "01/01/2014" Date or "January 1st, 2014" Date of the assembly file write time. Any suggestions on streamlining would be much appreciated.
// Grab the last date of revision of the assembly file write time
// You may pass an... | stackexchange/codereview |
At the moment I try to get used to SQLite and Python. I started with insert, select and so on. But now i want to get a bit further.
Now I have a DB with 200 rows for testing and in want to update two values of each row in this case called "Test2" and "Test3". My problem is that those two values should be the value tha... | stackexchange/codereview |
I'm working on a Django Twilio app, and I believe it's coming along well. I just want to improve my code writing skills. How can I improve the below code?
def save_number(request):
from_number = request.POST.get('From', '')
try:
obj = SaveNumber.objects.get(phone_number=from_number)
if obj == ob... | stackexchange/codereview |
I am new to android developement.
Created calculator application.
Want to improve my code quality.
Will be helpfull for any advice to make the code better and more professional
(overall structure, splitting onto logical units, accordance to code conventions, methods and variables names, comments etc).
Here is my code:
... | stackexchange/codereview |
I'm trying to learn Vuejs and started this project:
https://github.com/GhitaB/datatables-admin
(Live demo: https://ghitab.github.io/datatables-admin/).
Copied the current version (the question will refer to it): https://jsfiddle.net/ns6umqv2/
My goal is to have a nice admin panel that will be used by editors to generat... | stackexchange/codereview |
I have a lot of compressed csv files in a directory. I want to read all those files in a single dataframe. This is what I have done till now:
df = pd.DataFrame(columns=col_names)
for filename in os.listdir(path):
with gzip.open(path+"/"+filename, 'rb') as f:
temp = pd.read_csv(f, names=col_names)
df = d... | stackexchange/codereview |
I am having a huge brain fart with efficiency right now.
The idea here is if I have a static table (unfortunately formatted this way with the data I've received), how would I appropriately append a select option dropdown with every value from the table categorized easily?
I currently have it working, but it seems as if... | stackexchange/codereview |
Is it possible to write this in fewer lines of code?
If you input an integer it will output it as an ordinal number if it is less than 100. The below code works perfectly, but I'm wondering if it could be written more succinctly.
def ordinal(self, num):
"""
Returns ordinal number string from int, e.g. 1, 2, 3... | stackexchange/codereview |
I want a general criticism on this code. Using external modules is not an option, I can only use what comes with CPython.
from collections import Counter
from typing import Sequence, NamedTuple
Coordinates = Sequence[float]
class KNNPoint(NamedTuple):
coords: Coordinates
classif: str
def predict(target: Coor... | stackexchange/codereview |
I'm new to C programming but this is my attempt at a Scene/State machine. I haven't had a code review before so I'm guessing this is gonna hurt :D
§ Preliminary
SceneFSM manages Scenes, one Scene "active" at a time. A Scene is just a C file with method definitions;
Each scene may (or may not) contain three methods;
St... | stackexchange/codereview |
The problem with the original Lazy in C# is that you have to put the initialization in the constructor if you want to refer to this.
For me that is 95% of the cases. Meaning that I have to put half of my logic concerning the lazy property in the constructor, and having more boilerplate code.
See this question: https://... | stackexchange/codereview |
I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below,
def cumulativeTokenise(string: String): Array[String] = {
val array = string.split(" +")
var result: Array[String] = Array()
array.map { i => (
result = result :+ (
... | stackexchange/codereview |
In python, I sometimes write a while statement like
i = 0
while <condition that involves i>:
i += 1
The goal is, of course, to check the number of time the condition is true.
I was wondering if there's a more simple, pythonic way to do it ? something like i = while <condition that involves i>, maybe with the walru... | stackexchange/codereview |
If std::vector<vector<pair<int,int> > > v(n) represents the adjacency list of the graph with pair<int,int> is the {vertex,weight} pair, I tried to implement the algorithm the following way:
while(true)
{
long long yo = LLONG_MAX;
int ind=-1;
for(int i=0;i<n;++i)
... | stackexchange/codereview |
I have this script for creating SQLite backups, and I was wondering whether you'd have any suggestions on how to improve this. I was thinking that maybe it should create the backup dir if it doesn't exist, but not sure if it's necessarily better.
Besides functionality/performance tips, any styling/formatting tips are a... | stackexchange/codereview |
I'm learning from "Jumping into C++" by Alex Allain (sample chapter and TOC) and solved the first problem in Chapter 26 "Inheritance and Polymorphism".
I'm especially concerned about my use of dynamic_cast, as that isn't covered yet and I suspect there's a better way.
Implement a sort function that takes a vector of p... | stackexchange/codereview |
Here is a short python snippet to ingest train data:
x_train = []
y_train = []
for x,y in train:
x_train.append(x)
y_train.append(y)
x_train = np.asarray(x_train)
y_train = np.asarray(y_train)
The variable train is a list of 60000 (x,y) tuples.
| stackexchange/codereview |
I tried to build a "typed" property system in Java and this is what I came up with: first the class Properties that any class can use as an attribute (demo code in the end).
import java.util.HashMap;
import java.util.Objects;
public class Properties {
private HashMap<Type, Object> properties = new HashMap<>();
... | stackexchange/codereview |
I am working on a project which uses JNI. More than once I fell over the absence of type safety working with the variardic function calls. So I came up with this module. It wraps the variardic JNI functions using C++ variardc templates to offer a type-safe alternative. It also features integrated error checking for mor... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.