This morning we pull from our repo, and git put us on (no branch).
I don't understand this, why did this happen? And how get out of it without losing our changes?
I'm using the awesome_nested_set plugin in my Rails project. I have two models that look like this (simplified):
class Customer < ActiveRecord::Base
has_many :categories
end
class Category < ActiveRecord::Base
belongs_to :customer
# Columns in the categories table: lft, rgt and parent_id
acts_as_nested_set :scope => :customer_id
validates_presence_of :name
# Further validations...
end
The tree in the database is constructed as expected. All the values of parent_id, lft and rgt are correct. The tree has multiple root nodes (which is of course allowed in awesome_nested_set).
Now, I want to render all categories of a given customer in a correctly sorted tree like structure: for example nested <ul> tags. This wouldn't be too difficult but I need it to be efficient (the less sql queries the better).
Update: Figured out that it is possible to calculate the number of children for any given Node in the tree without further SQL queries: number_of_children = (node.rgt - node.lft - 1)/2. This doesn't solve the problem but it may prove to be helpful.
Hi,
i want to display a big string in Qlablel for this simply i have created a label in Qt GUI editor,
then i put the string, with the Wordwrap property ON.
here text is not coming to the next line itself, instead its crossing the view region.
but if i give "\n" it works well.
how to put up big string in label, to display in visible region.
I have a weird relationship that needs to be maintained for legacy processes.
I'm trying to figure out how to create the relationship given the new model association.
New Relationship Setup
Machine
has_many MachineReadings
has_many Disks
has_many DiskReadings
Old Relationship Setup
Machine
has_many MachineReadings
has_many DiskReadings
has_many Disks
The problem is data will come in on the Machine model as nested attributes using the new relationship setup. I need to update the machine_reading_id in the DiskReading model so the old association can continue to be used.
I tried doing this via an after_save hook that would traverse back up to the machine and then down to the readings to get the machine_reading.id so I could populate the DiskReading model. However, the associations aren't being saved in the order I would expect. They are saving the Disks & DiskReadings before saving the MachineReadings. So when I go after the machine_reading.id it hasn't been written and thus I am unable to get access to it.
For example:
#machine_disk_reading.rb
after_save :build_old_relationship
def build_old_relationship
self.machine_reading_id = self.disk.machine.readings.find_by_date_time(self.date_time).id
end
Hello,
I am using the curl found in /usr/bin/curl (Not the PHP Curl )
how do I pass authorization header using curl ?
It will be great if someone can reply.
Regards,
Mithun
I've something like this
Object[] myObjects = ...(initialized in some way)...
int[] elemToRemove = new int[]{3,4,6,8,...}
What's the most efficient way of removing the elements of index position 3,4,6,8... from myObjects ?
I'd like to implement an efficient Utility method with a signature like
public Object[] removeElements(Object[] object, int[] elementsToRemove) {...}
The Object[] that is returned should be a new Object of size myObjects.length - elemToRemove.length
I am using the StarIO SDK to print text to a receipt printer and I am trying to get a certain line of text larger than the rest. I have some help from their support but I can't really get it to go.
-(void)print{
NSMutableString *final=[NSMutableString stringWithFormat:@"-----"];
[final appendFormat:@"\n\nLevel:%@ Section:%@ Row:%@ Seat:%@", [response_dict objectForKey:@"level"], [response_dict objectForKey:@"section"],[response_dict objectForKey:@"row"],[response_dict objectForKey:@"seat"]];
There is a bunch of other stuff that is printing, but that is the line that I would like to be a different size than the rest. The StarIO support said that I should try and pass that to this...
-(IBAction)PrintText
{
NSString *portName = [IOS_SDKViewController getPortName];
NSString *portSettings = [IOS_SDKViewController getPortSettings];
[PrinterFunctions PrintTextWithPortname:portName portSettings:portSettings heightExpansion:heightExpansion widthExpansion:widthExpansion textData:textData textDataSize:[textNSData length]];
free(textData);
}
Would love some help if possible. :) Thanks so much.
This is the main bit I think I would need from the StarIO Text formatting doc...
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
array_hieghtExpansion = [[NSMutableArray alloc] init];
[array_hieghtExpansion addObject:@"1"];
[array_hieghtExpansion addObject:@"2"];
[array_hieghtExpansion addObject:@"3"];
[array_hieghtExpansion addObject:@"4"];
[array_hieghtExpansion addObject:@"5"];
[array_hieghtExpansion addObject:@"6"];
array_widthExpansion = [[NSMutableArray alloc] init];
[array_widthExpansion addObject:@"1"];
[array_widthExpansion addObject:@"2"];
[array_widthExpansion addObject:@"3"];
[array_widthExpansion addObject:@"4"];
[array_widthExpansion addObject:@"5"];
[array_widthExpansion addObject:@"6"];
array_alignment = [[NSMutableArray alloc] init];
[array_alignment addObject:@"Left"];
[array_alignment addObject:@"Center"];
[array_alignment addObject:@"Right"];
}
return self;
}
and
int heightExpansion = [pickerpopup_heightExpansion getSelectedIndex];
int widthExpansion = [pickerpopup_widthExpansion getSelectedIndex];
I feel like the answer to this question is really simple, but I really am having trouble finding it. So here goes:
Suppose you have the following classes:
class Base;
class Child : public Base;
class Displayer
{
public:
Displayer(Base* element);
Displayer(Child* element);
}
Additionally, I have a Base* object which might point to either an instance of the class Base or an instance of the class Child.
Now I want to create a Displayer based on the element pointed to by object, however, I want to pick the right version of the constructor. As I currently have it, this would accomplish just that (I am being a bit fuzzy with my C++ here, but I think this the clearest way)
object->createDisplayer();
virtual void Base::createDisplayer()
{
new Displayer(this);
}
virtual void Child::createDisplayer()
{
new Displayer(this);
}
This works, however, there is a problem with this:
Base and Child are part of the application system, while Displayer is part of the GUI system. I want to build the GUI system independently of the Application system, so that it is easy to replace the GUI. This means that Base and Child should not know about Displayer. However, I do not know how I can achieve this without letting the Application classes know about the GUI.
Am I missing something very obvious or am I trying something that is not possible?
When launching a process with CreateProcessW(), is it possible to have the process created with a different MBCP locale/codepage then the one that is configured as the system-wide default code page?
In the target process, this should have the same effect as calling _setmbcp().
The target process is not a unicode-enabled and uses a plain main(int argc, char **argv) entry point. I would like to be able to select the code page to which unicode arguments passed to CreateProcessW() are converted to be different from the system's default codepage for non-unicode programs.
I'm moving my application from 3.x to 4.x as I prepare for the app store and found that I need to have 2 copies of all my custom pngs - my question is how can I determine what img to show and when. Example - how do I know to show the Find.png vs the [email protected]
Is it "safe" or "correct" to look for 4.x specific apis or does the iphone have a way to determine what platform you are on at runtime?
Thank you in advance
its my first time using a ProgressBar in c#.
The idea is to use the ProgressBar as an health bar in a simple game.
The thing is I think the bar's maximum value is 100% but i would like to give it a higher value like let's say 1000% or, not sure if it's possible, give the bar an integer value instead of a percentage.
progressBar1.Increment(100);
This is where I initialize the health to 100points. Even if I use this syntax:
progressBar1.Increment(1000);
And I subtract :
progressBar1.Increment(-25);
The player is loosing 1/4 of is life as if he only had 100 Health Points.
Any idea how I could change the maximum Bar value?
Thanks in advance.
Hi
I try to create an hotspot by Extends of canvas and I try to add it on a panel witch painted by images , so I must to draw an icon (image) instead of clear rectangle of the screen,
to do that I override the paint method to draw the icon I want to use, so far there is no problem, the hotspot work true and the icon painted in true size I want(32,24 pixel)
I try to add this hotspot after painting image on the my panel in mypanel.paint(g) that override too.
The problem , I use an car icon that have no background !!(I hope you can understand me) just car icon must be show on the panel that painted with my images;
But an unwanted rectangle created around the icon and made bad view,
How I can paint may icon on panel without that background?
Please help me.
I have the following html code:
<i class="small ele class1"></i>
<i class="medium ele class1"></i>
<i class="large ele class1"></i>
<div class="clear"></div>
<i class="small ele class2"></i>
<i class="medium ele class2"></i>
<i class="large ele class2"></i>
<div class="clear"></div>
<i class="small ele class3"></i>
<i class="medium ele class3"></i>
<i class="large ele class3"></i>
<div class="clear"></div>
<i class="small ele class4"></i>
<i class="medium ele class4"></i>
<i class="large ele class4"></i>?
And my javascript looks like so:
var resize = function(face, s) {
var bb = face.getBBox();
console.log(bb);
var w = bb.width;
var h = bb.height;
var max = w;
if (h > max) {
max = h;
}
var scale = s / max;
var ox = -bb.x+((max-w)/2);
var oy = -bb.y+((max-h)/2);
console.log(s+' '+h+' '+bb.y);
face.attr({
"transform": "s" + scale + "," + scale + ",0,0" + "t" + ox + "," + oy
});
}
$('.ele').each(function() {
var s = $(this).innerWidth();
var paper = Raphael($(this)[0], s, s);
var face = $(this).hasClass("class1") ? class1Generator(paper) : class4Generator(paper);
/*switch (true) {
case $(this).hasClass('class1'):
class1Generator(paper);
break;
case $(this).hasClass('class2'):
class2Generator(paper)
break;
case $(this).hasClass('class3'):
class3Generator(paper)
break;
case $(this).hasClass('class4'):
class4Generator(paper)
break;
}*/
resize(face, s);
});
my question is, how could I make this line of code more scalable? I tried using a switch but
The script below is calling two functions if one of the elements has a class, but what If i have 10 classes?
I don't think is the best solution I created a jsFiddle http://jsfiddle.net/7uUgz/6/
//var face = $(this).hasClass("awesome") ? awesomeGenerator(paper) : awfulGenerator(paper);
I'm writing an application that models train routes, which are stored in the database table [TrainStop] as follows:
RouteId
StationCode
StopIndex
IsEnabled
So a given route consists of several rows with the StopIndex indicating the order. The problem I am trying to solve is to say which stations a user can get to from a given starting station. This would be relatively straightforward BUT it is also possible to disable stops which means that a user cannot get to any destinations after that stop. It is also possible that multiple routes can share stations e.g.:
Route 1: A, B, C, D, E
Route2: P, Q, B, C, D, R
So if a user is at B they can go to C, D, E and R but if station D is disabled they can get to C only.
Solving this problem is fairly straightforward within C# but I am wondering whether it can be solved elegantly and efficiently within SQL? I'm struggling to find a way, for each route, to rule out stations past a row that is not enabled.
I got function in Flash (Action Script 3) - that makes snowflakes falling. Now i want to make this snowflakes appear on screen only for 3 seconds. So I'm trying to use Timer class but i got problem:
var myTimer:Timer = new Timer(3000, 1);
myTimer.addEventListener(TimerEvent.TIMER, snowflakes);
myTimer.start();
function snowflakes(event:TimerEvent):void {
//snowflakes faling function
}
In this case snowflakes appear after 3 seconds and stay on the stage forver...So its kinda opposite what i wanted. I want them to appear from the very beginning then disappear after 3 second. How can I do that ?
Hi everyone,
i tried to hide textblock's in QTextEdit, but it doesn't work:
block = textedit.document().begin()
block.setVisible(False)
This code works fine for QPlainTextEdit, but not for QTextEdit. In documentation i haven't found any mention of how it should work for QTextEdit, just following:
void QTextBlock::setVisible ( bool visible )
Sets the block's visibility
to visible.
This function was introduced in Qt
4.4.
See also isVisible().
How can i hide block's in QTextEdit?
Thank you in advance
I have defined an Event class:
Event
and all the following classes inherit from Event:
SportEventType1 SportEventType2 SportEventType3 SportEventType4
Right now I will only have SportEvents but I don't know if in the future I'll want some other kind of events that doesn't even have anything to do with Sports.
Later, I will want to draw some graphics with info taken from Events, and the drawing logic can be a bit complex. But, for the moment, I think I shouldn't think of how the drawing will be done and I believe that maybe it'd be better if that drawing part was not put as an integral part of the Event/SportEventX class chain.
I am looking for solutions for this problem. I know I could just make Event have an instance variable(attribute, for the java crowds) pointing to something as an IDrawInterface, but that would make the Event class "assume" it will be later used for drawing. I would like to make the Event class oblivious to this if possible.
Thanks!
This might be an odd question, but I'm looking for a word to use in a function name. I'm normally good at coming up with succinct, meaningful function names, but this one has me stumped so I thought I'd appeal for help.
The function will take some desired state as an argument and compare it to the current state. If no change is needed, the function will exit normally without doing anything. Otherwise, the function will take some action to achieve the desired state.
For example, if wanted to make sure the front door was closed, i might say:
my_house.<something>_front_door('closed')
What word or term should use in place of the something? I'd like it to be short, readable, and minimize the astonishment factor.
A couple clarifying points...
I would want someone calling the function to intuitively know they didn't need to wrap the function an 'if' that checks the current state. For example, this would be bad:
if my_house.front_door_is_open():
my_house.<something>_front_door('closed')
Also, they should know that the function won't throw an exception if the desired state matches the current state. So this should never happen:
try:
my_house.<something>_front_door('closed')
except DoorWasAlreadyClosedException:
pass
Here are some options I've considered:
my_house.set_front_door('closed')
my_house.setne_front_door('closed') # ne=not equal, from the setne x86 instruction
my_house.ensure_front_door('closed')
my_house.configure_front_door('closed')
my_house.update_front_door('closed')
my_house.make_front_door('closed')
my_house.remediate_front_door('closed')
And I'm open to other forms, but most I've thought of don't improve readability. Such as...
my_house.ensure_front_door_is('closed')
my_house.conditionally_update_front_door('closed')
my_house.change_front_door_if_needed('closed')
Thanks for any input!
Hello,
I have the code
<iframe width=150px height=150px src=http://yahoo.com></iframe>
Here I will have a 150x150 iframe, but I want the whole site to be reduced to a 150x150.
Is it possible to do it.
Thanks
Jean
I have a table Course and every Course has many Resources.
Course
==========
course_id
Resource
==========
course_id
number
I want something like a seperate autoincrement for each course_id. Or, in other words, I want to auto-enumerate the resources for a given course. For example, the resource table could look something like:
course_id | number
==================
1 | 1
1 | 2
2 | 1
1 | 3
1 | 4
2 | 2
2 | 3
and so on.
I want to do this in SQL, using IBM DB2.
Hi all.
Problem: I have a method that creates a list from the parsed ArrayList. I manage to show the list in the GUI, without scrollbar. However, I am having problem setting it to show only the size of ArrayList. Meaning, say if the size is 6, there should only be 6 rows in the shown List. Below is the code that I am using. I tried setting the visibleRowCount as below but it does not work. I tried printing out the result and it shows that the change is made.
private void createSuggestionList(ArrayList<String> str) {
int visibleRowCount = str.size();
System.out.println("visibleRowCount " + visibleRowCount);
listForSuggestion = new JList(str.toArray());
listForSuggestion.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listForSuggestion.setSelectedIndex(0);
listForSuggestion.setVisibleRowCount(visibleRowCount);
System.out.println(listForSuggestion.getVisibleRowCount());
listScrollPane = new JScrollPane(listForSuggestion);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent mouseEvent) {
JList theList = (JList) mouseEvent.getSource();
if (mouseEvent.getClickCount() == 2) {
int index = theList.locationToIndex(mouseEvent.getPoint());
if (index >= 0) {
Object o = theList.getModel().getElementAt(index);
System.out.println("Double-clicked on: " + o.toString());
}
}
}
};
listForSuggestion.addMouseListener(mouseListener);
textPane.add(listScrollPane);
repaint();
}
To summarize: I want the JList to show as many rows as the size of the parsed ArrayList, without a scrollbar.
Any ideas? Please help. Thanks. Please let me know if a picture of the problem is needed in case I did not phrase my question correctly.
I have an air app created from one of Adobe's Examples using javascript / HTML. Is it possible to change the descriptor file so the application launches full screen or maximized?
I have a multi-dimensional array:
a=[[2,3,4],[1,3,4],[1,2],[1,2,3,4]]
i've to compare all the 4 sub-arrays and get common elements.Next,take 3 subarrays at a time and get common elements.then take 2 sub arrays at a time and get common elements, in RUBY.
In Visual studio 2008 is it possible to have a resource file that is included as a separate file after compilation rather than as an embedded resource. This is to enable small changes to be rolled out more easily.
I have tried build options of Resource, None, Compile and also copy local on and off for most of these. However when ever I try access the resource at run time I get a cannot find resource exception.
Is this actually possible or am I wasting my time?