instruction stringlengths 71 71.9k |
|---|
Is there a way I can link/associate an object (in this particular case a function) with a regular expression pattern?
Here's the function I'm working on:
def get_command(url):
"""
Return command for downloading a particular url.
>>> get_command('http://randomsite.com/XYZ')
['wget', '--content-dispositi... |
I have inherited a site which uses the Google API to create a map on my webpage. I don't know much about JavaScript but from the research I've done, I dont think this code is optimal as it is not loading asynchronously. Any help or pointers would be appreciated.
function initialize() {
var myLatlng = new google.maps.... |
I'm having trouble improving the performance of the solution to the Project Euler problem #34
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
I've done... |
I am currently reading Clean Code and for fun and profit, I intended to refactor some of the Java Tutorials and since I wanted to improve my Exception handling, the Byte Stream one with its lots of IOExceptions seemed nice.
This code does work, but is it better now? As far as I can tell it's more readable now, though t... |
I've written a small C++ utility that is intended for measuring the execution time of blocks of code, and I'd appreciate your feedback on it. I'm an experienced programmer, but a novice C++ programmer.
The code is written with performance in mind, and uses a libcuckoo hash table to support multiple concurrent calling t... |
I think I'm finally done with my code and was hoping for some pointers. My goal for this script was to:
Create new folder
Create AD group FS-TESTSHARE-R
Create AD group FS-TESTSHARE-RW
Apply both groups to the new share folder
Set full read permissions to FS-TESTSHARE-R
Set full read/Rights permissions to FS-TESTSHARE... |
I needed to make a timer to profile small programs a while back. My use wasn't for a major project or mission critical code or anything even remotely close to that, just for personal learning purposes.
As I reviewed my old timer I found I was using clock which measures cpu time. Now being aware of the difference bet... |
My team has developed an API and I've been tasked with creating an authentication layer that allows partners' applications to consume it. To that end, I've created a data store which houses an Application ID, Login and salted/hashed Password for that application to authenticate against. I want to hand back a Token for ... |
(See the first and initial iteration.)
Now I make only one pass over the data in order to compute the standard deviation of the input Numbers, and that's how:
\begin{align}
\sum_{i = 1}^n (x_i - \mu)^2 &= \sum_{i = 1}^n (x_i^2 - 2\mu x_i + \mu^2) \\
&= \sum_{i = 1}^n x_i^2 - 2\mu \sum_{i = ... |
This is hard to explain. I wanted to get all of the items in collection one (ints in the example below) that are the highest values that are lower than any of the items in collection two (otherInts). In the example below, only 2 and 8 should be returned from ints. 1 doesn't qualify because it is lower than 3 (in oth... |
I am working on below python copy utility that should work on windows & linux,
But I am looking for a more efficient approach that could optimize my I/O correction, as my target location is network dependent as well...
I have computed the utility execution time factor in the code.
#!/usr/bin/python
"""
Pythonic implem... |
I want to run rolling regressions over each group and store the coefficient. The following works, but it's slow, since I have too many series and I want to run too many regressions for each group.
Using foreach(), speeds things up (and also getting the coefficient with (X'X)^{-1}X'Y but is there a way to vectorize thi... |
Below is my code to detect cycle in an undirected graph. Could anyone please review and let me know if I have taken care of all the cases?
The basic idea is to use DFS (non-recursive using stack) and check if already visited vertices are found in the stack.
bool dfsDetectCycle(int vertex, int visited[10]) {
stack<... |
I'm building an app that tells you a stock's percentage change in price between two dates by using Yahoo's API. Given a stock ticker and two dates, it currently outputs the percentage return to the console.
I would like to later expand this app to give it a list of stock tickers and dates. For each, it would return the... |
To find the node next to a given node we need to consider two cases.
case 1: if the node has a right subtree then return the min node in its right subtree.
case 2: if the node doesn't have a right subtree then return the ancestor of the node whose left subtree contains the node.
class NodeWithParent {
int data;
... |
Below I have implemented a class that will validate and upload files based on the specified rules.
class Uploader
{
protected $finfo;
// extensions corresponding mime types
protected $mimes = [
'jpg' => 'image/jpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'gif' ... |
I worked starting from basic example code from an exercise in chapter 10 of Java: A Beginner's Guide, Sixth Edition, the code in the exercise was not very good and I wanted to improve upon it and make it my own, so this is what I came up with.
This reads the content of a text file, displays and reads titles/subjects, w... |
I'm simultaneously learning Erlang and writing a short guide on list operations. Here is a trivial function I wrote to demonstrate hd and tl:
headAndTail(List) ->
Head = hd(List),
Tail = tl(List),
{Head, Tail}.
This works, but it throws "Warning: variable 'Head' is unused." I know this function could be written ... |
public static long sumOfPrimes(long max){
long sum = 0;
long primes[] = new long[((int)max/2)+1];
int index = 0;
for(long counter = 2; counter <= max; counter++){
if(isPrime(counter, primes)){
sum += counter;
primes[index++] = counter;
}
}
return sum;
}
p... |
I have written a LaTeX package to visualize B+ trees.
The main purpose is to provide a simple but powerful package which provides a convenient interface.
However, this is my first LaTeX package and I would also like to know where I can do better.
So I'd like to get reviews from these two points of view:
Simplicity of ... |
I am learning Java's NIO and as an exercise, I have implemented a simple chat server. I would like to ask if I am using NIO's features in the correct way.
public class ChatServer implements Runnable {
private static final int BUFFER_SIZE = 256;
private static final int DEFAULT_PORT = 10523;
private static f... |
I needed a better way to benchmark code, because, well, rewriting the same benchmarking code every time I need it is just...well...unpleasant.
So, here's a class which does just that, it runs an Action over a specific number of rounds, and calculates certain stats on it.
Another nice feature is that it doesn't store th... |
My code prints the next 20 leap years:
def loop_year(year):
x = 0
while x < 20:
if year % 4 != 0 and year % 400 != 0:
year +=1
##print("%s is a common year") %(year)
elif year % 100 != 0:
year +=1
print("%s is a leap year") % (year)
x +... |
In my system I have a SMS authentication. Users input their user-id and get sent an SMS with a 5 digit pin number they input in a website to log in. The pin has a lifetime of a few minutes.
This pin number needs to be fairly secure so hackers can't try to guess the pin.
I would like to get some comments about my approa... |
I have a piece of JavaScript that's going to fire event every second after 10s, it's going to gradually increase the interval time. I'm new to JavaScript so it would be nice to have a codereview.
var _lastHeartbeat = window.performance.now();
var _config = {
heartbeat: {
start: 1000,
max: 10000000,
cap: ... |
I recently finished the project Euler problem # 41 :
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?
And I'm having trouble optimizing it.
Exp... |
Revisions:
Revision 1 (you are here)
Revision 2
Revision 3
I've been working on a simple command-line png2jpeg utility. Its purpose is to convert images from PNG format to JPEG.
The source code requires the libpng and libjpeg development libraries to be installed, and can be built with a C99 standard-compliant C comp... |
I'm sanitising personal data in a large database with a series of Regular Expressions. In many cases the sensitive data is in a colon-delimited field within a CSV file.
Here is a sample:
(142406, 202, '45759:2940:2016-04-12-21-24-08:300:2016-06-21:2016-04-11:1:Windows/Doors:', 2761, 4041931, 0, '1460492649'),
(142404, ... |
Using Rubocop, pretty much any case statement is caught by the Cyclomatic Complexity cop, often the Assignment Branch Condition and method length cops as well. To get around this, I've been refactoring code like this:
def preview
case object.panel_type
when "image"
asset_image_path(object.asset)
when "profile... |
I'm new in OCaml and just want to be sure that I write code in "ocaml way". My other first programs in OCaml was imperative and looks like python-code. So I decided to write simple code and share it for review.
let print lst =
List.map string_of_int lst
|> String.concat " "
|> print_endline
;;
let... |
have started learning Java recently and was looking into some easy algorithms.
I found the Sieve Of Erastothenes algorithm here
I am trying to get better at writing good code for my solutions. Please give me your suggestions.
import java.util.Scanner;
public class SieveofErastothenes {
public static void main(Str... |
I'm learning F#, starting with baby steps. Is there a way to write this code in a more succint way, while keeping the same semantics? Maybe by using a Seq or something like that?
let rec repeatingPrompt predicate (message:string) =
Console.WriteLine(message)
let value = Console.ReadLine()
if predicate value... |
I use this declaration for an array which must contain a bit for every minute in a day:
UCHAR minutesOfDay[(60 * 24 / CHAR_BIT) + (((60 * 24) % CHAR_BIT) ? 1 : 0)];
However, this look pretty awful. Is there a simpler way to state the same? It can be in C or C++.
|
A new question about a revised version of the code in this question, based on the advice in the accepted answer can be found here.
I need to signal my program to do something every X seconds. So I decided to make a separate thread that sends such a signal using ZeroMQ. All other behaviour is also triggered by ZeroMQ me... |
While trying to integrate react-select component on my codebase on documentation it's explained that you can pass an array of options with label and value attributes eg :
import Select from 'react-select';
let options = [
{
label: 'Color',
value: 'Blue'
}
]
<Select options={options} />
And it works fine, but ... |
I am trying to learn how to write more object oriented javascript code, but I am having a hard time understanding the correct way to do it, and how it is useful for front end development. As you can see below, I tried to rewrite my old javascript code to be more object oriented, but it just doesn't seem necessary for w... |
I am working on a simple Texas Hold'Em dealing simulator. I am new to Python and was hoping to get some advice on my use of classes here. I feel like I am not using them as efficiently as possible, especially when dealing out the player cards. Specifically, I feel like the def deal(self, n_players) could be simplified ... |
We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks.
bool make_bricks(int small,int big,int goal)
{
if(big > 0)
{
double test = (double)... |
In perl, there is that format facility for console output. I thought it might be good to practice some library design instead of algorithms once in a while. This may be compared to a GUI library: you start from an empty window, add some lines to it, add labels and other stuff to each line and so on. At this point I hav... |
SPOJ problem PRIME1 (also found on other sites in identical form):
Input
The input begins with the number t of test cases in a single line
(t<=10). In each of the next t lines there are two numbers m and n (1
<= m <= n <= 1000000000, n-m<=100000) separated by a space.
Output
For every test case print all prime num... |
I'm having trouble optimizing the Project Euler problem #43 :
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this w... |
I have some code that needs to access an API that requires OAuth authorization in the form of a token, and every time the token expires, it needs to be refreshed.
I made a function called _fetch() that wraps the API calls that I'm making, and will both authorize the requests, and automatically refresh the token if it h... |
Looking for code review, optimizations and best practices.
Node.java
class Node {
Node next;
int data;
public Node(int value) {
data = value;
}
}
Palindrome.java
public class Palindrome {
static Node reverse(Node head) {
Node prev = null;
Node current = hea... |
I want to make a vertical cycle slideshow. This works perfectly for me but I'm just wondering if it's possible to achieve the same functioning with a better code. I don't know if my code would provoke a problem in some situations or not.
jsFiddle
var pare = $('#slider'); // selecting the holder element;
var ob = $('#sl... |
I wrote a Brainfuck interpreter in Python and I'm wondering how to simplify it.
I handle separately loop commands and the others. A recursive function deals with loops.
import sys
array = [0] # byte array
ptr = 0 # data pointer
Read and execute commands except loop
def readNoLoop(char):
global ptr
# Increment/... |
I'm creating a relatively simple type-safe and thread-safe Rust event system. It is to be used with and within an IRC library I'm making, but should work just fine for other use-cases. It needs to be reasonably good and safe. Using it might require lazy-static, which makes me slightly worried, but even then it should b... |
I have written simple code to construct a graph, but I think there are too many different types for such a simple task.
In this code I need to store Node structs in the Graph instead of pure values because it encapsulates some logic. The user should not know about Key. The user will be working with references to nodes.... |
Recently I was experimenting with QTableViews and I wanted to create something where I can add a new row to a table without having any additional button/menu item outside the table. I achieved this by adding a single item to the view's model and set that not editable. Then if a double-click happens on the table I check... |
I'm using Rails 4.2.5, and I'd like to update existing records with a csv file with two fields: id,category. Where if the category field is blank, it defaults to misc.
Here's an example csv file:
id,category
123-123-123,0
123-123-124,1
123-123-125,
123-123-126,2
So, I've created some tasks, update_item_categories, and... |
Rob is looking to buy a used pickup truck. He will spend a maximum of
$10,000 but would like to spend as little as possible. He will spend
up to $3000 for a 2000 or older model, $5000 for a 2001-05 model,
$7000 for a 2006-09 model, $9000 for a 2010 or newer model. Rob will
not buy a red truck but he will pay 2... |
Assume the built-in function Ascii(c), where c is a one character
string, will return an integer containing the ASCII value of that
character. Write a function that accepts a string, uses Ascii(c) and
additional processing to produce a one way hash value from the string,
and returns the hash value as a string.... |
Scenario
Currently filtering through a list of ~3100 rows of data presented to the end-user in the form of an index (think, list of car models).
This is done in such a way that every item is available in a long list to the end-user however they have the possibility to filter down their results into something more rele... |
The following is an a self-tutored attempt to take a leap into understanding simple usage of wait() and notify() methods.
The code is responsible for scanning a directory structure with each directory being scanned by a new thread, for the files present in it. All results to get accumulated in a data collection and dis... |
project is the data frame. For the purpose of the code, HOUSE.NO is a column of the type character, and NO..OF.FAMILY.MEMBER is another column of the type integer. My aim was to find out the house numbers which repeated, and then find out if the no of family members reported for each of the house matched, and identify ... |
After coming across Douglas Crockford's views on class-free OOP, and doing away with new and this in Javascript I tried defining an object with its own variable and function, and returning it in JSON, as shown below:
var newObj = function (name, lang){
var obj = {
"name":name,
"greeter":gree... |
Sometimes, we have to do some fixing to insert a string into an HTML property. Or just to display it.
But not everything is safe! Consider the following example:
document.getElementById('name').innerHTML = prompt('What is your name?');
This allows to introduce HTML vulnerabilities quite easily. Specially when you wa... |
The method toggle of Element.classList expects a parameter which names a CSS-class.
You can't assign multiple classes at once by using for example an array.
So you have to write something like ...
div.classList.toggle("hidden-element");
div.classList.toggle("border-defs");
div.classList.toggle("green-theme");
Therefo... |
Kindly accept my apologies as Java is something my mind cannot digest no matter what I do. At the moment I have an assignment and have written a piece of code and have used Constructor (I think so) but not sure if I have used it correctly and if Yes then will need some guidance in order to refactor the code.
Anyhow I ... |
I have a query consisting of UNIONs.
SELECT CONCAT("You sent track request to ",u.username) AS ACTION, h.`dateTime` FROM login_user u
LEFT JOIN
history h ON u.id = h.`toUserId` WHERE h.`fromUserId`=28 AND h.`Action`="Request"
UNION
SELECT CONCAT("You Accepted track request from ",u.username) AS ACTION, h.`dateTime` ... |
I would like feedback on my first attempt to understand how hash tables work. I've read some on how hash tables use modulo operations to find the location of a key.
Can you help me understand, compare the modulo approach with my attempt to use a tree?
import random
import hashlib
from collections import defaultdict
i... |
At the moment, prtscn takes a server, and a list of port ranges to test (of the form x,y-z,a-c,d,e etc). The -v option will show all ports being scanned, and the -r option will return the first open port in the list. If -r is passed, the list of port ranges is optional. In this case, if the port list is missing, -r wil... |
My goal for this script was to:
Create new folder
Create AD group FS-TESTSHARE-R
Create AD group FS-TESTSHARE-RW
Apply both groups to the new share folder
Set full read permissions to FS-TESTSHARE-R
Set full read/Rights permissions to FS-TESTSHARE-RW
Set full access permissions for local machine admins and domain admi... |
One of the most annoying things about the VBE (VBA's IDE), is that it doesn't have a status bar.
Rubberduck 2.0 works around this by introducing the RubberduckCommandBar, which [ab]uses msoControlButton controls as though they were labels - the command bar constantly resizes as the text changes, but at least we get to ... |
The following code is for my Object Oriented Programming class. My program simulate the cashier's machine to order food. The code uses Model View Presenter. This class is the model.
I have an ArrayList to hold the possible order possible. The View uses it to create JButtons.
I have an ArrayList to hold data to know ... |
This method finds the common ancestor of two nodes in a binary tree.
Any style suggestions or ways to make it more idiomatic? Is the algorithm correct? Rubocop says the cyclomatic complexity is too high, how would you break this up?
class Node
def initialize(value = nil, left = nil, right = nil)
@value = value
... |
Below is the code for, Singly linked list implementation,
function List(){
this.start=null;
this.end=null;
}
List.makeNode=function(){
return {data:null,next:null};
};
List.prototype.add=function (data){
if(this.start===null){
this.start=List.makeNode();
this.end=this.start;
}e... |
I have a notebook here which details my code and may be more legible.
I worked on a project that flattens a table that initially looked like this (this is table1):
18+fem 18+male date station
17118 15925 12/1/2014 ADSM
16006 11379 12/2/2014 ADSM
19259 18846 12/3/2014 ADSM
16386 17068 12/... |
I am suppose was to incorporate arrays in my NIM game java code, so that we can allow the user to decide on how many heaps are in play. I am stuck and have no clue how to do so.
Heap Class
public class Heap {
private int heapSize;
public Heap(int size)
{
heapSize=size;
}
public boolean remove(int size)
{
bool... |
Link to sanitized xls on dropbox if test data is needed
Essentially the reports I work with aren't bad -
The issue is the way it exports to excel -
With the problem being that these cells are filled with LF characters breaking apart the data entries in the cells (usually a listing of employees in format empID / emp n... |
I wrote a small header that is supposed to take care of calling the right strtoX or or stoX function for me and doing so at compile time. The code contains two functions: num_cast and string_cast. Each returns a number or string from the argument specified. See main for an example on how to use this.
I'm looking for re... |
The code does the following:
Gets an array of objects and filters them according to some properties
Returns the array of objects with the filtered data
I'm using the following code which is working and I wonder if there is a way to write it better.
By the way, I can use LodashJS if it's helpful here.
filterNullUndefi... |
I'm creating a Pong clone for use in teaching JavaScript to beginners. Unfortunately, I am largely a JS beginner myself, so I probably missed something in the below code; however, I do not want to shortchange my students.
Also, the code does work as intended (with the exception of the sound-playing code, since I couldn... |
I built this game that I used to play at family get-togethers. I am still working on the final implementation of how to actually play someone in the game. Please critique the main logic of the dice and how I find the values.
var dice1 = new dice(1);
var dice2 = new dice(2);
var dice3 = new dice(3);
var dice4 = new d... |
CGbR project
I am currently working on a project that generates code from classes. The idea is to achieve maximum performance by replacing reflection use cases with fast, generated code.
Current results look good, but I want to take this chance to find room for further improvement.
Class under test:
[DataContract]
publ... |
After a lot of research, I created this wrapper which I think fits very well to my needs. My project is a TCP server and I will be using this wrapper every time the server receives a packet. Basically, the wrapper will work marshaling raw byte[] into higher-level representation of the data as marshalable structs.
What ... |
I have a school project to create a program that works the same as the Linux cat. The code works, but I just need find out where I can Improve it or handle errors. The program has 3 .c files and 1 header file. I'm also not allowed to use system functions; I have to use read(), close(), open() and write() and while loop... |
Here is my previous question:
Java Tic-Tac-Toe game (implemented through MVC)
I'm reposting again because I made a lot of changes to the code. I wasn't able to implement everything as I don't know some of the stuff, but I tried to do as much as possible.
Summary of changes:
View doesn't have as much logic now.
Model h... |
I'm solving the following problem using the Chain Of Responsibility design pattern in Swift:
Not all mechanics are created equally. Some mechanics are more
experienced and can do more than others. We need a system where every
job is propagated from the least experienced mechanic to the most.
This way experience... |
The following converts Arabic numbers to Roman numerals.
I decided to factor each digit into its place value, then use a mapping to convert it to its Roman equivalent.
For example, 1997 is factored to:
\$(1 \times 10^3) + (9 \times 10^2) + (9 \times 10^1) + (7 \times 10^0) = 1000 + 900 + 90 + 7\$
The Roman numerals fo... |
I'm solving the following problem using the Mediator design pattern in Swift:
Assume we track the location of all our mobile mechanics. We have
noticed that there are times when a mobile mechanic might need
assistance from another mechanic or a last minute need for a part that
someone else might carry. We want t... |
I'm just messing around with class inheritance. I originally had a separate goal in mind but I ended up here, and my new goal was to have a parent that was completely ignorant of it's self, i.e. no default attributes. This would seem to make it easier to subclass, the MeleClass could set; for instance canRange to True ... |
I'm looking for any kind of advice, like when or where to do exception handling, the overall library structure/layout, usage of classes/partial classes, code efficiency, naming conventions, and so on and so forth.
Note: Knowledge of cryptocurrency technology would be an advantage.
The following code is the section that... |
I'm writing some code which is basically supposed to http get some information from my own website and parse it, which (finally) works. However, when I compile the code, it shows this:
Sketch uses 14,466 bytes (44%) of program storage space. Maximum is
32,256 bytes. Global variables use 1,281 bytes (62%) of dynamic
... |
I have been coding Java for 5+ years and before that did a little professional C. Picking up C++ again for the fun of it and I feel like I am just writing Java in C++ rather than understanding the C++ way of doing things.
Anyway, I wanted some thoughts on my simple little class to make sure I am C++ing right.
This is m... |
I have this if else block code
if($_POST["item"]=="All"){
$notificatioSetting->AllNotification=$_POST["status"];
}
else if($_POST["item"]=="Accept"){
$notificatioSetting->AcceptTrackRequest=$_POST["status"];
}
else if($_POST["item"]=="Deny"){
$notificatioSetting->DenyTrackReques... |
I reproduced my version of Abstract Factory Pattern in Java. I know it's redundant but can I get critical comments about my code. Is it really the classic implementation of the pattern or not?
/*
* The demonstration of Abstract Factory Pattern
*
* Here the 'DocumentFactory' creates documents of types
* 'Resume' or 'L... |
I wrote a simple function to determine if a year is a leap year or not. It works, but does not feel idiomatic.
isLeapYear :: Int -> Bool
isLeapYear year =
(mod year 400) == 0 || ((mod year 4) == 0 && not ((mod year 100) == 0))
Is there a more "haskelly" way to write this function ?
|
I am currently discovering Golang, and I try to implement some random variable generation functions similar to R functions.
To avoid code repetition, I'd like to use inheritance, which is quite complex with Go at first sight.
Each variable implements a x.R() method, which generate a random value following x distributio... |
I'm developing a website and I cut the images that I will use:
<div class="news-top">
<p>CSS contains the top image</p>
</div>
<div class="news-center">
<p>CSS contains the center image (repeat-y)</p>
</div>
<div class="news-bottom">
<p>CSS contains the bottom image</p>
</div>
And inside news-center class ... |
I am building a simulation where you have 'Agents' distributed over a rather large landscape. Because the number of Agents is small, compared to the size of the landscape, I use the PIC approach where the landscape is divided into rather large cells and every cell can contain multiple agents - in contrast to a classica... |
Can this code be made more like idiomatic ruby using methods such as map or inject?
@random_tour is a variable length array of points on a graph:
[[0, 0], [2, 1], [4, 3]]
I want to calculate the distance to reach each point using the manhattan distance (number of moves horizontally + number of moves vertically).
For ex... |
I have an assignment to encrypt files (+- 1 gb) and speed is an important factor. I am also kinda forced to the C# language since nobody in my group knows C++. The time now recorded for 100 mb is 12 seconds could somebody give me advice if it is possible to improve the speed my encryption function below.
private void b... |
The idea is, you enter an amount of ships, for example 10. It will then place 10 ships on a 10x10 grid (0-9). You may enter a coordinate, and it will tell you if it is a hit or a miss. A simplified version of the well-known board game.
C indicates 'Computer'. These are not shown on the grid, but are stored in the 2D a... |
I have the following structure of a table:
| id | profile_id | sku | vendor | price | importRun |
| 1 | 39 | 123 | myVen | 2.0 | 1 |
| 2 | 39 | 456 | myVen | 2.0 | 1 |
| 3 | 39 | 123 | myVen | 3.0 | 2 |
Related: StackO... |
Here is my script which takes 50k records from a CSV and does CRUD operation with them. Unfortunately there are a lot of issues with the performance.
CSV fields are: msisdn, resellerid, product
Following are the steps performed:
Read the CSV.
Create Temp table.
Select top 1000 records and mark the status with random s... |
Purpose
Implement a solution that returns the values in the Nth row of Pascal's Triangle where N >= 0.
Math
First three rows of Pascal's Triangle:
1
1 1
1 2 1
...
...
These row values can be calculated by the following methodology:
For a given non-negative row index, the first row value will be the binom... |
public static List<Integer> storePrimes(){
int limit = Integer.MAX_VALUE / 10;
boolean primes[] = new boolean[limit];
List<Integer> primeList = new ArrayList<Integer>();
int i = 2;
while(primeList.size() <= 10001){
while(true){
if(primes[i] == false){
... |
I've written a C function to find the program less that the operating system should provide. If lessis not provided, some other pager variable should be used. I compile it with gcc -ansi -pedantic -Wall -O3.
int findless(char *less_token, int ret) {
int breakloop = 0;
char *new_str;
while (less_token != NU... |
I was wondering if there was a better way of writing this...
I have a CSV file (about 6640 lines). After reading through the file, the values for the DFN_Network are stored in a list. After that the values of the DFN_Network are matched with their corresponding existence in the values of the dictionary all_dictionary. ... |
Requirement:
Python Function will read a LIST of TUPLES. The structure of the tuple is ("STRING", "STRING","STRING",INT,"GEOGRAPHIC VALUE")
This Geographic value can have 5 values "zip", "city", "county", "state" and "country"
Now if a Tuple has elements where geographic values are (....,"zip"),(....,"county"), (....,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.