gmail Sidebar gadget is not showing
i am following this tutorial
https://developers.google.com/gmail/sidebar_gadgets when i am trying to
add a Hello World sidebar gadget to my gmail. i first hosted it on
http://cloudfactor9.appspot.com/ after that i added it in gadgets as you
can see in screen shot after that when i signout and signin into my gmail
there is no Hello World widget.can any one please tell why i am not able
to see Hello World widget ?? screenshot of gmail is
Saturday, 31 August 2013
jQuery ui autocomplete inside dialog
jQuery ui autocomplete inside dialog
I have this code:
$.ajax({
url: '/products/edit',
type: 'post',
data: {id: id},
success: function( data ) {
$( '#divDialog' ).html( data );
$( '#divDialog' ).dialog({
autoOpen: false,
height: 300,
width: 400,
modal: true,
resizable: false,
title: 'Edit Product',
closeOnEscape: false,
open: function() {
$( this ).parent().css( 'overflow', 'visible' );
$$.utils.forms.resize();
}
})
.find( 'button#cancelButton' ).click( function() {
var $form = $(this).parents( '.ui-dialog-content' );
$form.find( 'form' )[0].reset();
$form.dialog( 'close' );;
$form.dialog( 'destroy' );;
})
.end().find( 'button#saveButton' ).click( function() {
var $form = $(this).parents( '.ui-dialog-content' );
$form.validate({
submitHandler: function( form ) {
$.ajax({
url: '/products/edit',
type: 'post',
data: form.serialize(),
success: function( data ) {
$.jGrowl( data );
$form.dialog( 'close' );;
}
});
}
});
});
// show dialog
$( '#divDialog' ).dialog( 'open' );
}
});
So, I append a form to my div $('#divDialog'). My question is how to use
jQuery autocomplete to any input of my form?
I have this code:
$.ajax({
url: '/products/edit',
type: 'post',
data: {id: id},
success: function( data ) {
$( '#divDialog' ).html( data );
$( '#divDialog' ).dialog({
autoOpen: false,
height: 300,
width: 400,
modal: true,
resizable: false,
title: 'Edit Product',
closeOnEscape: false,
open: function() {
$( this ).parent().css( 'overflow', 'visible' );
$$.utils.forms.resize();
}
})
.find( 'button#cancelButton' ).click( function() {
var $form = $(this).parents( '.ui-dialog-content' );
$form.find( 'form' )[0].reset();
$form.dialog( 'close' );;
$form.dialog( 'destroy' );;
})
.end().find( 'button#saveButton' ).click( function() {
var $form = $(this).parents( '.ui-dialog-content' );
$form.validate({
submitHandler: function( form ) {
$.ajax({
url: '/products/edit',
type: 'post',
data: form.serialize(),
success: function( data ) {
$.jGrowl( data );
$form.dialog( 'close' );;
}
});
}
});
});
// show dialog
$( '#divDialog' ).dialog( 'open' );
}
});
So, I append a form to my div $('#divDialog'). My question is how to use
jQuery autocomplete to any input of my form?
Same column for two different relational entities with doctrine
Same column for two different relational entities with doctrine
Well, I have these three tables:
likes
id_like | post | post_type
post: it has the post id where the "like button" was triggered.
post_type: it has the type of the post, it could "article" or "comment".
Comment
id_comment | body
Article
id_article | body
I am trying to create the models "Article" and "Comment" where each one
can has an array of its likes. For example, I have tried this with:
Model Like
/**
* @Entity
* @Table(name="likes")
*/
class Like
{
/**
* @Id @Column(type="integer", nullable=false, name="id_like")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Column(type="integer", nullable=false, name="like_type")
*/
protected $type;
Model Article
namespace models;
use \Doctrine\Common\Collections\ArrayCollection;
/** * @Entity * @Table(name="article") */ class Article {
/**
* @Id @Column(type="integer", nullable=false, name="id_article")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @OneToMany(targetEntity="Vote", mappedBy="article")
* @JoinColumn(name="id_article", referencedColumnName="post")
*/
protected $likes;
My first problem comes when I try to get the "likes" from the article. If
I do:
$likes = $article->getLikes();
I get this error:
Severity: Notice
Message: Undefined index: article
Filename: Persisters/BasicEntityPersister.php
Line Number: 1574
Now, the second problem (or question) that eventually will come is about
the "Comment" model. Is be possible do a OneToMany from Comment to Likes
using as the same way as Article do?
Well, I have these three tables:
likes
id_like | post | post_type
post: it has the post id where the "like button" was triggered.
post_type: it has the type of the post, it could "article" or "comment".
Comment
id_comment | body
Article
id_article | body
I am trying to create the models "Article" and "Comment" where each one
can has an array of its likes. For example, I have tried this with:
Model Like
/**
* @Entity
* @Table(name="likes")
*/
class Like
{
/**
* @Id @Column(type="integer", nullable=false, name="id_like")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Column(type="integer", nullable=false, name="like_type")
*/
protected $type;
Model Article
namespace models;
use \Doctrine\Common\Collections\ArrayCollection;
/** * @Entity * @Table(name="article") */ class Article {
/**
* @Id @Column(type="integer", nullable=false, name="id_article")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @OneToMany(targetEntity="Vote", mappedBy="article")
* @JoinColumn(name="id_article", referencedColumnName="post")
*/
protected $likes;
My first problem comes when I try to get the "likes" from the article. If
I do:
$likes = $article->getLikes();
I get this error:
Severity: Notice
Message: Undefined index: article
Filename: Persisters/BasicEntityPersister.php
Line Number: 1574
Now, the second problem (or question) that eventually will come is about
the "Comment" model. Is be possible do a OneToMany from Comment to Likes
using as the same way as Article do?
umbraco 6 creating database 5%
umbraco 6 creating database 5%
I am new to Umbraco and I am trying it out. I am running Windows Server
2012 with iis 8. I am installing manually. I am getting stuck on the page
after you input your database information. I inter the information and
then the page comes up after I hit continue. This page says connecting to
database and shows 5% and just stays stuck there and does not move on. The
database tables are being created but the page does not move on to the
next step. Anyone have any ideas what could be wrong or how to solve this
problem? I am trying to install Umbraco 6.1.4 and I am using SQL server.
I am new to Umbraco and I am trying it out. I am running Windows Server
2012 with iis 8. I am installing manually. I am getting stuck on the page
after you input your database information. I inter the information and
then the page comes up after I hit continue. This page says connecting to
database and shows 5% and just stays stuck there and does not move on. The
database tables are being created but the page does not move on to the
next step. Anyone have any ideas what could be wrong or how to solve this
problem? I am trying to install Umbraco 6.1.4 and I am using SQL server.
Sort listview column No. 2 (Sub Item 1) by date in C# when listview is filled with unsorted data
Sort listview column No. 2 (Sub Item 1) by date in C# when listview is
filled with unsorted data
I would like to fill a listView already with pre-sorted data and dunno
how. The data which is being added contains a "Name" and a "Date" Item
where the Name Item is the Main Item and the Date Item is the first
subitem. By default it is sorted by nothing or by the name only. I would
need the data being added already in such way, that it would be added
sorted by date (it is the second column and the subitem no. 1). I do not
need a sorting via Column Click. The sorting should be already from
beginning there without having to click on any columns in the listView
first.
So I have a List with a varying amount of items in the list. each
containing listviewitem in this List has a "Date"-Subitem. How would I
sort the List before I add it with the AddRange-Method and the
.toArray()-conversion to the listView? I use C# Exp. Net 2.0 on VS 2008
and I use a System Windows Forms listView with two columns, 1) Name, 2
Date. When the data is being added it shall be already sorted in date
order, newest date first.
filled with unsorted data
I would like to fill a listView already with pre-sorted data and dunno
how. The data which is being added contains a "Name" and a "Date" Item
where the Name Item is the Main Item and the Date Item is the first
subitem. By default it is sorted by nothing or by the name only. I would
need the data being added already in such way, that it would be added
sorted by date (it is the second column and the subitem no. 1). I do not
need a sorting via Column Click. The sorting should be already from
beginning there without having to click on any columns in the listView
first.
So I have a List with a varying amount of items in the list. each
containing listviewitem in this List has a "Date"-Subitem. How would I
sort the List before I add it with the AddRange-Method and the
.toArray()-conversion to the listView? I use C# Exp. Net 2.0 on VS 2008
and I use a System Windows Forms listView with two columns, 1) Name, 2
Date. When the data is being added it shall be already sorted in date
order, newest date first.
Adding hyperlinks to index array in javascript
Adding hyperlinks to index array in javascript
How do I add a link in the description of an index array in javascript? My
code is below, thanks. I tried using push method, but I think I had a
conflict with the showpic function. I really don't know, so I would
appreciate any help.
<script type="text/javascript">
mypic = new Array();
mypic[0]=["images/Lg_image1.jpg","Large image 1 description."] //I want to
add an HTML link to a website at the end of this array
mypic[1]=["images/Lg_image2.jpg", "Large image 2 description."] //I want
to add an HTML link to a website at the end of this array
function showpic2(n){
document.getElementById("mainpic2").src=mypic[n][0]
document.getElementById("mycaption2").innerHTML=mypic[n][1]
count=n
}
count = 0;
function next() {
count++
if (count == mypic2.length) {
count = 0
}
document.getElementById("mainpic2").src=mypic2[count][0]
document.getElementById("mycaption2").innerHTML=mypic2[count][1]
}
function prev() {
count--
if (count<0) {
count = mypic2.length-1
}
document.getElementById("mainpic2").src=mypic2[count][0]
document.getElementById("mycaption2").innerHTML=mypic2[count][1]
}
</script>
</head>
<body>
<div id="container">
<div class="menu1">
<ul>
Link 1
<ul>
<li><a href="#">Link 2</a>
</li>
</ul>
</div>
<div id="large">
<img src="images/Lg_image1.jpg" class="mainpic2" id="mainpic2">
</div>
<div id="thumbs2">
<a href="javascript:showpic2(0)"><img src="images/sm_image1.jpg"
alt="image1"/></a>
<a href="javascript:showpic2(1)"><img src="images/sm_image2.jpg"
alt="image2"/></a>
</div>
<div id="mycaption2">Large image default description.
</div>
<div id="logohome">
<img src="images/#.png" alt="" />
</div>
<div id="homebox">
<img src="images/homebox1.png" alt="" />
</div>
</div>
</body>
</html>
How do I add a link in the description of an index array in javascript? My
code is below, thanks. I tried using push method, but I think I had a
conflict with the showpic function. I really don't know, so I would
appreciate any help.
<script type="text/javascript">
mypic = new Array();
mypic[0]=["images/Lg_image1.jpg","Large image 1 description."] //I want to
add an HTML link to a website at the end of this array
mypic[1]=["images/Lg_image2.jpg", "Large image 2 description."] //I want
to add an HTML link to a website at the end of this array
function showpic2(n){
document.getElementById("mainpic2").src=mypic[n][0]
document.getElementById("mycaption2").innerHTML=mypic[n][1]
count=n
}
count = 0;
function next() {
count++
if (count == mypic2.length) {
count = 0
}
document.getElementById("mainpic2").src=mypic2[count][0]
document.getElementById("mycaption2").innerHTML=mypic2[count][1]
}
function prev() {
count--
if (count<0) {
count = mypic2.length-1
}
document.getElementById("mainpic2").src=mypic2[count][0]
document.getElementById("mycaption2").innerHTML=mypic2[count][1]
}
</script>
</head>
<body>
<div id="container">
<div class="menu1">
<ul>
Link 1
<ul>
<li><a href="#">Link 2</a>
</li>
</ul>
</div>
<div id="large">
<img src="images/Lg_image1.jpg" class="mainpic2" id="mainpic2">
</div>
<div id="thumbs2">
<a href="javascript:showpic2(0)"><img src="images/sm_image1.jpg"
alt="image1"/></a>
<a href="javascript:showpic2(1)"><img src="images/sm_image2.jpg"
alt="image2"/></a>
</div>
<div id="mycaption2">Large image default description.
</div>
<div id="logohome">
<img src="images/#.png" alt="" />
</div>
<div id="homebox">
<img src="images/homebox1.png" alt="" />
</div>
</div>
</body>
</html>
Calculate the no of days based on year in ios
Calculate the no of days based on year in ios
I will calculate the no of days based on Years.For Ex:If this month is
September,then calculate the no of days (September...December) based on
Current year.And After Jan,It will be calculate based next year.
I retrieve the no of months from Current month upto end of month.
NSDate *curmonth=[NSDate date]; NSString *endmonthstr=@"2013-12-31";
NSDateFormatter *endmonthformatter=[[NSDateFormatter alloc]init];
[endmonthformatter setDateFormat:@"yyyy-MM-dd"];
NSDate *endmonth=[endmonthformatter dateFromString:endmonthstr];
NSInteger month = [[[NSCalendar currentCalendar] components:
NSMonthCalendarUnit
fromDate: curmonth
toDate: endmonth
options: 0] month];
NSInteger monthplus=month+1;
NSInteger count=monthplus;
NSLog(@"%d",monthplus);
But,I dont know how to compare this and calculate the days.
Any idea please help me
I will calculate the no of days based on Years.For Ex:If this month is
September,then calculate the no of days (September...December) based on
Current year.And After Jan,It will be calculate based next year.
I retrieve the no of months from Current month upto end of month.
NSDate *curmonth=[NSDate date]; NSString *endmonthstr=@"2013-12-31";
NSDateFormatter *endmonthformatter=[[NSDateFormatter alloc]init];
[endmonthformatter setDateFormat:@"yyyy-MM-dd"];
NSDate *endmonth=[endmonthformatter dateFromString:endmonthstr];
NSInteger month = [[[NSCalendar currentCalendar] components:
NSMonthCalendarUnit
fromDate: curmonth
toDate: endmonth
options: 0] month];
NSInteger monthplus=month+1;
NSInteger count=monthplus;
NSLog(@"%d",monthplus);
But,I dont know how to compare this and calculate the days.
Any idea please help me
Friday, 30 August 2013
Overloadin in WCF
Overloadin in WCF
Is there any solution to implement overloading in WCF? WCF and SOAP does
not support overloading because it's designed to be a completely general
communications framework, which means that clients might not be
.NET-based, and therefore might not have any understanding of method
overloading. Maybe exist option to force overloading in WCF?
Is there any solution to implement overloading in WCF? WCF and SOAP does
not support overloading because it's designed to be a completely general
communications framework, which means that clients might not be
.NET-based, and therefore might not have any understanding of method
overloading. Maybe exist option to force overloading in WCF?
Thursday, 29 August 2013
Call a function when particular div class has changed
Call a function when particular div class has changed
I working on project in which i m used the slider and slider has change
the class of particular after interval and show the image according the
classes have been changed So there is my need "call" a jquery function
when class has changed
I working on project in which i m used the slider and slider has change
the class of particular after interval and show the image according the
classes have been changed So there is my need "call" a jquery function
when class has changed
Opening a HTTP session with a username and password
Opening a HTTP session with a username and password
I am trying to open a HTTP session with a username and password using
AFNetworking.
The code I have at the moment is:
NSURL* serverURL = [NSURL URLWithString: @"http://myurl.com"];
AFHTTPClient* network = [[AFHTTPClient alloc] initWithBaseURL: serverURL];
[networkInstance setAuthorizationHeaderWithUsername:@"myUsername"
password:@"myPassword"];
Is this all there is to it? I've looked around a bit and I can't seem to
find any examples of a connection that uses a username and password.
I am trying to open a HTTP session with a username and password using
AFNetworking.
The code I have at the moment is:
NSURL* serverURL = [NSURL URLWithString: @"http://myurl.com"];
AFHTTPClient* network = [[AFHTTPClient alloc] initWithBaseURL: serverURL];
[networkInstance setAuthorizationHeaderWithUsername:@"myUsername"
password:@"myPassword"];
Is this all there is to it? I've looked around a bit and I can't seem to
find any examples of a connection that uses a username and password.
Wednesday, 28 August 2013
Loading validations from a table
Loading validations from a table
I need to load model validations from a table and validate my model. e.g.
I have a database table called validations, which has rows like :
validation_action validation_condition
---------------- --------------------
validates_presence_of if answer_name is name
validates_format_of if answer_type is date
In my model I want:
class Model < ActiveRecord::Base
load validation_actions , lambda {if validation_condition is true}
I need to load model validations from a table and validate my model. e.g.
I have a database table called validations, which has rows like :
validation_action validation_condition
---------------- --------------------
validates_presence_of if answer_name is name
validates_format_of if answer_type is date
In my model I want:
class Model < ActiveRecord::Base
load validation_actions , lambda {if validation_condition is true}
Using find before wc eliminates total
Using find before wc eliminates total
I'm using find to search through all subdirectories and current directory
to find all .py files, and then run wc -l to find number of lines.
However, when I use find with wc, the Total field is left off, unlike when
I run wc by itself. Does anyone know why this is happening?
find . -name \*.py -exec wc -l {} \;
187 ./check.py
43 ./file.py
33 ./mitch.py
...
1014 ./serve.py
41 ./test_scripts/line_graph.py
39 ./welcome.py
But no total, but when I run wc -l *.py in a directory I get a total:
wc -l *.py
187 check.py
43 file.py
94 log_com.py
154 log_results.py
33 mitch.py
1014 serve.py
39 welcome.py
1564 total
I'm using find to search through all subdirectories and current directory
to find all .py files, and then run wc -l to find number of lines.
However, when I use find with wc, the Total field is left off, unlike when
I run wc by itself. Does anyone know why this is happening?
find . -name \*.py -exec wc -l {} \;
187 ./check.py
43 ./file.py
33 ./mitch.py
...
1014 ./serve.py
41 ./test_scripts/line_graph.py
39 ./welcome.py
But no total, but when I run wc -l *.py in a directory I get a total:
wc -l *.py
187 check.py
43 file.py
94 log_com.py
154 log_results.py
33 mitch.py
1014 serve.py
39 welcome.py
1564 total
Lambda Statements in Linq
Lambda Statements in Linq
Is it possible to do something like the following in Linq?
List<Group> groupsCollection = new List<Group>();
groups.Select( g => {
String id = g.Attributes["id"].Value;
String title = g.Attributes["title"].Value;
groupsCollection.Add( new Group(id, title) );
} );
This is just an example. I know a Foreach loop would be sufficient but I
was querying whether it would be possible or not.
I tried it, and it's saying:
Cannot convert lambda expression to type
System.Collections.IEnumerable<CsQuery.IDomObject> because it's not a
delegate type
Edit: Group is my custom class.
Is it possible to do something like the following in Linq?
List<Group> groupsCollection = new List<Group>();
groups.Select( g => {
String id = g.Attributes["id"].Value;
String title = g.Attributes["title"].Value;
groupsCollection.Add( new Group(id, title) );
} );
This is just an example. I know a Foreach loop would be sufficient but I
was querying whether it would be possible or not.
I tried it, and it's saying:
Cannot convert lambda expression to type
System.Collections.IEnumerable<CsQuery.IDomObject> because it's not a
delegate type
Edit: Group is my custom class.
Text and Image edit on Canvas with save as file
Text and Image edit on Canvas with save as file
I am working on an application, in which there is requirement for one page
where user can Add/Edit text on canvas and save as file to print/edit it
again.
For example:
Add text to canvas, change its fonts, color, size, etc. Later I want to
add option for inserting the image on canvas.
It is just like MS Paint which is quite big software,here I just need
simple canvas, under that a stack panel where I want to add options to
edit text (color palette, size, & font).
Please help me out with suggestions & examples. It is not mandatory to use
canvas. My objective to text/image edit page, save as file, and editable
again.
Thank you in advance.
I am working on an application, in which there is requirement for one page
where user can Add/Edit text on canvas and save as file to print/edit it
again.
For example:
Add text to canvas, change its fonts, color, size, etc. Later I want to
add option for inserting the image on canvas.
It is just like MS Paint which is quite big software,here I just need
simple canvas, under that a stack panel where I want to add options to
edit text (color palette, size, & font).
Please help me out with suggestions & examples. It is not mandatory to use
canvas. My objective to text/image edit page, save as file, and editable
again.
Thank you in advance.
using jquery mask plugin with on() event
using jquery mask plugin with on() event
Is it possible to use mask function with "on()" event?
my jquery code for masking:
$("#ktel,#kmob").mask("(999) 999-9999");
what i need is something like this:
$("#ktel,#kmob").on("mask","(999) 999-9999");
Is it possible to use mask function with "on()" event?
my jquery code for masking:
$("#ktel,#kmob").mask("(999) 999-9999");
what i need is something like this:
$("#ktel,#kmob").on("mask","(999) 999-9999");
Tuesday, 27 August 2013
Mapping sharepoint 2013 Network drive to Mac
Mapping sharepoint 2013 Network drive to Mac
I'm trying to map a network drive to my Mac os X. I'm following this link
- http://www.usciences.edu/it/helpdesk/forstudents/MacDriveMapping.shtml ,
url of my network drive is -
https://moonraftinnovationlabs-public.sharepoint.com/_catalogs/masterpage/
I have a username and pwd for it
Whenever I click on connect it says - "problem connecting to the drive.
Contact your system administrator for more information"
I'm trying to map a network drive to my Mac os X. I'm following this link
- http://www.usciences.edu/it/helpdesk/forstudents/MacDriveMapping.shtml ,
url of my network drive is -
https://moonraftinnovationlabs-public.sharepoint.com/_catalogs/masterpage/
I have a username and pwd for it
Whenever I click on connect it says - "problem connecting to the drive.
Contact your system administrator for more information"
PL/SQL Group By - ORA-01422: exact fetch returns more than requested number of rows
PL/SQL Group By - ORA-01422: exact fetch returns more than requested
number of rows
I am writing the following query that I want to display car registration,
car group name, model name, cost and the number of bookings for each car.
I have to use an explicit cursor and I have to use an implicit cursor to
calculate the number of bookings that belong to each car.
My query is as follows:
SET SERVEROUTPUT ON FORMAT WRAP SIZE 12000
Declare
v_count number;
cursor carcur IS
SELECT * FROM i_car;
v_car carcur%ROWTYPE;
Begin
Select COUNT (registration)
INTO v_count
from i_booking
group by registration;
FOR v_car IN carcur LOOP
DBMS_OUTPUT.PUT_LINE('Registration:'|| ' '|| v_car.registration);
DBMS_OUTPUT.PUT_LINE('Car Group:'|| ' ' ||v_car.car_group_name);
DBMS_OUTPUT.PUT_LINE('Model Name:'|| ' '||v_car.model_name);
DBMS_OUTPUT.PUT_LINE('Cost:'|| ' '||v_car.cost);
DBMS_OUTPUT.PUT_LINE('Total Bookings:'|| ' '||v_count);
DBMS_OUTPUT.NEW_LINE;
END LOOP;
End;
The output I am getting is as follows: Declare * ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 7
I am sure it has something to do with the return values being put into the
variable, but I have no idea how to rectify this.
Any advice would be greatly appreciated.
Many thanks.
number of rows
I am writing the following query that I want to display car registration,
car group name, model name, cost and the number of bookings for each car.
I have to use an explicit cursor and I have to use an implicit cursor to
calculate the number of bookings that belong to each car.
My query is as follows:
SET SERVEROUTPUT ON FORMAT WRAP SIZE 12000
Declare
v_count number;
cursor carcur IS
SELECT * FROM i_car;
v_car carcur%ROWTYPE;
Begin
Select COUNT (registration)
INTO v_count
from i_booking
group by registration;
FOR v_car IN carcur LOOP
DBMS_OUTPUT.PUT_LINE('Registration:'|| ' '|| v_car.registration);
DBMS_OUTPUT.PUT_LINE('Car Group:'|| ' ' ||v_car.car_group_name);
DBMS_OUTPUT.PUT_LINE('Model Name:'|| ' '||v_car.model_name);
DBMS_OUTPUT.PUT_LINE('Cost:'|| ' '||v_car.cost);
DBMS_OUTPUT.PUT_LINE('Total Bookings:'|| ' '||v_count);
DBMS_OUTPUT.NEW_LINE;
END LOOP;
End;
The output I am getting is as follows: Declare * ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 7
I am sure it has something to do with the return values being put into the
variable, but I have no idea how to rectify this.
Any advice would be greatly appreciated.
Many thanks.
Script to strip out advertisements (PHP and/or Javascript)
Script to strip out advertisements (PHP and/or Javascript)
I'm looking for a script that will parse out a chunk of HTML (typically a
web-page) and strip out advertising.
It's really quite simple to do and I cant imagine it hasn't already been
done. All one has to do is - compile a list of ad-exchanges - strip out
HTML on a page that matches the (begining to end tags) for that domain.
I'd appreciate any help/pointers towards such a script?
Thanks in advance!!
I'm looking for a script that will parse out a chunk of HTML (typically a
web-page) and strip out advertising.
It's really quite simple to do and I cant imagine it hasn't already been
done. All one has to do is - compile a list of ad-exchanges - strip out
HTML on a page that matches the (begining to end tags) for that domain.
I'd appreciate any help/pointers towards such a script?
Thanks in advance!!
Sort a list of dictionaries while consolidating duplicates in Python?
Sort a list of dictionaries while consolidating duplicates in Python?
So I have a list of dictionaries like so:
data = [ {
'Organization' : '123 Solar',
'Phone' : '444-444-4444',
'Email' : '',
'website' : 'www.123solar.com'
}, {
'Organization' : '123 Solar',
'Phone' : '',
'Email' : 'joey@123solar.com',
'Website' : 'www.123solar.com'
}, {
etc...
} ]
Of course, this is not the exact data. But (maybe) from my example here
you can catch my problem. I have many records with the same "Organization"
name, but not one of them has the complete information for that record.
Is there an efficient method for searching over the list, sorting the list
based on the dictionary's first entry, and finally merging the data from
duplicates to create a unique entry? (Keep in mind these dictionaries are
quite large)
So I have a list of dictionaries like so:
data = [ {
'Organization' : '123 Solar',
'Phone' : '444-444-4444',
'Email' : '',
'website' : 'www.123solar.com'
}, {
'Organization' : '123 Solar',
'Phone' : '',
'Email' : 'joey@123solar.com',
'Website' : 'www.123solar.com'
}, {
etc...
} ]
Of course, this is not the exact data. But (maybe) from my example here
you can catch my problem. I have many records with the same "Organization"
name, but not one of them has the complete information for that record.
Is there an efficient method for searching over the list, sorting the list
based on the dictionary's first entry, and finally merging the data from
duplicates to create a unique entry? (Keep in mind these dictionaries are
quite large)
eg. i downloaded an application to my netbook, will it totally removed when i delete it?
eg. i downloaded an application to my netbook, will it totally removed
when i delete it?
I INstall a utorrent in my net book then there is an agreement that i
accept without totally read about whats in the agreement.When i delete it
just clicking right click then delete, will it totally removed in my net
book?
when i delete it?
I INstall a utorrent in my net book then there is an agreement that i
accept without totally read about whats in the agreement.When i delete it
just clicking right click then delete, will it totally removed in my net
book?
Hotkey to select content of the current cell
Hotkey to select content of the current cell
is there a hot-key or a sequence of hot-keys to select the content of a
table-cell in MS-word? the cursor is within that cell.
All I found is Tab for next cells content and Shift+Tab for previous cells
content.
Different hot key pages on the web show "toolbar 32778" as hot-key.
I need this information for a VBA Macro.
is there a hot-key or a sequence of hot-keys to select the content of a
table-cell in MS-word? the cursor is within that cell.
All I found is Tab for next cells content and Shift+Tab for previous cells
content.
Different hot key pages on the web show "toolbar 32778" as hot-key.
I need this information for a VBA Macro.
hide a table td using Jquery
hide a table td using Jquery
In the following code how can i hide the id column of the table.
var joblist = "";
joblist = joblist + "<table ><tr><th >Select</th><th id='td_1'>ID</th>
<th >Name</th><th >Names</th><th>OS</th><th >Server</th></tr>";
var tabString = '<tr ><td > ' + '<input type="radio" name="joblist"
onclick="myfunc(this);" id= ' + value.jobid + 'value=' +
value.jobid + '> </td><td id="td_1" >' + value._id +
'</td><td >'+ value.names + '</td><td a>' + value.os +
'</td><td >' + value.server + '</td></tr>';
joblist = joblist + tabString;
I tried
$("#td_1").hide()
But it is not working.Any other solutions?
In the following code how can i hide the id column of the table.
var joblist = "";
joblist = joblist + "<table ><tr><th >Select</th><th id='td_1'>ID</th>
<th >Name</th><th >Names</th><th>OS</th><th >Server</th></tr>";
var tabString = '<tr ><td > ' + '<input type="radio" name="joblist"
onclick="myfunc(this);" id= ' + value.jobid + 'value=' +
value.jobid + '> </td><td id="td_1" >' + value._id +
'</td><td >'+ value.names + '</td><td a>' + value.os +
'</td><td >' + value.server + '</td></tr>';
joblist = joblist + tabString;
I tried
$("#td_1").hide()
But it is not working.Any other solutions?
Syntax issue with match method
Syntax issue with match method
I want to match whatever word is after ">. This is my example text, and
text to match.
<a href="http://www.foo.bar">example_text (a)</a>
Text to grab:
example_text
Here's my code:
$page_html = Nokogiri::HTML.parse($browser.html)
$holder =
$page_html.xpath('/html/body/div[2]/div[5]/div/table/tbody/tr[4]/td/a')
$user = $holder.match('(?<=\"\>)\w*')
And my error:
bot.rb:19: syntax error, unexpected tIDENTIFIER, expecting keyword_end
$user = $holder.match('(?<=\"\>)\w*')
^
I'm guessing the reason is the quotes interfering.
I want to match whatever word is after ">. This is my example text, and
text to match.
<a href="http://www.foo.bar">example_text (a)</a>
Text to grab:
example_text
Here's my code:
$page_html = Nokogiri::HTML.parse($browser.html)
$holder =
$page_html.xpath('/html/body/div[2]/div[5]/div/table/tbody/tr[4]/td/a')
$user = $holder.match('(?<=\"\>)\w*')
And my error:
bot.rb:19: syntax error, unexpected tIDENTIFIER, expecting keyword_end
$user = $holder.match('(?<=\"\>)\w*')
^
I'm guessing the reason is the quotes interfering.
Monday, 26 August 2013
How do I clean up the classes properly in Lua and C++?
How do I clean up the classes properly in Lua and C++?
I have used Luabind to bind a class to Lua. I need to make sure the class
is correctly disposed of when it is destructed or made null through
myClass = nil.
This class adds itself to a static list inside itself like this:
template<typename T>
class component : public componentInterface
{
public:
static std::list<componentInterface *> list;
component() : componentInterface()
{
di::component<T>::list.push_back(this);
}
~component()
{
di::component<T>::list.remove(this);
}
};
And when the destructor is called it promptly removes itself from the list.
I have used Luabind to bind a class to Lua. I need to make sure the class
is correctly disposed of when it is destructed or made null through
myClass = nil.
This class adds itself to a static list inside itself like this:
template<typename T>
class component : public componentInterface
{
public:
static std::list<componentInterface *> list;
component() : componentInterface()
{
di::component<T>::list.push_back(this);
}
~component()
{
di::component<T>::list.remove(this);
}
};
And when the destructor is called it promptly removes itself from the list.
Deleting printed content in PHP mysql
Deleting printed content in PHP mysql
I'm creating a site to upload content and I want the user to be able to
delete content on their Edit page. The following code is what I have
echoed after the user inputs their content
`<div id="content_review">
<?php
$q_getRev = "SELECT * FROM REVIEWS ORDER BY RID DESC";
$r_getRev = mysql_query($q_getRev,$connection);
$n_getRev = mysql_num_rows($r_getRev);
for($i=0; $i<$n_getRev; $i++){
echo '<img class="poster" src="'.mysql_result($r_getRev,
$i, 'PREVIEW_IMG').' " />';
echo '<div class="title">'.mysql_result($r_getRev, $i,
'TITLE').'</div><br/>';
echo '<div class="reviews">'.mysql_result($r_getRev, $i,
'REVIEW').'</div>';
echo '<div><img src=image/x.png
id="delete">'.mysql_result($_delRev, $i,
'REVIEW').'</div>';
}
?>`
I want the user to be able to delete content that was previously printed
in PHP. I'm not entirely sure how to proceed to make the following line
delete content from my REVIEW column from mysql (the following line
appears as a delete button next to the already printed content)
echo '<div><img src=image/x.png id="delete">'.mysql_result($_delRev, $i,
'REVIEW').'</div>';
I'm creating a site to upload content and I want the user to be able to
delete content on their Edit page. The following code is what I have
echoed after the user inputs their content
`<div id="content_review">
<?php
$q_getRev = "SELECT * FROM REVIEWS ORDER BY RID DESC";
$r_getRev = mysql_query($q_getRev,$connection);
$n_getRev = mysql_num_rows($r_getRev);
for($i=0; $i<$n_getRev; $i++){
echo '<img class="poster" src="'.mysql_result($r_getRev,
$i, 'PREVIEW_IMG').' " />';
echo '<div class="title">'.mysql_result($r_getRev, $i,
'TITLE').'</div><br/>';
echo '<div class="reviews">'.mysql_result($r_getRev, $i,
'REVIEW').'</div>';
echo '<div><img src=image/x.png
id="delete">'.mysql_result($_delRev, $i,
'REVIEW').'</div>';
}
?>`
I want the user to be able to delete content that was previously printed
in PHP. I'm not entirely sure how to proceed to make the following line
delete content from my REVIEW column from mysql (the following line
appears as a delete button next to the already printed content)
echo '<div><img src=image/x.png id="delete">'.mysql_result($_delRev, $i,
'REVIEW').'</div>';
Why is x**3 slower than x*x*x?
Why is x**3 slower than x*x*x?
In NumPy, x*x*x is an order of magnitude faster than x**3 or even
np.power(x, 3).
x = np.random.rand(1e6)
%timeit x**3
100 loops, best of 3: 7.07 ms per loop
%timeit x*x*x
10000 loops, best of 3: 163 µs per loop
%timeit np.power(x, 3)
100 loops, best of 3: 7.15 ms per loop
Any ideas as to why this behavior happens? As far as I can tell all three
yield the same output (checked with np.allclose).
In NumPy, x*x*x is an order of magnitude faster than x**3 or even
np.power(x, 3).
x = np.random.rand(1e6)
%timeit x**3
100 loops, best of 3: 7.07 ms per loop
%timeit x*x*x
10000 loops, best of 3: 163 µs per loop
%timeit np.power(x, 3)
100 loops, best of 3: 7.15 ms per loop
Any ideas as to why this behavior happens? As far as I can tell all three
yield the same output (checked with np.allclose).
Creating Maven WAR Overlays building with ANT
Creating Maven WAR Overlays building with ANT
My team is currently looking at moving from using "vendor branches" to
utilizing Maven WAR Overlays to build a java-based ERP application. Part
of this means I will be trying to overlay multiple war files for core
code, enhancements, mods, etc.
The application itself natively builds in ANT, so I created a standard POM
that calls the AntRun plugin and performs a "headless-ant" task to build
the .war
My question is, since I am utilizing Maven (via Jenkins) to build this,
will I be able to leverage the Maven WAR overlay functionality when this
application is natively building with ANT, or does the application need to
natively build in Maven?
My thought process is that I can just add the other WAR files as
dependencies to my other POM's as I've added the dependencies to my Maven
'wrapper' POM.
Any help or input on this would be greatly appreciated.
My team is currently looking at moving from using "vendor branches" to
utilizing Maven WAR Overlays to build a java-based ERP application. Part
of this means I will be trying to overlay multiple war files for core
code, enhancements, mods, etc.
The application itself natively builds in ANT, so I created a standard POM
that calls the AntRun plugin and performs a "headless-ant" task to build
the .war
My question is, since I am utilizing Maven (via Jenkins) to build this,
will I be able to leverage the Maven WAR overlay functionality when this
application is natively building with ANT, or does the application need to
natively build in Maven?
My thought process is that I can just add the other WAR files as
dependencies to my other POM's as I've added the dependencies to my Maven
'wrapper' POM.
Any help or input on this would be greatly appreciated.
Reload a javascript using jquery
Reload a javascript using jquery
I have made a PHP file that shows up a session meter for Joomla's frontend
using JavaScript. I have also made an other PHP file that shows the user's
details and it reloads using jQuery. What I want to do is, when I press
jQuery's reload button, JavaScript session meter reload too.
Session Meter PHP:
<?php // NO DIRECT ACCESS
defined('_JEXEC') or die('Restricted access');
$document = & JFactory::getDocument();
$document->addStyleSheet('***/***/session_meter.css');
include('***/***/scripts.php');
$document->addScriptDeclaration($javascript);
$output = array();
$session = & JFactory::getSession();
$expire = $session->getExpire();
$output[] = '<span id="log_res" class="">'.$expire.'</span>';
foreach ($output as $item){echo $item;}
?>
Session Meter javascript (part of it):
<?php // NO DIRECT ACCESS
defined('_JEXEC') or die('Restricted access');
$javascript = ' var timer_start =$time(); '."\n";
$javascript .= 'blah blah blah...
?>
User Profile JQuery script (part of it):
<?php // NO DIRECT ACCESS
defined('_JEXEC') or die('Restricted access'); ?>
<script>
var $JQ_ = jQuery.noConflict();
$JQ_(document).ready(function(){
$JQ_("#refresh_button").click(function(){$JQ_("#r_points").load('index.php
#r_points').fadeOut(1000).fadeIn(1000);});
});
</script>
I am trying to do something like this:
$JQ_("#refresh_button").click(function(){
$JQ_("#log_res").load('index.php #log_res').fadeOut(1000).fadeIn(1000);
});
but it only reloads session meter's span and not its JavaScript!
Any idea?
I have made a PHP file that shows up a session meter for Joomla's frontend
using JavaScript. I have also made an other PHP file that shows the user's
details and it reloads using jQuery. What I want to do is, when I press
jQuery's reload button, JavaScript session meter reload too.
Session Meter PHP:
<?php // NO DIRECT ACCESS
defined('_JEXEC') or die('Restricted access');
$document = & JFactory::getDocument();
$document->addStyleSheet('***/***/session_meter.css');
include('***/***/scripts.php');
$document->addScriptDeclaration($javascript);
$output = array();
$session = & JFactory::getSession();
$expire = $session->getExpire();
$output[] = '<span id="log_res" class="">'.$expire.'</span>';
foreach ($output as $item){echo $item;}
?>
Session Meter javascript (part of it):
<?php // NO DIRECT ACCESS
defined('_JEXEC') or die('Restricted access');
$javascript = ' var timer_start =$time(); '."\n";
$javascript .= 'blah blah blah...
?>
User Profile JQuery script (part of it):
<?php // NO DIRECT ACCESS
defined('_JEXEC') or die('Restricted access'); ?>
<script>
var $JQ_ = jQuery.noConflict();
$JQ_(document).ready(function(){
$JQ_("#refresh_button").click(function(){$JQ_("#r_points").load('index.php
#r_points').fadeOut(1000).fadeIn(1000);});
});
</script>
I am trying to do something like this:
$JQ_("#refresh_button").click(function(){
$JQ_("#log_res").load('index.php #log_res').fadeOut(1000).fadeIn(1000);
});
but it only reloads session meter's span and not its JavaScript!
Any idea?
Combining functions in Haskell
Combining functions in Haskell
How can I combine these similar function in Haskell?
getGroup [] acc = reverse acc
getGroup ((Letter x):letfs) acc = getGroup letfs ((Letter x):acc)
getGroup ((Group x):letfs) acc = getGroup letfs ((Group (makeList x)):acc)
getGroup ((Star x):letfs) acc = getGroup letfs ((Star (makeList x)):acc)
getGroup ((Plus x):letfs) acc = getGroup letfs ((Plus (makeList x)):acc)
getGroup ((Ques x):letfs) acc = getGroup letfs ((Ques (makeList x)):acc)
Letter, Group, Star, Plus and Ques are all part of a data type definition.
data MyData a
= Operand a
| Letter a
| Star [RegEx a]
| Plus [RegEx a]
| Ques [RegEx a]
| Pipe [RegEx a] [RegEx a]
| Group [RegEx a]
deriving Show
I wonder if there is a better way to write those function because of their
similarities. Mostly, I wish to combine the functions for Group, Star,
Plus and Ques, because they are identical, but if there is a method to
combine all of them it would be better.
How can I combine these similar function in Haskell?
getGroup [] acc = reverse acc
getGroup ((Letter x):letfs) acc = getGroup letfs ((Letter x):acc)
getGroup ((Group x):letfs) acc = getGroup letfs ((Group (makeList x)):acc)
getGroup ((Star x):letfs) acc = getGroup letfs ((Star (makeList x)):acc)
getGroup ((Plus x):letfs) acc = getGroup letfs ((Plus (makeList x)):acc)
getGroup ((Ques x):letfs) acc = getGroup letfs ((Ques (makeList x)):acc)
Letter, Group, Star, Plus and Ques are all part of a data type definition.
data MyData a
= Operand a
| Letter a
| Star [RegEx a]
| Plus [RegEx a]
| Ques [RegEx a]
| Pipe [RegEx a] [RegEx a]
| Group [RegEx a]
deriving Show
I wonder if there is a better way to write those function because of their
similarities. Mostly, I wish to combine the functions for Group, Star,
Plus and Ques, because they are identical, but if there is a method to
combine all of them it would be better.
Dojo.query remove class
Dojo.query remove class
I want to remove a class so I use this following code :
var StyleToRemove = query(".someclass").parent().parent().parent().parent();
StyleToRemove.forEach(function(node) {
domClass.remove(node, "ui-state-default");
});
The code works on Firefox(StyleToRemove returns object HTMLdivElement) but
not on ie8(StyleToRemove returns object).
Why ?
I want to remove a class so I use this following code :
var StyleToRemove = query(".someclass").parent().parent().parent().parent();
StyleToRemove.forEach(function(node) {
domClass.remove(node, "ui-state-default");
});
The code works on Firefox(StyleToRemove returns object HTMLdivElement) but
not on ie8(StyleToRemove returns object).
Why ?
Conversion failed when converting date in stored procedure
Conversion failed when converting date in stored procedure
I have store procedure like this: ALTER procedure [dbo].[ParkingSummary1]
@startdate varchar(100), @enddate varchar(100) as begin declare @date1
datetime = CONVERT(datetime, @startdate + ' 00:01:00.000', 120); declare
@date2 datetime = CONVERT(datetime, @enddate + ' 23:23:59.000', 120);
DECLARE @cols AS NVARCHAR(MAX), @query AS NVARCHAR(MAX) select @cols =
STUFF((SELECT distinct ',' + QUOTENAME(Vtype) from VType_tbl FOR XML
PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)') ,1,1,'') set @query = 'SELECT
LocName, ' + @cols + ' from ( select l.LocName,Vtype from Transaction_tbl
t join VType_tbl v on t.vtid = v.vtid join dbo.Location_tbl l on
t.locid=l.Locid where dtime between '''+ @date1+''' and '''+@date2+''' and
Status = 5 ) d pivot ( count(Vtype) for Vtype in (' + @cols + ') ) p '
exec sys.sp_executesql @query end.while am passing startand enddate like
this: @startdate = '2013-08-05', @enddate = '2013-08-08' am getting error
like this:Conversion failed when converting date and/or time from
character string.
I have store procedure like this: ALTER procedure [dbo].[ParkingSummary1]
@startdate varchar(100), @enddate varchar(100) as begin declare @date1
datetime = CONVERT(datetime, @startdate + ' 00:01:00.000', 120); declare
@date2 datetime = CONVERT(datetime, @enddate + ' 23:23:59.000', 120);
DECLARE @cols AS NVARCHAR(MAX), @query AS NVARCHAR(MAX) select @cols =
STUFF((SELECT distinct ',' + QUOTENAME(Vtype) from VType_tbl FOR XML
PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)') ,1,1,'') set @query = 'SELECT
LocName, ' + @cols + ' from ( select l.LocName,Vtype from Transaction_tbl
t join VType_tbl v on t.vtid = v.vtid join dbo.Location_tbl l on
t.locid=l.Locid where dtime between '''+ @date1+''' and '''+@date2+''' and
Status = 5 ) d pivot ( count(Vtype) for Vtype in (' + @cols + ') ) p '
exec sys.sp_executesql @query end.while am passing startand enddate like
this: @startdate = '2013-08-05', @enddate = '2013-08-08' am getting error
like this:Conversion failed when converting date and/or time from
character string.
Sunday, 25 August 2013
boot problem in ubuntu
boot problem in ubuntu
Yestarday night i directly shut my computer down by pressing shut down key
from keyboard. Today morning when i started my computer purple screen
appears then ubuntu logo loads but it doesnot goes to the page that asks
my password, instead a dark screen with a cursor on upper left screen
appears and then nothing happens I am new to ubuntu OS . Plz help me fix
this problem without making me to reinstall ububtu. Thank you.
Yestarday night i directly shut my computer down by pressing shut down key
from keyboard. Today morning when i started my computer purple screen
appears then ubuntu logo loads but it doesnot goes to the page that asks
my password, instead a dark screen with a cursor on upper left screen
appears and then nothing happens I am new to ubuntu OS . Plz help me fix
this problem without making me to reinstall ububtu. Thank you.
Logic: some basic plane geometry
Logic: some basic plane geometry
Suppose you've got the language of some basic plane geometry, i.e. two
1-place relation symbols $P$ and $L$ for point and line and one 2-place
relation symbol $I$ for point $x$ lies on line $y$. Now, how is it
possible to express the following axiom in this language: for every line
$l$ and point $x$ (which is not on $l$), there is a unique line $m$
through point $x$.
This is what i've got: $\forall l,x$ $\neg I(x,l)\rightarrow \exists m$
$I(x,m)$.
Is this a correct sentence to begin with, and how could I express the
uniqueness of the line $m$?
Suppose you've got the language of some basic plane geometry, i.e. two
1-place relation symbols $P$ and $L$ for point and line and one 2-place
relation symbol $I$ for point $x$ lies on line $y$. Now, how is it
possible to express the following axiom in this language: for every line
$l$ and point $x$ (which is not on $l$), there is a unique line $m$
through point $x$.
This is what i've got: $\forall l,x$ $\neg I(x,l)\rightarrow \exists m$
$I(x,m)$.
Is this a correct sentence to begin with, and how could I express the
uniqueness of the line $m$?
AngularJS: Dependency Management
AngularJS: Dependency Management
We are currently planning a website which exists out of different
AngularJS apps that will make use of common services. Services will be
implemented in seperate files; to minimize the filesize of the apps we
want to include/concatenate only those service-files that are used in the
corresponding app - so we are looking for the best practise in dependency
management.
is there something like requireJS in angular or what would you suggest to
handle the includes? thanks in advance .)
We are currently planning a website which exists out of different
AngularJS apps that will make use of common services. Services will be
implemented in seperate files; to minimize the filesize of the apps we
want to include/concatenate only those service-files that are used in the
corresponding app - so we are looking for the best practise in dependency
management.
is there something like requireJS in angular or what would you suggest to
handle the includes? thanks in advance .)
give an example of a set that is countable but not denumerable.
give an example of a set that is countable but not denumerable.
give an example of a set that is countable but not denumerable. I know
that every denumberable set is countable.
give an example of a set that is countable but not denumerable. I know
that every denumberable set is countable.
Saturday, 24 August 2013
How to get select box option value in a input text field
How to get select box option value in a input text field
Here is my code:
<select name="art_type">
<option value="ra">Research
Article</option>
<option value="rea">Review
Article</option>
<option
value="re">Reviews</option>
<option
value="op">Opinions</option>
<option value="le">Letters
to the Editor</option>
</select>
<input style="border: none;" type="text" id="get_id_val" value="">
So whatever value user selects from the select box that value should be
entered in the textbox. How to do that?
So whatever value user selects from the select box that value should be
entered in the textbox. How to do that?
Here is my code:
<select name="art_type">
<option value="ra">Research
Article</option>
<option value="rea">Review
Article</option>
<option
value="re">Reviews</option>
<option
value="op">Opinions</option>
<option value="le">Letters
to the Editor</option>
</select>
<input style="border: none;" type="text" id="get_id_val" value="">
So whatever value user selects from the select box that value should be
entered in the textbox. How to do that?
So whatever value user selects from the select box that value should be
entered in the textbox. How to do that?
I did a simple irc bot how can i send a message to the channel after joined a channel?
I did a simple irc bot how can i send a message to the channel after
joined a channel?
This is the code :
private void connectToIrc()
{
//Connect to irc server and get input and output text streams
from TcpClient.
nick = textBox1.Text;
owner = textBox2.Text;
server = textBox3.Text;
port = Convert.ToInt32(textBox4.Text);
chan = "#" + textBox5.Text;
sock.Connect(server, port);//server, port);
richTextBox1.Invoke((MethodInvoker)delegate
{
ColorText.AppendText(richTextBox1, "Server: ", Color.Green);
ColorText.AppendText(richTextBox1, server+" ",
Color.Red);
ColorText.AppendText(richTextBox1, "Port: ", Color.Green);
ColorText.AppendText(richTextBox1, port.ToString() +
Environment.NewLine + Environment.NewLine, Color.Red);
});
if (!sock.Connected)
{
Console.WriteLine("Failed to connect!");
return;
}
input = new System.IO.StreamReader(sock.GetStream());
output = new System.IO.StreamWriter(sock.GetStream());
//Starting USER and NICK login commands
output.Write(
"USER " + nick + " 0 * :" + owner + "\r\n" +
"NICK " + nick + "\r\n"
);
output.Flush();
//Process each line received from irc server
//buf = input.ReadLine();
while ((buf = input.ReadLine()) != null)
{
buf = buf + Environment.NewLine;
//Display received irc message
//Console.WriteLine(buf);
richTextBox1.Invoke((MethodInvoker)delegate
{
ColorText.AppendText(richTextBox1, buf,Color.Black);
});
if (buf.StartsWith("ERROR")) break;
//Send pong reply to any ping messages
if (buf.StartsWith("PING ")) {
output.Write(buf.Replace("PING", "PONG") + "\r\n");
output.Flush(); }
if (buf[0] != ':') continue;
//After server sends 001 command, we can set mode to bot and
join a channel
if (buf.Split(' ')[1] == "001")
{
output.Write(
"MODE " + nick + " +B\r\n" +
"JOIN " + chan + "\r\n" + "PRIVMSG " + chan + " :hello"
);
output.Flush();
}
buf = input.ReadLine();
}
}
I added this part to the code: + "PRIVMSG " + chan + " :hello" But it does
nothing i dont see any "hello" in the channel.
I used the example in this site :
http://jakash3.wordpress.com/2012/02/13/simple-vb-net-and-csharp-irc-client/
The C# example.
How can i send a message to the channel after joined one ? I want to send
one message and if its working next step is to add messages in queue and
they will be send automatic one by one.
How can i do it ?
joined a channel?
This is the code :
private void connectToIrc()
{
//Connect to irc server and get input and output text streams
from TcpClient.
nick = textBox1.Text;
owner = textBox2.Text;
server = textBox3.Text;
port = Convert.ToInt32(textBox4.Text);
chan = "#" + textBox5.Text;
sock.Connect(server, port);//server, port);
richTextBox1.Invoke((MethodInvoker)delegate
{
ColorText.AppendText(richTextBox1, "Server: ", Color.Green);
ColorText.AppendText(richTextBox1, server+" ",
Color.Red);
ColorText.AppendText(richTextBox1, "Port: ", Color.Green);
ColorText.AppendText(richTextBox1, port.ToString() +
Environment.NewLine + Environment.NewLine, Color.Red);
});
if (!sock.Connected)
{
Console.WriteLine("Failed to connect!");
return;
}
input = new System.IO.StreamReader(sock.GetStream());
output = new System.IO.StreamWriter(sock.GetStream());
//Starting USER and NICK login commands
output.Write(
"USER " + nick + " 0 * :" + owner + "\r\n" +
"NICK " + nick + "\r\n"
);
output.Flush();
//Process each line received from irc server
//buf = input.ReadLine();
while ((buf = input.ReadLine()) != null)
{
buf = buf + Environment.NewLine;
//Display received irc message
//Console.WriteLine(buf);
richTextBox1.Invoke((MethodInvoker)delegate
{
ColorText.AppendText(richTextBox1, buf,Color.Black);
});
if (buf.StartsWith("ERROR")) break;
//Send pong reply to any ping messages
if (buf.StartsWith("PING ")) {
output.Write(buf.Replace("PING", "PONG") + "\r\n");
output.Flush(); }
if (buf[0] != ':') continue;
//After server sends 001 command, we can set mode to bot and
join a channel
if (buf.Split(' ')[1] == "001")
{
output.Write(
"MODE " + nick + " +B\r\n" +
"JOIN " + chan + "\r\n" + "PRIVMSG " + chan + " :hello"
);
output.Flush();
}
buf = input.ReadLine();
}
}
I added this part to the code: + "PRIVMSG " + chan + " :hello" But it does
nothing i dont see any "hello" in the channel.
I used the example in this site :
http://jakash3.wordpress.com/2012/02/13/simple-vb-net-and-csharp-irc-client/
The C# example.
How can i send a message to the channel after joined one ? I want to send
one message and if its working next step is to add messages in queue and
they will be send automatic one by one.
How can i do it ?
I am trying to find a set of coordinates by solving the repeating sequence given:
I am trying to find a set of coordinates by solving the repeating sequence
given:
I am trying to find a set of coordinates by solving the repeating sequence
given:
As seen in the following question:
AnOTHER puzzle. This was the last one I had in mind when I first starting
hiding caches last week so I'll probably start branching out after this.
Nano, log only, BYOP. Its on a pretty slow street but stealth will need to
be used for the muggles living nearby. Good luck...hope to keep the
streaks alive.
At the coords, however, you will find two radio towers. These towers are
called "repeater" towers. They take radio transmissions, between pilots
and air traffic controllers, and amplify them. This allows the
transmissions to be transmitted over a greater distance than otherwise.
The transmitters and receivers for this part of the aviation industry
operate on the Very High Frequency radio band, specifically 118.1 MHz to
137.0 MHz. As a piece of gee whiz information, Santa Monica Airports
operates two radio frequencies; one for airplanes on the ground and one
for airplanes in the air. They are 121.9 and 120.1 respectively.
1234871235896198698623453390823469844863512340073651388136541980016351458864538908086754178
73651434909112837451891176543123423167885460765226354563577645725643367543299637836799674635
given:
I am trying to find a set of coordinates by solving the repeating sequence
given:
As seen in the following question:
AnOTHER puzzle. This was the last one I had in mind when I first starting
hiding caches last week so I'll probably start branching out after this.
Nano, log only, BYOP. Its on a pretty slow street but stealth will need to
be used for the muggles living nearby. Good luck...hope to keep the
streaks alive.
At the coords, however, you will find two radio towers. These towers are
called "repeater" towers. They take radio transmissions, between pilots
and air traffic controllers, and amplify them. This allows the
transmissions to be transmitted over a greater distance than otherwise.
The transmitters and receivers for this part of the aviation industry
operate on the Very High Frequency radio band, specifically 118.1 MHz to
137.0 MHz. As a piece of gee whiz information, Santa Monica Airports
operates two radio frequencies; one for airplanes on the ground and one
for airplanes in the air. They are 121.9 and 120.1 respectively.
1234871235896198698623453390823469844863512340073651388136541980016351458864538908086754178
73651434909112837451891176543123423167885460765226354563577645725643367543299637836799674635
Browsers compatibility
Browsers compatibility
Hi i my trying to make a website. I am getting problem on menu bar..In
safari and chrome it works fine but on firefox i see a white gap in menu
items. Please check attached screenshots
and this is my css code and i am using for it--
Please help, i tried a lot, also googled stuff but couldn't figure it out
Thanks
Hi i my trying to make a website. I am getting problem on menu bar..In
safari and chrome it works fine but on firefox i see a white gap in menu
items. Please check attached screenshots
and this is my css code and i am using for it--
Please help, i tried a lot, also googled stuff but couldn't figure it out
Thanks
How to hide php extension using a .htaccess and still keep the path_info superglobal accessible
How to hide php extension using a .htaccess and still keep the path_info
superglobal accessible
I wonder what is the correct way to hide php extension from urls when
using a .htaccess. Currently I have my .htaccess like this:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+\.php)$/(.+)$/(.+)$/$ /$1.php/$2/$3 [S]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]
The above second rule is because I have to keep the PHP_INFO accessible
when giving a url like this: xxx/vision.php/2013/Enero
And in the htdocs directory I have AllowOverridde Options and it is set up
like this:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
But it's giving me an Internal Server Error whenever I try to access the
server document root. Perhaps someone is able to point me in the right
direction, and hopefully soon cause I'm in a hurry
superglobal accessible
I wonder what is the correct way to hide php extension from urls when
using a .htaccess. Currently I have my .htaccess like this:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+\.php)$/(.+)$/(.+)$/$ /$1.php/$2/$3 [S]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]
The above second rule is because I have to keep the PHP_INFO accessible
when giving a url like this: xxx/vision.php/2013/Enero
And in the htdocs directory I have AllowOverridde Options and it is set up
like this:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
But it's giving me an Internal Server Error whenever I try to access the
server document root. Perhaps someone is able to point me in the right
direction, and hopefully soon cause I'm in a hurry
RabbitMQ and relationship between channel and connection
RabbitMQ and relationship between channel and connection
The RabbitMQ Java client has the following concepts:
Connection - a connection to a RabbitMQ server instance
Channel - ???
Consumer thread pool - a pool of threads that consume messages off the
RabbitMQ server queues
Queue - a structure that holds messages in FIFO order
I'm trying to understand the relationship, and more importantly, the
associations between them.
I'm still not quite sure what a Channel is, other than the fact that this
is the structure that you publish and consume from, and that it is created
from an open connection. If someone could explain to me what the "Channel"
represents, it might help clear a few things up.
What is the relationship between Channel and Queue? Can the same Channel
be used to communicate to multiples Queues, or does it have to be 1:1?
What is the relationship between Queue and the Consumer Pool? Can multiple
Consumers be subscribed to the same Queue? Can multiple Queues be consumed
by the same Consumer? Or is the relationship 1:1?
Thanks in advance for any help here!
The RabbitMQ Java client has the following concepts:
Connection - a connection to a RabbitMQ server instance
Channel - ???
Consumer thread pool - a pool of threads that consume messages off the
RabbitMQ server queues
Queue - a structure that holds messages in FIFO order
I'm trying to understand the relationship, and more importantly, the
associations between them.
I'm still not quite sure what a Channel is, other than the fact that this
is the structure that you publish and consume from, and that it is created
from an open connection. If someone could explain to me what the "Channel"
represents, it might help clear a few things up.
What is the relationship between Channel and Queue? Can the same Channel
be used to communicate to multiples Queues, or does it have to be 1:1?
What is the relationship between Queue and the Consumer Pool? Can multiple
Consumers be subscribed to the same Queue? Can multiple Queues be consumed
by the same Consumer? Or is the relationship 1:1?
Thanks in advance for any help here!
PDOException - could not find driver - Unable to update the database scheme by php
PDOException - could not find driver - Unable to update the database
scheme by php
I am trying to update the schema of mysql database by doctorine
php app/console doctrine:schema:update --force
it shows
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/Cellar/php/5.3.10/lib/php/extensions/no-debug-non-zts-20090626/php_pdo_mysql.dll'
-
dlopen(/usr/local/Cellar/php/5.3.10/lib/php/extensions/no-debug-non-zts-20090626/php_pdo_mysql.dll,
9): image not found in Unknown on line 0
[PDOException]
could not find driver
it looks like extension is not available.
but according to my phpinfo();
pdo_mysql is enabled.
pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.10 - 20111026 - $Id:
e707c415db32080b3752b232487a435ee0372157 $
Directive Local Value Master Value
pdo_mysql.default_socket /tmp/mysql.sock /tmp/mysql.sock
Is there any other point to check for me?
I also tried comment or uncomment this line in php.ini
;extension=php_pdo_mysql.dll
thanks a lot.
scheme by php
I am trying to update the schema of mysql database by doctorine
php app/console doctrine:schema:update --force
it shows
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/Cellar/php/5.3.10/lib/php/extensions/no-debug-non-zts-20090626/php_pdo_mysql.dll'
-
dlopen(/usr/local/Cellar/php/5.3.10/lib/php/extensions/no-debug-non-zts-20090626/php_pdo_mysql.dll,
9): image not found in Unknown on line 0
[PDOException]
could not find driver
it looks like extension is not available.
but according to my phpinfo();
pdo_mysql is enabled.
pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.10 - 20111026 - $Id:
e707c415db32080b3752b232487a435ee0372157 $
Directive Local Value Master Value
pdo_mysql.default_socket /tmp/mysql.sock /tmp/mysql.sock
Is there any other point to check for me?
I also tried comment or uncomment this line in php.ini
;extension=php_pdo_mysql.dll
thanks a lot.
How to properly implement RabbitMQ RPC from Java servlet web container?
How to properly implement RabbitMQ RPC from Java servlet web container?
I'd like for incoming Java servlet web requests to invoke RabbitMQ using
the RPC approach as described here.
However, I'm not sure how to properly reuse callback queues between
requests, as per the RabbitMQ tutorial linked above creating a new
callback queue per every request is inefficient (RabbitMQ may not cope
even if using the Queue TTL feature).
There would generally be only 1-2 RPC calls per every servlet request, but
obviously a lot of servlet requests per second.
I don't think I can share the callback queues between threads, so I'd want
at least one per each web worker thread.
My first idea was to store the callback queue in a ThreadLocal, but that
can lead to memory leaks.
My second idea was to store them in a session, but I am not sure they will
serialize properly and my sessions are currently not replicated/shared
between web servers, so it is IMHO not a good solution.
My infrastructure is Tomcat / Guice / Stripes Framework.
Any ideas what the most robust/simple solution is?
Am I missing something in this whole approach, and thus over-complicating
things?
Note 1- This question relates to the overall business case described here
- see option 1.
Note 2 - There is a seemingly related question How to setup RabbitMQ RPC
in a web context, but it is mostly concerned with proper shutdown of
threads created by the RabbitMQ client.
I'd like for incoming Java servlet web requests to invoke RabbitMQ using
the RPC approach as described here.
However, I'm not sure how to properly reuse callback queues between
requests, as per the RabbitMQ tutorial linked above creating a new
callback queue per every request is inefficient (RabbitMQ may not cope
even if using the Queue TTL feature).
There would generally be only 1-2 RPC calls per every servlet request, but
obviously a lot of servlet requests per second.
I don't think I can share the callback queues between threads, so I'd want
at least one per each web worker thread.
My first idea was to store the callback queue in a ThreadLocal, but that
can lead to memory leaks.
My second idea was to store them in a session, but I am not sure they will
serialize properly and my sessions are currently not replicated/shared
between web servers, so it is IMHO not a good solution.
My infrastructure is Tomcat / Guice / Stripes Framework.
Any ideas what the most robust/simple solution is?
Am I missing something in this whole approach, and thus over-complicating
things?
Note 1- This question relates to the overall business case described here
- see option 1.
Note 2 - There is a seemingly related question How to setup RabbitMQ RPC
in a web context, but it is mostly concerned with proper shutdown of
threads created by the RabbitMQ client.
Friday, 23 August 2013
how to create loading window while web conncetion is checking in windows form app C#?
how to create loading window while web conncetion is checking in windows
form app C#?
I have a test web connection form in c#. I want to show a loading window
while my connection is being checked, and then show the result of
checking.
This is my code for testing the web connection:
public bool ConnectionAvailable(string strServer)
{
try
{
HttpWebRequest reqFP =
(HttpWebRequest)HttpWebRequest.Create(strServer);
HttpWebResponse rspFP = (HttpWebResponse)reqFP.GetResponse();
if (HttpStatusCode.OK == rspFP.StatusCode)
{
// HTTP = 200 - Internet connection available, server online
rspFP.Close();
return true;
}
else
{
// Other status - Server or connection not available
rspFP.Close();
return false;
}
}
catch (WebException)
{
// Exception - connection not available
return false;
}
}
And this:
private void button1_Click(object sender, EventArgs e)
{
string url = "Web-url";
label1.Text = "Checking ...";
button1.Enabled = false;
if (ConnectionAvailable(url))
{
WebClient w = new WebClient();
w.Headers[HttpRequestHeader.ContentType] =
"application/x-www-form-urlencoded";
label1.Text = w.UploadString(url, "post", "SN=" + textBox1.Text);
button1.Enabled = true;
}
else
{
label1.Text = "Conntion fail";
button1.Enabled = true;
}
}
form app C#?
I have a test web connection form in c#. I want to show a loading window
while my connection is being checked, and then show the result of
checking.
This is my code for testing the web connection:
public bool ConnectionAvailable(string strServer)
{
try
{
HttpWebRequest reqFP =
(HttpWebRequest)HttpWebRequest.Create(strServer);
HttpWebResponse rspFP = (HttpWebResponse)reqFP.GetResponse();
if (HttpStatusCode.OK == rspFP.StatusCode)
{
// HTTP = 200 - Internet connection available, server online
rspFP.Close();
return true;
}
else
{
// Other status - Server or connection not available
rspFP.Close();
return false;
}
}
catch (WebException)
{
// Exception - connection not available
return false;
}
}
And this:
private void button1_Click(object sender, EventArgs e)
{
string url = "Web-url";
label1.Text = "Checking ...";
button1.Enabled = false;
if (ConnectionAvailable(url))
{
WebClient w = new WebClient();
w.Headers[HttpRequestHeader.ContentType] =
"application/x-www-form-urlencoded";
label1.Text = w.UploadString(url, "post", "SN=" + textBox1.Text);
button1.Enabled = true;
}
else
{
label1.Text = "Conntion fail";
button1.Enabled = true;
}
}
gridExtra Colour different rows with tableGrob
gridExtra Colour different rows with tableGrob
I have a question regarding tableGrob/grid.table from the gridExtra
package. Using the regular parameter settings, it is straightforward to
colour alternate rows. However, I was hoping that it might be feasible to
get a bit more control over the colouring of the rows. For example, is it
possible to colour every third row in a different colour? I suspect the
grid.edit function is one way to approach this, judging by the example in
this link: http://code.google.com/p/gridextra/wiki/tableGrob but I can't
figure out how to apply that to my question.
I believe the person who posted this question had the same in mind. Table
with rows of different colors with tableGrob
I am currently stuck with R 2.13 due to compatibility issues, so if there
are any suggestions which don't involve later versions that would be
ideal.
I have a question regarding tableGrob/grid.table from the gridExtra
package. Using the regular parameter settings, it is straightforward to
colour alternate rows. However, I was hoping that it might be feasible to
get a bit more control over the colouring of the rows. For example, is it
possible to colour every third row in a different colour? I suspect the
grid.edit function is one way to approach this, judging by the example in
this link: http://code.google.com/p/gridextra/wiki/tableGrob but I can't
figure out how to apply that to my question.
I believe the person who posted this question had the same in mind. Table
with rows of different colors with tableGrob
I am currently stuck with R 2.13 due to compatibility issues, so if there
are any suggestions which don't involve later versions that would be
ideal.
Specify different sort orders after click with jQuery tablesorter
Specify different sort orders after click with jQuery tablesorter
I just started using the excellent jQuery tablesorter script. This might
be a dumb question, however I cannot figure out how to specify the order
in which the columns are sorted after clicking. I am not referring to
whether columns are sorted in ascending or descending order, but rather
the sequence in which the columns are sorted.
For example, if a one clicks on column 2, I might want to sort by column
2, then column 4, then column 5. However, if a one clicks on column 3, I
might want to sort by column 3, then column 5, then column 4.
Thanks in advance for any advice!
--MC
I just started using the excellent jQuery tablesorter script. This might
be a dumb question, however I cannot figure out how to specify the order
in which the columns are sorted after clicking. I am not referring to
whether columns are sorted in ascending or descending order, but rather
the sequence in which the columns are sorted.
For example, if a one clicks on column 2, I might want to sort by column
2, then column 4, then column 5. However, if a one clicks on column 3, I
might want to sort by column 3, then column 5, then column 4.
Thanks in advance for any advice!
--MC
Syntax rules for Lazarus Pascal procedural "Units"
Syntax rules for Lazarus Pascal procedural "Units"
I organise my app's source code into Pascal compilation Units using File
-> New Unit
The following Unit compiles OK ...
unit CryptoUnit;
{$mode objfpc}{$H+}
interface
function Encrypt(key, plaintext:string):string;
function Decrypt(key, ciphertext:string):string;
implementation
uses
Classes, SysUtils, Blowfish;
function Encrypt(key, plaintext:string):string;
...
However this one has compilation errors as it can't identify "Exception"
at line 6 ...
unit ExceptionUnit;
{$mode objfpc}{$H+}
interface
procedure DumpExceptionCallStack(E: Exception); // <--- problem
implementation
uses
Classes, SysUtils, FileUtil;
{ See http://wiki.freepascal.org/Logging_exceptions }
procedure DumpExceptionCallStack(E: Exception);
...
If I assume that Exception is defined in SysUtils (how can I tell?) I
can't put uses SysUtils before interface (the compiler complains it was
expecting interface)
How do I tell the compiler that Exception is defined in SysUtils?
I organise my app's source code into Pascal compilation Units using File
-> New Unit
The following Unit compiles OK ...
unit CryptoUnit;
{$mode objfpc}{$H+}
interface
function Encrypt(key, plaintext:string):string;
function Decrypt(key, ciphertext:string):string;
implementation
uses
Classes, SysUtils, Blowfish;
function Encrypt(key, plaintext:string):string;
...
However this one has compilation errors as it can't identify "Exception"
at line 6 ...
unit ExceptionUnit;
{$mode objfpc}{$H+}
interface
procedure DumpExceptionCallStack(E: Exception); // <--- problem
implementation
uses
Classes, SysUtils, FileUtil;
{ See http://wiki.freepascal.org/Logging_exceptions }
procedure DumpExceptionCallStack(E: Exception);
...
If I assume that Exception is defined in SysUtils (how can I tell?) I
can't put uses SysUtils before interface (the compiler complains it was
expecting interface)
How do I tell the compiler that Exception is defined in SysUtils?
Storing program options in Java
Storing program options in Java
i am developing a java application. I've got a txt file such like this:
Component(Journal, Account, AnalysisCodes...):
Journal
*****
Method(Query, Import, CreateOrAmend...):
Import
*****
Username:
PKP
*****
Password:
test
*****
Host:
localhost
*****
Port:
8080
*****
Program's path:
C:/Connect Manager/
*****
XML Name:
ledger.xml
*****
This java program does not write anything in this file, it just reads it.
However i could not figure out where to store this txt file. Path must be
same for every users since it is hard coded inside. I cannot read path of
the program if i don't know the path of program.
Here is my code:
String lineconfig="";
String pathconfig= "C:/Connect Manager/" + "config.txt";
BufferedReader readerconfig= new BufferedReader(new FileReader(pathconfig));
while((lineconfig=readerconfig.readLine())!=null)
{
stringList.add(lineconfig);
}
readerconfig.close();
As you see, i need an exact location for pathconfig.
Sorry if i caused any confusion in question. I would appreciate your
suggestions.
i am developing a java application. I've got a txt file such like this:
Component(Journal, Account, AnalysisCodes...):
Journal
*****
Method(Query, Import, CreateOrAmend...):
Import
*****
Username:
PKP
*****
Password:
test
*****
Host:
localhost
*****
Port:
8080
*****
Program's path:
C:/Connect Manager/
*****
XML Name:
ledger.xml
*****
This java program does not write anything in this file, it just reads it.
However i could not figure out where to store this txt file. Path must be
same for every users since it is hard coded inside. I cannot read path of
the program if i don't know the path of program.
Here is my code:
String lineconfig="";
String pathconfig= "C:/Connect Manager/" + "config.txt";
BufferedReader readerconfig= new BufferedReader(new FileReader(pathconfig));
while((lineconfig=readerconfig.readLine())!=null)
{
stringList.add(lineconfig);
}
readerconfig.close();
As you see, i need an exact location for pathconfig.
Sorry if i caused any confusion in question. I would appreciate your
suggestions.
curious about what CR and LF means
curious about what CR and LF means
I know that file line separaters are very different under certain
operating systems, for windows it's CRLF, under linux is LF, and under
MacOS is CR. But who on earth named those ascii characters? Are those (LF
and CR etc.) abbreviation or something else? And dose every ascii
character have a name like this?
I know that file line separaters are very different under certain
operating systems, for windows it's CRLF, under linux is LF, and under
MacOS is CR. But who on earth named those ascii characters? Are those (LF
and CR etc.) abbreviation or something else? And dose every ascii
character have a name like this?
Thursday, 22 August 2013
How can I define a struct in (*.cpp) instead (*.h) in a class
How can I define a struct in (*.cpp) instead (*.h) in a class
I want to define a struct out of the head file.
Below is what I declare in the (*.h)
class MyVertex
{
public:
struct Vertex{};
};
How can I define the struct Vertex more detailedly in the (*.cpp)? I've
tried several times with several ways but failed.
I want to define a struct out of the head file.
Below is what I declare in the (*.h)
class MyVertex
{
public:
struct Vertex{};
};
How can I define the struct Vertex more detailedly in the (*.cpp)? I've
tried several times with several ways but failed.
Apache, Lighttpd, Niginx Differences in Features [on hold]
Apache, Lighttpd, Niginx Differences in Features [on hold]
What are the differences between Apache, Lighttpd, Niginx from a features
perspective?
For example, I don't want to know about differences in mod_rewrite syntax,
but would like to know if one of them doesn't support mod_rewrite.
What are the differences between Apache, Lighttpd, Niginx from a features
perspective?
For example, I don't want to know about differences in mod_rewrite syntax,
but would like to know if one of them doesn't support mod_rewrite.
Trying to figure out how to do math in sql queries related to time stamps
Trying to figure out how to do math in sql queries related to time stamps
I need to do some math around a time stamp in a column in a mysql
database. I am using these queries within PHP to extrapolate values, then
using them as variables to feed into another function that generates a
highcharts graph.
So for example:
SELECT COUNT(blah) FORM blah WHERE start_stamp >=now() - interval 1 day
but then I need to subtract from another value from a similar query to get
the the count from the previous day, like:
SELECT COUNT(blah) FORM blah WHERE start_stamp >=now() - interval 2 day
So let's say these two become variables $today and $yesterday, how can I
do this most effectively within a SQL query? Obviously I can do the math
within PHP but I am sure there is a better way to do this within the query
itself.
I need to do some math around a time stamp in a column in a mysql
database. I am using these queries within PHP to extrapolate values, then
using them as variables to feed into another function that generates a
highcharts graph.
So for example:
SELECT COUNT(blah) FORM blah WHERE start_stamp >=now() - interval 1 day
but then I need to subtract from another value from a similar query to get
the the count from the previous day, like:
SELECT COUNT(blah) FORM blah WHERE start_stamp >=now() - interval 2 day
So let's say these two become variables $today and $yesterday, how can I
do this most effectively within a SQL query? Obviously I can do the math
within PHP but I am sure there is a better way to do this within the query
itself.
TextField.setText() returning an odd error
TextField.setText() returning an odd error
I wanted to create a simple calculator to brush up on my skills. When I
try to set the text for the answer field, instead of putting in a number
or getting an error in the console, it puts this in the field
java.awt.TextField[textfield0,356,6,52x23,invalid,text=,selection=0-0]
I've never had such a problem before, so I can't quite think of the cause.
Here is the code for it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class aa extends JFrame implements ActionListener {
static TextField num1 = new TextField(3);
static TextField num2 = new TextField(3);
int numA = 0;
static TextField ans = new TextField(4);
JButton addB = new JButton("+");
JButton subB = new JButton("-");
JButton mulB = new JButton("*");
JButton divB = new JButton("%");
public static void main(String[] args) {
aa app =new aa();
}
public aa(){
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setSize(500, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel content = new JPanel();
this.setLayout(new FlowLayout());
this.add(num1);
this.add(num2);
this.add(addB);
addB.addActionListener(this);
this.add(subB);
subB.addActionListener(this);
this.add(mulB);
divB.addActionListener(this);
this.add(divB);
divB.addActionListener(this);
this.add(ans);
ans.setEditable(false);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == this.addB){
ans.setText("");
int x = Integer.parseInt(num1.getText());
int y = Integer.parseInt(num2.getText());
numA = x + y;
System.out.print(numA);
ans.setText(ans.toString());
}
if(e.getSource() == this.subB){
ans.setText("");
int x = Integer.parseInt(num1.getText());
int y = Integer.parseInt(num2.getText());
numA = x - y;
System.out.print(numA); //these parts were to make sure that it
was actually doing the math, which it was.
ans.setText("");
}
if(e.getSource() == this.mulB){
ans.setText("");
}
}
}
Any ideas would be appreciated.
I wanted to create a simple calculator to brush up on my skills. When I
try to set the text for the answer field, instead of putting in a number
or getting an error in the console, it puts this in the field
java.awt.TextField[textfield0,356,6,52x23,invalid,text=,selection=0-0]
I've never had such a problem before, so I can't quite think of the cause.
Here is the code for it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class aa extends JFrame implements ActionListener {
static TextField num1 = new TextField(3);
static TextField num2 = new TextField(3);
int numA = 0;
static TextField ans = new TextField(4);
JButton addB = new JButton("+");
JButton subB = new JButton("-");
JButton mulB = new JButton("*");
JButton divB = new JButton("%");
public static void main(String[] args) {
aa app =new aa();
}
public aa(){
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setSize(500, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel content = new JPanel();
this.setLayout(new FlowLayout());
this.add(num1);
this.add(num2);
this.add(addB);
addB.addActionListener(this);
this.add(subB);
subB.addActionListener(this);
this.add(mulB);
divB.addActionListener(this);
this.add(divB);
divB.addActionListener(this);
this.add(ans);
ans.setEditable(false);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == this.addB){
ans.setText("");
int x = Integer.parseInt(num1.getText());
int y = Integer.parseInt(num2.getText());
numA = x + y;
System.out.print(numA);
ans.setText(ans.toString());
}
if(e.getSource() == this.subB){
ans.setText("");
int x = Integer.parseInt(num1.getText());
int y = Integer.parseInt(num2.getText());
numA = x - y;
System.out.print(numA); //these parts were to make sure that it
was actually doing the math, which it was.
ans.setText("");
}
if(e.getSource() == this.mulB){
ans.setText("");
}
}
}
Any ideas would be appreciated.
PYTHON : How to print this code in mod-wsgi script?
PYTHON : How to print this code in mod-wsgi script?
i want to print
* yield " they came to downvote the question, but the question was
temproarily deleted by the OP, OP means ORIGINAL POSTER, but the enemy
thought they were intelligent beings, they waited and waited, and ended up
having to read the whole post 2 times, TWICE AS HOT, ICE ICE BABY TWICE AS
HOT. you know the britney spears song? TWICE AS HOT, ICE ICE BABY TWICE AS
HOT ".. *
*http://www.youtube.com/watch?v=ePVHkXD_XGE*
====================================================
You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world.
updated daily in a cvs file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.
i want to print
* yield " they came to downvote the question, but the question was
temproarily deleted by the OP, OP means ORIGINAL POSTER, but the enemy
thought they were intelligent beings, they waited and waited, and ended up
having to read the whole post 2 times, TWICE AS HOT, ICE ICE BABY TWICE AS
HOT. you know the britney spears song? TWICE AS HOT, ICE ICE BABY TWICE AS
HOT ".. *
*http://www.youtube.com/watch?v=ePVHkXD_XGE*
====================================================
You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world.
updated daily in a cvs file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.
i have an article driven from a db and it contains image tag, i need a regex to grab that image and put it into anchor tags
i have an article driven from a db and it contains image tag, i need a
regex to grab that image and put it into anchor tags
Some text before <img style="float: left;"
src="../images/265218_imgthw.jpg" alt="" width="81" height="88"> some text
after
Say i have something like that wrap inside some text coming from db. I
need it to be changed to:
Some text before <a href='../images/265218_imgthw.jpg'><img style="float:
left;" src="../images/265218_imgthw.jpg" alt="" width="81"
height="88"></a> some text after
Any help please.
regex to grab that image and put it into anchor tags
Some text before <img style="float: left;"
src="../images/265218_imgthw.jpg" alt="" width="81" height="88"> some text
after
Say i have something like that wrap inside some text coming from db. I
need it to be changed to:
Some text before <a href='../images/265218_imgthw.jpg'><img style="float:
left;" src="../images/265218_imgthw.jpg" alt="" width="81"
height="88"></a> some text after
Any help please.
Regex to match SQL Server field name that should be delimited
Regex to match SQL Server field name that should be delimited
I want to write a regex in VB.NET that takes a string and determines
whether it should be delimited for it to be valid as a field name in SQL
server.
For example, myField is valid (example context: SELECT myField from
myTable), but my field is not and would need to be delimited with square
brackets (select [my field] from myTable).
The regex should match a string containing any of the following:
Whitespace characters
Special characters (!"£$%^ etc), not including _, @, #
String starting with a number or @
Any other field naming rules (not including sql reserved keywords, a
separate function deals with that)
My current regex pattern is [^A-Za-z]+, which thereabouts works as it
matches any non-alphabetical character, but it unecessarily matches names
such as my_field or field0
I want to write a regex in VB.NET that takes a string and determines
whether it should be delimited for it to be valid as a field name in SQL
server.
For example, myField is valid (example context: SELECT myField from
myTable), but my field is not and would need to be delimited with square
brackets (select [my field] from myTable).
The regex should match a string containing any of the following:
Whitespace characters
Special characters (!"£$%^ etc), not including _, @, #
String starting with a number or @
Any other field naming rules (not including sql reserved keywords, a
separate function deals with that)
My current regex pattern is [^A-Za-z]+, which thereabouts works as it
matches any non-alphabetical character, but it unecessarily matches names
such as my_field or field0
Wednesday, 21 August 2013
How to get value by reference from WIN32OLE::ARGV?
How to get value by reference from WIN32OLE::ARGV?
Below code returns 0
v = 0
obj.foo('',0)
printf("v : %d \n", WIN32OLE::ARGV[1])
when really it must return another value by reference.
For example in python it works like here:
v = obj.foo('')
print('v : %d' % v)
because second argument is marked as retval it works. I don't get yet how
to make same on Ruby.
Below code returns 0
v = 0
obj.foo('',0)
printf("v : %d \n", WIN32OLE::ARGV[1])
when really it must return another value by reference.
For example in python it works like here:
v = obj.foo('')
print('v : %d' % v)
because second argument is marked as retval it works. I don't get yet how
to make same on Ruby.
How to make C++ work interactively with Java GUI using JNI?
How to make C++ work interactively with Java GUI using JNI?
Ok..
I am creating a simple Win32 console application that loads Java GUI which
has it's form file..
However, I got some problem.. Here is a part of code..
if(status != JNI_ERR)
{
cls = env->FindClass("PWNJava");
if(cls != 0)
{
cout<<"class found!"<<endl;
mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
env->CallStaticVoidMethod(cls, mid);
}
else
{
printf("Can't find class\n");
return;
}
jvm->DestroyJavaVM();
cout<<"\nJVM Destroyed!!"<<endl;
}
Ok.. My problem is that, When Java GUI application starts, the console
application get stopped.
If I debug it each line, Java Gui Application starts at a code line
"jvm->DestroyJavaVM();", which is presumed to kill Java Virtual Machine
but not create Java GUI application. it just automatically terminates
console application if I close my Java GUI application.
about a code at a bottom, cout<<"\nJVM Destroyed!!"<
this "JVM Destroyed!!" never shows on Console Windows... Once after I
closed Java GUI Application, Console application does not work anymore. it
just shows "push any button to close".
What I want to do later is, After I choose any radio button and lastly
click finish button on Java GUI, then Java GUI application should be
terminated, and then c++ program should be able to receive variables from
Java GUI Program. idk it is possible or impossible though..?
But First of all, this console application seem to be automatically
terminated by Java GUI Program.
How to fix this automatic termination of Console Program by Java Gui
Application?
Below is address of downloadable source code: (MSVS 2008 for C++ and
Netbeans for Java)
http://cfile209.uf.daum.net/attach/241D3F3D5214C4ED07ECE1
Ok..
I am creating a simple Win32 console application that loads Java GUI which
has it's form file..
However, I got some problem.. Here is a part of code..
if(status != JNI_ERR)
{
cls = env->FindClass("PWNJava");
if(cls != 0)
{
cout<<"class found!"<<endl;
mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
env->CallStaticVoidMethod(cls, mid);
}
else
{
printf("Can't find class\n");
return;
}
jvm->DestroyJavaVM();
cout<<"\nJVM Destroyed!!"<<endl;
}
Ok.. My problem is that, When Java GUI application starts, the console
application get stopped.
If I debug it each line, Java Gui Application starts at a code line
"jvm->DestroyJavaVM();", which is presumed to kill Java Virtual Machine
but not create Java GUI application. it just automatically terminates
console application if I close my Java GUI application.
about a code at a bottom, cout<<"\nJVM Destroyed!!"<
this "JVM Destroyed!!" never shows on Console Windows... Once after I
closed Java GUI Application, Console application does not work anymore. it
just shows "push any button to close".
What I want to do later is, After I choose any radio button and lastly
click finish button on Java GUI, then Java GUI application should be
terminated, and then c++ program should be able to receive variables from
Java GUI Program. idk it is possible or impossible though..?
But First of all, this console application seem to be automatically
terminated by Java GUI Program.
How to fix this automatic termination of Console Program by Java Gui
Application?
Below is address of downloadable source code: (MSVS 2008 for C++ and
Netbeans for Java)
http://cfile209.uf.daum.net/attach/241D3F3D5214C4ED07ECE1
Beamer: Reuse incremental overlay number from list item?
Beamer: Reuse incremental overlay number from list item?
I'm using an item list with the overlay specification <+(1)->. For one of
the items, I want a text after the item list to be uncovered
simultaneously with the item. How can I achieve that?
\begin{itemize}[<+(1)->]
\item First item
\item ...
\item An item somewhere in the middle of the list
\item ...
\item Last item
\end{itemize}
Some text to be synchronized with the item in the middle of the list
Note: Although the text I want to be uncovered simultaneously with the
list item is currently located after the list, I may decide to move it to
before the list.
I'm using an item list with the overlay specification <+(1)->. For one of
the items, I want a text after the item list to be uncovered
simultaneously with the item. How can I achieve that?
\begin{itemize}[<+(1)->]
\item First item
\item ...
\item An item somewhere in the middle of the list
\item ...
\item Last item
\end{itemize}
Some text to be synchronized with the item in the middle of the list
Note: Although the text I want to be uncovered simultaneously with the
list item is currently located after the list, I may decide to move it to
before the list.
How to use Inner Join and Except in Linq EntityFramework 4
How to use Inner Join and Except in Linq EntityFramework 4
I have two tables with a one (Parent) to many (Details) relationship.
I would like to write this query (which is written in SQL) in Linq. As you
see; it is an inner join on a subquery, which contains Except:
select pa.* from dbo.Parent pa
inner join
( select p.ID from dbo.Parent p except ( select d.ID from dbo.Details d
where (d.ParentID = 371) ) ) p
on pa.ID = p.ID
where pa.ID <> 371
I have two tables with a one (Parent) to many (Details) relationship.
I would like to write this query (which is written in SQL) in Linq. As you
see; it is an inner join on a subquery, which contains Except:
select pa.* from dbo.Parent pa
inner join
( select p.ID from dbo.Parent p except ( select d.ID from dbo.Details d
where (d.ParentID = 371) ) ) p
on pa.ID = p.ID
where pa.ID <> 371
Java with String length limit
Java with String length limit
I am trying to solve a CodeChef problem in Java and found out that I could
not create a String with length > one million chars (with my compiler at
least). I pasted the first one million decimal digits of Pi in a string
(e.g. String PI = "3.1415926535...151") in the Java file and it fails to
compile. When I take out the Pi and replace it with a shorter string like
"dog", the code compiles. Can anyone confirm if this is indeed a
limitation of Java?
Thanks.
I am trying to solve a CodeChef problem in Java and found out that I could
not create a String with length > one million chars (with my compiler at
least). I pasted the first one million decimal digits of Pi in a string
(e.g. String PI = "3.1415926535...151") in the Java file and it fails to
compile. When I take out the Pi and replace it with a shorter string like
"dog", the code compiles. Can anyone confirm if this is indeed a
limitation of Java?
Thanks.
int.Parse on negative number results in exception
int.Parse on negative number results in exception
This line of code:
int.Parse("-1");
Results in a FormatException that says "Input string was not in the
correct format" when i run it on a device. On the emulator it works just
fine. I've tested this with a bunch of devices, and the only one that is
working as intended (i.e. returns an int with value -1) is the Samsung
Galaxy Nexus, running android 4.2.1. All these devices generates an
exception:
Google Nexus 7 (4.3)
Samsung S3 (4.1.2)
Samsung Galaxy Tab (4.0.4)
LG P970 (2.2.2)
HTC Sensation (2.3.4)
I also tried to download the app C#Shell from playstore on a device, and
enter the line above, the result is the same:
Do anyone know why this happens, or what can be done to resolve this issue?
This line of code:
int.Parse("-1");
Results in a FormatException that says "Input string was not in the
correct format" when i run it on a device. On the emulator it works just
fine. I've tested this with a bunch of devices, and the only one that is
working as intended (i.e. returns an int with value -1) is the Samsung
Galaxy Nexus, running android 4.2.1. All these devices generates an
exception:
Google Nexus 7 (4.3)
Samsung S3 (4.1.2)
Samsung Galaxy Tab (4.0.4)
LG P970 (2.2.2)
HTC Sensation (2.3.4)
I also tried to download the app C#Shell from playstore on a device, and
enter the line above, the result is the same:
Do anyone know why this happens, or what can be done to resolve this issue?
binding listview to database entity framwork
binding listview to database entity framwork
Hi I have a problem with how the binding listview to database entity
framwork And mode of listview to show details..This code only shows the
first row of the table and the records do not show
var item = (from p in db.tbl_film
select p).FirstOrDefault();
string[] items =
{item.flm_id.ToString(),item.flm_name,item.flm_description,item.flm_category
};
foreach (var itemlist in items)
{
ListViewItem lvi = new ListViewItem(items);
listView1.Items.Add(lvi);
}
Hi I have a problem with how the binding listview to database entity
framwork And mode of listview to show details..This code only shows the
first row of the table and the records do not show
var item = (from p in db.tbl_film
select p).FirstOrDefault();
string[] items =
{item.flm_id.ToString(),item.flm_name,item.flm_description,item.flm_category
};
foreach (var itemlist in items)
{
ListViewItem lvi = new ListViewItem(items);
listView1.Items.Add(lvi);
}
Tuesday, 20 August 2013
How to clear input buffer after fgets overflow?
How to clear input buffer after fgets overflow?
I'm facing a little problem with fgets when the input string exceeds its
predefined limit.
Taking the example below:
for(index = 0; index < max; index++)
{
printf(" Enter the %d th string :",index);
while ((ch = getchar()) != '\n' && ch != EOF); //An attempt to clear
buffer
if(fgets(input,MAXLEN,stdin))
{
removeNewLine(input);
if(strcmp(input,"end") != 0)
// Do something with input
}
}
Now when I exceed the length MAXLEN and enter a string, I know that the
input will append a '\0' at MAXLEN -1 and that would be it. The problem
happens when I try to enter the 2nd string which is not asked for i.e
Output :
Enter the first string : Aaaaaaaaaaaaaaaaaaaa //Exceeds limit
Enter the second string : Enter the third string : ....Waits input
So, I thought I should clear the buffer the standard way as in C. It waits
until I enter
return
two times, The first time it being appended to the string and the next
time,acting as end of input.
Is there any method by which I can clear the buffer without entering the
extra return?
How do I implement error handling for the same? Because the fgets return
value will be Non-null and strlen(input) gives me the accepted size of the
string by fgets, what should be done?
Thanks a lot
I'm facing a little problem with fgets when the input string exceeds its
predefined limit.
Taking the example below:
for(index = 0; index < max; index++)
{
printf(" Enter the %d th string :",index);
while ((ch = getchar()) != '\n' && ch != EOF); //An attempt to clear
buffer
if(fgets(input,MAXLEN,stdin))
{
removeNewLine(input);
if(strcmp(input,"end") != 0)
// Do something with input
}
}
Now when I exceed the length MAXLEN and enter a string, I know that the
input will append a '\0' at MAXLEN -1 and that would be it. The problem
happens when I try to enter the 2nd string which is not asked for i.e
Output :
Enter the first string : Aaaaaaaaaaaaaaaaaaaa //Exceeds limit
Enter the second string : Enter the third string : ....Waits input
So, I thought I should clear the buffer the standard way as in C. It waits
until I enter
return
two times, The first time it being appended to the string and the next
time,acting as end of input.
Is there any method by which I can clear the buffer without entering the
extra return?
How do I implement error handling for the same? Because the fgets return
value will be Non-null and strlen(input) gives me the accepted size of the
string by fgets, what should be done?
Thanks a lot
Access to apache2 on ubuntu from phone
Access to apache2 on ubuntu from phone
I would like to access my Apache 2 from my smartphone for testing
purposes. I have Apache2 running on Ubuntu.I already checked similar
questions here on forum,but I didn't manage to access my site. On my phone
i get "Network problem , site unavailable" error. I tried to set my
ports.conf to listen to *:80 , but i reverted to backup because that didnt
work.
I would like to access my Apache 2 from my smartphone for testing
purposes. I have Apache2 running on Ubuntu.I already checked similar
questions here on forum,but I didn't manage to access my site. On my phone
i get "Network problem , site unavailable" error. I tried to set my
ports.conf to listen to *:80 , but i reverted to backup because that didnt
work.
Twitter / Facebook Sharing in Emails
Twitter / Facebook Sharing in Emails
I have an email that get sent out to users, which needs to have a share to
facebook or twitter button.
I know there are URL's which can open the share dialogs etc, but the
problem is i need to track the number of shares for the item being shared
(just a count).
I know there are things like the Twitter Count API, but it's unofficial,
private and not supposed to be used, so i don't want to use that and then
have it turned off and left with no data to work with.
The only thing i can think of, is have the email link to my website, which
contains JS which opens up the Twitter/Facebook dialog, posts it then in
the callback tracks the information back to my server.
Any other ideas?
I have an email that get sent out to users, which needs to have a share to
facebook or twitter button.
I know there are URL's which can open the share dialogs etc, but the
problem is i need to track the number of shares for the item being shared
(just a count).
I know there are things like the Twitter Count API, but it's unofficial,
private and not supposed to be used, so i don't want to use that and then
have it turned off and left with no data to work with.
The only thing i can think of, is have the email link to my website, which
contains JS which opens up the Twitter/Facebook dialog, posts it then in
the callback tracks the information back to my server.
Any other ideas?
Google Play Service Installation
Google Play Service Installation
Q: Y SDK manager won't display google play services under extras to
install the same? I'm using eclipse Indigo Service Release 1. When I open
SDK manager it shows updates for SDK tools and SDK platform tools only.
Q: Y SDK manager won't display google play services under extras to
install the same? I'm using eclipse Indigo Service Release 1. When I open
SDK manager it shows updates for SDK tools and SDK platform tools only.
How to self host a web service using c#
How to self host a web service using c#
I want to self host a SAOP Web Service with c# .net. Do anyone has
experience with that? I'm not able to use WCF because the Service I have
to host is a Web Reference Service.
Can anyone help me??
best regards
I want to self host a SAOP Web Service with c# .net. Do anyone has
experience with that? I'm not able to use WCF because the Service I have
to host is a Web Reference Service.
Can anyone help me??
best regards
mod_rewrite redirects only index page
mod_rewrite redirects only index page
The problem is that following .htaccess syntax:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L]
Redirects only index page. So if I go to bd-spb.ru I will get
áèçíåñ-äèàëîã.ðô, but if I go for example here its not redirects me here.
How to make this happens?
The problem is that following .htaccess syntax:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L]
Redirects only index page. So if I go to bd-spb.ru I will get
áèçíåñ-äèàëîã.ðô, but if I go for example here its not redirects me here.
How to make this happens?
Print out the entries from the map when the value gets changed
Print out the entries from the map when the value gets changed
I am working on a project in which I need to print out the data from the
database in a certain way. Let's take an example, suppose in my database,
I have below entries only-
Framework 1.0.0
BundleB 1.0.0
BundleC 1.0.0
Then my Java method that will make a call to the database which will
return me a map of above data.
My map will have above data as below-
Key as Framework, Value as 1.0.0
Key as BundleB, Value as 1.0.0
Key as BundleC, Value as 1.0.0
Suppose, I started my program for the first time, then it will print out
like this with the below code I have, which is perfectly fine.
Framework - 1.0.0
And then I am running background thread every 2 seconds that will make a
call to the database and get all the data again from the database. And
every two seconds, it will print out the same thing as below- (which is
not what I want)
Framework - 1.0.0
I want to print out Framework - 1.0.0 for the first time when I am running
my program but second time when the background thread is running, it
should print out only when the version gets changed for that Framework,
otherwise don't print out anything.
Meaning after some time, if somebody changes the version information in
the database like this-
Framework 1.0.1
BundleB 1.0.0
BundleC 1.0.0
then only it should print out like this-
Framework - 1.0.1
I hope the questions is clear enough. Below is my code that I have so far.
public class Test {
public static Map<String, String> bundleList = new
LinkedHashMap<String, String>();
private static Map<String, String> oldBundleList = new
LinkedHashMap<String, String>();
public static void main(String[] args) {
getAttributesFromDatabase();
loggingAfterEveryXMilliseconds();
}
private static void getAttributesFromDatabase() {
Map<String, String> bundleInformation = new LinkedHashMap<String,
String>();
bundleInformation = getFromDatabase();
if(!bundleInformation.isEmpty()) {
oldBundleList = bundleList;
bundleList = bundleInformation;
}
final Map<String, MapDifference.ValueDifference<String>>
entriesDiffering = Maps.difference(oldBundleList,
bundleList).entriesDiffering();
if (!entriesDiffering.isEmpty()) {
for (String key : entriesDiffering.keySet()) {
bundleList.put(key, bundleList.get(key));
}
}
String version = bundleList.get("Zero");
printOutZeroInformation("Zero", version);
}
private static void printOutZeroInformation(String string, String
version) {
System.out.println(string+" - "+version);
}
private static Map<String, String> getFromDatabase() {
Map<String, String> hello = new LinkedHashMap<String, String>();
String version0 = "1.0.0";
String version1 = "1.0.0";
String version2 = "1.0.0";
hello.put("Framework", version0);
hello.put("BundleA", version1);
hello.put("BundleB", version2);
return hello;
}
private static void loggingAfterEveryXMilliseconds() {
new Thread() {
public void run() {
while (true) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
}
getAttributesFromDatabase();
}
}
}.start();
}
}
Any help will be appreciated on this.
I am working on a project in which I need to print out the data from the
database in a certain way. Let's take an example, suppose in my database,
I have below entries only-
Framework 1.0.0
BundleB 1.0.0
BundleC 1.0.0
Then my Java method that will make a call to the database which will
return me a map of above data.
My map will have above data as below-
Key as Framework, Value as 1.0.0
Key as BundleB, Value as 1.0.0
Key as BundleC, Value as 1.0.0
Suppose, I started my program for the first time, then it will print out
like this with the below code I have, which is perfectly fine.
Framework - 1.0.0
And then I am running background thread every 2 seconds that will make a
call to the database and get all the data again from the database. And
every two seconds, it will print out the same thing as below- (which is
not what I want)
Framework - 1.0.0
I want to print out Framework - 1.0.0 for the first time when I am running
my program but second time when the background thread is running, it
should print out only when the version gets changed for that Framework,
otherwise don't print out anything.
Meaning after some time, if somebody changes the version information in
the database like this-
Framework 1.0.1
BundleB 1.0.0
BundleC 1.0.0
then only it should print out like this-
Framework - 1.0.1
I hope the questions is clear enough. Below is my code that I have so far.
public class Test {
public static Map<String, String> bundleList = new
LinkedHashMap<String, String>();
private static Map<String, String> oldBundleList = new
LinkedHashMap<String, String>();
public static void main(String[] args) {
getAttributesFromDatabase();
loggingAfterEveryXMilliseconds();
}
private static void getAttributesFromDatabase() {
Map<String, String> bundleInformation = new LinkedHashMap<String,
String>();
bundleInformation = getFromDatabase();
if(!bundleInformation.isEmpty()) {
oldBundleList = bundleList;
bundleList = bundleInformation;
}
final Map<String, MapDifference.ValueDifference<String>>
entriesDiffering = Maps.difference(oldBundleList,
bundleList).entriesDiffering();
if (!entriesDiffering.isEmpty()) {
for (String key : entriesDiffering.keySet()) {
bundleList.put(key, bundleList.get(key));
}
}
String version = bundleList.get("Zero");
printOutZeroInformation("Zero", version);
}
private static void printOutZeroInformation(String string, String
version) {
System.out.println(string+" - "+version);
}
private static Map<String, String> getFromDatabase() {
Map<String, String> hello = new LinkedHashMap<String, String>();
String version0 = "1.0.0";
String version1 = "1.0.0";
String version2 = "1.0.0";
hello.put("Framework", version0);
hello.put("BundleA", version1);
hello.put("BundleB", version2);
return hello;
}
private static void loggingAfterEveryXMilliseconds() {
new Thread() {
public void run() {
while (true) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
}
getAttributesFromDatabase();
}
}
}.start();
}
}
Any help will be appreciated on this.
Monday, 19 August 2013
How to declare an array of objects C#
How to declare an array of objects C#
I'm making a 2D tile map for a game. I Have a Cell class (tiles) makes
cell objects that have 4 attributes: TopWall, BottomWall, LeftWall,
RightWall. The wall may or may not be there, so those attributes are
boolean true or false, and if they are true, a line will be drawn down
that cell wall (not allowing the player to pass through the cell). I want
to declare a (2 dimensional? As in, row, and column) array of my cell
objects called Map1 (as they will make up a game map). Then i want to set
each member of the array to having specific wall attributes. Here is what
i have:
Cell.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Map
{
public class Cell : PictureBox
{
bool LeftWall;
bool TopWall;
bool RightWall;
bool BottomWall;
public Cell(bool TopWall, bool RightWall, bool BottomWall, bool
LeftWall)
{
this.TopWall = TopWall;
this.RightWall = RightWall;
this.BottomWall = BottomWall;
this.LeftWall = LeftWall;
}
}
}
This is me starting to attempt making the array of cell objects and set
the wall attributes: Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Map
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// Array of tiles
/// </summary>
//PictureBox[,] Boxes = new PictureBox[4,4];
Cell[,] Map1 = new Cell[4,4];
for (int row = 0; row < Map1.Length; row++)
{
for (int column = 0; column < length; column++)
{
Map1[i] = new Cell();
}
}
Map1[0,0] = Cell(true, false, false, true);
It is showing a lot of errors and i was wondering if anyone can see where
i'm going wrong. Thanks.
I'm making a 2D tile map for a game. I Have a Cell class (tiles) makes
cell objects that have 4 attributes: TopWall, BottomWall, LeftWall,
RightWall. The wall may or may not be there, so those attributes are
boolean true or false, and if they are true, a line will be drawn down
that cell wall (not allowing the player to pass through the cell). I want
to declare a (2 dimensional? As in, row, and column) array of my cell
objects called Map1 (as they will make up a game map). Then i want to set
each member of the array to having specific wall attributes. Here is what
i have:
Cell.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Map
{
public class Cell : PictureBox
{
bool LeftWall;
bool TopWall;
bool RightWall;
bool BottomWall;
public Cell(bool TopWall, bool RightWall, bool BottomWall, bool
LeftWall)
{
this.TopWall = TopWall;
this.RightWall = RightWall;
this.BottomWall = BottomWall;
this.LeftWall = LeftWall;
}
}
}
This is me starting to attempt making the array of cell objects and set
the wall attributes: Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Map
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// Array of tiles
/// </summary>
//PictureBox[,] Boxes = new PictureBox[4,4];
Cell[,] Map1 = new Cell[4,4];
for (int row = 0; row < Map1.Length; row++)
{
for (int column = 0; column < length; column++)
{
Map1[i] = new Cell();
}
}
Map1[0,0] = Cell(true, false, false, true);
It is showing a lot of errors and i was wondering if anyone can see where
i'm going wrong. Thanks.
W@TCH ~ Pittsburgh Steelers vs Washington Redskins live streaming online on pc Tv ESPN Buy Now
W@TCH ~ Pittsburgh Steelers vs Washington Redskins live streaming online
on pc Tv ESPN Buy Now
You can see easily watch NFL Match Between Pittsburgh Steelers vs
Washington Redskins live streaming online on pc, just follow our streaming
link. Enjoy Pittsburgh Steelers vs Washington Redskins live streaming NFL
Game Online HD on your Pc. Pittsburgh Steelers vs Washington Redskins live
streaming online on pc, just follow our streaming link.Ensure that you
must be 100% satisfied in our service so don't be hesitated just click the
link bellow and start watching and enjoy more.
TODAY START NOW
wAtCh Pittsburgh vs Washington live NFL 2013@!==>
http://nfl247sports.blogspot.com
Match Shedule DATE: Monday August 19, 2013 TIME: 8:00 pm ET preseason
week-2 Tame:Pittsburgh Steelers vs Washington Redskins live NFL 2013/2014
GAME PASS Ensure that you must be 100% satisfied in our service so don't
be hesitated just click the link bellow and start watching and enjoy
more.Pittsburgh Steelers vs Washington Redskins live stream now on Fox
Network,NBC,Sky Sports 4, bet air tv, CBS, HD4 ,This Match Pittsburgh
Steelers vs Washington Redskins live. Both team are ready to face each
other. So this match will be very enjoyable Watch Live FOX, CBS, NBC, ESPN
TV Get the best online sports coverage on the net directly on your PC, MAC
or LAPTOP.
wAtCh Pittsburgh vs Washington live NFL 2013@!==>
http://nfl247sports.blogspot.com
Pittsburgh Steelers vs Washington Redskins Live
Over 4500 Live Streaming HD Channels Stream Directly to your PC or Laptop
No hardware purchases required ever No Monthly charges / No Bandwidth
limits Unrestricted worldwide TV Channel coverage No TV restrictions / No
Streaming restrictions Full HD widescreen Playback Suppor
CLICK HERE THE HD TV You all about US,UK,CAN AUS,NEZ,Game entertainment
like NFL,NCAAF, NFL, MLB, RUGBY, NASCAR, SOCCER, BOXING, FORMULA ONE, ect
by which All of you can watch each and every games live streaming online.
From any location! Get instant access and most exciting sports coverage
stream software online directly on your PC. Download and install our
software and enjoy all the pleasures of the sporting world comfortably
like you are at the stadium watching theOur software also allows you to
watch Pittsburgh Steelers vs Washington Redskins Live Game online in
perfect HD quality, plus over 4500 HD channels including Pay Per View TV
channels, movie, sports, etc. So Watch and enjoy the Live Stream Event.It
only takes a minute to download and install it onto your computer and you
can watch many other TV channels live online, legally, and with good
quality right on your computer. This can be used anywhere in the world.
Pittsburgh Steelers vs Washington Redskins Live stream NFL,Pittsburgh
Steelers vs Washington Redskins Live,Pittsburgh Steelers vs Washington
Redskins Live stream Video
on pc Tv ESPN Buy Now
You can see easily watch NFL Match Between Pittsburgh Steelers vs
Washington Redskins live streaming online on pc, just follow our streaming
link. Enjoy Pittsburgh Steelers vs Washington Redskins live streaming NFL
Game Online HD on your Pc. Pittsburgh Steelers vs Washington Redskins live
streaming online on pc, just follow our streaming link.Ensure that you
must be 100% satisfied in our service so don't be hesitated just click the
link bellow and start watching and enjoy more.
TODAY START NOW
wAtCh Pittsburgh vs Washington live NFL 2013@!==>
http://nfl247sports.blogspot.com
Match Shedule DATE: Monday August 19, 2013 TIME: 8:00 pm ET preseason
week-2 Tame:Pittsburgh Steelers vs Washington Redskins live NFL 2013/2014
GAME PASS Ensure that you must be 100% satisfied in our service so don't
be hesitated just click the link bellow and start watching and enjoy
more.Pittsburgh Steelers vs Washington Redskins live stream now on Fox
Network,NBC,Sky Sports 4, bet air tv, CBS, HD4 ,This Match Pittsburgh
Steelers vs Washington Redskins live. Both team are ready to face each
other. So this match will be very enjoyable Watch Live FOX, CBS, NBC, ESPN
TV Get the best online sports coverage on the net directly on your PC, MAC
or LAPTOP.
wAtCh Pittsburgh vs Washington live NFL 2013@!==>
http://nfl247sports.blogspot.com
Pittsburgh Steelers vs Washington Redskins Live
Over 4500 Live Streaming HD Channels Stream Directly to your PC or Laptop
No hardware purchases required ever No Monthly charges / No Bandwidth
limits Unrestricted worldwide TV Channel coverage No TV restrictions / No
Streaming restrictions Full HD widescreen Playback Suppor
CLICK HERE THE HD TV You all about US,UK,CAN AUS,NEZ,Game entertainment
like NFL,NCAAF, NFL, MLB, RUGBY, NASCAR, SOCCER, BOXING, FORMULA ONE, ect
by which All of you can watch each and every games live streaming online.
From any location! Get instant access and most exciting sports coverage
stream software online directly on your PC. Download and install our
software and enjoy all the pleasures of the sporting world comfortably
like you are at the stadium watching theOur software also allows you to
watch Pittsburgh Steelers vs Washington Redskins Live Game online in
perfect HD quality, plus over 4500 HD channels including Pay Per View TV
channels, movie, sports, etc. So Watch and enjoy the Live Stream Event.It
only takes a minute to download and install it onto your computer and you
can watch many other TV channels live online, legally, and with good
quality right on your computer. This can be used anywhere in the world.
Pittsburgh Steelers vs Washington Redskins Live stream NFL,Pittsburgh
Steelers vs Washington Redskins Live,Pittsburgh Steelers vs Washington
Redskins Live stream Video
Can I host my front end in one hosting service and the backend somewhere else?
Can I host my front end in one hosting service and the backend somewhere
else?
I have a website hosted in justhost.com. So far it is only HTML/CSS/JS
done all from scratch. Recently I have been learning about Server Side
Java Script (SSJS) using nodejs and I would like to add some JS backend
processing to my site. The problem is that justhost.com does not seem to
support nodejs applications, so now I am kind of stuck.
Is there a way to keep all the front end of my site (HTML, CSS and front
end JS) hosted in justhost.com and then build the backend in nodejs SSJS
and keep that part hosted in another service or server and somehow make it
all work together?
Right not it is not a commercial application, so I can play around and
break things, so I am open to any suggestion.
Thanks in advance.
else?
I have a website hosted in justhost.com. So far it is only HTML/CSS/JS
done all from scratch. Recently I have been learning about Server Side
Java Script (SSJS) using nodejs and I would like to add some JS backend
processing to my site. The problem is that justhost.com does not seem to
support nodejs applications, so now I am kind of stuck.
Is there a way to keep all the front end of my site (HTML, CSS and front
end JS) hosted in justhost.com and then build the backend in nodejs SSJS
and keep that part hosted in another service or server and somehow make it
all work together?
Right not it is not a commercial application, so I can play around and
break things, so I am open to any suggestion.
Thanks in advance.
DOM traversing for a searched keyword is not showing as expected?
DOM traversing for a searched keyword is not showing as expected?
I am trying to implement filtering mechanism using JavaScript in the UI by
traverse through the DOM and find for a searched word. This is how my HTML
and UI looks like.
So the idea is that once the data(which is dynamic) get loaded from the
back-end(through java) i want to traverse the DOM in HTML for a particular
keyword they searched. this is how i am writing the JS in Jquery
$(document).ready(function() {
jQuery('#txtSearch').keyup(function(event){
if (event.keyCode == 27) {
resetSearch();
}
if (jQuery('#txtSearch').val().length > 0) {
jQuery('.list-group-item').hide();
jQuery('.list-group-item span.assignee-style:Contains(\'' +
jQuery('#txtSearch').val() + '\')').
parent('li').parent('ul').parent('li').show();
}
if (jQuery('#txtSearch').val().length == 0) {
resetSearch();
}
});
function resetSearch(){
jQuery('#txtSearch').val('');
jQuery('.list-group-item').show();
jQuery('#txtSearch').focus();
}
});
The behavior i am expecting is that when i search for "john" i want only
the data(in all 3 columns) that contains "John" to appear. just as a start
i am just traversing the DOM by Assignee name only. but the results are
not as i wanted. What am i doing wrong?
I am trying to implement filtering mechanism using JavaScript in the UI by
traverse through the DOM and find for a searched word. This is how my HTML
and UI looks like.
So the idea is that once the data(which is dynamic) get loaded from the
back-end(through java) i want to traverse the DOM in HTML for a particular
keyword they searched. this is how i am writing the JS in Jquery
$(document).ready(function() {
jQuery('#txtSearch').keyup(function(event){
if (event.keyCode == 27) {
resetSearch();
}
if (jQuery('#txtSearch').val().length > 0) {
jQuery('.list-group-item').hide();
jQuery('.list-group-item span.assignee-style:Contains(\'' +
jQuery('#txtSearch').val() + '\')').
parent('li').parent('ul').parent('li').show();
}
if (jQuery('#txtSearch').val().length == 0) {
resetSearch();
}
});
function resetSearch(){
jQuery('#txtSearch').val('');
jQuery('.list-group-item').show();
jQuery('#txtSearch').focus();
}
});
The behavior i am expecting is that when i search for "john" i want only
the data(in all 3 columns) that contains "John" to appear. just as a start
i am just traversing the DOM by Assignee name only. but the results are
not as i wanted. What am i doing wrong?
How do I breed the Sun dragon?
How do I breed the Sun dragon?
I have tried a few combinations several times trying to get the sun dragon
but have failed every time. Does anyone know a surefire way to get it?
I have tried a few combinations several times trying to get the sun dragon
but have failed every time. Does anyone know a surefire way to get it?
Sunday, 18 August 2013
Shifted exponentials functions
Shifted exponentials functions
Define the set of functions $(f_m)$ for $m\in\mathbb{Z}$ where
$f:\mathbb{R}\to(0,\infty)$ is given by $$f_m(x)=\exp(x+m)$$ How is it
possible to prove that the functions $f_m$ are linearly independent over
$\mathbb{Q}$?
Define the set of functions $(f_m)$ for $m\in\mathbb{Z}$ where
$f:\mathbb{R}\to(0,\infty)$ is given by $$f_m(x)=\exp(x+m)$$ How is it
possible to prove that the functions $f_m$ are linearly independent over
$\mathbb{Q}$?
Bitmap storage / memory representation for N-bit RGB bitmaps
Bitmap storage / memory representation for N-bit RGB bitmaps
Typically, the most common RGB format seems to be 24-bit RGB (8-bits for
each channel). However, historically, RGB has been represented in many
other formats, including 3-bit RGB (1-bit per channel), 6-bit RGB (2-bits
per channel), 9-bit RGB (3-bits per channel), etc.
When an N-bit RGB file has a value of N that is not a multiple of 8, how
are these bitmaps typically represented in memory? For example, if we have
6-bit RGB, it means each pixel is 6 bits, and thus each pixel is not
directly addressable by a modern computer without using bitwise
operations.
So, is it common practice to simply covert N-bit RGB files into bitmaps
where each pixel is of an addressable size (e.g. convert 6-bit to 8-bit)?
Or is it more common to simply use bitwise operations to manipulate
bitmaps where the pixel size is not addressable?
And what about disk storage? How is, say, a 6-bit RGB file stored on disk,
when the last byte of the bitmap may not even contain a full pixel?
Typically, the most common RGB format seems to be 24-bit RGB (8-bits for
each channel). However, historically, RGB has been represented in many
other formats, including 3-bit RGB (1-bit per channel), 6-bit RGB (2-bits
per channel), 9-bit RGB (3-bits per channel), etc.
When an N-bit RGB file has a value of N that is not a multiple of 8, how
are these bitmaps typically represented in memory? For example, if we have
6-bit RGB, it means each pixel is 6 bits, and thus each pixel is not
directly addressable by a modern computer without using bitwise
operations.
So, is it common practice to simply covert N-bit RGB files into bitmaps
where each pixel is of an addressable size (e.g. convert 6-bit to 8-bit)?
Or is it more common to simply use bitwise operations to manipulate
bitmaps where the pixel size is not addressable?
And what about disk storage? How is, say, a 6-bit RGB file stored on disk,
when the last byte of the bitmap may not even contain a full pixel?
iPhone field test instructions
iPhone field test instructions
Access the iPhone's Field Test mode by typing 3001#12345# in the phone's
keypad and press dial. This will bring up the Field Test menu
doesn't work for me
Access the iPhone's Field Test mode by typing 3001#12345# in the phone's
keypad and press dial. This will bring up the Field Test menu
doesn't work for me
How to render a table with dynamic columns in JSF
How to render a table with dynamic columns in JSF
I want to create a datatable where each column should consists of elements
which comes from different lists.For example consider world as a table.It
should have columns like continents ,countries,Animals,etc.
I want to create a datatable where each column should consists of elements
which comes from different lists.For example consider world as a table.It
should have columns like continents ,countries,Animals,etc.
How to invite contacts, that they approve the invitation and enter the data?
How to invite contacts, that they approve the invitation and enter the data?
I want to invite my engineering students to try ubuntu. But as new guests
that they approve the invitation and enter the data. I do not want to
enter the data one by one on the web.
Emilio Castro.
I want to invite my engineering students to try ubuntu. But as new guests
that they approve the invitation and enter the data. I do not want to
enter the data one by one on the web.
Emilio Castro.
Need Help Whith My Webite
Need Help Whith My Webite
So will someone help me this my website Please
so i wanted it set out like this but when i go do this the main column
pushes the other two columns down, this is my Css. Please Help me.
So will someone help me this my website Please
so i wanted it set out like this but when i go do this the main column
pushes the other two columns down, this is my Css. Please Help me.
Intersection of two quadratic equations with two variables
Intersection of two quadratic equations with two variables
I have two quadratic equations with two variables. Basically I just want
to find the point of intersection between the two curves. How should I
proceed with the solution?
The equations are ¡¼4x¡½^2-¡¼9x¡½^2+ 16x+52=0 and x^2+2+3p-23=0. Thanks!
Your help would be very much appreciated.
I have two quadratic equations with two variables. Basically I just want
to find the point of intersection between the two curves. How should I
proceed with the solution?
The equations are ¡¼4x¡½^2-¡¼9x¡½^2+ 16x+52=0 and x^2+2+3p-23=0. Thanks!
Your help would be very much appreciated.
Saturday, 17 August 2013
Launchig an activity from list view
Launchig an activity from list view
I am trying to achieve Many to one mapping in ListView and populate
elements relating to that item from the database
Hello I am trying to solve a problem which involves launching an activity
on click of an item
I am successful on launching an activity on click of an element
I have a requirement and need some ideas on how to achieve that
As I said onclick of an item I launch an activity as many to one mapping,
Suppose I click an element Item-1 the activity should populate the
text-views in the new activity from elements related to that activity
Again same if I click item-2 it should populate the text-views of in the
same new activity with elements related to that item 2 activity from the
database
Many to one mapping is must I am trying to achieve
Any ideas on how to achieve this
Any links to understand the concept will be helpful
Ps:: I am retrieving data from server as JSON resonse
I am trying to achieve Many to one mapping in ListView and populate
elements relating to that item from the database
Hello I am trying to solve a problem which involves launching an activity
on click of an item
I am successful on launching an activity on click of an element
I have a requirement and need some ideas on how to achieve that
As I said onclick of an item I launch an activity as many to one mapping,
Suppose I click an element Item-1 the activity should populate the
text-views in the new activity from elements related to that activity
Again same if I click item-2 it should populate the text-views of in the
same new activity with elements related to that item 2 activity from the
database
Many to one mapping is must I am trying to achieve
Any ideas on how to achieve this
Any links to understand the concept will be helpful
Ps:: I am retrieving data from server as JSON resonse
simple fade javascript image rotator
simple fade javascript image rotator
I found this old post asking for a simple fade image rotator:
Looking for a simple fade javascript image rotator
and found what I was looking for:
$(function() {
$('#fader img:not(:first)').hide();
$('#fader img').css('position', 'absolute');
$('#fader img').css('top', '0px');
$('#fader img').css('left', 'auto');
$('#fader img').css('right', 'auto');
//$('#fader img').css('left', '50%');
$('#fader img').each(function() {
var img = $(this);
$('<img>').attr('src', $(this).attr('src')).load(function() {
//img.css('margin-left', -this.width / 2 + 'px');
});
});
var pause = false;
function fadeNext() {
$('#fader img').first().fadeOut().appendTo($('#fader'));
$('#fader img').first().fadeIn();
}
function fadePrev() {
$('#fader img').first().fadeOut();
$('#fader img').last().prependTo($('#fader')).fadeIn();
}
$('#fader, #next').click(function() {
fadeNext();
});
$('#prev').click(function() {
fadePrev();
});
$('#fader, .arwBtn').hover(function() {
pause = true;
},function() {
pause = false;
});
function doRotate() {
if(!pause) {
fadeNext();
}
}
var rotate = setInterval(doRotate, 4000);
});
this was the original fiddle
http://jsfiddle.net/jtbowden/UNZR5/1/
I have already spent some time adapting it (not a jquery programmer :/)
And all I need to add are captions to each picture. Can someone help me
just add captions to that same code?
Really appreciate it : )
I found this old post asking for a simple fade image rotator:
Looking for a simple fade javascript image rotator
and found what I was looking for:
$(function() {
$('#fader img:not(:first)').hide();
$('#fader img').css('position', 'absolute');
$('#fader img').css('top', '0px');
$('#fader img').css('left', 'auto');
$('#fader img').css('right', 'auto');
//$('#fader img').css('left', '50%');
$('#fader img').each(function() {
var img = $(this);
$('<img>').attr('src', $(this).attr('src')).load(function() {
//img.css('margin-left', -this.width / 2 + 'px');
});
});
var pause = false;
function fadeNext() {
$('#fader img').first().fadeOut().appendTo($('#fader'));
$('#fader img').first().fadeIn();
}
function fadePrev() {
$('#fader img').first().fadeOut();
$('#fader img').last().prependTo($('#fader')).fadeIn();
}
$('#fader, #next').click(function() {
fadeNext();
});
$('#prev').click(function() {
fadePrev();
});
$('#fader, .arwBtn').hover(function() {
pause = true;
},function() {
pause = false;
});
function doRotate() {
if(!pause) {
fadeNext();
}
}
var rotate = setInterval(doRotate, 4000);
});
this was the original fiddle
http://jsfiddle.net/jtbowden/UNZR5/1/
I have already spent some time adapting it (not a jquery programmer :/)
And all I need to add are captions to each picture. Can someone help me
just add captions to that same code?
Really appreciate it : )
How to sort by arbitrary keywords?
How to sort by arbitrary keywords?
I have the following query:
SELECT
*
FROM
`Magic The Gathering`
WHERE
`set` = 'Magic 2013'
ORDER BY
`rarity` ASC
LIMIT
500
Rarity consists of the following keywords: Mythic, Rare, Uncommon, Common
Currently it sorts alphbetically, so it's sorted as Common, Mythic, Rare,
Uncommon.
How can I sort rarity so it's displayed in the following order?
Mythic, Rare, Uncommon, Common
I have the following query:
SELECT
*
FROM
`Magic The Gathering`
WHERE
`set` = 'Magic 2013'
ORDER BY
`rarity` ASC
LIMIT
500
Rarity consists of the following keywords: Mythic, Rare, Uncommon, Common
Currently it sorts alphbetically, so it's sorted as Common, Mythic, Rare,
Uncommon.
How can I sort rarity so it's displayed in the following order?
Mythic, Rare, Uncommon, Common
StackOverflow Space Reserved- Removed
StackOverflow Space Reserved- Removed
Question Closed for the moment. You can come back later. - Space RESERVED
- Space RESERVED - Space RESERVED - Space RESERVED - Space RESERVED
Question Closed for the moment. You can come back later. - Space RESERVED
- Space RESERVED - Space RESERVED - Space RESERVED - Space RESERVED
Java Thread lock on static method
Java Thread lock on static method
As per my knowledge in Java class with
Non static synchronize method : lock acquire on particular object
Static synchronize method : lock acquire on class
I am little bit confuse with this, since we can call the static method by
class name OR by object name.
please assume there are 4 methods is my class all are synchronize. 2
methods are static and 2 are non static. if i will create 1 object of my
class "obj1" and there are 2 thread Thread1 and Thread2 as well
Question 1 : if i will try to access the static synchronize method, using
the obj1 (or class name). does it mean there is no lock on "obj1" only 2
static methods will be locked (class level lock) ? means other thread can
access non static method but not the static method using the "obj1"
simultaneously ?
Question 2 : if i will try to access the non static synchronize method,
using the obj1 in Thread1. does it mean only 2 methods are locked for
Thread2 ? means Thread2 can access 2 static method , OR we can access the
static method using the className(MyClass) as well simultaneously
Question 3 : if all the methods in my class are static and synchronize .
does it means there will be no object level lock and there is only one
class level lock for all thread. ?
please explain little bit about the class level lock
Thanks in advance.
As per my knowledge in Java class with
Non static synchronize method : lock acquire on particular object
Static synchronize method : lock acquire on class
I am little bit confuse with this, since we can call the static method by
class name OR by object name.
please assume there are 4 methods is my class all are synchronize. 2
methods are static and 2 are non static. if i will create 1 object of my
class "obj1" and there are 2 thread Thread1 and Thread2 as well
Question 1 : if i will try to access the static synchronize method, using
the obj1 (or class name). does it mean there is no lock on "obj1" only 2
static methods will be locked (class level lock) ? means other thread can
access non static method but not the static method using the "obj1"
simultaneously ?
Question 2 : if i will try to access the non static synchronize method,
using the obj1 in Thread1. does it mean only 2 methods are locked for
Thread2 ? means Thread2 can access 2 static method , OR we can access the
static method using the className(MyClass) as well simultaneously
Question 3 : if all the methods in my class are static and synchronize .
does it means there will be no object level lock and there is only one
class level lock for all thread. ?
please explain little bit about the class level lock
Thanks in advance.
WATCH! Australia vs New Zealand Live Stream Online Rugby Hd Video Tv Broadcast Link 17th Aug 2013
WATCH! Australia vs New Zealand Live Stream Online Rugby Hd Video Tv
Broadcast Link 17th Aug 2013
WATCH! Australia vs New Zealand Live Stream Online Rugby Hd Video Tv
Broadcast Link 17th Aug 2013 ((Wallabies vs All Blacks)) Australia vs New
Zealand Live Rugby streaming hd video free online. The Rugby Championship
August 17th , 2013 Watch Rugby Australia vs New Zealand Live Stream.
Welcome to watch Australia vs New Zealand live streaming Rugby match . You
can easily watch the live action of Australia vs New Zealand match on your
pc/laptop.
CLICK HERE TO WATCH LIVE ONLINE
Australia vs New Zealand Live International Rugby Events The Rugby
Championship 2013 Date:Saturday, August 17,Time:16:05 GMT
Bledisloe-Cup-Website-620-x-436 CLICK HERE TO WATCH LIVE ONLINE
http://sportstvonpc.com/australia-vs-new-zealand-live-stream/
Australia Wallabies Vs New Zealand All Blacks Live Stream Rugby When,
where and how to watch Australia Wallabies Vs New Zealand All Blacks live
streaming online Rugby Championship Bledisloe Cup HD broadcast coverage.
Here is Wallabies Vs All Blacks Game Kickoff Time, TV Schedule, Radio
Commentary, Match Odds, Scores, Results, Highlights Videos : New Zealand
All Blacks Vs Australia Wallabies will be played on Saturday 17 August at
ANZ Stadium, Sydney on Saturday. The kickoff time is 20:00 AEST ET. You
can watch All Blacks Vs Wallabies live stream broadcast coverage on Fox TV
Channel.
http://sportstvonpc.com/australia-vs-new-zealand-live-stream/
Broadcast Link 17th Aug 2013
WATCH! Australia vs New Zealand Live Stream Online Rugby Hd Video Tv
Broadcast Link 17th Aug 2013 ((Wallabies vs All Blacks)) Australia vs New
Zealand Live Rugby streaming hd video free online. The Rugby Championship
August 17th , 2013 Watch Rugby Australia vs New Zealand Live Stream.
Welcome to watch Australia vs New Zealand live streaming Rugby match . You
can easily watch the live action of Australia vs New Zealand match on your
pc/laptop.
CLICK HERE TO WATCH LIVE ONLINE
Australia vs New Zealand Live International Rugby Events The Rugby
Championship 2013 Date:Saturday, August 17,Time:16:05 GMT
Bledisloe-Cup-Website-620-x-436 CLICK HERE TO WATCH LIVE ONLINE
http://sportstvonpc.com/australia-vs-new-zealand-live-stream/
Australia Wallabies Vs New Zealand All Blacks Live Stream Rugby When,
where and how to watch Australia Wallabies Vs New Zealand All Blacks live
streaming online Rugby Championship Bledisloe Cup HD broadcast coverage.
Here is Wallabies Vs All Blacks Game Kickoff Time, TV Schedule, Radio
Commentary, Match Odds, Scores, Results, Highlights Videos : New Zealand
All Blacks Vs Australia Wallabies will be played on Saturday 17 August at
ANZ Stadium, Sydney on Saturday. The kickoff time is 20:00 AEST ET. You
can watch All Blacks Vs Wallabies live stream broadcast coverage on Fox TV
Channel.
http://sportstvonpc.com/australia-vs-new-zealand-live-stream/
Friday, 16 August 2013
How can I avoid these kinds of memory leaks in my C++ code?
How can I avoid these kinds of memory leaks in my C++ code?
I have memory leak problem with my C++ code. I think this is because of
pointer assignment. For example, I have several lines like this:
**int **p= new int *[g+2];
for(int k=0;k<=g+1;k++){
p[k]=new int [n_k[k]+1];
for(int l=0;l<=n_k[k];l++){
p[k][l]=0;
}
}
int **temp= new int *[g+2];
for(int k=0;k<=g+1;k++){
temp[k]=new int [n_k[k]+1];
for(int l=0;l<=n_k[k];l++){
temp[k][l]=p[k][l];
}
}
...
...
for(int r=0; r<=g+1;r++){
delete []temp[r];
}
delete []temp;
for(int r=0; r<=g+1;r++){
delete []p[r];
}
delete []p;
How can I avoid these kinds of memory leaks? I delete the pointers but I
think the memory leaks are because of pointer assignments. I've used such
pointer assignments several times in my code.
I have memory leak problem with my C++ code. I think this is because of
pointer assignment. For example, I have several lines like this:
**int **p= new int *[g+2];
for(int k=0;k<=g+1;k++){
p[k]=new int [n_k[k]+1];
for(int l=0;l<=n_k[k];l++){
p[k][l]=0;
}
}
int **temp= new int *[g+2];
for(int k=0;k<=g+1;k++){
temp[k]=new int [n_k[k]+1];
for(int l=0;l<=n_k[k];l++){
temp[k][l]=p[k][l];
}
}
...
...
for(int r=0; r<=g+1;r++){
delete []temp[r];
}
delete []temp;
for(int r=0; r<=g+1;r++){
delete []p[r];
}
delete []p;
How can I avoid these kinds of memory leaks? I delete the pointers but I
think the memory leaks are because of pointer assignments. I've used such
pointer assignments several times in my code.
Thursday, 8 August 2013
feedparser media_content attribute
feedparser media_content attribute
I am creating an RSS reader and I want to pull the url attribute of
media:content using feedparser on Google App Engine, but I am running into
problems when an entry doesn't have a media_content attribute.
for feedURL in feedURLs:
logging.debug('feedURL iteration')
feed=feedparser.parse(feedURL.sourceLink)
for entry in feed.entries:
logging.debug('entry iteration')
title=entry.get('title')
link=entry.get('link')
description=entry.get('description')
pubDate=entry.get('pubDate')
image=entry.get('image')
mediaContent=entry.media_content
This works great if I eliminate the mediaContent line, but it fails when
it is included. I think it is because only a few of the entries have
media:content tags. Is there a way to get the url of the media:content tag
when it exists and just have mediaContent set to None when it doesn't? Am
I barking up the wrong tree?
This is the error in the log:
object has no attribute 'media_content' Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party
Thanks!
I am creating an RSS reader and I want to pull the url attribute of
media:content using feedparser on Google App Engine, but I am running into
problems when an entry doesn't have a media_content attribute.
for feedURL in feedURLs:
logging.debug('feedURL iteration')
feed=feedparser.parse(feedURL.sourceLink)
for entry in feed.entries:
logging.debug('entry iteration')
title=entry.get('title')
link=entry.get('link')
description=entry.get('description')
pubDate=entry.get('pubDate')
image=entry.get('image')
mediaContent=entry.media_content
This works great if I eliminate the mediaContent line, but it fails when
it is included. I think it is because only a few of the entries have
media:content tags. Is there a way to get the url of the media:content tag
when it exists and just have mediaContent set to None when it doesn't? Am
I barking up the wrong tree?
This is the error in the log:
object has no attribute 'media_content' Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party
Thanks!
Get headers Ajax Jquery
Get headers Ajax Jquery
I try to get the header value "Date" like this but it gives:
xhr.getResponseHeader is not a function
I see the response header in firebug and it exists :S
Maybe no JQuery support? Can this be done in JavaScript instead maybe?
must work, I can see the headers...
Code:
function ajaxDate(myUrl){
var res;
var ajaxCall=$.ajax({
type: 'GET',
url: myUrl,
crossDomain: true,
async: false,
cache: false
}).always(function(output, status, xhr) {
//alert(xhr.getResponseHeader("MyCookie"));
console.log(xhr);
console.log(output);
console.log(status);
res=xhr.getResponseHeader('Date');
});
return res;
}
I try to get the header value "Date" like this but it gives:
xhr.getResponseHeader is not a function
I see the response header in firebug and it exists :S
Maybe no JQuery support? Can this be done in JavaScript instead maybe?
must work, I can see the headers...
Code:
function ajaxDate(myUrl){
var res;
var ajaxCall=$.ajax({
type: 'GET',
url: myUrl,
crossDomain: true,
async: false,
cache: false
}).always(function(output, status, xhr) {
//alert(xhr.getResponseHeader("MyCookie"));
console.log(xhr);
console.log(output);
console.log(status);
res=xhr.getResponseHeader('Date');
});
return res;
}
Animate table with jquery (if possible)
Animate table with jquery (if possible)
I have code that shows dynamically created tables of varying lengths, with
'expand' and 'condense' buttons that show/hide extra table rows. It works
but it's ugly. I'd love to animate it but apparently that's not possible.
This is probably a duplicate of jQuery - How to Use slideDown (or show)
function on a table row?, in which case feel free to close it, but that
was four years old and I was hoping there might be a new/better solution
(I couldn't get those to work, but I can keep trying). If animating is not
an option, maybe someone can suggest some other design feature that might
look decent?
$(document).ready(function(){
$('.table').each(function(){
$(this).find("tr:even").addClass("even");
$(this).find("tr:odd").addClass("odd");
var numShown = 2; // Initial rows shown & index
var $table = $(this).find('tbody'); // tbody containing all the rows
var numRows = $table.find('tr').length; // Total # rows
var tableWidth = $table.find('tr:first td').length;
var expandDiv = '<tbody class="more"><tr><td colspan="' +
tableWidth + '"><div>Show
More</div</tbody></td></tr>';
var condenseDiv = '<tbody class="less"><tr><td colspan="' +
$table.find('tr:first td').length + '"><div>Show
Less</div</tbody></td></tr>';
if(numRows>numShown){
$(function () {
// Hide rows and add clickable div
$table.find('tr:gt(' + (numShown - 1) + ')').hide().end()
.after(expandDiv);
})
};
$(this).on('click', '.more', (function() {
// numShown = numShown + numMore;
$(this).remove();
$table.find('tr').show();
$table.after(condenseDiv);
}));
$(this).on('click', '.less', (function() {
$table.find('tr:gt(' + (numShown - 1) + ')').hide().end()
.after(expandDiv);
$(this).remove();
})
)
});
});
I have code that shows dynamically created tables of varying lengths, with
'expand' and 'condense' buttons that show/hide extra table rows. It works
but it's ugly. I'd love to animate it but apparently that's not possible.
This is probably a duplicate of jQuery - How to Use slideDown (or show)
function on a table row?, in which case feel free to close it, but that
was four years old and I was hoping there might be a new/better solution
(I couldn't get those to work, but I can keep trying). If animating is not
an option, maybe someone can suggest some other design feature that might
look decent?
$(document).ready(function(){
$('.table').each(function(){
$(this).find("tr:even").addClass("even");
$(this).find("tr:odd").addClass("odd");
var numShown = 2; // Initial rows shown & index
var $table = $(this).find('tbody'); // tbody containing all the rows
var numRows = $table.find('tr').length; // Total # rows
var tableWidth = $table.find('tr:first td').length;
var expandDiv = '<tbody class="more"><tr><td colspan="' +
tableWidth + '"><div>Show
More</div</tbody></td></tr>';
var condenseDiv = '<tbody class="less"><tr><td colspan="' +
$table.find('tr:first td').length + '"><div>Show
Less</div</tbody></td></tr>';
if(numRows>numShown){
$(function () {
// Hide rows and add clickable div
$table.find('tr:gt(' + (numShown - 1) + ')').hide().end()
.after(expandDiv);
})
};
$(this).on('click', '.more', (function() {
// numShown = numShown + numMore;
$(this).remove();
$table.find('tr').show();
$table.after(condenseDiv);
}));
$(this).on('click', '.less', (function() {
$table.find('tr:gt(' + (numShown - 1) + ')').hide().end()
.after(expandDiv);
$(this).remove();
})
)
});
});
Subscribe to:
Posts (Atom)