We are designing a small framework to create and send messages to external parties as a result of internal events. I am reasonably happy with the design, but I am wandering if it can be further improved.
The external messages are large and complex and involve getting data from different areas i...
Out of curiosity, I built a recursive Sieve of Eratosthenes in Python and I was wondering how it could be improved for efficiency and how it can improved to be aligned with python best practices.
Essentially, there is a recursive function (coded horrendously IMO), filter_multiples, which removes...
I hate having unnecessary catch blocks to make my code look beautiful. In most of the cases in my project, which is a web application(not a web site), I can't declare many exceptions as checked exceptions as there is little that my client(browser or alike) can do to recover from the exception. Ho...
I wanna to create an one way sync mechanism from django models to cloud datastore. My first version reference django's manager design.
An manager take care of sync
from gcloudorm import model as ndb
class DatastoreManager(object):
def __init__(self, model):
assert isinstnace(model...
I wrote this code with lists, but the program never seemed to come to an end. I rewrote it with arrays, and it's still the same. Starting from 10, increasing the number 10 times seems to increase the program run time by roughly 100 times, and at this rate it will take about 15 days for it to comp...
I'm trying to solve Project Euler for the largest palindrome from a 2 3-digit number. Please take a look at my code and I'm wondering why I'm not getting any output. thanks!
public class Palindrome
{
static int product;
static StringBuilder SB = new StringBuilder();
public St...
Can anyone please check the solution below to find the minimum no. of coins to make up the given sum from the list of the denomination of coins. I used the greedy approach with recursion. Actually I tried this with Dynamic Programming approach but time complexity was very huge when sum is changed...
I'm currently finishing an "application" (I.e. code) for a machine learning, feature extraction framework, written in python (with scikit learn,pandas and biopython). The framework extracts various simple biophysical and informational properties from proteins (think of them as sequences of letter...
I'm moving a system over to PDO and since the queries are parameterized, I need to specify both the type and value of each parameter when preparing them.
Right now I have a prepare method to create the PDOStatement object:
/**
* Prepares a statement
* @param string $sql The query
* @param ar...
I want to understand iterators more, so I used an extremely simple insertion sort to experiment with it. Please review this code.
template<typename C>
void insertion_sort(C& c) {
for (auto i = c.begin(); i != c.end(); ++i) {
for (auto j = i; j > c.begin() && *j < *(j-1); --j) {
...
java.lang.IllegalArgumentException: Raster sun.awt.image.SunWritableRaster@5feb7411 is incompatible with ColorModel ColorModel: #pixelBits = 32 numComponents = 1 color space = java.awt.color.ICC_ColorSpace@45c61c42 transparency = 1 has alpha = false isAlphaPre = false
at java.awt.image.BufferedImage.<init>(Unknown Source) ~[?:1.8.0_20]
at de.vorb.leptonica.util.PixConversions.pix2img(PixConversions.java:190) ~[jleptonica-0.0.3.jar:0.0.3]
Merge Function
void merge(int outputArray[], int firstArray[], int sizeFirst, int secondArray[], int sizeSecond){
int p = 0;
int p1 = 0;
int p2 = 0;
while(p1 < sizeFirst && p2 < sizeSecond){
if(first[p1] < second[p2])
outputArray[p++] = firstArray[p1++];
...
Well, that's why I don't like using third party libraries. Even if I'm only an average skilled programmer, that still means half of all programmers are worse at their jobs than I am. And I already spend enough time debugging my own code.
2
Why would I pay money to get a library full of someone else's bugs?
Hey guys, this question was wrongly deleted on SO. It's a good signpost and of a higher quality than the original, anyone care to cast an undelete vote?
We are trying to make the game othello (reversi from the old nokia)
We now have a swap function, whitch will swap in all the directions (by being called with a number in "richting" (1 to 8)
We have the problem in the part which is called vergelijkvak when we compare:
cmp bx, 1
je @F
jmp ve...
Please don't delete you duplicate question.
Duplicates act as sign posts, lighting the way to the canonical question. Your question used different keywords, different language to ask about the same concept, and now those keywords can be used to find the original.
If you deleted your post you'd ...
If anyone has input on code and structure for a tutorial guide I am putting together for a Express based CRM I would greatly appreciate it. The code is complete but the lesson documentation is in progress at: github.com/webbrandon/simple-secure-auth
I want to do simple encryption using PHP 5.5. By “simple” I mean I want to use native PHP functions. I have created this code that works, can it be improved? It's to encrypt/decrypt strings and binary files that are to be stored in a database and accessed via a website. Assume that it is done ove...
I have written a simple wrapper for WinSCP in C#. I have written it to simplify SFTP connections I will needing to perform.
public class WinSCPConn : IDisposable
{
//private fields
private SessionOptions sessionOptions;
private TransferOptions transferOptions;
pr...
I have created a system where user select files from their Google drive, and where I would want that file selected to be uploaded into Parse.
I have done so separately though, where I have one code that allows user to select an item from Google drive, and one that allows user to upload a file fro...
I am using a recursive directory scan to find all objects inside a unity3d project. After that I wish to move all these files to a sorted List. Is there a cleaner and/or more optimal way off doing so? Because I have the feeling the AssignFileToList could be less complex than it currently is
publ...
Anyone able to give input on code for a tutorial guide I am putting together for an Express based CRM using MongoDB, I would greatly appreciate it. The code: github.com/webbrandon/simple-secure-auth
I am working on a web app that uses a WebSocket to log in users. I would like to minimize bandwidth usage by using binary messages. I came up with the following, and would like to know whether there is something better I could be doing:
-define(LOGIN, 1).
websocket_handle({binary, <<?LOGIN:8,Le...
I am new to python. I have tried to implement In-Place QuickSort Algorithm in Python 2. Please suggest how I can
make the code more efficient
increase readability
improve writing style
make it more pythonic
Below is the code:
def swap(x,y):
return y,x
def sort(ar, start, end, l):
...
I'm trying to read doubles from a relatively small binary file. This currently reads a 100 KB file in about 6 milliseconds in my system. I would like to reduce that if possible.
void readNParseData(const char* filePath, vector<double> *&data){
ifstream ifs(filePath, ios::in | ios::binary);
...
InputStream in;
try{
in = new FileInputStream(new File ("C:\\Users\\Sony\\Desktop\\all_shook_up.wav"));
AudioStream audios = new AudioStream(in);
AudioPlayer.player.start(audios);
}
catch(Exception e){
System.out.println("Wrong.");
}
Whenever I run this program, the output s...
There are some cases with Java (since Java has its own agenda in the JVM) where you may not see the error in the code, but rahter it happens when Java has its own fun. You can however tell the JVM that certain things have to happen in a certain order else all hell breaks loose.
@Hosch250 I don't really agree with that (as a general thing), since at least in java, you can write really stinky code and it works, until you try to add or subtract to it.
Just because it runs it doesn't mean it's good code.
I have a Windows Store and Windows Phone app, and in this app I have many pages like this:
<Grid Background="Transparent">
<ScrollViewer Style="{StaticResource DataPage}">
<StackPanel>
<TextBlock>
Some text here:
<LineBreak/>
<...
I like what little C++ I did and still remembetr from highschool, but Java fits the bill. It'll land me a job and I can keep learning other languages on my own in the spare time :3
My problem with WPF in general is that it seems half-baked. Microsoft did a lot of cool things with it, but seemed to omit the drudgery like providing useful exceptions and more than a bare-bones list of user controls. I don't do enough UI work to see if it ever gets better, though.
@skiwi - I look at that code, and it took me so long to figure out that the first line was not the problem you were referring to, that I did not see the logic fault until I read @Hosch250's comment
I am doing the Python Koans to practise python a bit more and I got to the greed dice project. It is a very simple dice game that scores a set of up to five rolls.
These are the rules:
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
# * A set of three numbers (ot...
I am displaying menus and submenus in my WinRT app, and I think I am doing it wrong. I have though I was doing it wrong for a long time, so here it is for review.
This is the section in my ViewModel. Probably needless to say, both Remove() and NewSelectionWS() have had large quantities of near...
I am displaying menus and submenus in my WinRT app, and I think I am doing it wrong. I have though I was doing it wrong for a long time, so here it is for review.
This is the section in my ViewModel. Probably needless to say, both Remove() and NewSelectionWS() have had large quantities of near...
When this ViewModel loads we kick off the IsAuthenticatedCommand:
If the result of IsAuthenticatedCommand is false we set the value of NeedsToLogin to true.
If the result of IsAuthenticatedCommand is true we set the value of IsAuthenticated to true.
There are subscriptions (btw: is that the co...
What is syntax highlighting?
Syntax highlighting allows code in posts to be highlighted based on the language it's written in, to make it easier to read.
How does it work?
Stack Exchange does not have its own syntax highlighting engine. It uses Google Code Prettify. Therefore, any bugs and fea...
I have no idea what I'm doing, that "parser" is a shame.... badly, badly, badly written, understands a fraction of the language, ...and no review has pointed it out yet... or is the wheel octogonal and "round enough" to just feel a little clunky but functional? I wonder...
@JeroenVannevel I'm starting to seriously consider it... but no, haven't. I totally played by ear.. worked for guitar, should work for parsing VBA, no?
A split-string function seems to be missing in R7RS.
I came up with the following implementation today:
(define (split-string delim str)
(let ((add (lambda (current output)
(cons (list->string (reverse current)) output))))
(let loop ((input (string->list str))
...
@Hosch250 the input is a string[] where each index is a physical line of code. I think I corectly turned those into logical lines of code, but I'm losing the physical line numbers along the way (although I can "fix" that pretty easily). The output ought to be some SyntaxTreeNode, but I think that class may need to be molten and reforged.