instruction stringlengths 71 71.9k |
|---|
Using pandas and Python 3, information about a simple timeseries data set is being processed. Within the span of .5 seconds, 3 names are being said. We record the onset of each utterance, the length of the name, and the sex of the referent, and store it in a sparse Pandas DataFrame.
We also construct a second DataFrame... |
I was attempting an online problem given on a programming website which asked us to tell us the number of integers in a given list which can be obtained as an average of any two other integers in that list, where one of them can be equal to the average (so the other is obviously equal too).
The server tells me that my ... |
I have the following query:
SELECT *
INTO ##TempStaffT
FROM Staff HF
WHERE HF.[businessline_id]='T'
AND HF.[offices_id] IN (SELECT * FROM ##TempParamOffice)
AND HF.[specialism_id]IN (SELECT * FROM ##TempParamSpecialism)
AND HF.[onetouch]IN (SELECT * FROM ##TempParamConsultant)
SET @sql4 = N'
INSERT INTO ##TempFee... |
This script updates a settings in ssl config file for Nginx. I generate DHEC key and then update the Nginx SSL file to that location. I also give an option for the user through arguments if they want to change the bit size of the key and if they want more conservative or hardened SSL cipher suites.
I don't know how to... |
I am designing a web application and a windows service and want to use the unit of work + repository layer in conjunction with a service layer, and I am having some trouble putting it all together so that the client apps control the transaction of data with the unit of work.
The unit of work has a collection of all rep... |
I have created a java program that should take a list of conversions and be able to convert one unit to another. My main goals are maintainability and readability, but speed would be nice as well.
Example input.in
1 meters = 100 centimeters
10 millimeters = 1 centimeters
1 meters = 0.001 kilometers
1 kilometers = 10000... |
I am working on a personal project for managing one's Pinboard bookmarks. Since this is already quite a big project, I am not sure if my question fits the guidelines. My main concern is with the complexity of one of my controllers. I have the feeling I should cut it into smaller controllers or directives, but I am not ... |
I just wrote a program to solve one dimensional Euler equation for fluid dynamics. Attached is a snippet of the vtune profile result for one of the function.
There are a few things which looks weird to me. For example, difference in line 72 takes more time than division in line 70. Also line 70 takes more time than 69... |
This is my first attempt at a programme. Is it good form? Does it follow best practice? Or am I completely off the mark?
#include "stdafx.h"
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
string a;
string b;
string enterName()
{
while (true)
{
cout << "what is your na... |
My main concern in this script is the 'js' task. Each time I change 'frontend.js' I concat and minify 'jquery.js', 'bootstrap.js', and frontend.js. I'm only really editing one file, yet on every save I am concatenating all three and minifying. Is there a better way to to this?
// Load plugins
var gulp = require(... |
I've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity.
Sure the complexity buys you (sometimes) full decoupling from Entity Framework, which in theory would possibly allow swapping EF for, say, NHibernate, or even "downgrade" to a lowe... |
I am creating a simple SqlHelper which will simplify the ADO.NET method usage. Can someone please review this class for any issue or missing something?
public static class SqlHelper
{
public static async Task<int> ExecuteNonQueryAsync(string connectionString, CommandType cmdType, string cmdText,
params SqlP... |
Now that I know that MVC can help do better code, I want to make my SettingsTableViewController class conform to it.
SettingsTableViewController is a subclass of UITableViewController. It is linked to a storyboard scene that contains a UITableView with two cells (grouped tableView style, prototype cells). The first cel... |
Project Euler presents problem 17:
If the numbers 1 to 5 are written out in words: one, two, three,
four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in
total. If all the numbers from 1 to 1000 (one thousand) inclusive
were written out
in words, how many letters would be used?
Pleas... |
I'm busy on a site, and we've made a custom Twitter class. The tweets are send from our panel, where they're posted and saved in the DB. In this class, we get the tweets from the database and show them on our site.
These are my helping points:
Is this code as efficient as possible?
Is there a easier way to achieve the... |
In mathematics, the Bell triangle is a triangle of numbers analogous to Pascal's triangle, whose values count partitions of a set in which a given element is the largest singleton. It is named for its close connection to the Bell numbers, which may be found on both sides of the triangle, and which are in turn named af... |
Followup to Simple key-value store in C.
Response to previous reviews
You may want to hide the KVSstore structure
Done.
Add a comparison function pointer to KVSstore. If this pointer is null, kvs_sort_compare just compare key pointers, otherwise, it passes the keys to the comparison function.
Done, now kvs_create ... |
I'm looking for your opinions on anything that I am doing wrong in the application below, such as best practices, glaringly horrible errors or even just your own personal opinion.
Task: Grab an Nginx access log, ask it some questions and dump responses out to a templated report.
I have removed all comments from this po... |
I am using the following code poor form. I am interested in how I can optimise this and use the correct methods. I understand the DRY concept and will look to employ that throughout my code. However, this works and its pretty quick too, even with large result sets. I would like to learn and improve this code.
<?php
... |
Following-up on the Automagic testing framework for VBA review, I've refactored much of the TestEngine static class, and introduced a TestMethod class.
Refactoring part of the TestEngine into its own class introduced new problems that needed new solutions; because the client code is using the Assert class default insta... |
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.MutableDateTime;
import org.joda.time.ReadWritableDateTime;
import org.joda.time.Weeks;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class WorkDa... |
I am trying to implement a program which can convert number into words. My code can convert numbers between 0 - 999. It uses recursive function calls and simple arithmetic operations. Can you please review it and give me your feedback?
I used three different vectors to store words such as "Six" and "Eleven" and then a... |
I have a task which I need to run every 6 in the morning. I have the below code which does the job and uses ScheduledExecutorService.
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int hour = calendar... |
I am wondering if there is a more efficient route to take here. Using AspNet.Identity I would like to allow the user to sign in to the same text box using either their usernameor email. I went ahead and addressed this issue in theAccountController Login ActionResult`.
I run the check before calling:
var result = awai... |
The following working C++11 code demonstrates working code for a pattern for representing one-to-many relationships between objects.
GitHub
(A variant of that code is also copied inline at the bottom of this post).
I think these are the desirable features:
Children only created through owning parent so that they are m... |
I'd really appreciate some general formatting/style/performance tips, as well as any ways I could improve this code in general that I wrote for an assignment (title) that's due at the end of the week. The code passes every test input given (leap years and such), so the logic is all set. I had the HashSet as a List or... |
I have that XML-to-JSON function based on ElementTree. It looks very simple but until now it does what it's supposed to do: give a JSON description of the document's ElementTree.
import xml.etree.ElementTree as ET
def dirtyParser(node):
'''dirty xml parser
parses tag, attributes, text, children
recursive
... |
I have written my first Python script that will go into live use at my workplace. I am relatively new to Python and I think this script is pretty good but I would like your input.
It runs very fast, as far as I can tell (~0.01seconds). It is also my first time writing a script that takes arguments from the way it is c... |
I have a 2D array (or rather, an array of arrays) representing tile maps in game. The 'world' map array holds smaller arrays representing individual map parts which I am calling 'rooms':
var worldMap = [
[room1, room2],
[room3, room4]
];
I have some code which takes note of the 'current' room (which will be vi... |
I'd like to refactor my extractSimplePromptName so it does the same but it's "prettier", hence less code. As far as looking at it, it seems like it could be refactored so it does the same thing, but it's just less code.
I'm guessing it has something to do with putting some stuff out of the first if sentence or perhaps ... |
Is there a better way to implement my code in Java? I used to code this in C++ and pretty much worked right off the bat. But in Java, it is different, as it won't let me input data on the string array name. It seems to skip and move on to ask the user for the age rather than starting on name.
package student;
import ... |
I am trying to solve longest collatz sequence problem under 1000000 with the below code. Can anyone suggest a faster way to approach this problem? I was thinking of dynamic programming, but I'm having trouble in understanding it.
#include <stdio.h>
long long int col(long long int n)
{
if(n==1)
{
retu... |
I am very new to JS and am having a bit of a problem with making this happen.
function updateDisplay23() {
var statElem = document.getElementById("stat_ht");
if (statElem) {
statElem.innerHTML = stats["ht"];
}
}
I load all the functions from the index at the startup then call the function with:
updateDi... |
I am new to Ruby on Rails. Can some one please help me with this question?
How would you modify the following to be consistent with Ruby's style?
class Add_dash
def dashesHere(word)
attachTheDashes = "--" + word + "--"
return attachTheDashes
end
end
|
Some time ago I wrote a series of functions for turning a string of user information from multiple users an array containing the information needed: Name, username and location. The raw userinfo string (userinfo_raw) looks like this:
1074;#Fring,, Gustavo (US - New Mexico),#i:0ǵ.t|adfs|gfring,#gfring@LPH.com,#gfring@lp... |
I am working on trying to create a range function in JavaScript that imitates PERL's 'a'..'zz'.
which expands to:
a->z
aa->az
ba->bz
...
za->zz
And so on for every extra character you add to the end of the range( e.g zzz .... ).
I have a working implementation, However, I think that there is a more efficient - and pe... |
I was tasked with conducting a large number of text searches in the code files of multiple projects. Initially, I just used the Find in Files feature of Visual Studio in a couple of the running instances, but then I realized I needed to search other solutions as well. So I quickly created an F# Script (below) to condu... |
For the last few days I have been working on this code to develop a class that allow me to crypt a block of byte with many algorithme.
One block will be divided into three equal blocks and every block will be encrypted and decrypted by one of the three algorithme.
I want to discover the main weak points of my code espe... |
I've created this little library to help ease myself (and for others, hopefully) with the pain of having to convert integers to string and vice-versa. It's written in C, and for maximum portability I decided to try and stick to C89 (no booleans yet by that time I believe). I'd like to ask you to give some of your comme... |
Currently I check whether a string contains all words from an array like this:
function contains($string, array $array) {
$count = 0;
foreach($array as $value) {
if (false !== stripos($string,$value)) {
++$count;
};
}
return $count == count($array);
}
Example call:
$string =... |
cout << format(
"%? %?!\n" // Hello world!
"%1% %3% :)\n" // Hello again :)
"%%05X: %05X\n" // %05X: 01234
"%%g: %g\n" // %g: 3.14159
"%%.3f: %5$.3f\n" // %.3f: 3.142
, "Hello", "world", "again"
, 0x1234, 3.14159265f);
The above shows the usage of universal formatting ... |
I'm using $window.scroll twice in a jQuery script for different uses. Should I try and combine them?
jQuery(document).ready(function($) {
// Add class .fixed when .site-header hits top of viewport
var distance = $('.site-header').offset().top,
$window = $(window);
$window.scroll(function() {
if ( $window.scr... |
On the main view, all you see is a button to click on that says, "start setup". Once the user clicks on Start Setup, a file is read in the background and a progress bar is shown in the main thread. Once the "setup" is complete, a "Setup Complete" notification should pop up. After that, some kind of status indicating th... |
I wrote a set of extension methods for the EventHandler class that add the method Fire, which raises the event after creating a local reference for thread safety, and checking to make sure the event had subscribers.
public static class EventExtensions
{
/// <summary>
/// Raises an event thread-safely if the eve... |
I'm working on a project to find anagrams of words. My goal is to figure out the longest anagrams out there. I took a look at my code and it works but is woefully inefficient.
I have two arrays, each containing a length of long words:
words_one = ["sarcocarcinomata", "dactylopteridae", "autoradiographic", "pterylograph... |
I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing these different tasks in an efficient and or correct way.
This section is of the MySQL Connection class I ha... |
I have written code to return anagrams from a list of words. I'm a newbie in time complexity analysis so pardon my ignorance if this is a blatantly obvious question. Am I right in thinking this is in O(n log n) time, since it's just performing a quicksort and the rest is done in O(1) time because it's hashmaps? Also an... |
I've been learning C# and was looking for some feedback on my latest project, which is a standard Noughts and Crosses game. Two people are required to play (no AI yet).
MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Win... |
Lately I've been working on a small C++ Entity-Component-System framework.
Like most other ECS frameworks the internal data is presented as a table where an entity is a simple row index and each Component type maps to a column index.
In contrast to many other C++ ECS frameworks that usually map the Components to the in... |
I am trying to solve the below mentioned problem from HackerEarth.
Although the results are fine, the code takes extraordinarily long time to run execute. I am pretty sure the problem is because of the nested loops, and I am working on it.
I would like to know:
How can this code be optimized to run within 1 sec?
What ... |
I am working on a project in Angular where I have a number of similar data objects. When you click on anyone of them it's state and amount of data shown will change. All of the objects start in the minimal state, when you click on one it becomes medium. From a medium you can click on the button to go to maximum or clic... |
I am building a store. When a user decides to make a purchase I need to store it in the database, but since the purchase might be of more than 1 item I'm wondering which way is the best to insert multiple rows, here are my 3 options.
I use a database object that combines PDO with PDOStatement, which is why I don't defi... |
A friend sent me this question, and I'd love somebody to review this and give his opinion.
Write an algorithm that counts the number of ways you can paint a
fence with N posts using K colors such that no more than 2 adjacent
fence posts are painted with the same color"
Is this algorithm accurate? Could it be impl... |
I am trying to teach myself about repository pattern in ruby. Could you please review my code.
adapter.rb
module Adapter
class Main
def prebuild(obj)
self.set_table_name = obj.table_name.to_s
variables = obj.instance_variables
@values = []
@keys = []
variables.reject! { |c| c.to_s =... |
I have below snippet of code which gets all the available menu items for a zone(top or left)and adds the widgets for which user has access to an ArrayList collection. For now the getWidgetsByZone(zone) returns 64 items and iterates over them. Am seeing some performance lag in this method(in a tool called GlowRoot which... |
I'm practicing algorithms (for future interviews) while learning about Big O notation and was wondering if there's a faster or more optimal way of writing an algorithm to see if a string has all unique characters (assuming you can't use additional data structures).
- (BOOL)containsUniqueCharacters:(NSString *)string {
... |
Any tips on how to improve my code and make it cleaner to read for other programmers? Formatting, spacing, etc.
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <cstdlib>
#include <windows.h>
using namespace std;
int main()
{
int userInput;
int number;
int min = 1;
int max = 10;
... |
I've been developing a metalsmith static site and I came across an issue where Visual Studio was automatically adding a BOM to the pages.
I wrote the following plugin for metalsmith (it needs to be run as the first plugin). This feels a little messy. It was written mostly as a copy-paste and a lot of debugging.
var st... |
The following function finds all local maxima.
A local maxima is an element of a list such that it's greater than either of its neighbor elements. An element with 1 neighbor is not a local maximum.
localMaxima :: [Integer] -> [Integer]
localMaxima (x:y:z:zs) = if (y > x && y > z) then y : localMaxima (y:z:zs)
... |
I would like if someone who has more experience in JavaScript reviewed this. I went through and tried to minimize this as much as possible, but I still feel this could be smaller and more compact.
I am really just looking to see if my way of making a low-level solution in JavaScript needs to be a bit more polished.
fu... |
I have written two queries for searching, but I want to simplify them as it seems needed.
def searching(term: String): List[String] = {
DB.withConnection { implicit c =>
var list = List[String]()
val pinfo = SQL("SELECT body FROM tableName WHERE body like {term} limit 0,14 ").on("term" -> ("%" + term + ... |
I mean the Builder presented in Effective Java by Joshua Bloch.
OnStopScrollingObserverTask is using to detect when scrolling a ScrollView stops.
Please criticize my code and tell me if using Builder for such a simple class is too excessive.
public class OnStopScrollingObserverTask implements Runnable {
public sta... |
I'm going through the Adventure in Prolog tutorial and I'm trying to implement an open/close rule for each of the doors I have.
Add an open/closed status for each of the doors. Write open and close predicates that do the obvious
:- dynamic here/1, location/2, have/1, turned_on/1, turned_off/1.
room(kitchen).
room(off... |
I want to check if the given string is a Panagram or not.
A Panagram is a sentence containing every letter of the alphabet at least once.
This is what I've come up with as solution:
import java.util.Scanner;
public class Panagram {
public static void main(String[] args) {
Scanner sc = new Scanner(Syste... |
I'm designing a web interface to a controller for my school's bell. Are there any security flaws in this code?
The source code is available here.
Front End:
bell-ringer.cgi:
#!/bin/bash
function unescape
{
local s="$1"
while [ "a$s" != "a" ]; do
if [ "a${s:0:1}" == "a%" -a "a`echo "${s:1:2}" | sed '{s... |
This is a revised and expanded version of Transforming complex strings into simple arrays
My function grabPerson turns strings of user information from multiple users to "business cards" on my webpage, via an array containing the information needed: Name, username and location.
The raw userinfo string (userinfo_raw) lo... |
I've been given a task to create elements with some special corners, and those elements should be responsive.
This works, but am I wondering if something better could come up.
Less code to maintain.
I wish NOT to use any CSS Preprocessor. I prefer the more readable pure and simple CSS.
jsFiddle
<div class="module-wr... |
I'd like the following to happen:
var person = new Person(); // Create instance of new person with Id 0
var person1 = new Person(1); // Creates instance of existing person from database
var list = new Person().List(); // Creates instance of all persons from database
I'm sure there's a better way than what I'm currentl... |
I am preparing for interview and I want to write the function in the way that the interviewers will expect me to write.
private static void printReverse(ListNode l1){
if(l1 != null){
printReverse(l1.next);
System.out.print(l1.val + " ");
}
}
However, this function does not d... |
I am reading a ~120 MB log file (~300 Million lines of text).
...
30/05/2014 15:07:18 0000030-0000738 Net SourceID 11000006
30/05/2014 15:07:18 0000030-0000738 Communication RouteID 108
30/05/2014 15:14:44 0000030-0002027 Communication Route_Complete Already Completed
30/05/2014 15:07:40 0000030-0000739 Communication... |
I have a block of code that checks to see if a check box is checked or not, and assigns a value to a variable for saving to a MySQL table. There are approximately 8 of these boxes.
if ($("#amOld").is(":checked")) {
var amOldGuide=1;
} else {
var amOldGuide=0;
}
if ($("#folOld").is(":checked")) {
var folOld... |
I was wondering what would be the efficient way to determine the value of a position on an array based on its nearest datapoint known value in Python?
Problem description:
There are datapoints in an array which are 1000 units apart and their values are known (see the figure). However,
there are datapoints which fall... |
I have this code for updating time of login failure.The other parts of the code are stripped and simplified because my question is related to PDO.Here I have a db_config.php and a function to update time.I want to know is this a best practice for PDO connection and accessing variables in a function?
db_config.php
<?p... |
I have the following query which updates the quantity when there are duplicate items and users (there should only ever be 2 duplicates), then deletes the row which doesn't get updated...
UPDATE cart_items t
JOIN (
SELECT MinID, b.itemQuantity LatestName
FROM cart_items b
JOIN (
SELECT MIN(id) MinID,... |
I have a list of posts. I need to generate it each one by one. For generation of each post, I need to know about other posts. However, I want to make the current post marked.
def generate(posts):
print(posts) #faking generation
def marked_active_post(orig_posts, active_index):
posts_view = orig_posts.copy()
... |
I have this code and I want to generalize it and make it efficient. Each time I generate a number of random variables and I put it in the m equation to generate m. Can I get any help to simplify this code till m[20] ?
m[0]=0
x=rnorm(1,0,1)
m[1]=max(0,x[1]-0.2+m[0])
x=rnorm(2,0,1)
m[2]=max(0,x[2]-0.2+max(0,x[1]-0.2+m[0]... |
I am working on a project called neoCode that takes a users input URL and turns it into HTML or Machine Code. I am so close to pushing this to TestFlight for beta testing but I have a pretty bad performance issue that I can't figure out.
Let me first start by explaining what the app does and then at the end I will le... |
function parse_request_uri() {
$parts = [];
if (array_key_exists('REQUEST_URI', $_SERVER)) {
$request_path = explode('?', $_SERVER['REQUEST_URI']);
$parts['base'] = rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/');
$parts['path'] = substr(urldecode($request_path[0]), strlen($parts['base']... |
I tried to build a solution to dynamically load JS code, but to only expose predefined functions. Is this the correct approach? Is there any Method to execute arbitrary code if I put all my code inside of (function($$) { ... }).call({}, $$) statements?
// scope.js
// $$ holds all global variables, and is not accessible... |
I wrote a set data structure with some useful functions. I'm not sure if it is a good implementation and if there are other essential functions that a set should support.
class CustomSet
def initialize(list=[])
@cs =[]
list.each do |n|
put(n)
end
end
def size
@cs.size
end
def each(&... |
I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing these different tasks in an efficient and or correct way.
This section is of the system configuration file (... |
I have a project that reads spreadsheets as a rectangular list of lists (matrix) transforms the matrix and then writes it to another spreadsheet. I want to be able to read from and write to multiple formats. Consequentially, the program should double as spreadsheet conversion tool.
Here is an example of just copying ... |
Leaving aside absolutely everything about the code itself (but if you find stuff that's not ok feel free to comment on them).
What I'm asking here is the following:
Is my code properly commented? Should I add more comments?
Is it understandable as it stands?
Are there some general rules that I should adhere to when... |
Continuing my C++ saga, this is the third project for my CS1 class:
Buoyancy is the ability of an object to float. Archimedes' principle
states that the buoyant force is equal to the weight of the fluid that
is displaced by the submerged object. The buoyant force can be
computed by
$$ F_b = V \cdot y $$
where ... |
The following code is my first C program I have made for an university assignment about Interprocess Communication. This involved creating a parent process, the farmer, and then creating a certain number of forked processes, the workers, and we had to let the workers calculate something and use message queues to commun... |
Yes, another FizzBuzz! I know you guys may be tired of these but I think it's a tradition stepping stone for beginners on this site.
Here are some notes on my thinking:
I tried to keep it as flexible as possible where the logic is deducted from the variables as much as possible. So one could potentially make a user in... |
I'm trying to improve the security for my backend:
/**
* This is the script that is executed when I add a new user - after the input has passed the validation.
*/
$salt = base64_encode(mcrypt_create_iv(24,MCRYPT_DEV_URANDOM)); // generate a random 32 character salt
$hash = hash('sha256',$salt.$_POST['secre... |
I wrote a function, doSkip.
For an N-sized list, an element at index 0 consists of the entire input. Index 1 consists of every other element, i.e. the odd elements. Then, indexes 2 to N consist of the respective index of the input.
doSkip :: [a] -> [[a]]
doSkip [] = []
doSkip [x] = [[x]]
doSkip xxs... |
The Collatz Conjecture is related to a type of problem called a Hailstone problem; because hailstones circulate up and down through a cloud around a planet until they eventually fall. The Collatz conjecture posits that for the function
$$
f(n) = \begin{cases} \text{even: } & n/2\\ \text{odd: } & 3n+1\end{cases}
$$
the ... |
I acknowledge that this exact question was asked here. I was working on the same problem from the same website. I had the same question and consulted the above as a reference, however with respect to the person answering the question, it is the wrong answer. That is why I decided to restart this thread.
Problem
With ... |
Using the accepted answer from this question, I made a random number generator which can regenerate previous numbers in order.
Ideone version
byte[] Encrypt(byte[] ClearData, byte[] Key)
{
MemoryStream ms = new MemoryStream();
Rijndael alg = Rijndael.Create();
alg.KeySize = 128;
alg.BlockSize = 128;
... |
I am currently learning Haskell in parallel of following the Scala course proposed by Coursera.
To practice Haskell I try to implement exercices and/or course example from this course.
So there is a simpler square root estimation implementation:
sqrt' :: Double -> Double -> Double
sqrt' x guess
| guessIsGoodEnough = ... |
First of all, here's the code I'm working on:
def get_data(filename, cols):
with codecs.open(filename, 'r') as csvFile:
for row in csv.reader(csvFile):
# build data dictionnary
data = {}
for i in range(len(cols)):
key = cols[i]
# update
... |
I have some experience in Java. I am reading Effective Java by Joshua Bloch, the book talks about Builder pattern which I was unaware of. So,I have assembled a quick example of what I think builder pattern is all about. Is my implementation correct? Are there any gotchas in Builder pattern?
/* Object to be built using ... |
I am in the process of learning JS and I constantly have feeling that my code is bloat and not optimal.
I built this simple DEMO of background changing on click. Can somebody tell me if this is good approach to build this, what can be improved? Can I write this with less code?
jsFiddle
HTML
<div id="one">
<div id... |
For a school project I'm working on a small library to do steganography. I've just finished the first method of steganography and thought I'd get some feedback.
This steganography method works by changing the last bit of each channel of each pixel to a bit of the file. Reading the file from the image does the reverse o... |
I am very new in Python, I would like to know if the style presented below attends a good implementation in Python.
import numpy as np
from collections import deque
def BFS(theGraph,source):
n=len(theGraph)
explored=np.empty(n,bool)
for i in range(0,n):
explored[i]=False
explored[source]=True
... |
I am making an application using Phonegap where users can select and share files. When the user selects it, even if it goes offline or closes the app, I should upload it back to the server, so I need to store the reference file path.
Steps I have used:
User selects/captures video or image using Camera.
File may not co... |
Is my implementation of quicksort efficient, in-place, pythonic ?
def quicksort(array, lo, hi):
if hi - lo < 2:
return
key = random.randrange(lo, hi)
array[key], array[lo] = array[lo], array[key]
y = 1 + lo
for x in xrange(lo + 1, hi):
if array[x] <= array[lo]:
array[x], ... |
I have made two SQL statements as I was unable to figure out how to solve my problem. One is called Product_GetID and the other Product_SaveRecord. I wanted the save record to read and see if there was an ID entered in a field in a VB front end and if there was not, it would assign one for it, but I was unable to figu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.