SE sites use Google Code Prettify for code formatting. While it's still up in the air as to whether we would be able to get SE to use community-voted code formatting, I've been experimenting with Prettify.
There are a few options for line numbering in Prettify, and I was interested to know what...
@Phrancis, if it's your preference you can edit your editor to have bold styles here and there but nothing that I have seen so far in the standard IDE.
if you can install it on Mac all you need to do is to press Ctrl + Shift + P (or it's equivalent ( I would say Command + Command + P ) and type SSPython
or any other language. Then it will pretty it for you
a = 5
b = a + (a = a + 5)
result b = 15
Why the first 'a' do not changes after that (a = a + 5)? But why second one changes? What exactly is happening here by steps?
We have a jquery-mobile tag, and there are questions with jquery and mobile. Should all of these be retagged, possibly along with others? I'm not sure how important this tag is.
@Mehrad I see that. I just have reservations that the community would like a black BG (though I'll make one just for kicks) I'm looking to replicate as closely as possible what a standard IDE formatting would be
'use strict';
var State = function (definitions, autostart) {
var keys = Object.keys(definitions);
for (var i = 0, l = keys.length; i < l; i++) {
this[ keys[i] ] = definitions[ keys[i] ];
}
var paused = false;
Object.defineProperty(this, 'isPaused', {
get: function () {
...
My code works fine, continuously outputting whatever audio is input
However, when I try to copy the data to a buffer of the exact same size and then output the copy buffer as I'm doing in the gist, it breaks and I'm clueless as to why
Task: Print sum of first 1000 primes.
public class PrimeSummation {
public static void main(String[] args) {
System.out.println(sumFirstPrimes(1000));
}
// Calculates the total of the first n primes
public static int sumFirstPrimes(int n) {
/* Since 2 is the only ...
We have a new jquery-mobile tag. This is the tag description from to SO:
jQuery Mobile is a touch-optimized web framework for smartphones and tablets. It provides a unified user interface system across all popular mobile device platforms, built on jQuery.
We currently have questions tagged...
I pass variable by reference in the following code:
$arr = array();
$arr[] = array('code' => 123, 'name' => 'Tom');
$arr[] = array('code' => 234, 'name' => 'Peter');
foreach($arr as &$entry) {
$entry['code'] += 100;
}
print_r($arr);
but I saw from this PHP documentation, this feature is remo...
Combination of things. A bit personal, but also for CR
I find the current formatting for code on CR... lackluster, or ugly. Since we're (likely) going to have graduation "colors" this year I wanted to see if we could improve it
SE has employees. They're based in NY I think. Beta sites have pro tempore moderators (chosen by SE, I think). Graduated sites have elections for moderators
just couldn't relate some of us (say you in this case) can pass suggestions such as how the website need to look to the people who actually can make it happen. I mean have an access to the Admin tools
From my understanding, when a graduated site's "colors" (looks) start being worked on, I think some people from SE reach out to the site's community for input..? Really not certain how that works. Moderators can likely provide more valuable input than mine.
In any case, I'm trying to contribute something tangible :)
Only have 4.2K but I guess my posts are mostly well received. But, most of them are SQL, and that's not really programming (IMO) rather just telling a machine to change or fetch some data :)
I thought I would stop by and see how things were going. Although I can't say I will awe you very much. I'm the kind of guy whose top priorities are hot topics like data mapping instead of prime numbers.
I agree, to an extent. A lot of times the problem is not complex enough so a lot of times if you bring high math into it you're taking it there to a degree
Challenge: Write a program that prints out the final series of numbers where those divisible by X, Y and both are replaced by “F” for fizz, “B” for buzz and “FB” for fizz buzz
Specifications: Your program should accept a file as its first argument. The file contains multiple separated lines; eac...
Well, as someone who has been known to rant about how particular stackexchange sites can be about posts, I may not be the right person to help your question along
public static int Calculate(ref Vars vars)
{
int functionReturnValue = 0;
int retValue = 0;
retValue = MethodA(ref vars);
if (retValue != 0)
{
goto Err_Blk;
}
// Gas or pressurised water.
if (vars.CatagoryType == OmgType)
{
retValue = MethodB...
I wrote a view to update my draft object , before updating my draft I need to see if any draft exists for package(draft.package) in db or not .
If any draft available, i need to update that draft's fields.
I am using get queryset to look into db to check draft availability.
I want to know th...
I have a structure like this:
<a>
<b>
<c>foo</c>
<d>bar</d>
</b>
<b>
<c>baz</c>
<d>qux</d>
</b>
</a>
I set /a/b as context and loop through all occurrences to get the texts of c and d.
VTDGen vg = new VTDGen();
vg.parseFile("test.xml", true);
VTDNav vn = vg.getNav();
...
My implementation of generic Tree structure:
/**
* Tree data structure
*/
public class Tree<T> {
private T value;
private Tree<T> parent;
protected List<Tree<T>> children = Collections.emptyList();
public Tree(T value) {
this.value = value;
}
public Tree()...
Previous question:
Text-based Tetris game CRTP 2
Summary of improvements:
Fixed Issues preventing the code from compiling on Clang
Implemented helper class range_impl
Removed all std::initializer_list
Elimination of magic numbers
How can I improve this code further?
#include <iostream>
#i...
I am reading a large data file where the time is given in number of days since some epoch. I am currently converting this to Python's datetime format using this function:
import datetime as dt
def days2dt(days_since_epoch):
epoch = dt.datetime(1980, 1, 6)
datelist = [epochRef + dt.timede...
I am using the following code to copy the contents of two files into one. Earlier I was not closing the Buff and as eclipse gave warnings I did close it. I want to know if this code is susceptible to failure.
public void mergeFiles() throws IOException{
ArrayList<String> list = ne...
Following from this question
I created a Image cache of sorts (let's call it version 1.0) that used WeakReference as "cache" items. And this comes from the accepted answer:
It looks like weak reference would serve the purpose of what you are trying to achieve [IF] those images will go out of...
I wanted to add to the conversation, but I'm not sure this is really an answer, because I don't know. We really need a domain expert here.
jquery-mobile seems to be a good tag. jQuery Mobile is a framework. Traditionally, there's been little question that technology tags are good tags. The singl...
So, yeah..... if anybody knows jquery and jquery-mobile, we could use an expert's opintion there ^
I've got a question about the Single Responsibility Principle... I've got a class that reads and parses a log file, that seems to violate it...
However only the parser itself knows if it needs to know more lines to build up an entry
The main flow of the application is that you read the lines yourself, then ask every parser if it can handle that line, if so it handlesit, but during handling it may request extra lines if it thinks it needs them
I have been using the John Resig javascript class implementation in my web apps, but the tests shows it is really slow. I really find it useful for the way of extending objects, and the benefits got from having a better code and less redundancy.
In some post was explained that it was slow becau...
Here's my function for calculating the volume of a tetrahedron. I've tried to comment well, and perform a few checks on the types of the objects passed to it. Can it be improved for commenting?
I'd also like an opinion about my method for checking the object types: is it better to use assert for...
You should have a reader class and a writer class. Whether or not you want to expose these individually or not is or create a ReadWrite wrapper class is another question entirely.
I have this code, this code used to toggle buttons within a div
var chosen = {};
var form_name = 'the_div';
function(what) {
if('number' != typeof what) { // toggle-one
var el = $(what);
var name = el.html();
var ch = ['success','default'];
if( !chosen[name] ) ...
Last summer we burninated a number of meta tags. These were mostly tags that described what the original poster of a question was concerned about or wanted to have reviewed. I stumbled across the comments tag this morning and I'm thinking it should go.
From the tag wiki:
Comments are non-exe...
I'm new to Bash programming. These functions work well for me. Can they be improved or made more standard in some way?
:<<COMMENT
Alias function for recursive deletion, with are-you-sure prompt.
Example call:
srf /home/jeffy/django_files/rest_tutorial/rest_venv/
Short descri...
I am learning CoreData and I wanted to have my code reviewed. As usual, I get something to work, then I attempt to refine it.
I have a data model that consists of an Item entity and a subItem entity. The Item has a 'to many' relationship with the subItem and subItem has a 'to one' relationship ...
Let's say we have this classes below:
class User(id: int, name:String, userRole:List<UserRole>) {}
class UserRole(identifier:String) {}
class AdminRole(administration:Administration) extends UserRole {} //Administration is a specific feature of this class, could by anything.
class VisitorRole...
Write a application for simulating the work of a FCFS scheduler on a single CPU system, when
processes block due to I/O. Your program should be able to read from a file the description of a set
of tasks and calculate their turnaround time.
An example that illustrates the format of the task specif...
I am declaring a "class" using a "constructor method". In both samples, properties uuid and dateCreated are initialized but in different places.
I would like to know, what is "best practice" in this scenario and why (also in term of readability).
Solution A
define([
'dojo/_base/declare',...
> Did you quit school or do you have a few years of experience with Java? > Experience doesn't matter, just be passionate! > (...) > Profile: > * You own a bachelors or masters degree
I am working in C# to write a scheduling application for operations in a factory. I have a custom class Workday, with properties to represent a Workday for the operations in the shop. And I have a class Timeline that contains a dictionary of DateTimes as keys (using DateTime.Date to make sure we ...
I've built the groundwork for an attributes (as in Stength, Intelligence, not as in DebuggerHidden, TestMethod) framework for my game. Each attribute can be upgraded and downgraded individually as well as part of a bulk change (such as for upgrades that have side effects, or leveling up).
I'm lo...
Given my IUnitOfWork interface
using System;
public interface IUnitOfWork : IDisposable
{
void Commit();
}
I then create an abstract factory interface called IUnitOfWorkFactory
using System.Transactions;
public interface IUnitOfWorkFactory
{
IUnitOfWork GetUnitOfWork(IsolationLe...
lol @JeroenVannevel I'm loving it, they essentially first get you warmed up if you have had experience with Java, and then they say a big I DON'T CARE in case you actually have experience
@CaptainObvious That's a good first question, it ought to get some love votes!
@Donald.McLean Wonder if it's dependent on locale... I tried with 15/03/2012 and 15-03-2012 and both gave an out-of-range exception, even though both are valid date formats (in some countries)
I am learning to code in the Assembly language for the x86 architecture. I currently know of a few registers and certain arithmetic operations like add, sub, inc, dec, mov and to check for conditionality using certain jump statements. I am using some "ready-baked" code for input and output. The i...
I got it working, all variations are displayed Sint-Anna as should be, but I wonder, is there a simpler way to this, since it looks very cluttered?
String.prototype.capitalize = function(){
var sa = this.replace(/-/g,' ');
var saa = sa.toLowerCase();
var sb = saa.replace( /(^|\s)([a-...
@nhgrif I would have assumed that the date formats should be required to be input in the same way they are output, e.g., 2015-01-15, and not in the "American" format
But, it's MS SQL so I guess I shouldn't be surprised. Postgres requires the YYYY-MM-DD format, pretty sure MySQL does too
I implemented a simple FFT below (the final scaling is ignored):
typedef complex<double> base;
vector<base> w;
int FFTN = 1024;
void fft(vector<base> &fa){
int n = fa.size();
if (n==1) return;
int half = (n>>1);
vector<base> odd(half),even(half);
for(int i=0,j = 0;i<n;i+=2,j+...
I saw this implementation of Least common ancestor and thought that it was very inefficient as it used Queues. I have tried to implement it using a normal tree traversal.
I have also tried to keep all the utility methods as public static so that they could be accessed from anywhere.
Is the implem...
I have a script that I am working on that creates a grid on the desktop which eventually will become a voice activated grid for mouse control. The problem I am having is that for grids 4 through 9 the horizontal lines are not being drawn correctly. I have played with the math on the button presse...
Unfortunately, I agree it is off-topic for Code Review, but it is unlikely going to fare well on Stack Overflow, since there's too much code, and it needs to be a simplified example of the problem. SO needs small examples, CR needs more complete and real code. Migration in it's current state is not a good option. — rolfl ♦7 secs ago
The objective of the two classes below is to manage a collection of records where the record structure (i.e. the fields that comprise the record) is variable and defined at run-time. The record structure may contain integers, amounts, dates and strings.
The RecordDefinition class is used to def...
I got it working, all variations are displayed Sint-Anna as should be, but I wonder, is there a simpler way to this, since it looks very cluttered?
String.prototype.capitalize = function(){
var sa = this.replace(/-/g,' ');
var saa = sa.toLowerCase();
var sb = saa.replace( /(^|\s)([a-...
Regarding the isolation level. Typically with CRUD operations, Create Updates and Deletes I like to use a Serializable isolation level and use a ReadCommitted isolation level with any Read operations. But that is why I think it shouldn't be hard coded into a container. It can change depending on what the user is doing. — Issa Fram11 mins ago
could TransactionScope be not DI-friendly?
OP isn't showing their IRepository implementation...