How do you solve the dependencies of packages within your functions? I add require(package) into the function, but I wonder if there's a preferred way of accomplishing this task.
Is there a way to simply have my blocks and their closing end keyword align properly with vim? If I have a function which is nested with several conditions, things can start to get ugly fast. Can vim save the day?
How do I add a new method to an object "on the fly"?
$me= new stdClass;
$me->doSomething=function ()
{
echo 'I\'ve done something';
};
$me->doSomething();
//Fatal error: Call to undefined method stdClass::doSomething()
I have a function foo(i) that takes an integer and takes a significant amount of time to execute. Will there be a significant performance difference between any of the following ways of initializing a:
a = [foo(i) for i in xrange(100)]
a = map(foo, range(100))
vfoo = numpy.vectorize(foo)
a = vfoo(range(100))
(I don't care whether the output is a list or a numpy array.)
Is there a better way?
I want to change css class of an element on certain event in jquery.
eg.
focusin: function()
{
if(this.val()=="First Name")
$(this).find("span ").css
}
$(this).find("span which contains _set").class= mycssclass here I want to change the CSS class of span element whose id contains "_set" as a part of substring in class name and also want to change the text i.e. InnerHtml property of javascript of this span element
I'm totally new to GreaseMonkey, but I'm trying to make a little script.
// ==UserScript==
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
(function() {
$ = unsafeWindow.jQuery;
alert($); // this gives 'undefined'
}());
Why does the alert give undefined and how to fix this?
I have a class like this
class someclass{
public function somemethod(){}
}
Now I have an array:
$somearray['someclass'] = new someclass();
$somearray['somemethod'] = 'somemethod';
How can I fire them, I tried the following:
$somearray['someclass']->$somearray['somemethod']();
usign this I get the following error:
Fatal error: Method name must be a string in ......................
Anyone have an idea on how to do this?
Hi..
I want to prevent drag drop in some column header .
Thanks
My code
private function _headerShift(evt:IndexChangedEvent):void{
var dg:AdvancedDataGrid= AdvancedDataGrid(evt.currentTarget);
var column:AdvancedDataGridColumn = dg.columns[evt.newIndex];
var dropTarget:AdvancedDataGrid = AdvancedDataGrid(evt.currentTarget);
if(evt.oldIndex > 3){
evt.stopImmediatePropagation();
evt.preventDefault();
dropTarget.validateNow();
}
}
I have implemented the curl progress bar using
curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, 'callback');
curl_setopt($curl, CURLOPT_BUFFERSIZE,64000);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
and a callback function.
problem is, the script is outputting the percentage on my html everytime like this :
0
0.1
0.2
0.2
0.3
0.4
..
..
..
1
1.1
How do i combine this with CSS to show a changing progress bar ?
I am using malloc_stats() function to display the amount of "system bytes" and "in use" bytes used by the process. I wanted to know if the in use bytes also include the memory used by STL C++ Objects like map, vector, sets?
If yes, is it safe to assume that this is only amount of memory that will be used by the process?
I am trying to find the correct syntax to pass a varible to my JQuery Post.
var id = empid;
$.ajax({
type: "POST",
url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
data: "{empid: empid}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(result) {
alert(result.d);
}
I don't think the data: value is quite right. Someone set me straight?
Thanks!
Is there a way to bind event after fullCalendar has been created?
Something like:
jQuery( '#calendar' ).bind( 'dayClick', function( date, allDay, jsEvent, view ){} );
I have this code (which doesn't work):
Public Class Form1
End Class
Public Module test1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form1.Button1.Click
MsgBox("HI")
End Sub
End Module
I know I could handle the button click event in Form1, and then call a function in test1, but I would like to handle the button click event directly in the test1 module. Is there a way to automatically send UI events from the Form1 class to another module?
I want to write a ini. file in MFC ,and I know those typical methods with section names, key names and key values. I`m wondering how to write a ini file which contains only a section name.
a ini file like below
...
[section]
...
I have tried the function writeprivateprofilestring() with two NULL parameters but it failed.
Hi everyone!
I'm using the libpq library in C to accessing my PostgreSQL database. So, when I do res = PQexec(conn, "SELECT point FROM test_point3d"); I don't know how to convert the PGresult I got to my custom data type.
I know I can use the PQgetValue function, but again I don't know how to convert the returning string to my custom data type.
Any suggestion?
Thanks in advice.
This is my query
$id contains primary key and $status contains new status
public function updateStatus($id,$status)
{
$qb=$this-createQueryBuilder('b')
-update()
-set('b.status',$status)
-where('b.id='.$id);
echo $qb;
return $qb-getQuery()
-getResult();
}
Problem I am facing is
[Semantical Error] line 0, col 56 near 'Complete WHERE': Error: 'Complete' is not defined.
DEAR All
I'm new to the C++, so maybe someone can say what the proper way to write a function that gets a string char (represents number) and converts it to the integer number.
For example : input : Sixty five, output: 65.
Maybe it should use by cin.getline() ?
Well, vice-versa is little bit simlper...
Thanks for advance.
Igal
Here one more basic question asked in MS interview recently
Class A {
public virtual void Method1(){}
public void Method2() {
Method1(); }
}
class B:A { public override void Method1() { } }
Class main
{
A obk = new B(); obk.Method2(); }
now tell me which function gets called ? sorry for the typos.
I'd like to be able to determine which store the user connects to from inside my app, so that I can direct them to some appropriate content for their device AND store. Does anyone know how to get this information?
Basically, if the user is in the UK, and connects to the UK store, I want my function/method to return GB, if in Korea, I want KR, Australia = AU etc. Any help would be appreciated.
I am creating an element with document.createElement().
Now how can I pass it to a function that only takes a Jquery object?
$("#id")
I can not use it, as the element has not been rendered in the page yet.
i have a form that submits data to a database, i have a function that looks like this:
//connect
foreach ($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
now when i post, SOMETIMES i get an error that says this:
Allowed memory size of 268435456 bytes exhausted
i figured out that when i do a linebreak, or press enter in the message field, then that is when it causes the error, otherwise it works normal. any ideas?
Hello,
I am looking for the fastest way to remove duplicate values in a string separated by commas.
So my string looks like this;
$str = 'one,two,one,five,seven,bag,tea';
I can do it be exploding the string to values and then compare, but I think it will be slow. what about preg_replace() will it be faster? Any one did it using this function?