in java is the name of a method a string? why or why not?
so if i have something like:
public static int METHODNAME (some parameters or not)
{
something to do ;
}
is METHODNAME a string?
I wasted plenty of hours trying to figure out the problem but no luck. Tried asking the TA at my school, but he was useless. I am a beginner and I know there are a lot of mistakes in it, so it would be great if I can get some detail explanation as well. Anyways, basically what I am trying to do with the following function is:
Use while loop to check and see if random_string is in TEXT, if not
return NoneType
if yes, then use a for loop to read lines from that TEXT and put it
in list, l1.
then, write an if statement to see if random_string is in l1.
if it is, then do some calculations.
else read the next line
Finally, return the calculations as a whole.
TEXT = open('randomfile.txt')
def random (TEXT, random_string):
while random_string in TEXT:
for lines in TEXT:
l1=TEXT.readline().rsplit()
if random_string in l1:
'''
do some calculations
'''
else:
TEXT.readline() #read next line???
return #calculations
return None
I have used this snippet to prevent webkit from changing antialiasing when using CSS transforms:
html{ -webkit-font-smoothing: antialiased; }
This works fine for most cases, however I noticed some weirdness in chrome when playing around with Bootstrap using this HTML:
<button class="btn btn-inverse">John Doe</button>
<a class="btn btn-inverse">John Doe</a>?
This is how it looks in OSX/Chrome:
Fiddle: http://jsfiddle.net/hY2J7/. In fact, it seems that it is not applied to buttons at all. Is there a safer technique to trigger the same antialiasing in webkit for all elements?
Hi,
I have setup OpenVPN. All seems to be working fine except that Name Lookups are not done via the BIND DNS server on the server. I have added
push "redirect-gateway def1" and push "dhcp-option DNS 10.8.0.1"
to the OpenVPN server config. It does seem like this is being pushed to the Client.
The problem however is that I believe the BIND DNS is not allowing the Client to connect and do name lookups.
How do I go about configuring BIND to allow connections from the VPN clients?
There are many discussions about what people's favourite source control is (subversion, mercurial ...). But what source control systems have you used that you certainly wouldn't recommend? And more beneficial, how would you go about promoting change in the business to a new source control system?
A few years ago I developed using a source control system called Synergy. There were two Synergy experts in the company that constantly had to help the developers do check-ins/outs and merges were especially difficult.
What would be your steps of migrating to a better source control. Would you host everything internally or pay for services such as github?
I have a need to design a system to track users memberships to groups with varying roles (currently three).
class Group < ActiveRecord::Base
has_many :memberships
has_many :users, :through => :memberships
end
class Role < ActiveRecord::Base
has_many :memberships
has_many :users, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :role
belongs_to :group
end
class User < ActiveRecord::Base
has_many :memberships
has_many :groups, :through => :memberships
end
Ideally what I want is to simply set
@group.users << @user
and have the membership have the correct role. I can use :conditions to select data that has been manually inserted as such :
:conditions => ["memberships.grouprole_id= ? ", Grouprole.find_by_name('user')]
But when creating the membership to the group the grouprole_id is not being set.
Is there a way to do this as at present I have a somewhat repetitive piece of code for each user role in my Group model.
I need to work with TagLib for my project. I've created a framework (and I tried using it as a lib) but the compiler cannot find #include < strings on compiling (No such file or Directory). I've created a test C++ project and it #includes < strings just fine. I've looked at the project settings and I cannot find a difference between them. But the standard cocoa projects obviously so not have the search path set to include C++ libraries (Or am I completely getting it wrong?).
I've searched for a solution but no one else seems to have run into this problem.
I am trying to translate the following:
Action:
pushl %ebp
movl %esp, %eax
subl $32, %esp
movl $0, -8(%eax)
movl $0, -4(%eax)
movl -4(%eax), %eax
cmpl 32(%eax), %ebp
movl -4(%ebp), %eax
sall $2, %ebp
addl 8(%ebp), %ebp
movl (%ebp), %ebp
addl %ebp, -8(%eax)
addl $1, -4(%eax)
What is the best way to learn assembly and translating this code?
How would you unit test do_int_to_string_conversion?
#include <string>
#include <iostream>
void do_int_to_string_conversion(int i, std::string& s) {
switch(i) {
case 1:
s="1";
break;
case 2:
s="2";
break;
default:
s ="Nix";
}
std::cout << s << "\n";
}
int main(int argc, char** argv){
std::string little_s;
do_int_to_string_conversion(1, little_s);
do_int_to_string_conversion(2, little_s);
do_int_to_string_conversion(3, little_s);
}
Let's say I have a thread pool containing X items, and a given task employs Y of these items (where Y is much smaller than X).
I want to wait for all of the threads of a given task (Y items) to finish, not the entire thread pool.
If the thread pool's execute() method returned a reference to the employed thread I could simply join() to each of these Y threads, but it doesn't.
Does anyone know of an elegant way to accomplish this? Thanks.
Hi,
I have the following MySQL tables:
TABLE: Products
----------------------
id | productname
1030 | xBox 360
1031 | PlayStation 3
1032 | iPod Touche
TABLE: Sales
----------------------
productid | saledate
1031 | 2010-06-14 06:30:12
1031 | 2010-06-14 08:54:38
1030 | 2010-06-14 08:58:10
1032 | 2010-06-14 10:12:47
I want to fetch using php the products i sold today and groupe them by sales number and order by sale date (if possible) , example of Output:
Today's statistics:
-Playstation 3 (2 sales)
-Xbox 360 (1 sale)
-iPod Touche (1 sale)
Thanks
What's the cleanest way of editing the characters in a string in C#?
What's the C# equivalent of this in C++:
std::string myString = "boom";
myString[0] = "d";
Hi,
Basically what I have here is a button that adds a new list item to an unordered list. Within this list item is a dropdown box (.formSelector) that when changed triggers an ajax call to get the values for another dropdown box (.fieldSelector) in the same list item.
The problem is on this line:
$(this).closest(".fieldSelector").append(
If I change it to
$(".fieldSelector").append(
the second box updates correctly. The problem with this is that when I have multiple list items it updates every dropdown box on the page with the class fieldSelector, which is undesirable. How can I traverse the DOM to just pick the fieldSelector in the current list item? Any help is greatly appreciated.
Complete code:
$("button", "#newReportElement").click(function() {
$("#reportElements").append("<li class=\"ui-state-default\"> <span class=\"test ui-icon ui-icon-arrowthick-2-n-s \"></span><span class=\"ui-icon ui-icon-trash deleteRange \"></span> <select name=\"form[]\" class=\"formSelector\"><? foreach ($forms->result() as $row) { echo "<option value='$row->formId'>$row->name</option>"; }?></select><select class=\"fieldSelector\" name=\"field[]\"></select></li>");
$(".deleteRange").button();
$('.formSelector').change(function() {
var id = $(this).val();
var url = "<? echo site_url("report/formfields");?>" + "/" + id;
var atext = "ids:";
$.getJSON(url,
function(data){
$.each(data.items, function(i,item){
$(this).closest(".fieldSelector").append(
$('<option></option>').val(item.formId).html(item.formLabel)
);
});
});
});
return false;
});
I have this in a php to show a mp3 file, it code works fine on firefox and explorer but in chrome it not work. The chrome player appears but no sound and not increases time
$ext = strtolower(substr(strrchr($filename,"."),1));
$ctype="audio/mpeg";
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
header("Content-Type: $ctype");
header("Content-Length: ".$len);
I'm writing a Windows Forms Application in C#.NET
On startup, the application displays a splash screen which is running in a separate thread. Whilst the splash screen is showing, the main application is initialising.
Once the main application has finished initialising, the main form of the application is displayed, and the splash screen still shows over the top.
Everything so far is as expected.
Then, the Splash screen is closed, which causes that thread to exit. For some reason, at the point, the main application windows gets sent behind all other open Windows, notably the Windows Explorer window where you clicked the .exe file to run the application in the first place!
What could be causing the windows to suddenly jump "behind" like this?
Hi,
I'm working on a quite big magento: it will have 50 different shops (1 magento install, 1 admin to rule them all) for start, this number is expected to raise in the future, and a catalog of more than 1k products. This catalog will be shared by all shops.
I'm concerned about the server requirements I need for this to run smoothly. So far this is what I've found to get the most of it:
Caching: using magento's cache with APC, MySQL's querys
Images sprite in the theme
use FastCGI instead of mod_php
database clustering: I don't think it will be necesary for 1k products, what do you think?
using Zend Server
Are there other thing I can do in order to improve magento's performance? I'd like to know all I need from the beginning so I can find the right server.
thanks in advance.
I want to know how many elements of a certain class appear in the DOM before an element that let's say has been clicked on.
<html>
<div class="a">
</div>
<div class="b">
<div class="a">
</div>
</div>
<button>CLick me!</button>
<div class="a">
</div>
</html>
So in the previous DOM tree if the element to be clicked is the button, and Im looking for divs with class "a" it should return 2, even though in the whole tree there are 3, but "before" the button there are only 2.
How could I do that?
Thanks
Hi!
I try to upload file, how can i check if file is upload
when i send empty input witch file upload i get
AttributeError: 'unicode' object has no attribute 'filename'
How can i check added file?
Consider a table like
tbl_ranks
--------------------------------
family_id | item_id | view_count
--------------------------------
1 10 101
1 11 112
1 13 109
2 21 101
2 22 112
2 23 109
3 30 101
3 31 112
3 33 109
4 40 101
4 51 112
4 63 109
5 80 101
5 81 112
5 88 109
I need to generate a result set with the top two(2) rows for a subset of family ids (say, 1,2,3 and 4) ordered by view count.
I'd like to do something like
select top 2 * from tbl_ranks where family_id = 1 order by view_count
union all
select top 2 * from tbl_ranks where family_id = 2 order by view_count
union all
select top 2 * from tbl_ranks where family_id = 3 order by view_count
union all
select top 2 * from tbl_ranks where family_id = 4 order by view_count
but, of course, order by isn't valid in a union all context in this manner. Any suggestions? I know I could run a set of 4 queries, store the results into a temp table and select the contents of that temp as the final result, but I'd rather avoid using a temp table if possible.
Note: in the real app, the number of records per family id is indeterminate, and the view_counts are also not fixed as they appear in the above example.
How do you even look at the web.config file? I don't know where to go to turn custom errors off...help!
I tried command prompt and java script....can any one help me?
Is it possible to have VIM auto populate a file based on the extension?
For example, when I open a new .sh file, I would like VIM to automatically type
#!/bin/bash
as the first line. (This example simplified down to the essentials)
Is there a simple framework for processing form submissions via a servlet? For my needs, a framework like STRUTS seems like over kill.
My ideal processor would be a servlet that converts form elements into a bean object, possibly using typing information in the form to help with the conversion. Does something like this exist or is there another solution out there geared toward simpler needs?
Thanks!