Hi folks, today, i am defining a set of variables in a hash that I use in various functions all over the model and the controller.
From the code below, you see that I am defining functions like get_stats, get_fans to target the exact variable.
My question is, would it be possible to define just one function?
NOW:
REQ={:USER_STATS_I...
I have a bunch of Python modules I want to clean up, reorganize and refactor (there's some duplicate code, some unused code ...), and I'm wondering if there's a tool to make a map of which module uses which other module.
Ideally, I'd like a map like this:
main.py
-> task_runner.py
-> task_utils.py
-> deserialization.py
-> file_...
Hi there. I have a more or less large Perl script of ~ 1000 lines. The script accepts a few arguments and it runs straight forward. No modules, no functions. The script could be divided into three parts, initialization part, arguments parsing part and work part, but I don't know how to do that. Everything must be kept in a single file. P...
I need a regex that matches all instances of a particular PHP function name in given a piece of code.
The regex should match foo in:
foo("qwe");
function foo($param);
return foo();
An not match foo in:
my_foo("qwe");
foo_bar();
"some foo string"
...
Back story:
So I've been stuck on an architecture problem for the past couple of nights on a refactor I've been toying with. Nothing important, but it's been bothering me. It's actually an exercise in DRY, and an attempt to take it to such an extreme as the DAL architecture is completely DRY. It's a completely philosophical/theoretic...
If you've got a codebase which is a bit messy in respect to coding standards - a mix of different conventions from different people - is it reasonable to give one person the task of going through every file and bringing it up to meet standards?
As well as being tremendously dull, you're going to get a mass of changes in SVN (or whatever...
Hello,
Here is a pattern I am thinking about in ASP :
Imagine you have a file main.asp that contains
<!--#include file="1.asp"-->
code of 1.asp
...my code...
Do you think it is valid to refactor this as
main.asp
Dim defined_1_asp = false
<!--#include file="1.asp"-->
1.asp
if (not defined_1_asp) then
defined_1_asp = tr...
I need to write a script to do the following:
Monitor a queuing system, which is accessible by shell commands.
Create directories from templates using a mix of inline text editing, cp/mv, command line scripts, and compiled c++ programs.
Check for error conditions.
Write files on error conditions.
Note: 2D arrays would be mildly usefu...
Typically, we define a hash as
h={:a=>val1, :b=>val2}
However, i want to add a condition to only add in the key :b if val2 is not a nil value. Something like
h={:a=>val1}
h[:b]=val2 if val2
But can it be encapsulated in a single line?
...
How would you refactor this logic filled partial?
<%- for post in @posts -%>
<div class="post">
<%= link_to post.title, post %>
<%- if post.name.empty? -%>
<%- else -%>
<span class="name">
by
<%- if post.email.blank? -%>
<%= post.name %>
<%- else -%>
<a href="mailto:<...
Hi all,
I am a junior software engineer who've been given a task to take over a old system. This system has several problems, based on my preliminary assessment.
spaghetti code
repetitive code
classes with 10k lines and above
misuse and over-logging using log4j
bad database table design
Missing source control -> I have setup Subvers...
Our code sucks. Actually, let me clarify that. Our old code sucks. It's difficult to debug and is full of abstractions that few people understand or even remember. Just yesterday I spent an hour debugging in an area that I've worked for over a year and found myself thinking, "Wow, this is really painful." It's not anyone's fault - I...
I am trying to remove elements from a Dictionary<string, List<string>> in C# when the count of the list<string> is lesser than or equal to 1.
I got some code working but it is not elegant and I have a gut feeling that this can be done elegantly in linq.
This is the code I have now
Dictionary<string,List<string>> FindAnagrams(...
I need a very specific tool for VB (or multi-language). I ask for it, before I start making one myself (probably, in python).
What I need:
The tool must crawl, recursivelly or not, a path, searching for a list of extension, such as .bas, .frm, .xxx
Then, It has to parse that files, searching for functions, routines, etc.
And finally, ...
Hi,
I have a HibernateUtil class which is the standard by the book (Hibernate in action) class.
It gets a session, flushes and closes it. begins,commits and rollbacks transactions and build the sessionFactory.
Currently, by mistake, this is called HibernateSessionFactory in our package.
I want to refactor it to a more appropriate name bu...
I have several tds, with ids = row[0], row[2] row[4] and so on.
<td id="row[4]">02:45</td>
<td id="row[6]">03:45</td>
The content in these are times like 03:45, 04:45 which I want to change to 03:15, 04:15 etc. using jQuery.
EDIT:
I ended up with this:
jQuery('td[id^="row"]').each(function(){
min = parseInt(jQuery(this).text()...
I would like to collect and store all this info into an array.
I have the following, how should I refactor this?
require 'rubygems'
require 'nokogiri'
require 'open-uri'
@urls = %w{http://url_01.com http://url_02.com http://url_03.com}
@link_01_arr = []
@link_02_arr = []
@link_03_arr = []
link_01 = Nokogiri::HTML(open("#{@urls[0]}"...
I got this code, along with CMS
when I try to add code using prototype 1.6
piece of code will be the first one and it will work
but second not work
this first piece
<script language="JavaScript1.2">
var slidemenu_width='120px'
var slidemenu_reveal='11px'
var slidemenu_top='78px'
var ns4=document.layers?1:0
var ie4=document.all
var n...
I did right-click > refactor > move from the project menu, "Move everything from .../../ to another directory" > OK selected a different folder, and wham, all my data is gone.
I did a grep -r in the project tree to find it, and a find . -iname 'mydataas' still nothing shows up. Its gone.
Why does Intellij do this?
...
i want to turn off annoying file refactoring as I have a php project and it is useless
If i click a folder and press f2 to rename that folder, it won't let me do it without going through the refactoring dialogue, which is buggy so that makes it worse.
Any ideas?
...