A probability problem on limit theorem (!)
Each of the 300 workers of a factory takes his lunch in one of the three
competing restaurants (equally likely, so with probability $1/3$). How
many seats should each restaurants have so that, on average, at most one
in 20 customers will remain unseated?
How can I approach this?
It is not clear to me why it is given as an excercise to the limit
theorems chapter.
Monday, 30 September 2013
Two partitions on USB drive superuser.com
Two partitions on USB drive – superuser.com
I want to have two partitions on my USB drive. First one mainly for all
files, I decided to be FAT32 because it works on Linux and Windows. Second
one for my Linux Mint backup and private files, ...
I want to have two partitions on my USB drive. First one mainly for all
files, I decided to be FAT32 because it works on Linux and Windows. Second
one for my Linux Mint backup and private files, ...
How to begin implementing RPC subroutines for NFS V3?
How to begin implementing RPC subroutines for NFS V3?
I have understood the basic structures required for implementing the
subroutines by reading XDR/RPC specifications. I wish to implement
subroutines for lookup,mount,umount,create etc. I don't know how to start.
I have just converted a simple function to an RPC using rpcgen on the
lines of RFC.
I wish to implement the mount function first. Following are the structures
fed to XDR that when compiled with rpcgen generates the client and server
stub and a .h and .c files containing the various declarations.
const MNTPATHLEN = 1024; /* Maximum bytes in a path name */
const MNTNAMLEN = 255; /* Maximum bytes in a name */
const FHSIZE2 = 32; /* Maximum bytes in a V2 file handle */
const FHSIZE3 = 64; /* Maximum bytes in a V3 file handle */
typedef opaque fhandle2[FHSIZE2];
typedef opaque fhandle3<FHSIZE3>;
typedef string dirpath<MNTPATHLEN>;
typedef string name<MNTNAMLEN>;
union fhstatus switch (unsigned fhs_status) {
case 0:
fhandle2 fhs_fhandle;
default:
void;
};
enum mountstat3 {
MNT3_OK = 0, /* no error */
MNT3ERR_PERM = 1, /* Not owner */
MNT3ERR_NOENT = 2, /* No such file or directory */
MNT3ERR_IO = 5, /* I/O error */
MNT3ERR_ACCES = 13, /* Permission denied */
MNT3ERR_NOTDIR = 20, /* Not a directory */
MNT3ERR_INVAL = 22, /* Invalid argument */
MNT3ERR_NAMETOOLONG = 63, /* Filename too long */
MNT3ERR_NOTSUPP = 10004, /* Operation not supported */
MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */
};
/* Structure returned when mount succeeds */
struct mountres3_ok {
fhandle3 fhandle;
int auth_flavors<>;
};
union mountres3 switch (mountstat3 fhs_status) {
case MNT3_OK:
mountres3_ok mountinfo;
default:
void;
};
typedef struct mountbody *mountlist;
/* Mount body */
struct mountbody {
name ml_hostname;
dirpath ml_directory;
mountlist ml_next;
};
typedef struct groupnode *groups;
struct groupnode {
name gr_name;
groups gr_next;
};
typedef struct exportnode *exports;
struct exportnode {
dirpath ex_dir;
groups ex_groups;
exports ex_next;
};
program MOUNT_PROGRAM {
version MOUNT_V1 {
void MOUNTPROC_NULL (void) = 0;
fhstatus MOUNTPROC_MNT (dirpath) = 1;
mountlist MOUNTPROC_DUMP (void) = 2;
void MOUNTPROC_UMNT (dirpath) = 3;
void MOUNTPROC_UMNTALL (void) = 4;
exports MOUNTPROC_EXPORT (void) = 5;
exports MOUNTPROC_EXPORTALL (void) = 6;
} = 1;
version MOUNT_V3 {
void MOUNTPROC3_NULL (void) = 0;
mountres3 MOUNTPROC3_MNT (dirpath) = 1;
mountlist MOUNTPROC3_DUMP (void) = 2;
void MOUNTPROC3_UMNT (dirpath) = 3;
void MOUNTPROC3_UMNTALL (void) = 4;
exports MOUNTPROC3_EXPORT (void) = 5;
} = 3;
} = 100005;
I know that I have to write a function mount() that the server calls when
the client passes in the directory path and the function would probably
contain a call to mount system call. I'm having a hard time visualizing
how to handle different structures such as file handles and return them
appropriately. I'm very stuck. Any insights would be greatly appreciated.
Thank you.
I have understood the basic structures required for implementing the
subroutines by reading XDR/RPC specifications. I wish to implement
subroutines for lookup,mount,umount,create etc. I don't know how to start.
I have just converted a simple function to an RPC using rpcgen on the
lines of RFC.
I wish to implement the mount function first. Following are the structures
fed to XDR that when compiled with rpcgen generates the client and server
stub and a .h and .c files containing the various declarations.
const MNTPATHLEN = 1024; /* Maximum bytes in a path name */
const MNTNAMLEN = 255; /* Maximum bytes in a name */
const FHSIZE2 = 32; /* Maximum bytes in a V2 file handle */
const FHSIZE3 = 64; /* Maximum bytes in a V3 file handle */
typedef opaque fhandle2[FHSIZE2];
typedef opaque fhandle3<FHSIZE3>;
typedef string dirpath<MNTPATHLEN>;
typedef string name<MNTNAMLEN>;
union fhstatus switch (unsigned fhs_status) {
case 0:
fhandle2 fhs_fhandle;
default:
void;
};
enum mountstat3 {
MNT3_OK = 0, /* no error */
MNT3ERR_PERM = 1, /* Not owner */
MNT3ERR_NOENT = 2, /* No such file or directory */
MNT3ERR_IO = 5, /* I/O error */
MNT3ERR_ACCES = 13, /* Permission denied */
MNT3ERR_NOTDIR = 20, /* Not a directory */
MNT3ERR_INVAL = 22, /* Invalid argument */
MNT3ERR_NAMETOOLONG = 63, /* Filename too long */
MNT3ERR_NOTSUPP = 10004, /* Operation not supported */
MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */
};
/* Structure returned when mount succeeds */
struct mountres3_ok {
fhandle3 fhandle;
int auth_flavors<>;
};
union mountres3 switch (mountstat3 fhs_status) {
case MNT3_OK:
mountres3_ok mountinfo;
default:
void;
};
typedef struct mountbody *mountlist;
/* Mount body */
struct mountbody {
name ml_hostname;
dirpath ml_directory;
mountlist ml_next;
};
typedef struct groupnode *groups;
struct groupnode {
name gr_name;
groups gr_next;
};
typedef struct exportnode *exports;
struct exportnode {
dirpath ex_dir;
groups ex_groups;
exports ex_next;
};
program MOUNT_PROGRAM {
version MOUNT_V1 {
void MOUNTPROC_NULL (void) = 0;
fhstatus MOUNTPROC_MNT (dirpath) = 1;
mountlist MOUNTPROC_DUMP (void) = 2;
void MOUNTPROC_UMNT (dirpath) = 3;
void MOUNTPROC_UMNTALL (void) = 4;
exports MOUNTPROC_EXPORT (void) = 5;
exports MOUNTPROC_EXPORTALL (void) = 6;
} = 1;
version MOUNT_V3 {
void MOUNTPROC3_NULL (void) = 0;
mountres3 MOUNTPROC3_MNT (dirpath) = 1;
mountlist MOUNTPROC3_DUMP (void) = 2;
void MOUNTPROC3_UMNT (dirpath) = 3;
void MOUNTPROC3_UMNTALL (void) = 4;
exports MOUNTPROC3_EXPORT (void) = 5;
} = 3;
} = 100005;
I know that I have to write a function mount() that the server calls when
the client passes in the directory path and the function would probably
contain a call to mount system call. I'm having a hard time visualizing
how to handle different structures such as file handles and return them
appropriately. I'm very stuck. Any insights would be greatly appreciated.
Thank you.
What's wrong with this block formating code?
What's wrong with this block formating code?
-(void)
vPerformBlockOnAllAutoCompleteHandler:((^)(BGMotherofAutoCompleteHandler *
acHandler))block
{
for (BGMotherofAutoCompleteHandler * acHandler in [self
arBGKeywordAutoCompleteHandlers]) {
block(acHandler);
}
}
Okay, so block is a block that takes BGMotherofAutoCompleteHandler as
argument. I went through the loop and call block(acHandler).
What's wrong?
-(void)
vPerformBlockOnAllAutoCompleteHandler:((^)(BGMotherofAutoCompleteHandler *
acHandler))block
{
for (BGMotherofAutoCompleteHandler * acHandler in [self
arBGKeywordAutoCompleteHandlers]) {
block(acHandler);
}
}
Okay, so block is a block that takes BGMotherofAutoCompleteHandler as
argument. I went through the loop and call block(acHandler).
What's wrong?
Sunday, 29 September 2013
jquery mobile and knockout checkbox not updating with viewmodel
jquery mobile and knockout checkbox not updating with viewmodel
I have two jQuery Mobile checkboxes bound to the same knockout viewmodel
member. I expect clicking on one check box to update the viewmodel and in
turn update the other checkbox to be checked too. see example here
The HTML
<span data-bind="text: chk"></span>
<input id="checkbox1" name="" data-bind="checked: chk" type="checkbox">
<label for="checkbox1">A</label>
<input id="checkbox2" name="" data-bind="checked: chk" type="checkbox">
<label for="checkbox2">B</label>
The Javascript
function ViewModel(){
var self = this;
self.chk = ko.observable(false);
}
ko.applyBindings(new ViewModel());
I can see the model is updating, with a text field showing its value. But
the checkbox is not
I have two jQuery Mobile checkboxes bound to the same knockout viewmodel
member. I expect clicking on one check box to update the viewmodel and in
turn update the other checkbox to be checked too. see example here
The HTML
<span data-bind="text: chk"></span>
<input id="checkbox1" name="" data-bind="checked: chk" type="checkbox">
<label for="checkbox1">A</label>
<input id="checkbox2" name="" data-bind="checked: chk" type="checkbox">
<label for="checkbox2">B</label>
The Javascript
function ViewModel(){
var self = this;
self.chk = ko.observable(false);
}
ko.applyBindings(new ViewModel());
I can see the model is updating, with a text field showing its value. But
the checkbox is not
Find if an object tree has a given property
Find if an object tree has a given property
I am passing a set of options as an object:
var options={
sortRules:[
{...}, // rule 1
{...}, // rule 2
// etc.
},
filterRules:[
{...}, // rule 1
{...}, // rule 2
// etc.
},
etc.
};
My issue: if any rule contains an "encodedName" property, I need to
retrieve ASAP a dictionary of codes via a Web service. The dictionary is
not needed if no "encodedName" property gets passed.
What is the most efficient way to check if an "encodedName" property is
present within this object hierarchy? Looping through all the objects and
sub-objects sounds painful, and I was wondering if there is a faster way.
I am passing a set of options as an object:
var options={
sortRules:[
{...}, // rule 1
{...}, // rule 2
// etc.
},
filterRules:[
{...}, // rule 1
{...}, // rule 2
// etc.
},
etc.
};
My issue: if any rule contains an "encodedName" property, I need to
retrieve ASAP a dictionary of codes via a Web service. The dictionary is
not needed if no "encodedName" property gets passed.
What is the most efficient way to check if an "encodedName" property is
present within this object hierarchy? Looping through all the objects and
sub-objects sounds painful, and I was wondering if there is a faster way.
ubuntu php mail function is not working
ubuntu php mail function is not working
I have installed lamp server in ubuntu but php mail function is not
working ,I have two domains in server so what I need to install on server
?
I have installed lamp server in ubuntu but php mail function is not
working ,I have two domains in server so what I need to install on server
?
Saturday, 28 September 2013
URLMon Interfaces in Delphi
URLMon Interfaces in Delphi
I've tried using IInternetBindInfoEx, IInternetProtocolEx, IUri in Delphi
XE4 to make a custom HTTP/HTTPS handler for TEmbeddedWB. But the
interfaces are missing from URLMon.pas. So my question is how or where to
get them?
I've tried using IInternetBindInfoEx, IInternetProtocolEx, IUri in Delphi
XE4 to make a custom HTTP/HTTPS handler for TEmbeddedWB. But the
interfaces are missing from URLMon.pas. So my question is how or where to
get them?
Can you use QWebView cookies/sessions with QNetworkAccessManager?
Can you use QWebView cookies/sessions with QNetworkAccessManager?
I am making a program with a QWebView that shows the user pages from our
site. At the same time I want to use QNetworkManager to make background
HTTP requests to the site. Is there a way to share the user's cookies
between the QWebView and QNetworkManager so that they just have one
session? Right now the user can log in in the QWebView, but then when I
make get() calls on the QNetworkManager object the site behaves as if the
user is not logged in, although they are logged in in the QWebView.
I am making a program with a QWebView that shows the user pages from our
site. At the same time I want to use QNetworkManager to make background
HTTP requests to the site. Is there a way to share the user's cookies
between the QWebView and QNetworkManager so that they just have one
session? Right now the user can log in in the QWebView, but then when I
make get() calls on the QNetworkManager object the site behaves as if the
user is not logged in, although they are logged in in the QWebView.
Error: Misplace Else
Error: Misplace Else
I tried to print the largest number in the array but there's an error
showing misplaced else. I tried putting brackets around but there's still
an error in it. I don't have an idea why there is a misplaced else error.
Please help : >.<
#include <stdio.h>
#include <conio.h>
void main()
{
int lar, yem;
clrscr();
int aray[10];
for (yem = 0; yem < 10; ++yem)
{
printf("Input numbers:");
scanf("%d", &aray[yem]);
}
lar = aray[0];
for (yem = 1; yem < 10; ++yem)
{
if (aray[yem] > lar);
lar = aray[yem];
else
++yem;
printf("Biggest: %d\n", lar);
}
getch();
}
I tried to print the largest number in the array but there's an error
showing misplaced else. I tried putting brackets around but there's still
an error in it. I don't have an idea why there is a misplaced else error.
Please help : >.<
#include <stdio.h>
#include <conio.h>
void main()
{
int lar, yem;
clrscr();
int aray[10];
for (yem = 0; yem < 10; ++yem)
{
printf("Input numbers:");
scanf("%d", &aray[yem]);
}
lar = aray[0];
for (yem = 1; yem < 10; ++yem)
{
if (aray[yem] > lar);
lar = aray[yem];
else
++yem;
printf("Biggest: %d\n", lar);
}
getch();
}
Friday, 27 September 2013
WCF service communicating with web app client and android client
WCF service communicating with web app client and android client
I'm new to the community, I hope I'm asking right.
I have a WCF service that should receive connections from both "web app
client" and "Android app".
Is it possible to do this? As I understood the best way to connect to
Android is using JSON, but how can I manage the connection to the web app?
Thank you.
I'm new to the community, I hope I'm asking right.
I have a WCF service that should receive connections from both "web app
client" and "Android app".
Is it possible to do this? As I understood the best way to connect to
Android is using JSON, but how can I manage the connection to the web app?
Thank you.
jQuery functions not firing until you resize window
jQuery functions not firing until you resize window
I have a Foundation Orbit image slider that doesn't show up until you
resize the browser window. The space is empty until you even just change
the window size by a pixel. Foundation is calculating the hight of the
slider on the fly but when the page first loads there's no height set on
the container.
I also have a nav bar that doesn't correct itself to its calculated width
until I resize the window.
Here's the nav bar code:
Ew.ApplicationView = Ember.View.extend({
didInsertElement: function() {
$(".nav").width($(window).width() - 406);
$(".subnav").width($(window).width() - 396);
return $(window).resize(function() {
$(".nav").width($(window).width() - 406);
return $(".subnav").width($(window).width() - 396);
});
}
});
And the slider initialization code:
Ew.OrbitSliderComponent = Ember.Component.extend({
initOrbit: function() {
$(document).foundation('orbit', {
stack_on_small: true;
navigation_arrows: false;
variable_height: true;
});
}.on('didInsertElement')
});
What causes jQuery functions to not fire until the window resizes?
I have a Foundation Orbit image slider that doesn't show up until you
resize the browser window. The space is empty until you even just change
the window size by a pixel. Foundation is calculating the hight of the
slider on the fly but when the page first loads there's no height set on
the container.
I also have a nav bar that doesn't correct itself to its calculated width
until I resize the window.
Here's the nav bar code:
Ew.ApplicationView = Ember.View.extend({
didInsertElement: function() {
$(".nav").width($(window).width() - 406);
$(".subnav").width($(window).width() - 396);
return $(window).resize(function() {
$(".nav").width($(window).width() - 406);
return $(".subnav").width($(window).width() - 396);
});
}
});
And the slider initialization code:
Ew.OrbitSliderComponent = Ember.Component.extend({
initOrbit: function() {
$(document).foundation('orbit', {
stack_on_small: true;
navigation_arrows: false;
variable_height: true;
});
}.on('didInsertElement')
});
What causes jQuery functions to not fire until the window resizes?
Why is my log level not being used when loadapp from paste.deploy?
Why is my log level not being used when loadapp from paste.deploy?
I want to temporailiy turn on debug messages in a production pyramid
projeckt so I adjusted the production.ini file, pushed it to Heroku and
saw only error and warn level messages.
So I thought, that seems odd since if I start the pyramid application like
the following on my local PC I get all the log level messages.
env/bin/pserve production.ini
OK, so that's not exactly how it runs on Heroku, it is actually run from a
little bit of python that looks like this (in a file called runapp.py):
import os
from paste.deploy import loadapp
from waitress import serve
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app = loadapp('config:production.ini', relative_to='.')
serve(app, host='0.0.0.0', port=port)
Now, sure enough if I do this on my local PC I get the same behavior as
when it is deployed to Heroku (hardly surprising).
python runapp.py
My question is, what am I missing here? Why does running it the second way
result in no log messages other than ERROR and WARN being output to
standard out? Surely, since it is using the same production.ini file it
should work the same as if I use the pserve process?
Here is my logging section from production.ini:
###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
###
[loggers]
keys = root, test
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = DEBUG
handlers = console
[logger_test]
level = DEBUG
handlers = console
qualname = test
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = DEBUG
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
I want to temporailiy turn on debug messages in a production pyramid
projeckt so I adjusted the production.ini file, pushed it to Heroku and
saw only error and warn level messages.
So I thought, that seems odd since if I start the pyramid application like
the following on my local PC I get all the log level messages.
env/bin/pserve production.ini
OK, so that's not exactly how it runs on Heroku, it is actually run from a
little bit of python that looks like this (in a file called runapp.py):
import os
from paste.deploy import loadapp
from waitress import serve
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app = loadapp('config:production.ini', relative_to='.')
serve(app, host='0.0.0.0', port=port)
Now, sure enough if I do this on my local PC I get the same behavior as
when it is deployed to Heroku (hardly surprising).
python runapp.py
My question is, what am I missing here? Why does running it the second way
result in no log messages other than ERROR and WARN being output to
standard out? Surely, since it is using the same production.ini file it
should work the same as if I use the pserve process?
Here is my logging section from production.ini:
###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
###
[loggers]
keys = root, test
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = DEBUG
handlers = console
[logger_test]
level = DEBUG
handlers = console
qualname = test
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = DEBUG
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
How to play button sounds in Cocos2d
How to play button sounds in Cocos2d
If I create a button like this:
CCMenuItemImage *okBtn = [CCMenuItemImage
itemWithNormalImage:@"gameOkBtn.png"
selectedImage:@"gameOkBtnPressed.png"
block:^(id
sender)
{
//actions
}];
How could I play a sound both on press and on release? In regular iOS dev
I can subclass UIButton and add selectors for the UIControl events.
If I create a button like this:
CCMenuItemImage *okBtn = [CCMenuItemImage
itemWithNormalImage:@"gameOkBtn.png"
selectedImage:@"gameOkBtnPressed.png"
block:^(id
sender)
{
//actions
}];
How could I play a sound both on press and on release? In regular iOS dev
I can subclass UIButton and add selectors for the UIControl events.
set property of Object in Array
set property of Object in Array
I have an Array of Objects like so:
manualInputHeaders = [
{text: 'Store No', title: 'Enter Destination Store Number'},
{text: 'Promise Date', title: 'Enter promise ship data', classes:
{classAdditions: 'tooltipInput'}}
]
I'm trying to set with
manualInputHeaders[0].classes.classAdditions = 'setMe'
However, chrome console gives:
Uncaught TypeError: Cannot set property 'classAdditions' of undefined
How can a property of an Object within an Array be set?
I have an Array of Objects like so:
manualInputHeaders = [
{text: 'Store No', title: 'Enter Destination Store Number'},
{text: 'Promise Date', title: 'Enter promise ship data', classes:
{classAdditions: 'tooltipInput'}}
]
I'm trying to set with
manualInputHeaders[0].classes.classAdditions = 'setMe'
However, chrome console gives:
Uncaught TypeError: Cannot set property 'classAdditions' of undefined
How can a property of an Object within an Array be set?
Loading about 5000 contacts and removing duplicates gives performance issue
Loading about 5000 contacts and removing duplicates gives performance issue
I m loading about 5000 contacts using addressbook and removing duplicates
from it but it taking lot off time and thus affecting performance of my
app.
I m loading about 5000 contacts using addressbook and removing duplicates
from it but it taking lot off time and thus affecting performance of my
app.
Thursday, 19 September 2013
Parallels - Access Visual Studio 2012 Express Server in OSx Host
Parallels - Access Visual Studio 2012 Express Server in OSx Host
I have Parallels 8 with a Windows 7 virtual machine and Visual Studio 2012
installed within.
I am attempting to access the IIS Express server built into Visual Studio
2012 from Firefox on OSx (or any other device on the local network
iPad/iPhone etc...).
The URL given by Visual Studio is usually localhost:4468/default.aspx.
The IP of the Win7 Virtual Machine is setup as 10.211.55.3
The IP of the OSx host is within the standard network range of 192.168.1.102
However it is not as simple as calling the VM from it's IP and just
including the port. 10.211.55.3:4468.
I have attempted several different tactics from postings around the net,
but with no avail. One posting included the use of Fiddler used as a port
forwarder but this was very difficult to follow since the posting was
several years dated.
Any assistance is appreciated and thank you for your time in advance!
I have Parallels 8 with a Windows 7 virtual machine and Visual Studio 2012
installed within.
I am attempting to access the IIS Express server built into Visual Studio
2012 from Firefox on OSx (or any other device on the local network
iPad/iPhone etc...).
The URL given by Visual Studio is usually localhost:4468/default.aspx.
The IP of the Win7 Virtual Machine is setup as 10.211.55.3
The IP of the OSx host is within the standard network range of 192.168.1.102
However it is not as simple as calling the VM from it's IP and just
including the port. 10.211.55.3:4468.
I have attempted several different tactics from postings around the net,
but with no avail. One posting included the use of Fiddler used as a port
forwarder but this was very difficult to follow since the posting was
several years dated.
Any assistance is appreciated and thank you for your time in advance!
Trying to complie c++ code base in Visual studio gives hard time
Trying to complie c++ code base in Visual studio gives hard time
I am trying to compile a c++ code base in Visual studio. It is a
reasonably popular application called i-Perf. I downloaded the source code
form http://sourceforge.net/projects/iperf/
Now, while trying to compile the source code in Visual studio gives all
the kind of errors from function not defined to variable not defined. I
can understand that sometimes when we load the source code then we have to
fix the references here and there but it should ideally work without
making any major changes in the code.
What makes me wonder is that since it is my first ever c++ application,
there are chances that I am doing something wrong OR it is not a good idea
to try to compile the application in Visual studio environment.
What confuses me is that whether there is something wrong in the code or
there is something wrong in my approach?
Any suggestionsH
I am trying to compile a c++ code base in Visual studio. It is a
reasonably popular application called i-Perf. I downloaded the source code
form http://sourceforge.net/projects/iperf/
Now, while trying to compile the source code in Visual studio gives all
the kind of errors from function not defined to variable not defined. I
can understand that sometimes when we load the source code then we have to
fix the references here and there but it should ideally work without
making any major changes in the code.
What makes me wonder is that since it is my first ever c++ application,
there are chances that I am doing something wrong OR it is not a good idea
to try to compile the application in Visual studio environment.
What confuses me is that whether there is something wrong in the code or
there is something wrong in my approach?
Any suggestionsH
How do I run a deploy a rails + mongodb application to an actual domain?
How do I run a deploy a rails + mongodb application to an actual domain?
I have followed this tutorial to set up a basic Rails 4 application with
Mongoid and Mongodb.
I have Passenger set up on the server for deployment. When I go to
domain.com:3000 the application works. Also when I go to domain.com:28017
it shows that mongodb is working.
In all the examples/tutorials I can find the application is hosted at
localhost:3000 whereas I am trying to deploy to my actual domain.
When I go to domain.com I get the following error message:
Problem:
No sessions configuration provided.
Summary:
Mongoid's configuration requires that you provide details about each
session that can be connected to, and requires in the sessions
config at least 1 default session to exist.
Resolution:
Double check your mongoid.yml to make sure that you have a top-level
sessions key with at least 1 default session configuration for it.
You can regenerate a new mongoid.yml for assistance via `rails g
mongoid:config`.
Example:
development:
sessions:
default:
database: mongoid_dev
hosts:
- localhost:27017
(Mongoid::Errors::NoSessionsConfig)
The issue appears to be my mongoid.yml file which is as follows:
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect
to.
# (required).
database: myapp_development
# Provides the hosts the default session can connect to. Must be an
array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
# safe: false
# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :eventual
# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30
# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false
# Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
sessions:
default:
database: myapp_test
hosts:
- localhost:27017
options:
consistency: :strong
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0
How is this issue usually resolved? Thanks in advance
I have followed this tutorial to set up a basic Rails 4 application with
Mongoid and Mongodb.
I have Passenger set up on the server for deployment. When I go to
domain.com:3000 the application works. Also when I go to domain.com:28017
it shows that mongodb is working.
In all the examples/tutorials I can find the application is hosted at
localhost:3000 whereas I am trying to deploy to my actual domain.
When I go to domain.com I get the following error message:
Problem:
No sessions configuration provided.
Summary:
Mongoid's configuration requires that you provide details about each
session that can be connected to, and requires in the sessions
config at least 1 default session to exist.
Resolution:
Double check your mongoid.yml to make sure that you have a top-level
sessions key with at least 1 default session configuration for it.
You can regenerate a new mongoid.yml for assistance via `rails g
mongoid:config`.
Example:
development:
sessions:
default:
database: mongoid_dev
hosts:
- localhost:27017
(Mongoid::Errors::NoSessionsConfig)
The issue appears to be my mongoid.yml file which is as follows:
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect
to.
# (required).
database: myapp_development
# Provides the hosts the default session can connect to. Must be an
array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
# safe: false
# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :eventual
# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30
# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false
# Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
sessions:
default:
database: myapp_test
hosts:
- localhost:27017
options:
consistency: :strong
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0
How is this issue usually resolved? Thanks in advance
How to get a Random Non Final variable inside a runnable ? -Android
How to get a Random Non Final variable inside a runnable ? -Android
Can't explain this before showing the code, so :
final int randomcolor = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256),
rnd.nextInt(256));
final Runnable updater = new Runnable() {
@Override
public void run() {
relativeLayout.setBackgroundColor(randomcolor);
handler.postDelayed(this, 25);
}
}
};
Above I have a runnable named Updater... and below I'm starting it up on a
button click..
Button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
handler.postDelayed(updater,2000 );
}
});
(I've cut out most of my code so this may not make sense why I want to do
this. The above will create an infinite loop as the runnable is stuck with
no way out... Just assume that I can get out of it.)
Explaination of the code
ALL this is in Oncreate()... So, on a button click I'm starting up a
Runnable after a delay of two seconds... and then, after every 25
millisecond gap the same runnable is running again and again till the end
of time( Like I said, ignore this last point.)
You will see I'm doing only one thing in the runnable, changing the
background color of the relative layout.
Important, what I want is that after every 25 milliseconds, ie., everytime
the runnable runs, It should change the relative Layout's background color
to something random. It will probably look like a drunkard flashy epilepsy
inducing app... Leave the reason to me (again)
The problem is, the handler can't take a non-final runnable... and a
random variable for every run can't be final and final and non-final don't
work together. (read it again)
So, I need a new Color integer everytime the runnable runs...So that every
time it runs, it changes the background color to something different and
random.
I feel the solution is quite simple, but I can't seem to in it down..
Any ideas people? How I might go about doing this ?
Can't explain this before showing the code, so :
final int randomcolor = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256),
rnd.nextInt(256));
final Runnable updater = new Runnable() {
@Override
public void run() {
relativeLayout.setBackgroundColor(randomcolor);
handler.postDelayed(this, 25);
}
}
};
Above I have a runnable named Updater... and below I'm starting it up on a
button click..
Button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
handler.postDelayed(updater,2000 );
}
});
(I've cut out most of my code so this may not make sense why I want to do
this. The above will create an infinite loop as the runnable is stuck with
no way out... Just assume that I can get out of it.)
Explaination of the code
ALL this is in Oncreate()... So, on a button click I'm starting up a
Runnable after a delay of two seconds... and then, after every 25
millisecond gap the same runnable is running again and again till the end
of time( Like I said, ignore this last point.)
You will see I'm doing only one thing in the runnable, changing the
background color of the relative layout.
Important, what I want is that after every 25 milliseconds, ie., everytime
the runnable runs, It should change the relative Layout's background color
to something random. It will probably look like a drunkard flashy epilepsy
inducing app... Leave the reason to me (again)
The problem is, the handler can't take a non-final runnable... and a
random variable for every run can't be final and final and non-final don't
work together. (read it again)
So, I need a new Color integer everytime the runnable runs...So that every
time it runs, it changes the background color to something different and
random.
I feel the solution is quite simple, but I can't seem to in it down..
Any ideas people? How I might go about doing this ?
"Adding Enable for commenting Adobe Reader" using Acrobat
"Adding Enable for commenting Adobe Reader" using Acrobat
I am using iTextSharp to create on PDF document, later i want to add
"Adding Enable for commenting Adobe Reader" using Acrobat, but i getting
error as "You do not have permission to write to this file".
Here my code used to create PDF file:
using (FileStream FS = new FileStream(dPDFFile_temp, FileMode.Create,
FileAccess.Write, FileShare.None))
{
using (Document Doc = new Document())
{
using (PdfCopy writer = new PdfCopy(Doc, FS))
{
Doc.Open();
for (int i = 1; i <= R.NumberOfPages; i++)
{
writer.AddPage(writer.GetImportedPage(R, i));
}
Doc.Close();
}
}
}
`
I am using iTextSharp to create on PDF document, later i want to add
"Adding Enable for commenting Adobe Reader" using Acrobat, but i getting
error as "You do not have permission to write to this file".
Here my code used to create PDF file:
using (FileStream FS = new FileStream(dPDFFile_temp, FileMode.Create,
FileAccess.Write, FileShare.None))
{
using (Document Doc = new Document())
{
using (PdfCopy writer = new PdfCopy(Doc, FS))
{
Doc.Open();
for (int i = 1; i <= R.NumberOfPages; i++)
{
writer.AddPage(writer.GetImportedPage(R, i));
}
Doc.Close();
}
}
}
`
how to get actual cpu usage of a proces in linux-2.6.18.8
how to get actual cpu usage of a proces in linux-2.6.18.8
In recent linux kernels task structure has sum_exec_runtime field and it
shows almost the actual cpu usage but in old kernels such as 2.6.18.8, it
doesn't exist. In old kernels task structure has utime and stime fields
too, but those fields don't show the actual usage. For example when I run
a process which has spend some cpu and then sleeps 1 in a infinite loop,
those fields change very slowly and they do not show small usages.
In recent linux kernels task structure has sum_exec_runtime field and it
shows almost the actual cpu usage but in old kernels such as 2.6.18.8, it
doesn't exist. In old kernels task structure has utime and stime fields
too, but those fields don't show the actual usage. For example when I run
a process which has spend some cpu and then sleeps 1 in a infinite loop,
those fields change very slowly and they do not show small usages.
C# - Registering dependency dlls necessary for COM Visible Class?
C# - Registering dependency dlls necessary for COM Visible Class?
I have a C# library that was developed in-house to provide an interface to
our legacy software. Over the time requirements grew and now here I am to
add COM visibility to this interface library so that it can be accessed
from something like VBA in the MS Office applications.
Existing Design: Let's call my interface library as Interface.dll. There
are a few dependencies for this Interface.dll. Lets call them as:
MyTypeLib.dll, MyHelper1.dll, MyHelper2.dll and few more helpers.
My approach was:
Develop a new library that has a COM visible class. I did something like:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("A023101A-D9B3-4A24-AAE4-B3CFEDA04BAF")]
public class MyCOMVisibleClass
...
...
and selectively call methods from Interface.dll, making these selected
methods COM visible. Let's say above class produces
MyCOMVisibleClassLib.dll. I used RegAsm.exe to register this library and
to produce MyCOMVisibleClassLib.tlb file.
To test this implementation, I decided to use MS Excel 2010. I opened VBA
editor and added a reference to MyCOMVisibleClassLib.tlb. In the code, I
can now see all the methods in MyCOMVisibleClass so it seems to be working
until.....
I ran this code and got "Run-time Error -2146233088 (80131500). Unable to
find MyTypeLib.dll" I used Assembly Binding Log Viewer to see more details
of this error and found that MS Excel was looking for this (MyTypeLib.dll)
everywhere except where actually this file is. If I copy this file into
Excel installation folder under Program Files, Excel would compain about
next dependency - MyHelper1.dll and so on. After I copied all the dlls to
Excel install folder all was good. But this is not the solution I am
looking for.
Questions:
Is my approach correct to open up few methods to COM?
I think that MyCOMVisibleClassLib.dll is the only one that needs to be
registered. Am I right in thinking so?
How do I make Excel to find all my dependencies (MyTypeLib.dll,
MyHelper1.dll, MyHelper2.dll ) without having to copy them in MS Excel
install folder?
I also think that I am missing something basic that I should have known
before I start this but can't seem to figure it out.
Any help is very much appreciated. Thanks in advance.
I have a C# library that was developed in-house to provide an interface to
our legacy software. Over the time requirements grew and now here I am to
add COM visibility to this interface library so that it can be accessed
from something like VBA in the MS Office applications.
Existing Design: Let's call my interface library as Interface.dll. There
are a few dependencies for this Interface.dll. Lets call them as:
MyTypeLib.dll, MyHelper1.dll, MyHelper2.dll and few more helpers.
My approach was:
Develop a new library that has a COM visible class. I did something like:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("A023101A-D9B3-4A24-AAE4-B3CFEDA04BAF")]
public class MyCOMVisibleClass
...
...
and selectively call methods from Interface.dll, making these selected
methods COM visible. Let's say above class produces
MyCOMVisibleClassLib.dll. I used RegAsm.exe to register this library and
to produce MyCOMVisibleClassLib.tlb file.
To test this implementation, I decided to use MS Excel 2010. I opened VBA
editor and added a reference to MyCOMVisibleClassLib.tlb. In the code, I
can now see all the methods in MyCOMVisibleClass so it seems to be working
until.....
I ran this code and got "Run-time Error -2146233088 (80131500). Unable to
find MyTypeLib.dll" I used Assembly Binding Log Viewer to see more details
of this error and found that MS Excel was looking for this (MyTypeLib.dll)
everywhere except where actually this file is. If I copy this file into
Excel installation folder under Program Files, Excel would compain about
next dependency - MyHelper1.dll and so on. After I copied all the dlls to
Excel install folder all was good. But this is not the solution I am
looking for.
Questions:
Is my approach correct to open up few methods to COM?
I think that MyCOMVisibleClassLib.dll is the only one that needs to be
registered. Am I right in thinking so?
How do I make Excel to find all my dependencies (MyTypeLib.dll,
MyHelper1.dll, MyHelper2.dll ) without having to copy them in MS Excel
install folder?
I also think that I am missing something basic that I should have known
before I start this but can't seem to figure it out.
Any help is very much appreciated. Thanks in advance.
Wednesday, 18 September 2013
GNU debugger; eclipse throws error message
GNU debugger; eclipse throws error message
I spent almost an hour looking for something specific related to gdb
debugger installed inside Cygwin. have seen many people facing the same
problem but not any useful answer to that. I need to use gcc debugger
inside my c/c++ enabled eclipse. every time I'm trying to launch the
debugger I'm getting an error that gdb --version can't be determined. I
went deep through performing some checkups, I get this:
$ gdb --version /usr/bin/gdb.exe: error while loading shared libraries:
cygexpat-1.dll: cannot open shared >object file: No such file or directory
pulling up Cygwin command prompt, I get this as a result:
cygchec gdb cygcheck: track_down: could not find cygexpat-1.dll
I know there has to be a way to make the GNU debugger work in eclipse,
help me out.
I spent almost an hour looking for something specific related to gdb
debugger installed inside Cygwin. have seen many people facing the same
problem but not any useful answer to that. I need to use gcc debugger
inside my c/c++ enabled eclipse. every time I'm trying to launch the
debugger I'm getting an error that gdb --version can't be determined. I
went deep through performing some checkups, I get this:
$ gdb --version /usr/bin/gdb.exe: error while loading shared libraries:
cygexpat-1.dll: cannot open shared >object file: No such file or directory
pulling up Cygwin command prompt, I get this as a result:
cygchec gdb cygcheck: track_down: could not find cygexpat-1.dll
I know there has to be a way to make the GNU debugger work in eclipse,
help me out.
Is there such a jQuery selector that states 'all matched items except $(this)?
Is there such a jQuery selector that states 'all matched items except
$(this)?
here is a line of code that works except that it selects the item that was
clicked on. i want to select all items except what was clicked on.
$('ul.open').removeClass('open').addClass('close').slideUp();
my pseudo code something like this…
$('ul.open:not(' + $(this))).addClass('close').removeClass('open').slideUp();
thanks in advance,
$(this)?
here is a line of code that works except that it selects the item that was
clicked on. i want to select all items except what was clicked on.
$('ul.open').removeClass('open').addClass('close').slideUp();
my pseudo code something like this…
$('ul.open:not(' + $(this))).addClass('close').removeClass('open').slideUp();
thanks in advance,
paintComponent only called sometimes
paintComponent only called sometimes
I am making a program that takes a two dimensional integer array and uses
its data to draw tiles to the screen in the arrangement specified in the
array. Without modifying any of the code, the program will execute fine
about 4 out of 5 times. Other times the custom JPanel will not display
anything. After inserting system.out.print() in various places I have
determined that it is caused by the paintComponent method not being called
when nothing is displayed. Obviously it is called when the tiles are
displayed perfectly. I can't seem to find the source of this
inconsistency. Why would it work the majority of the time and not every
once in a while?
Its called Isopanel because it will eventually display tiles in an
isometric formation. 0s equate to water tiles and 1s equate to sand tiles.
JPanel Class and JFrame class:
public class IsoPanel extends JPanel
{
private ArrayList <BufferedImage> tiles;
private int[][] leveldata =
{
{0,0,0,0,0,0,0,0,0,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,0,0,0,0,0,0,0,0,0}
};
public IsoPanel()
{
tiles = new ArrayList<BufferedImage>();
tiles.add(Frame.loadImage("water.png"));
tiles.add(Frame.loadImage("sand.png"));
}
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
for (int i=0; i<10; i++)
{
for (int j=0; j<10; j++)
{
int x = j * 50;
int y = i * 50;
int tileType = leveldata[i][j];
placeTile(tileType, x, y, g);
}
}
}
public void placeTile (int tile,int x,int y, Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
g2.drawImage(tiles.get(tile), null, x, y);
}
}
public class Frame extends JFrame
{
public Frame()
{
super ("Iso");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width, screenSize.height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
BorderLayout bord = new BorderLayout();
setLayout(bord);
IsoPanel iso = new IsoPanel();
add(iso,BorderLayout.CENTER);
GridLayout grid = new GridLayout(1,1);
iso.setLayout(grid);
iso.setVisible(true);
}
public static BufferedImage loadImage(String filename)
{
{
try
{
return ImageIO.read(new File(System.getProperty( "user.dir"
)+"/src/"+filename));
}
catch(IOException e)
{
}
}
return null;
}
public static void main(String[] args)
{
Frame one = new Frame();
}
}
I am making a program that takes a two dimensional integer array and uses
its data to draw tiles to the screen in the arrangement specified in the
array. Without modifying any of the code, the program will execute fine
about 4 out of 5 times. Other times the custom JPanel will not display
anything. After inserting system.out.print() in various places I have
determined that it is caused by the paintComponent method not being called
when nothing is displayed. Obviously it is called when the tiles are
displayed perfectly. I can't seem to find the source of this
inconsistency. Why would it work the majority of the time and not every
once in a while?
Its called Isopanel because it will eventually display tiles in an
isometric formation. 0s equate to water tiles and 1s equate to sand tiles.
JPanel Class and JFrame class:
public class IsoPanel extends JPanel
{
private ArrayList <BufferedImage> tiles;
private int[][] leveldata =
{
{0,0,0,0,0,0,0,0,0,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,0,0,0,0,0,0,0,0,0}
};
public IsoPanel()
{
tiles = new ArrayList<BufferedImage>();
tiles.add(Frame.loadImage("water.png"));
tiles.add(Frame.loadImage("sand.png"));
}
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
for (int i=0; i<10; i++)
{
for (int j=0; j<10; j++)
{
int x = j * 50;
int y = i * 50;
int tileType = leveldata[i][j];
placeTile(tileType, x, y, g);
}
}
}
public void placeTile (int tile,int x,int y, Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
g2.drawImage(tiles.get(tile), null, x, y);
}
}
public class Frame extends JFrame
{
public Frame()
{
super ("Iso");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width, screenSize.height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
BorderLayout bord = new BorderLayout();
setLayout(bord);
IsoPanel iso = new IsoPanel();
add(iso,BorderLayout.CENTER);
GridLayout grid = new GridLayout(1,1);
iso.setLayout(grid);
iso.setVisible(true);
}
public static BufferedImage loadImage(String filename)
{
{
try
{
return ImageIO.read(new File(System.getProperty( "user.dir"
)+"/src/"+filename));
}
catch(IOException e)
{
}
}
return null;
}
public static void main(String[] args)
{
Frame one = new Frame();
}
}
Text blocks over images
Text blocks over images
I'm using the instafeed library to get instagram images to my website, now
with the instafeed library its really easy to get the caption of the
images.
Now my problem is that i would like to have the caption text on the bottom
of every image.
But since this is dynamically created I cant manipulate the outputted
html, so I wonder if its possible with CSS to put the image text on bottom
of every image.
HTML
<div id="instafeed">
<img
src="http://distilleryimage9.s3.amazonaws.com/3a81fe1e206d11e38bc322000a9d0dcb_7.jpg">
<div class="caption">#windows #shadows #art #bw #abstract #overlap</div>
</div>
CSS
.caption {
background-color:#ccc;
}
img {
width: 33.33%;
float: left;
}
JSFiddle
I'm using the instafeed library to get instagram images to my website, now
with the instafeed library its really easy to get the caption of the
images.
Now my problem is that i would like to have the caption text on the bottom
of every image.
But since this is dynamically created I cant manipulate the outputted
html, so I wonder if its possible with CSS to put the image text on bottom
of every image.
HTML
<div id="instafeed">
<img
src="http://distilleryimage9.s3.amazonaws.com/3a81fe1e206d11e38bc322000a9d0dcb_7.jpg">
<div class="caption">#windows #shadows #art #bw #abstract #overlap</div>
</div>
CSS
.caption {
background-color:#ccc;
}
img {
width: 33.33%;
float: left;
}
JSFiddle
Sublime Text 2 Slowness with Emmet
Sublime Text 2 Slowness with Emmet
I recently installed Emmet on sublime text 2 and since then I have been
noticing a lot of slowness when working with large files.
One file I am working with has 1500 lines and whenever I hit "tab" after
typing an html/tag short cut Sublime Text 2 becomes unresponsive for about
10-15 seconds...
When I work with smaller files, this is not an issue at all. When I
uninstall Emmet/PyV8 performance on the larger files returns to normal.
I have searched here and other forums and haven't found much on subject
but was wondering if there some other plugin/setting I'm missing?
Thanks in advance.
I recently installed Emmet on sublime text 2 and since then I have been
noticing a lot of slowness when working with large files.
One file I am working with has 1500 lines and whenever I hit "tab" after
typing an html/tag short cut Sublime Text 2 becomes unresponsive for about
10-15 seconds...
When I work with smaller files, this is not an issue at all. When I
uninstall Emmet/PyV8 performance on the larger files returns to normal.
I have searched here and other forums and haven't found much on subject
but was wondering if there some other plugin/setting I'm missing?
Thanks in advance.
Retrieve data from form built from multiple dataviews with Wicket
Retrieve data from form built from multiple dataviews with Wicket
I have a form built with a datatable populated from multiple dataviews.
How i can retrieve the data when the user submit the form?
public class MyPanel extends Panel {
public void init() {
final Form<MyBean> myBeanForm = new Form<MyBean>("myBeanForm");
Datatable myBeanDatatable = new Datatable("myBeanDatatable",1 );
myBeanForm .add(myBeanDatatable);
// 1st dataView
MyBeanDataProvider firstProvider = new MyBeanDataProvider();
DataView<MyBean> firstDataView = new
MyBeanDataModel("firstDataView", firstProvider );
myBeanDatatable.add(firstDataView);
// 2st dataView
MyBeanDataProvider secondProvider = new MyBeanDataProvider();
DataView<MyBean> secondDataView = new
MyBeanDataModel("secondDataView", secondProvider);
myBeanDatatable.add(secondDataView);
final Button submitButton= new AjaxButton("submitButton") {
@Override
protected void executeSubmit(AjaxRequestTarget target, Form<?>
form) {
try {
// ?????? At this point i need to retrieve all data and
save it in the DB
} catch (Exception e) {
}
}
};
myBeanForm.add(fromSettingsToConfigurations);
add(myBeanForm);
}
}
Thanks in advance!
I have a form built with a datatable populated from multiple dataviews.
How i can retrieve the data when the user submit the form?
public class MyPanel extends Panel {
public void init() {
final Form<MyBean> myBeanForm = new Form<MyBean>("myBeanForm");
Datatable myBeanDatatable = new Datatable("myBeanDatatable",1 );
myBeanForm .add(myBeanDatatable);
// 1st dataView
MyBeanDataProvider firstProvider = new MyBeanDataProvider();
DataView<MyBean> firstDataView = new
MyBeanDataModel("firstDataView", firstProvider );
myBeanDatatable.add(firstDataView);
// 2st dataView
MyBeanDataProvider secondProvider = new MyBeanDataProvider();
DataView<MyBean> secondDataView = new
MyBeanDataModel("secondDataView", secondProvider);
myBeanDatatable.add(secondDataView);
final Button submitButton= new AjaxButton("submitButton") {
@Override
protected void executeSubmit(AjaxRequestTarget target, Form<?>
form) {
try {
// ?????? At this point i need to retrieve all data and
save it in the DB
} catch (Exception e) {
}
}
};
myBeanForm.add(fromSettingsToConfigurations);
add(myBeanForm);
}
}
Thanks in advance!
Laravel 4 - get raw SQL error message
Laravel 4 - get raw SQL error message
I'm using Laravel 4 with Postgres.
If I run the following statement in PGAdmin
SELEC * FROM tables
I get the following error message
ERROR: syntax error at or near "selec"
LINE 1: selec * from tables
^
********** Error **********
ERROR: syntax error at or near "selec"
SQL state: 42601
Character: 1
Now when I run the following query in Laravel 4
DB::select("SELEC * FROM tables");
I get a whole lot of other extra error messages.
Is it possible to actually get the raw Postgres error message somehow?
I'm using Laravel 4 with Postgres.
If I run the following statement in PGAdmin
SELEC * FROM tables
I get the following error message
ERROR: syntax error at or near "selec"
LINE 1: selec * from tables
^
********** Error **********
ERROR: syntax error at or near "selec"
SQL state: 42601
Character: 1
Now when I run the following query in Laravel 4
DB::select("SELEC * FROM tables");
I get a whole lot of other extra error messages.
Is it possible to actually get the raw Postgres error message somehow?
asp.net:cannot resolve symbol asp net
asp.net:cannot resolve symbol asp net
i have made a simple table (lets call it volunteers), but when i want to
call it in my code behind Visual studio can not recognize it. The error is
cannot resolve symbol.
here isthe code:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="root_VerifyUsers.aspx.cs"
MasterPageFile="~/Root.Master" %>
<asp:Content ID="BodyContent" runat="server"
ContentPlaceHolderID="MainContent">
<p>
<asp:Table runat="server" ID="volunteers"
ForeColor="Green" Width="100%" Height="85%"
BorderColor="Red"></asp:Table>
<asp:TableHeaderCell ID="NationalId"
runat="server">National Id</asp:TableHeaderCell>
<asp:TableHeaderCell ID="Email"
runat="server">Email</asp:TableHeaderCell>
</p>
</asp:Content>
that is behind code:
public partial class RootVerifyUsers : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TableRow tr = new TableRow();
TableCell fname = new TableCell();
TableCell NationalId=new TableCell();
tr.Cells.Add(NationalId);
volunteers.Rows.add(tr);
}
}
i have made a simple table (lets call it volunteers), but when i want to
call it in my code behind Visual studio can not recognize it. The error is
cannot resolve symbol.
here isthe code:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="root_VerifyUsers.aspx.cs"
MasterPageFile="~/Root.Master" %>
<asp:Content ID="BodyContent" runat="server"
ContentPlaceHolderID="MainContent">
<p>
<asp:Table runat="server" ID="volunteers"
ForeColor="Green" Width="100%" Height="85%"
BorderColor="Red"></asp:Table>
<asp:TableHeaderCell ID="NationalId"
runat="server">National Id</asp:TableHeaderCell>
<asp:TableHeaderCell ID="Email"
runat="server">Email</asp:TableHeaderCell>
</p>
</asp:Content>
that is behind code:
public partial class RootVerifyUsers : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TableRow tr = new TableRow();
TableCell fname = new TableCell();
TableCell NationalId=new TableCell();
tr.Cells.Add(NationalId);
volunteers.Rows.add(tr);
}
}
Why PhoneGap always shows default splashscreen image?
Why PhoneGap always shows default splashscreen image?
I'm testing a sample iOS app now, although I set all new launch images in
Xcode (Summary tab of Project Target screen), PhoneGap 3.0 keeps showing
its default splashscreen. Why? even when splashscreen is a plugin and not
included by default in PhoneGap 3.0 now.
iOS document say about launch images but not splashscreen, and it even
strongly recommend us to use a "first screen" similar as launch image, not
something like about screen. Are these same?
I'm testing a sample iOS app now, although I set all new launch images in
Xcode (Summary tab of Project Target screen), PhoneGap 3.0 keeps showing
its default splashscreen. Why? even when splashscreen is a plugin and not
included by default in PhoneGap 3.0 now.
iOS document say about launch images but not splashscreen, and it even
strongly recommend us to use a "first screen" similar as launch image, not
something like about screen. Are these same?
Tuesday, 17 September 2013
How to handle the DBNull with Expression in this case?
How to handle the DBNull with Expression in this case?
I have use the following code snippet to some Comparison
Expression.Constant(DBNull.Value, typeof (Int32));
While execute these lines I got the following Exception
System.ArgumentException occurred
HResult=-2147024809
Message=Argument types do not match
Source=System.Core
StackTrace:
at System.Linq.Expressions.Expression.Constant(Object value, Type type)
InnerException:
I have use the following code snippet to some Comparison
Expression.Constant(DBNull.Value, typeof (Int32));
While execute these lines I got the following Exception
System.ArgumentException occurred
HResult=-2147024809
Message=Argument types do not match
Source=System.Core
StackTrace:
at System.Linq.Expressions.Expression.Constant(Object value, Type type)
InnerException:
Algorithm Efficiency for Nested For/If Loops in R
Algorithm Efficiency for Nested For/If Loops in R
This is my first post on SO, so I apologize if this question has been
asked somewhere else, but I can't seem to figure out how to even phrase my
question so it's difficult to look.
The issue I'm having is that I'm working with a data frame which contains
a variable, which is a factor, called PrimaryType. This variable has like
15 levels and I want to create new binary variables off of this so that I
can perform statistical analyses on the various levels. Here is the code
I'm using:
df <- read.csv('Data/ChiCrime11_13.txt', header=T, sep='\t')
for (i in 1:nrow(df)){
for (crimes in levels(df$PrimaryType)){
if (df$PrimaryType == crimes) {
df[crimes] <- 1
}
else{
df[crimes] <- 0
}
}
}
The problem I'm having is that my data frame is over 900,000 observations
long and so clearly this process is going to take a LOT of time to run
(900,000^15 iterations I believe). This brings me to my question: Is there
a way to make this more efficient?
Any thoughts/advice would be appreciated. Thanks!
This is my first post on SO, so I apologize if this question has been
asked somewhere else, but I can't seem to figure out how to even phrase my
question so it's difficult to look.
The issue I'm having is that I'm working with a data frame which contains
a variable, which is a factor, called PrimaryType. This variable has like
15 levels and I want to create new binary variables off of this so that I
can perform statistical analyses on the various levels. Here is the code
I'm using:
df <- read.csv('Data/ChiCrime11_13.txt', header=T, sep='\t')
for (i in 1:nrow(df)){
for (crimes in levels(df$PrimaryType)){
if (df$PrimaryType == crimes) {
df[crimes] <- 1
}
else{
df[crimes] <- 0
}
}
}
The problem I'm having is that my data frame is over 900,000 observations
long and so clearly this process is going to take a LOT of time to run
(900,000^15 iterations I believe). This brings me to my question: Is there
a way to make this more efficient?
Any thoughts/advice would be appreciated. Thanks!
importing mongodb data across different versions
importing mongodb data across different versions
can I use mongodump to get the data dump from mongo version2.0 and do
mongorestore on mongo version 2.4. OR the best way is to use
mongoimport/mongoexport and use json as the data format?
can I use mongodump to get the data dump from mongo version2.0 and do
mongorestore on mongo version 2.4. OR the best way is to use
mongoimport/mongoexport and use json as the data format?
Add function to html (distanceMatrix service)
Add function to html (distanceMatrix service)
Here I have a probem to write a distance and time beetween two places
based on google map distanceMatrix service
First I write a function calculateDistances(start,stop):
function calculateDistances(start,stop) {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origin: start,
destination: stop,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
after that I call this function to execute with real values start,stop:
//Start function for calculate distance
var start = document.getElementById("from").value;
var stop = place.formatted_address;
contentStr += '<p>'+ calculateDistances(start,stop); + '</p>';
and finaly I try to write a distance and time into HTML so I write:
$(contentStr).dialog({
modal:true
});
But I dont get anything, when I click on link nothing happend... Why?
In console I get this:
Uncaught ReferenceError: callback is not defined 94:145
calculateDistances 94:145
(anonymous function) 94:215
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
Io.c
(anonymous function)
How I can solve this problem?
Here I have a probem to write a distance and time beetween two places
based on google map distanceMatrix service
First I write a function calculateDistances(start,stop):
function calculateDistances(start,stop) {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origin: start,
destination: stop,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
after that I call this function to execute with real values start,stop:
//Start function for calculate distance
var start = document.getElementById("from").value;
var stop = place.formatted_address;
contentStr += '<p>'+ calculateDistances(start,stop); + '</p>';
and finaly I try to write a distance and time into HTML so I write:
$(contentStr).dialog({
modal:true
});
But I dont get anything, when I click on link nothing happend... Why?
In console I get this:
Uncaught ReferenceError: callback is not defined 94:145
calculateDistances 94:145
(anonymous function) 94:215
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
(anonymous function)
Io.c
(anonymous function)
How I can solve this problem?
Open a new window Onclick of image button
Open a new window Onclick of image button
I am using primefaces 3.5, the latest release for our development work!
Inside the i have which is used to open a new window , based on the URL
constructed with the request paramter.Attached the code for reference.
<p:dataTable>
<p:column style="text-align:center;">
<h:commandLink value="" action="#{claimStatusBean.npfInfo.handleNpf }"
target="_blank" >
<h:graphicImage library="images" name="star_small.png"
rendered="#{claimStatus.npfProvider}"/>
</h:commandLink>
</p:column>
<p:dataTable>
But when i click the action is never invoked.
I am using primefaces 3.5, the latest release for our development work!
Inside the i have which is used to open a new window , based on the URL
constructed with the request paramter.Attached the code for reference.
<p:dataTable>
<p:column style="text-align:center;">
<h:commandLink value="" action="#{claimStatusBean.npfInfo.handleNpf }"
target="_blank" >
<h:graphicImage library="images" name="star_small.png"
rendered="#{claimStatus.npfProvider}"/>
</h:commandLink>
</p:column>
<p:dataTable>
But when i click the action is never invoked.
Find ultimate parent of an entity using recursion in c#
Find ultimate parent of an entity using recursion in c#
I have an Entity which in turn refers to same table which is its parent.
Below is the table which describes it more better.
| ID | Source_ID |
+----+----------+
| 1 | null |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 4 |
Now, when I am at ID = 5, I need to fetch its ultimate parent, which is ID
= 1.
I tried writing a function which is as below:
<entity> ultimateparententity;
internal <entity> FetchParentComponentRecursive(<entity> entity)
{
if (component.ParentEntity!= null)
{
FetchParentComponentRecursive(entity.ParentEntity);
}
else
{
ultimateparententity = component;
return component;
}
return component;
}
I am using variable declared at class level to return the ultimate parent
which is not totally right. Any directions will be helpful.
I have an Entity which in turn refers to same table which is its parent.
Below is the table which describes it more better.
| ID | Source_ID |
+----+----------+
| 1 | null |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 4 |
Now, when I am at ID = 5, I need to fetch its ultimate parent, which is ID
= 1.
I tried writing a function which is as below:
<entity> ultimateparententity;
internal <entity> FetchParentComponentRecursive(<entity> entity)
{
if (component.ParentEntity!= null)
{
FetchParentComponentRecursive(entity.ParentEntity);
}
else
{
ultimateparententity = component;
return component;
}
return component;
}
I am using variable declared at class level to return the ultimate parent
which is not totally right. Any directions will be helpful.
Sunday, 15 September 2013
Pass Element Id from file to another filer Revit Api c#
Pass Element Id from file to another filer Revit Api c#
I'm trying to make copy from family file contain Extrusion (the Element i
want to select ) and make copy of it in another file "I mean there is two
opened files where i select the element from the family file and paste it
in another project file ". So the Question: how to transfer the Element Id
and location data from file to file in c#?
i tried to load the family in the project i work on but nothing appears .
So any Guidlines how to do that?
Thanks In Advance
I'm trying to make copy from family file contain Extrusion (the Element i
want to select ) and make copy of it in another file "I mean there is two
opened files where i select the element from the family file and paste it
in another project file ". So the Question: how to transfer the Element Id
and location data from file to file in c#?
i tried to load the family in the project i work on but nothing appears .
So any Guidlines how to do that?
Thanks In Advance
Creating A Counter In C# As A Repeatable Tool
Creating A Counter In C# As A Repeatable Tool
I have a very basic program that's essentially a few counters with buttons
to increase/decrease the count that is pictured below.
The problem is I had to create each of the items somewhat independently so
for every button there's a function rather than just 1 function for - and
1 for +.
Is there anyway to essentially save the entire counter so that the label
and buttons automatically go together and I don't have to recode the same
thing multiple times?
I have a very basic program that's essentially a few counters with buttons
to increase/decrease the count that is pictured below.
The problem is I had to create each of the items somewhat independently so
for every button there's a function rather than just 1 function for - and
1 for +.
Is there anyway to essentially save the entire counter so that the label
and buttons automatically go together and I don't have to recode the same
thing multiple times?
NoClassDefFoundError: com/google/api/client/util/Lists when setting up oauth2 on app engine
NoClassDefFoundError: com/google/api/client/util/Lists when setting up
oauth2 on app engine
We're using the following libraries:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<version>v2-rev114-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev98-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev50-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.13.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.17.0-rc</version>
</dependency>
However, we're getting the following error:
java.lang.NoClassDefFoundError: com/google/api/client/util/Lists
at
com.google.api.client.auth.oauth2.Credential$Builder.<init>(Credential.java:625)
at
com.google.api.client.googleapis.auth.oauth2.GoogleCredential$Builder.<init>(GoogleCredential.java:356)
at
com.google.api.client.googleapis.auth.oauth2.GoogleCredential.<init>(GoogleCredential.java:193)
at com.xyz.getStoredCredentials(GoogleUserCredentialManager.java:155)
So which library are we missing here?
oauth2 on app engine
We're using the following libraries:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<version>v2-rev114-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev98-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev50-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.13.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.17.0-rc</version>
</dependency>
However, we're getting the following error:
java.lang.NoClassDefFoundError: com/google/api/client/util/Lists
at
com.google.api.client.auth.oauth2.Credential$Builder.<init>(Credential.java:625)
at
com.google.api.client.googleapis.auth.oauth2.GoogleCredential$Builder.<init>(GoogleCredential.java:356)
at
com.google.api.client.googleapis.auth.oauth2.GoogleCredential.<init>(GoogleCredential.java:193)
at com.xyz.getStoredCredentials(GoogleUserCredentialManager.java:155)
So which library are we missing here?
Three buttons(span's), jQuery IF clicked, addClass - removeClass
Three buttons(span's), jQuery IF clicked, addClass - removeClass
I have three buttons (spans) that looks like this:
<span id="size_default"><?php echo JText::_('VIDEO_DEFAULT');?></span>
<span id="size_450"><?php echo JText::_('VIDEO_450');?></span>
<span id="size_600"><?php echo JText::_('VIDEO_600');?></span>
These are supposed to work like buttons, and they work now, but not
correctly, what I need is, when for example "size_600" is cliked, 2
actions must occur ->
<span id="size_600">
must get a "active" class + remove the "active" class on other 2 spans if
they were clicked before AND then add a class to OTHER div and remove
other classes that are related to the other 2 spans...
The description I made may look confusing, but here is the jQuery code I
wrote, this should be more clear:
$('size_default').addEvent('click',function(){
$('size_default').addClass('active');
$('youtube-player').addClass('h_355');
$('size_450').removeClass('active');
$('size_600').removeClass('active');
$('youtube-player').removeClass('h_450');
$('youtube-player').removeClass('h_600');
});
$('size_450').addEvent('click',function(){
$('size_450').addClass('active');
$('youtube-player').addClass('h_450');
$('size_355').removeClass('active');
$('size_600').removeClass('active');
$('youtube-player').removeClass('h_355');
$('youtube-player').removeClass('h_600');
});
$('size_600').addEvent('click',function(){
$('size_600').addClass('active');
$('youtube-player').addClass('h_600');
$('size_355').removeClass('active');
$('size_450').removeClass('active');
$('youtube-player').removeClass('h_355');
$('youtube-player').removeClass('h_450');
});
Currently it "does" it's work when you click ONE time for each 3
spans(buttons), but after that only the first block of jQuery code works
(size_default)...
Can somebody give me a hand on this please.. I'm not to good in jQuery...
Thank you
I have three buttons (spans) that looks like this:
<span id="size_default"><?php echo JText::_('VIDEO_DEFAULT');?></span>
<span id="size_450"><?php echo JText::_('VIDEO_450');?></span>
<span id="size_600"><?php echo JText::_('VIDEO_600');?></span>
These are supposed to work like buttons, and they work now, but not
correctly, what I need is, when for example "size_600" is cliked, 2
actions must occur ->
<span id="size_600">
must get a "active" class + remove the "active" class on other 2 spans if
they were clicked before AND then add a class to OTHER div and remove
other classes that are related to the other 2 spans...
The description I made may look confusing, but here is the jQuery code I
wrote, this should be more clear:
$('size_default').addEvent('click',function(){
$('size_default').addClass('active');
$('youtube-player').addClass('h_355');
$('size_450').removeClass('active');
$('size_600').removeClass('active');
$('youtube-player').removeClass('h_450');
$('youtube-player').removeClass('h_600');
});
$('size_450').addEvent('click',function(){
$('size_450').addClass('active');
$('youtube-player').addClass('h_450');
$('size_355').removeClass('active');
$('size_600').removeClass('active');
$('youtube-player').removeClass('h_355');
$('youtube-player').removeClass('h_600');
});
$('size_600').addEvent('click',function(){
$('size_600').addClass('active');
$('youtube-player').addClass('h_600');
$('size_355').removeClass('active');
$('size_450').removeClass('active');
$('youtube-player').removeClass('h_355');
$('youtube-player').removeClass('h_450');
});
Currently it "does" it's work when you click ONE time for each 3
spans(buttons), but after that only the first block of jQuery code works
(size_default)...
Can somebody give me a hand on this please.. I'm not to good in jQuery...
Thank you
how can i delete "(",")"?
how can i delete "(",")"?
how can i delete "("?
is it correct ? :
import re, sys
my_source = {}
list_of_words = {}
text_we_need = {}
dict_of_words = {}
max_characters = 0
with open("my_source2.txt") as f:
my_source = f.read()
p = re.compile(r'<a(.*?)</a>')
my_source = p.sub('<a></a>', my_source, re.DOTALL)
my_source = re.sub('<a>','',my_source)
my_source = re.sub('(','',my_source)
my_source = re.sub(')','',my_source)
why this code,doesn't work for '(' ??
how can i delete "("?
is it correct ? :
import re, sys
my_source = {}
list_of_words = {}
text_we_need = {}
dict_of_words = {}
max_characters = 0
with open("my_source2.txt") as f:
my_source = f.read()
p = re.compile(r'<a(.*?)</a>')
my_source = p.sub('<a></a>', my_source, re.DOTALL)
my_source = re.sub('<a>','',my_source)
my_source = re.sub('(','',my_source)
my_source = re.sub(')','',my_source)
why this code,doesn't work for '(' ??
WCF: How to return a datacontract object with a specific value
WCF: How to return a datacontract object with a specific value
[ServiceContract]
public interface Imyjob
{
[OperationContract]
Job GetJobInfo(String fn, String ln);
}
[DataContract]
public class Job
{
[DataMember]
public String companyName { get; set; }
[DataMember]
public int positionNumber { get; set; }
[DataMember]
public String positionTitle { get; set; }
[DataMember]
public String positionDescription { get; set; }
}
I'm learning C# WCF service, I define a DataContract and those details all
saved in a txt file, for example, currently i get 1 as
positionNumber(under datacontract class Job). How can i return Job only
contain "1" positinNumber?
public class myjob : Imyjob
{
public Job GetJobInfo(String fn, String ln)
{
Job jobresult = new Job();
return ???;
}
}
[ServiceContract]
public interface Imyjob
{
[OperationContract]
Job GetJobInfo(String fn, String ln);
}
[DataContract]
public class Job
{
[DataMember]
public String companyName { get; set; }
[DataMember]
public int positionNumber { get; set; }
[DataMember]
public String positionTitle { get; set; }
[DataMember]
public String positionDescription { get; set; }
}
I'm learning C# WCF service, I define a DataContract and those details all
saved in a txt file, for example, currently i get 1 as
positionNumber(under datacontract class Job). How can i return Job only
contain "1" positinNumber?
public class myjob : Imyjob
{
public Job GetJobInfo(String fn, String ln)
{
Job jobresult = new Job();
return ???;
}
}
Please explain the following C++ class definition
Please explain the following C++ class definition
class A {
public:
A (int n = 0) : m_n(n) {}
A (const A& a) : m_n(a.m_n) {}
private:
int m_n;
}
or:
namespace std {
template <class T1, class T2>
struct pair {
//type names for the values
typedef T1 first_type;
typedef T2 second_type;
//member
T1 first;
T2 second;
/* default constructor - T1 () and T2 () force initialization for
built-in types */
pair() : first(T1()), second(T2()) {}
//constructor for two values
pair(const T1& a, const T2& b) : first(a), second(b) {}
//copy constructor with implicit conversions
template<class U, class V>
pair(const pair<U,V>& p) : first(p.first), second(p.second) {}
};
....
}
I don't understand the constructors, copy constructor of these two
classes. Please explain for me what does the part ": m_n(n)" do?
class A {
public:
A (int n = 0) : m_n(n) {}
A (const A& a) : m_n(a.m_n) {}
private:
int m_n;
}
or:
namespace std {
template <class T1, class T2>
struct pair {
//type names for the values
typedef T1 first_type;
typedef T2 second_type;
//member
T1 first;
T2 second;
/* default constructor - T1 () and T2 () force initialization for
built-in types */
pair() : first(T1()), second(T2()) {}
//constructor for two values
pair(const T1& a, const T2& b) : first(a), second(b) {}
//copy constructor with implicit conversions
template<class U, class V>
pair(const pair<U,V>& p) : first(p.first), second(p.second) {}
};
....
}
I don't understand the constructors, copy constructor of these two
classes. Please explain for me what does the part ": m_n(n)" do?
Saturday, 14 September 2013
Is it counted as rank for GA when we put tracking code in our websites?
Is it counted as rank for GA when we put tracking code in our websites?
When we use Google Analytics and put the tracking code in our websites
source code, each hit our website gets, the GA code is loaded 1 time. So I
want to know if these hits are counted for GA as a hit, too? Like does it
affect their alexa rank or google rank?
Thanks
When we use Google Analytics and put the tracking code in our websites
source code, each hit our website gets, the GA code is loaded 1 time. So I
want to know if these hits are counted for GA as a hit, too? Like does it
affect their alexa rank or google rank?
Thanks
php session not working correctly
php session not working correctly
I have a small messaging system in which I am having a problem with
sessions. The problem is that: I have inbox.php and view_inbox.php in
which all the messages will be listed on inbox.php and when the user click
on one of the messages it will show the message body on the second page.
Also I have a reply button on view_inbox.php to reply to the sender. if
user1 sends message to user2 it works fine even with replying each other
however when user3 sends a message and I try to reply to user3, it sends
to user2 instead of user3.
As you can see below, I am using session to identify to which user to
reply to and the problem is that it is inserting the old session(if I had
replied to user2 and again try to reply to user3 it doesn;t work).
I can use $_GET variable to avoid this issue but I did not want to show
the sender's name in the url. any ideas?
inbox.php
$stmt = $mydb->prepare("SELECT * FROM messages where to_user = ? and
deleted = '' order by id desc");
$stmt->bind_param('s', $username->username);
$stmt->execute();
<?php
while ($row = $max->fetch_assoc()) {
$_SESSION['sender'] = $row['from_user'];
echo $row['from_user'];
?>
view_inbox.php this is just the reply part which is causing the prob.
$to_user = $_SESSION['sender'];
if (isset($_POST['replyto']))
$reply = $_POST['reply']; {
if(!empty($reply)){
$date = date('m-d-Y h:i:s');
$insert = $mydb->prepare("insert into `messages`(`to_user`, `from_user`,
`message`, `date`) values(?,?,?,?)");
echo $mydb->error;
$insert->bind_param('ssss', $to_user, $username->username, $reply, $date);
$insert->execute();
}
I have a small messaging system in which I am having a problem with
sessions. The problem is that: I have inbox.php and view_inbox.php in
which all the messages will be listed on inbox.php and when the user click
on one of the messages it will show the message body on the second page.
Also I have a reply button on view_inbox.php to reply to the sender. if
user1 sends message to user2 it works fine even with replying each other
however when user3 sends a message and I try to reply to user3, it sends
to user2 instead of user3.
As you can see below, I am using session to identify to which user to
reply to and the problem is that it is inserting the old session(if I had
replied to user2 and again try to reply to user3 it doesn;t work).
I can use $_GET variable to avoid this issue but I did not want to show
the sender's name in the url. any ideas?
inbox.php
$stmt = $mydb->prepare("SELECT * FROM messages where to_user = ? and
deleted = '' order by id desc");
$stmt->bind_param('s', $username->username);
$stmt->execute();
<?php
while ($row = $max->fetch_assoc()) {
$_SESSION['sender'] = $row['from_user'];
echo $row['from_user'];
?>
view_inbox.php this is just the reply part which is causing the prob.
$to_user = $_SESSION['sender'];
if (isset($_POST['replyto']))
$reply = $_POST['reply']; {
if(!empty($reply)){
$date = date('m-d-Y h:i:s');
$insert = $mydb->prepare("insert into `messages`(`to_user`, `from_user`,
`message`, `date`) values(?,?,?,?)");
echo $mydb->error;
$insert->bind_param('ssss', $to_user, $username->username, $reply, $date);
$insert->execute();
}
Development and production configurations for mailers
Development and production configurations for mailers
For deliverability reasons, I installed SPF records and other types of
authentication to make sure production emails aren't flagged as spam. The
side-effect is that when I run tests from my localhost they don't work. Is
there a "Rails Way" to have development vs. production credentials for a
mailer? It seems like I could build my own logic based on the Rails.env
variable, but I don't want to reinvent the wheel if there is already
support for this.
For deliverability reasons, I installed SPF records and other types of
authentication to make sure production emails aren't flagged as spam. The
side-effect is that when I run tests from my localhost they don't work. Is
there a "Rails Way" to have development vs. production credentials for a
mailer? It seems like I could build my own logic based on the Rails.env
variable, but I don't want to reinvent the wheel if there is already
support for this.
Strings in C++: Problems with good() and get()
Strings in C++: Problems with good() and get()
I am trying to read from a file. The code I used is
ifstream is;char c;
is.open("text.txt");
while(is.good() && !isdigit(is.peek()))
{ is.get(c)
word+=c;
}
The problem is that the last character is read twice (why?) For e.g. if
the word in the file is pink the value of word becomes pinkk after the
loop Please suggest a solution
I am trying to read from a file. The code I used is
ifstream is;char c;
is.open("text.txt");
while(is.good() && !isdigit(is.peek()))
{ is.get(c)
word+=c;
}
The problem is that the last character is read twice (why?) For e.g. if
the word in the file is pink the value of word becomes pinkk after the
loop Please suggest a solution
jquery autocomplete: call another webmethod in select
jquery autocomplete: call another webmethod in select
in my app i am using jQuery autocomplate to fill a textbox and a hidden
field with the id. it is working fine. Now i want to pull some more data
based on the id selected. I am new to jquery and could not find any other
threads based on this. Here is the code i use for select an item from the
list
select: function (event, ui)
{
this.value = ui.item.value;
$("#" + name).val(ui.item.label);
$("#" + idfld).val(ui.item.value);
return false;
}
inside this function i want to call another webmethod which will return
data curresponding to the id. i want to fill other textboxes based on this
data. Please help any suggestions
in my app i am using jQuery autocomplate to fill a textbox and a hidden
field with the id. it is working fine. Now i want to pull some more data
based on the id selected. I am new to jquery and could not find any other
threads based on this. Here is the code i use for select an item from the
list
select: function (event, ui)
{
this.value = ui.item.value;
$("#" + name).val(ui.item.label);
$("#" + idfld).val(ui.item.value);
return false;
}
inside this function i want to call another webmethod which will return
data curresponding to the id. i want to fill other textboxes based on this
data. Please help any suggestions
Learning file system
Learning file system
What is the best way to learn about any filesystem internals? I am a
beginner and interested to learn about xfs and btrfs. I have capability to
use them but learning them through source code and understanding there
design, capabilities and use cases is difficult to understand.
Hence would like to know pointers in these areas.
What is the best way to learn about any filesystem internals? I am a
beginner and interested to learn about xfs and btrfs. I have capability to
use them but learning them through source code and understanding there
design, capabilities and use cases is difficult to understand.
Hence would like to know pointers in these areas.
Remote POST request with jQuery and Ajax
Remote POST request with jQuery and Ajax
I need to do a POST request to a remote domain trhough Ajax, I know there
is the restriction of the Same-Origin Policy but I've read that could be
possible make a bridge in PHP on my server to forward the request.
The fact is that I've not idea of how to write this bridge and I can't
find info on Google.
Can someone explain me how to write one?
I need to do a POST request to a remote domain trhough Ajax, I know there
is the restriction of the Same-Origin Policy but I've read that could be
possible make a bridge in PHP on my server to forward the request.
The fact is that I've not idea of how to write this bridge and I can't
find info on Google.
Can someone explain me how to write one?
Friday, 13 September 2013
how to start week from sunday instead of current date
how to start week from sunday instead of current date
below is my code which show current week next week and previous week
problem is when current wek is 37 when click on nextweek is first show 36
then show 37 and then week 38 39 40 same as for last week if current week
s 37 when click on next week button is first show 38 then 37 36... also my
calendar start week form current date i want to show from sunday what do i
do?
Button last_week;
Button next_week;
static Button e00;
static Button e01;
static Button e02;
static Button e03;
static Button e04;
static Button e05;
static Button e06;
int next = 1;
int currentweekno;
static TextView txt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e00 = (Button) findViewById(R.id.e00);
e01 = (Button) findViewById(R.id.e01);
e02 = (Button) findViewById(R.id.e02);
e03 = (Button) findViewById(R.id.e03);
e04 = (Button) findViewById(R.id.e04);
e05 = (Button) findViewById(R.id.e05);
e06 = (Button) findViewById(R.id.e06);
// e00 = Sun;
// e01 = Mon;
// e02 = Tues;
// e03 = Wed;
// e04 = thur;
// e05 = Fri;
// e06 = Sat;
last_week = (Button) findViewById(R.id.last_week);
next_week = (Button) findViewById(R.id.next_week);
Calendar mCalendar = Calendar.getInstance();
currentweekno = mCalendar.get(Calendar.WEEK_OF_YEAR);
Log.d("Current Week:", "" + mCalendar.get(Calendar.WEEK_OF_YEAR));
last_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
weekOfGivenMonth(currentweekno--);
}
});
next_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
weekOfGivenMonth(currentweekno++);
}
});
weekOfGivenMonth(currentweekno++);
}
private static void weekOfGivenMonth(int weekNext) {
String val;
val=String.valueOf(weekNext);
Calendar c = Calendar.getInstance();
c.set(Calendar.WEEK_OF_YEAR, weekNext);
String[] days = new String[7];
DateFormat df = new SimpleDateFormat("EEE dd/MM/yyyy");
for (int i = 0; i < 7; i++) {
Log.d("DATEA TAG",df.format(c.getTime()));
c.add(Calendar.DATE, 1);
}
}
below is my code which show current week next week and previous week
problem is when current wek is 37 when click on nextweek is first show 36
then show 37 and then week 38 39 40 same as for last week if current week
s 37 when click on next week button is first show 38 then 37 36... also my
calendar start week form current date i want to show from sunday what do i
do?
Button last_week;
Button next_week;
static Button e00;
static Button e01;
static Button e02;
static Button e03;
static Button e04;
static Button e05;
static Button e06;
int next = 1;
int currentweekno;
static TextView txt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e00 = (Button) findViewById(R.id.e00);
e01 = (Button) findViewById(R.id.e01);
e02 = (Button) findViewById(R.id.e02);
e03 = (Button) findViewById(R.id.e03);
e04 = (Button) findViewById(R.id.e04);
e05 = (Button) findViewById(R.id.e05);
e06 = (Button) findViewById(R.id.e06);
// e00 = Sun;
// e01 = Mon;
// e02 = Tues;
// e03 = Wed;
// e04 = thur;
// e05 = Fri;
// e06 = Sat;
last_week = (Button) findViewById(R.id.last_week);
next_week = (Button) findViewById(R.id.next_week);
Calendar mCalendar = Calendar.getInstance();
currentweekno = mCalendar.get(Calendar.WEEK_OF_YEAR);
Log.d("Current Week:", "" + mCalendar.get(Calendar.WEEK_OF_YEAR));
last_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
weekOfGivenMonth(currentweekno--);
}
});
next_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
weekOfGivenMonth(currentweekno++);
}
});
weekOfGivenMonth(currentweekno++);
}
private static void weekOfGivenMonth(int weekNext) {
String val;
val=String.valueOf(weekNext);
Calendar c = Calendar.getInstance();
c.set(Calendar.WEEK_OF_YEAR, weekNext);
String[] days = new String[7];
DateFormat df = new SimpleDateFormat("EEE dd/MM/yyyy");
for (int i = 0; i < 7; i++) {
Log.d("DATEA TAG",df.format(c.getTime()));
c.add(Calendar.DATE, 1);
}
}
How to format to a string to a fixed length which stores in a variable?
How to format to a string to a fixed length which stores in a variable?
I have a number and I want to format to a string with zero padding and a
specific length . Suppose if the fixed length is 22 , I know I can do in
this way
format(variable,"%022d")
but does there exist any way can do by this
length = 22
format(variable,"%0lengthd")
It means I need to use variable in % variable d expression
thanks
I have a number and I want to format to a string with zero padding and a
specific length . Suppose if the fixed length is 22 , I know I can do in
this way
format(variable,"%022d")
but does there exist any way can do by this
length = 22
format(variable,"%0lengthd")
It means I need to use variable in % variable d expression
thanks
Variable Interpolation in Vimscript catch clause
Variable Interpolation in Vimscript catch clause
I'm working on a small testing framework for vim plugins and am trying to
implement a function that calls a user-specified function and checks if
the function calls exceptions when needed. The problem I'm having is that
I can't get the vim catch clause to accept a string passed in to the
testing function.
Here's a simplified version of what I'd like.
function! TestException(fx, arguments, exception)
let Fx = function(a:fx)
try
call call(Fx, a:arguments)
catch a:exception " Here's the problem line
return 1
endtry
return 0
endfunction
This function works fine if I hard code the exception into the catch clause
catch /E740/or whatever, but it doesn't interpolate the passed in
variable. I've tried executing the whole block in an 'execute' string, but
that doesn't seem to work either.
So far I've tabled this issue and just allowed it to catch any exception
and trust the caller to understand the limitation of that kind of general
test.
So, does anybody know how to fix this, or, does anybody know of a way to
figure out which exception was thrown after it's caught so I can compare
that to the argument after the fact?
I'm working on a small testing framework for vim plugins and am trying to
implement a function that calls a user-specified function and checks if
the function calls exceptions when needed. The problem I'm having is that
I can't get the vim catch clause to accept a string passed in to the
testing function.
Here's a simplified version of what I'd like.
function! TestException(fx, arguments, exception)
let Fx = function(a:fx)
try
call call(Fx, a:arguments)
catch a:exception " Here's the problem line
return 1
endtry
return 0
endfunction
This function works fine if I hard code the exception into the catch clause
catch /E740/or whatever, but it doesn't interpolate the passed in
variable. I've tried executing the whole block in an 'execute' string, but
that doesn't seem to work either.
So far I've tabled this issue and just allowed it to catch any exception
and trust the caller to understand the limitation of that kind of general
test.
So, does anybody know how to fix this, or, does anybody know of a way to
figure out which exception was thrown after it's caught so I can compare
that to the argument after the fact?
uWSGI, Django, VirtualEnv, Ubuntu: Unable to locate all python/django modules
uWSGI, Django, VirtualEnv, Ubuntu: Unable to locate all python/django modules
I'm trying to setup uWSGI to serve my django app but I'm having issues
with the path, or at least I think it's a path issue. The symptom is that
when I make a curl request to the application, I get tracebacks indicating
that basic python/django modules can't be found. ex:
File
"/opt/example/venvs/example/lib/python2.7/site-packages/django/test/_doctest.py",
line 104, in <module> import unittest, difflib, pdb, tempfile
File "/usr/lib/python2.7/pdb.py", line 59, in <module>
class Pdb(bdb.Bdb, cmd.Cmd): AttributeError: 'module' object has no
attribute 'Cmd'
I've looked at the other SO related questions but none appear to be my issue.
Here's my setup:
django==1.5.1
uwsgi==1.9.15 (installed from pip)
python is 2.7
Ubuntu 12.04 LTS
nginx = 0.8.54 ( but I don't believe this is relevant as I haven't
connected uwsgi up to nginx yet )
I'm running in a vagrant created virtualbox, with chef and fab doing all
the typical provisioning.
Here's the path of the VM once I've ssh'd into the machine:
PATH="/opt/example/venvs/example/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin"
Here's the .wsgi file ( fairly standard except for the print path that I
added for debug ):
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
import sys
print sys.path
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Here's the uwsgi ini file ( notice all the various pythonpaths that I had
to add ):
[uwsgi]
#socket=/tmp/hs.com.sock
virtualenv=/opt/example/venv
chdir=/opt/example/apps/example/src
module=example.wsgi:application
master=true
workers=8
pidfile=/opt/example/apps/example/src/example/uwsgi-master.pid
max-requests=5000
#plugins=python
enable-threads=true
processes=2
no-site=true
http=:8003
#env=DJANGO_SETTINGS_MODULE=example.settings
pythonpath=..
pythonpath=/vagrant/src
pythonpath=/opt/example/apps/example/src/example
pythonpath=/opt/example/venvs/example/lib/python2.7
pythonpath=/opt/example/venvs/example/lib/python2.7/plat-linux2
pythonpath=/opt/example/venvs/example/lib/python2.7/lib-tk
pythonpath=/opt/example/venvs/example/lib/python2.7/lib-old
pythonpath=/opt/example/venvs/example/lib/python2.7/lib-dynload
pythonpath=/opt/example/venvs/example/lib/python2.7/distutils
#pythonpath=/opt/example/venvs/example/lib/python2.7/encodings
#pythonpath=/opt/example/venvs/example/lib/python2.7/config
pythonpath=/usr/lib/python2.7/
pythonpath=/usr/lib/python2.7/lib-dynload/
pythonpath=/usr/lib/python2.7/distutils/
pythonpath=/usr/lib/python2.7/plat-linux2/
pythonpath=/usr/lib/python2.7/lib-tk/
#pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/
#pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/core/
pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management
#pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management/commands
pythonpath=/opt/example/venvs/example/local/lib/python2.7/site-packages
pythonpath=/opt/example/venvs/example/lib/python2.7
pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages
pythonpath=/vagrant/src/example
The reason there are so many pythonpaths in there is because the app was
failing to find very basic modules, and so I kept adding paths to make it
resolve. This worked for several errors, but 1) I can't find the proper
path for the Cmd attributerror above and 2) adding each of these
individual paths just doesn't FEEL right.
the uwsgi output to 'uwsgi --ini inifile'
[uWSGI] getting INI configuration from xxx
*** Starting uWSGI 1.9.15 (32bit) on [Fri Sep 13 18:12:44 2013] ***
compiled with version: 4.6.3 on 13 September 2013 06:46:44
os: Linux-3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012
nodename: xxx
machine: i686
clock source: unix
detected number of CPU cores: 1
current working directory: /vagrant/src
writing pidfile to /opt/example/apps/example/src/example/uwsgi-master.pid
detected binary path: /opt/example/venvs/example/bin/uwsgi
your processes number limit is 1824
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uWSGI http bound on localhost:8003 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:34622 (port auto-assigned) fd 3
Python version: 2.7.3 (default, Apr 10 2013, 06:03:17) [GCC 4.6.3]
Set PythonHome to /opt/example/venv
Python main interpreter initialized at 0xa044e58
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 192012 bytes (187 KB) for 2 cores
*** Operational MODE: preforking ***
added ../ to pythonpath.
added /vagrant/src/ to pythonpath.
added /opt/example/apps/example/src/example/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/plat-linux2 to pythonpath.
added /opt/example/venvs/example/lib/python2.7/lib-tk to pythonpath.
added /opt/example/venvs/example/lib/python2.7/lib-old to pythonpath.
added /opt/example/venvs/example/lib/python2.7/lib-dynload/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/distutils/ to pythonpath.
added /usr/lib/python2.7/ to pythonpath.
added /usr/lib/python2.7/lib-dynload/ to pythonpath.
added /usr/lib/python2.7/distutils/ to pythonpath.
added /usr/lib/python2.7/plat-linux2/ to pythonpath.
added /usr/lib/python2.7/lib-tk/ to pythonpath.
added
/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management/
to pythonpath.
added /opt/example/venvs/example/local/lib/python2.7/site-packages/ to
pythonpath.
added /opt/example/venvs/example/lib/python2.7/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/site-packages/ to pythonpath.
added /vagrant/src/example/ to pythonpath.
['/vagrant/src/example/',
'/opt/example/venvs/example/lib/python2.7/site-packages/',
'/opt/example/venvs/example/lib/python2.7/',
'/opt/example/venvs/example/local/lib/python2.7/site-packages/',
'/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management/',
'/usr/lib/python2.7/lib-tk/', '/usr/lib/python2.7/plat-linux2/',
'/usr/lib/python2.7/distutils/', '/usr/lib/python2.7/lib-dynload/',
'/usr/lib/python2.7/',
'/opt/example/venvs/example/lib/python2.7/distutils/',
'/opt/example/venvs/example/lib/python2.7/lib-dynload/',
'/opt/example/venvs/example/lib/python2.7/lib-old',
'/opt/example/venvs/example/lib/python2.7/lib-tk',
'/opt/example/venvs/example/lib/python2.7/plat-linux2',
'/opt/example/venvs/example/lib/python2.7/',
'/opt/example/apps/example/src/example/', '/vagrant/src/', '../', '.', '',
'/opt/example/venv/lib/python2.7/',
'/opt/example/venv/lib/python2.7/plat-linux2',
'/opt/example/venv/lib/python2.7/lib-tk',
'/opt/example/venv/lib/python2.7/lib-old',
'/opt/example/venv/lib/python2.7/lib-dynload', '/vagrant/src/example']
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xa044e58
pid: 2911 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2911)
spawned uWSGI worker 1 (pid: 2912, cores: 1)
spawned uWSGI worker 2 (pid: 2913, cores: 1)
spawned uWSGI http 1 (pid: 2914)
From another terminal I run curl -v localhost:8003 and I get the
'AttributeErrror...' i posted above. The curl output is:
curl: (52) Empty reply from server
* Closing connection #0
Here's what I've tried:
using the latest uWSGI version 1.9.15 and the LTS version 1.4.x
installing uWSGI inside the virtualenv and outside of it
django's runserver serves my app just fine, and I can see the path that's
printed out because of the debug print sys.path statement in the wsgi file
and it's simply a subset of the paths that I have in my wsgi.ini file
also printed out environment variables in both runserver and uwsgi
environments from the wsgi.py file and I don't see anything of importance
that are different
uwsgi is able to serve a basic test.py application file without issue, so
I believe that eliminates any installation/setup issues
tried running uwsgi with sudo
I also tried it with a basic django app ( created directly from
startproject ), and this ALSO FAILS with the same attributeerror, and
requires the same list of pythonpaths.
I must be missing some simple setup or configuration... ? Let me know if
more information is required.
I'm trying to setup uWSGI to serve my django app but I'm having issues
with the path, or at least I think it's a path issue. The symptom is that
when I make a curl request to the application, I get tracebacks indicating
that basic python/django modules can't be found. ex:
File
"/opt/example/venvs/example/lib/python2.7/site-packages/django/test/_doctest.py",
line 104, in <module> import unittest, difflib, pdb, tempfile
File "/usr/lib/python2.7/pdb.py", line 59, in <module>
class Pdb(bdb.Bdb, cmd.Cmd): AttributeError: 'module' object has no
attribute 'Cmd'
I've looked at the other SO related questions but none appear to be my issue.
Here's my setup:
django==1.5.1
uwsgi==1.9.15 (installed from pip)
python is 2.7
Ubuntu 12.04 LTS
nginx = 0.8.54 ( but I don't believe this is relevant as I haven't
connected uwsgi up to nginx yet )
I'm running in a vagrant created virtualbox, with chef and fab doing all
the typical provisioning.
Here's the path of the VM once I've ssh'd into the machine:
PATH="/opt/example/venvs/example/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin"
Here's the .wsgi file ( fairly standard except for the print path that I
added for debug ):
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
import sys
print sys.path
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Here's the uwsgi ini file ( notice all the various pythonpaths that I had
to add ):
[uwsgi]
#socket=/tmp/hs.com.sock
virtualenv=/opt/example/venv
chdir=/opt/example/apps/example/src
module=example.wsgi:application
master=true
workers=8
pidfile=/opt/example/apps/example/src/example/uwsgi-master.pid
max-requests=5000
#plugins=python
enable-threads=true
processes=2
no-site=true
http=:8003
#env=DJANGO_SETTINGS_MODULE=example.settings
pythonpath=..
pythonpath=/vagrant/src
pythonpath=/opt/example/apps/example/src/example
pythonpath=/opt/example/venvs/example/lib/python2.7
pythonpath=/opt/example/venvs/example/lib/python2.7/plat-linux2
pythonpath=/opt/example/venvs/example/lib/python2.7/lib-tk
pythonpath=/opt/example/venvs/example/lib/python2.7/lib-old
pythonpath=/opt/example/venvs/example/lib/python2.7/lib-dynload
pythonpath=/opt/example/venvs/example/lib/python2.7/distutils
#pythonpath=/opt/example/venvs/example/lib/python2.7/encodings
#pythonpath=/opt/example/venvs/example/lib/python2.7/config
pythonpath=/usr/lib/python2.7/
pythonpath=/usr/lib/python2.7/lib-dynload/
pythonpath=/usr/lib/python2.7/distutils/
pythonpath=/usr/lib/python2.7/plat-linux2/
pythonpath=/usr/lib/python2.7/lib-tk/
#pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/
#pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/core/
pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management
#pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management/commands
pythonpath=/opt/example/venvs/example/local/lib/python2.7/site-packages
pythonpath=/opt/example/venvs/example/lib/python2.7
pythonpath=/opt/example/venvs/example/lib/python2.7/site-packages
pythonpath=/vagrant/src/example
The reason there are so many pythonpaths in there is because the app was
failing to find very basic modules, and so I kept adding paths to make it
resolve. This worked for several errors, but 1) I can't find the proper
path for the Cmd attributerror above and 2) adding each of these
individual paths just doesn't FEEL right.
the uwsgi output to 'uwsgi --ini inifile'
[uWSGI] getting INI configuration from xxx
*** Starting uWSGI 1.9.15 (32bit) on [Fri Sep 13 18:12:44 2013] ***
compiled with version: 4.6.3 on 13 September 2013 06:46:44
os: Linux-3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012
nodename: xxx
machine: i686
clock source: unix
detected number of CPU cores: 1
current working directory: /vagrant/src
writing pidfile to /opt/example/apps/example/src/example/uwsgi-master.pid
detected binary path: /opt/example/venvs/example/bin/uwsgi
your processes number limit is 1824
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uWSGI http bound on localhost:8003 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:34622 (port auto-assigned) fd 3
Python version: 2.7.3 (default, Apr 10 2013, 06:03:17) [GCC 4.6.3]
Set PythonHome to /opt/example/venv
Python main interpreter initialized at 0xa044e58
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 192012 bytes (187 KB) for 2 cores
*** Operational MODE: preforking ***
added ../ to pythonpath.
added /vagrant/src/ to pythonpath.
added /opt/example/apps/example/src/example/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/plat-linux2 to pythonpath.
added /opt/example/venvs/example/lib/python2.7/lib-tk to pythonpath.
added /opt/example/venvs/example/lib/python2.7/lib-old to pythonpath.
added /opt/example/venvs/example/lib/python2.7/lib-dynload/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/distutils/ to pythonpath.
added /usr/lib/python2.7/ to pythonpath.
added /usr/lib/python2.7/lib-dynload/ to pythonpath.
added /usr/lib/python2.7/distutils/ to pythonpath.
added /usr/lib/python2.7/plat-linux2/ to pythonpath.
added /usr/lib/python2.7/lib-tk/ to pythonpath.
added
/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management/
to pythonpath.
added /opt/example/venvs/example/local/lib/python2.7/site-packages/ to
pythonpath.
added /opt/example/venvs/example/lib/python2.7/ to pythonpath.
added /opt/example/venvs/example/lib/python2.7/site-packages/ to pythonpath.
added /vagrant/src/example/ to pythonpath.
['/vagrant/src/example/',
'/opt/example/venvs/example/lib/python2.7/site-packages/',
'/opt/example/venvs/example/lib/python2.7/',
'/opt/example/venvs/example/local/lib/python2.7/site-packages/',
'/opt/example/venvs/example/lib/python2.7/site-packages/django/core/management/',
'/usr/lib/python2.7/lib-tk/', '/usr/lib/python2.7/plat-linux2/',
'/usr/lib/python2.7/distutils/', '/usr/lib/python2.7/lib-dynload/',
'/usr/lib/python2.7/',
'/opt/example/venvs/example/lib/python2.7/distutils/',
'/opt/example/venvs/example/lib/python2.7/lib-dynload/',
'/opt/example/venvs/example/lib/python2.7/lib-old',
'/opt/example/venvs/example/lib/python2.7/lib-tk',
'/opt/example/venvs/example/lib/python2.7/plat-linux2',
'/opt/example/venvs/example/lib/python2.7/',
'/opt/example/apps/example/src/example/', '/vagrant/src/', '../', '.', '',
'/opt/example/venv/lib/python2.7/',
'/opt/example/venv/lib/python2.7/plat-linux2',
'/opt/example/venv/lib/python2.7/lib-tk',
'/opt/example/venv/lib/python2.7/lib-old',
'/opt/example/venv/lib/python2.7/lib-dynload', '/vagrant/src/example']
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xa044e58
pid: 2911 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2911)
spawned uWSGI worker 1 (pid: 2912, cores: 1)
spawned uWSGI worker 2 (pid: 2913, cores: 1)
spawned uWSGI http 1 (pid: 2914)
From another terminal I run curl -v localhost:8003 and I get the
'AttributeErrror...' i posted above. The curl output is:
curl: (52) Empty reply from server
* Closing connection #0
Here's what I've tried:
using the latest uWSGI version 1.9.15 and the LTS version 1.4.x
installing uWSGI inside the virtualenv and outside of it
django's runserver serves my app just fine, and I can see the path that's
printed out because of the debug print sys.path statement in the wsgi file
and it's simply a subset of the paths that I have in my wsgi.ini file
also printed out environment variables in both runserver and uwsgi
environments from the wsgi.py file and I don't see anything of importance
that are different
uwsgi is able to serve a basic test.py application file without issue, so
I believe that eliminates any installation/setup issues
tried running uwsgi with sudo
I also tried it with a basic django app ( created directly from
startproject ), and this ALSO FAILS with the same attributeerror, and
requires the same list of pythonpaths.
I must be missing some simple setup or configuration... ? Let me know if
more information is required.
How do I get the date diff based on a different column in R
How do I get the date diff based on a different column in R
I have a data fame with data like the following:
ID Date Value ----- --------- --------- 001 2012-01-15 8.6 003 2000-05-03
10.1 001 2005-03-30 7.3 1002 2013-07-05 1.4
I am trying to get the initial date per ID and then get the number of
months of each subsequent value for that ID. I can get the min date for
each ID simply enough using aggregate but I am stumped on how to do the
rest.
Any thoughts on how to accomplish this? I am brand new to R so any
pointers would be most appreciated.
TIA!
I have a data fame with data like the following:
ID Date Value ----- --------- --------- 001 2012-01-15 8.6 003 2000-05-03
10.1 001 2005-03-30 7.3 1002 2013-07-05 1.4
I am trying to get the initial date per ID and then get the number of
months of each subsequent value for that ID. I can get the min date for
each ID simply enough using aggregate but I am stumped on how to do the
rest.
Any thoughts on how to accomplish this? I am brand new to R so any
pointers would be most appreciated.
TIA!
Icons not being deleted using 'objFSO.DeleteFile()'
Icons not being deleted using 'objFSO.DeleteFile()'
I have a VBScript that should delete all users desktop icons and replace
them with a clean version, but for some reason it is not deleting.
If I manually delete, the icons are copied. However if I comment out the
copy line, and then run the script, they are not deleted. No error occurs.
Can somebody please suggest what the problem might be? Thanks.
'****************************************************
'* Logon Script File For Users in the DD Domain *
'* Purpose: Ensure required icons are on desktop *
'****************************************************
Option Explicit
Dim objFSO ' A File System object (for checking
files/folders exist, copying, and deleting)
Dim objShell ' A shell object (for accessing special folders)
Dim user_name ' The user name of the currently logged in user
Dim i ' Dummy for looping
'****************************************************
'* Create the required desktop icons *
'****************************************************
' Set the desktop folder location
Set objShell = WScript.CreateObject("WScript.Shell")
desktop_location = objShell.SpecialFolders.Item("Desktop")
' Set the location where the files to copy can be found
desktop_icon_store = "\\videss\Shortcuts\Desktop\"
'Check that the users desktop location exists
If (objFSO.FolderExists(desktop_location)) Then
' Delete all files in the desktop folder
objFSO.DeleteFile(desktop_location & "*.*")
' Copy all files to the desktop folder
objFSO.CopyFile desktop_icon_store & "*.*", desktop_location, True
End IF
'****************************************************
'* Reset the objects and exit *
'****************************************************
Set objFSO = Nothing
Set objShell = Nothing
WScript.Quit
I have a VBScript that should delete all users desktop icons and replace
them with a clean version, but for some reason it is not deleting.
If I manually delete, the icons are copied. However if I comment out the
copy line, and then run the script, they are not deleted. No error occurs.
Can somebody please suggest what the problem might be? Thanks.
'****************************************************
'* Logon Script File For Users in the DD Domain *
'* Purpose: Ensure required icons are on desktop *
'****************************************************
Option Explicit
Dim objFSO ' A File System object (for checking
files/folders exist, copying, and deleting)
Dim objShell ' A shell object (for accessing special folders)
Dim user_name ' The user name of the currently logged in user
Dim i ' Dummy for looping
'****************************************************
'* Create the required desktop icons *
'****************************************************
' Set the desktop folder location
Set objShell = WScript.CreateObject("WScript.Shell")
desktop_location = objShell.SpecialFolders.Item("Desktop")
' Set the location where the files to copy can be found
desktop_icon_store = "\\videss\Shortcuts\Desktop\"
'Check that the users desktop location exists
If (objFSO.FolderExists(desktop_location)) Then
' Delete all files in the desktop folder
objFSO.DeleteFile(desktop_location & "*.*")
' Copy all files to the desktop folder
objFSO.CopyFile desktop_icon_store & "*.*", desktop_location, True
End IF
'****************************************************
'* Reset the objects and exit *
'****************************************************
Set objFSO = Nothing
Set objShell = Nothing
WScript.Quit
scrolltop with animate not working
scrolltop with animate not working
I'm trying to animate while scrolling but no luck with my code...
I have this jquery
$(window).scrollTop(200);
Now wanted to give animation effect
So tried these but not working:
1. $(window).animate({scrollTop:200},1000);
2. $('body').animate({scrollTop: 200}, 1000);
I have applied this in a click function like this:
$('.goto').click(function(){
$(window).scrollTop(485); // its working
});
And now I want to give effect of animate but not working...
I'm trying to animate while scrolling but no luck with my code...
I have this jquery
$(window).scrollTop(200);
Now wanted to give animation effect
So tried these but not working:
1. $(window).animate({scrollTop:200},1000);
2. $('body').animate({scrollTop: 200}, 1000);
I have applied this in a click function like this:
$('.goto').click(function(){
$(window).scrollTop(485); // its working
});
And now I want to give effect of animate but not working...
Thursday, 12 September 2013
Bash. Inserting blank line between strings that starts with different number
Bash. Inserting blank line between strings that starts with different number
Please help me with that. I Want to transform the file
1.0 0.1 0.02
1.0 0.2 0.04
1.1 -0.2 0.1
1.1 -0.1 0.1
1.2 1.0 0.2
into
1.0 0.1 0.02
1.0 0.2 0.04
1.1 -0.2 0.1
1.1 -0.1 0.1
1.2 1.0 0.2
Please help me with that. I Want to transform the file
1.0 0.1 0.02
1.0 0.2 0.04
1.1 -0.2 0.1
1.1 -0.1 0.1
1.2 1.0 0.2
into
1.0 0.1 0.02
1.0 0.2 0.04
1.1 -0.2 0.1
1.1 -0.1 0.1
1.2 1.0 0.2
C++: Getters and Setters?
C++: Getters and Setters?
I am attempting to write some code to create getters and setters for the
ID number, first name, last name, midterm score, and final score of the
following data, which is in a text file, in a class i'm writing...
10601 ANDRES HYUN 88 91 94 94 89 84 94 84 89 87 89 91
10611 THU ZECHER 83 79 89 87 88 88 86 81 84 80 89 81
10622 BEVERLEE WAMPOLE 95 92 91 96 99 97 99 89 94 96 90 97
10630 TRUMAN SOVIE 68 73 77 76 72 71 72 77 67 68 72 75
The ID is the first number, first and last name are self explanatory, the
midterm score is the second to last number, and the last number is the
final score. This is my first time using getters and setters and so far I
have...
int getID()const{return ID;}
void setID(int i) {ID=i}
string getFname()const{return Fname;}
void setFname(string f) {Fname = f}
string getLname()const{return Lname;}
void setLname(string l) {Lname = l}
int getMidterm()const{return Midterm;}
void setMidterm(int m) {Midterm=m}
int getFinal()const{return Final;}
void setFinal(int fl) {Final=fl}
Am I on the right track at all? Also, how do I specify that the first
number in the data set is the ID, the first string is the first name,
second string second name, second to last number is Midterm, and last
number is final score?
I am attempting to write some code to create getters and setters for the
ID number, first name, last name, midterm score, and final score of the
following data, which is in a text file, in a class i'm writing...
10601 ANDRES HYUN 88 91 94 94 89 84 94 84 89 87 89 91
10611 THU ZECHER 83 79 89 87 88 88 86 81 84 80 89 81
10622 BEVERLEE WAMPOLE 95 92 91 96 99 97 99 89 94 96 90 97
10630 TRUMAN SOVIE 68 73 77 76 72 71 72 77 67 68 72 75
The ID is the first number, first and last name are self explanatory, the
midterm score is the second to last number, and the last number is the
final score. This is my first time using getters and setters and so far I
have...
int getID()const{return ID;}
void setID(int i) {ID=i}
string getFname()const{return Fname;}
void setFname(string f) {Fname = f}
string getLname()const{return Lname;}
void setLname(string l) {Lname = l}
int getMidterm()const{return Midterm;}
void setMidterm(int m) {Midterm=m}
int getFinal()const{return Final;}
void setFinal(int fl) {Final=fl}
Am I on the right track at all? Also, how do I specify that the first
number in the data set is the ID, the first string is the first name,
second string second name, second to last number is Midterm, and last
number is final score?
Writing with C++ functions
Writing with C++ functions
I am trying to write code using multiple functions that simply gets
average days employees missed for a company i tried to use global
identifiers here is my code
#include<iostream>
using namespace std;
int days;
int numberemployees;
int main()
{
int days;
int numberemployees;
double average;
cout<<"How many employees do you have";
cin>>numberemployees;
daysmissed;
averagedays;
return 0;
}
int daysmissed(int)
{
int days;
cout<<"How many total days where missed by employees this year";
cin>>days;
return days;
}
double averagedays(double)
{
double average;
average=days/numberemployees;
return average;
}
I am trying to write code using multiple functions that simply gets
average days employees missed for a company i tried to use global
identifiers here is my code
#include<iostream>
using namespace std;
int days;
int numberemployees;
int main()
{
int days;
int numberemployees;
double average;
cout<<"How many employees do you have";
cin>>numberemployees;
daysmissed;
averagedays;
return 0;
}
int daysmissed(int)
{
int days;
cout<<"How many total days where missed by employees this year";
cin>>days;
return days;
}
double averagedays(double)
{
double average;
average=days/numberemployees;
return average;
}
Three.js - ColladaLoader - Animated model (DAE) - Black texture
Three.js - ColladaLoader - Animated model (DAE) - Black texture
I loaded a DAE file based on the ColladaLoader example. I exported from
Maya 2012, including a skin. I already had to fix 1 thing by adding the
tag in the .dae file otherwise I'd get the error Couldn't find skin. Then
I thought if thats a problem perhaps I need to change the localized url of
the skin material to just name.jpg because they are in the same folder.
But that didn't work.
So my question is: Am I doing something wrong? Or missing something?
Already tried of few techniques of editing the material afterwards, they
did work but then the model stopped animating.
You can see it live here: www.mariusposthumus.nl/webgl
I loaded a DAE file based on the ColladaLoader example. I exported from
Maya 2012, including a skin. I already had to fix 1 thing by adding the
tag in the .dae file otherwise I'd get the error Couldn't find skin. Then
I thought if thats a problem perhaps I need to change the localized url of
the skin material to just name.jpg because they are in the same folder.
But that didn't work.
So my question is: Am I doing something wrong? Or missing something?
Already tried of few techniques of editing the material afterwards, they
did work but then the model stopped animating.
You can see it live here: www.mariusposthumus.nl/webgl
Show/Hide with Multiple Raio Buttons
Show/Hide with Multiple Raio Buttons
I am very new to building forms with js. I copied and applied a bit of
code to get fields to pop up depending on the Radion button I select. This
works great for two radio buttons... my issues is I wan to include several
5+ and would like to reset the fields with every change.
I was thinking I can input additional code to reset all fields "onchange"
but I can't get this piece of code to work... here is what I copied and
modified for my use:
works great with 2 buttons as designed:
{
toggleSelectionFields: function() {
var isLaptop = ca_fdIsSelectRadio('showhide','group','short');
if (isLaptop) {
ca_fdHideField('showhide','longfields');
ca_fdShowField('showhide','shortfields');
} else {
ca_fdHideField('showhide','shortfields');
ca_fdShowField('showhide','longfields');
}
}
}
Here is what I tried to do:
{
toggleSelectionFields: function() {
Var discovery =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','discovery');
Var headset =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','headset');
Var fac =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','feature');
Var calls =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','calls');
if (discovery)
{ca_fdShowField('phone','deskphone4610','selectproblem','discovermode')}
if (headset)
{ca_fdShowField('phone','deskphone4610','selectproblem','headset')}
if (fac)
{ca_fdShowField('phone','deskphone4610','selectproblem','feature')}
if (calls)
{ca_fdShowField('phone','deskphone4610','selectproblem','calls')}
}
}
}
I am very new to building forms with js. I copied and applied a bit of
code to get fields to pop up depending on the Radion button I select. This
works great for two radio buttons... my issues is I wan to include several
5+ and would like to reset the fields with every change.
I was thinking I can input additional code to reset all fields "onchange"
but I can't get this piece of code to work... here is what I copied and
modified for my use:
works great with 2 buttons as designed:
{
toggleSelectionFields: function() {
var isLaptop = ca_fdIsSelectRadio('showhide','group','short');
if (isLaptop) {
ca_fdHideField('showhide','longfields');
ca_fdShowField('showhide','shortfields');
} else {
ca_fdHideField('showhide','shortfields');
ca_fdShowField('showhide','longfields');
}
}
}
Here is what I tried to do:
{
toggleSelectionFields: function() {
Var discovery =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','discovery');
Var headset =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','headset');
Var fac =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','feature');
Var calls =
ca_fdIsSelectRadio('phone','deskphone4610','selectproblem','SelectIssue','calls');
if (discovery)
{ca_fdShowField('phone','deskphone4610','selectproblem','discovermode')}
if (headset)
{ca_fdShowField('phone','deskphone4610','selectproblem','headset')}
if (fac)
{ca_fdShowField('phone','deskphone4610','selectproblem','feature')}
if (calls)
{ca_fdShowField('phone','deskphone4610','selectproblem','calls')}
}
}
}
Notepad++ deleting duplicate lines
Notepad++ deleting duplicate lines
I have a txt document which contains of one word followed up with a date
in one line, and so on in each line. How can notepad++ recognize same
words in different lines and delete duplicate lines ?
I have a txt document which contains of one word followed up with a date
in one line, and so on in each line. How can notepad++ recognize same
words in different lines and delete duplicate lines ?
Magento stopped generating sitemap suddenly
Magento stopped generating sitemap suddenly
Sitemap stopped generating suddenly.
Started displaying 'Unable to create XML sitemap.'
Please help
Sitemap stopped generating suddenly.
Started displaying 'Unable to create XML sitemap.'
Please help
Wednesday, 11 September 2013
Can somebody help me?
Can somebody help me?
A method called printIndented() that takes a String, an integer and a
boolean. The integer represents the size of an indentation from the left
margin in spaces, so the method should first p rint that many spaces. Then
the string should be printed. Then, if the boolean is true, a newline
should be printed. So for example, printIndented(3, "Hello", false) would
print: ˽˽˽ Hello ...with no newline at the end.
I'm stuck with this. my version is incomplete:
int printIndented(int size, String word, boolean n) {
String spaces = ("");
print(spaces);
print(word);
if(n == true) println("");
else
if(n == false) print("");
return(size);
A method called printIndented() that takes a String, an integer and a
boolean. The integer represents the size of an indentation from the left
margin in spaces, so the method should first p rint that many spaces. Then
the string should be printed. Then, if the boolean is true, a newline
should be printed. So for example, printIndented(3, "Hello", false) would
print: ˽˽˽ Hello ...with no newline at the end.
I'm stuck with this. my version is incomplete:
int printIndented(int size, String word, boolean n) {
String spaces = ("");
print(spaces);
print(word);
if(n == true) println("");
else
if(n == false) print("");
return(size);
How to build a wordpress theme
How to build a wordpress theme
It's great when we search on google search unwittingly download website
for ebooks with very friendly interface http://www.downloadebookz.com ,
we'd love to have the look of this site. Please help us, thank you very
much
It's great when we search on google search unwittingly download website
for ebooks with very friendly interface http://www.downloadebookz.com ,
we'd love to have the look of this site. Please help us, thank you very
much
I need a textbox value in form 1 to be inserted into form2 as a string in the html level in asp
I need a textbox value in form 1 to be inserted into form2 as a string in
the html level in asp
I would like to 'transfer' a textbox value into a html code. E.g the
textbox value is a website like http://www.google.com in form1.aspx. and i
would like the value to be put into the html code in form2.aspx . Might i
ask how i should be going around on this?
<span class="logoposition">
<a href="http://www.google.com"><img src="Logo.jpg" height= "120";
width="280"; /></a>
</span>
Like i would like the textbox1 value to replace the current www.google.com
the html level in asp
I would like to 'transfer' a textbox value into a html code. E.g the
textbox value is a website like http://www.google.com in form1.aspx. and i
would like the value to be put into the html code in form2.aspx . Might i
ask how i should be going around on this?
<span class="logoposition">
<a href="http://www.google.com"><img src="Logo.jpg" height= "120";
width="280"; /></a>
</span>
Like i would like the textbox1 value to replace the current www.google.com
processing a variable size map in pig
processing a variable size map in pig
I have a data set that is incoming as
(str,[[40,74],[50,75],[60,73],[70,43]])
and I need to be able to get this in the output variable using pig:
str, 40, 74
str , 50, 75
str, 60, 73
str, 70, 43
and this could be variable set of elements.
Tried with tokenizing and then flatten, but that doesn't help as it
creates token using comma. and end up being this way..
str , {([[40), (74]), ... }
Would any one suggestions on if I could use built in functions or write a
UDF for this.
many thanks, Ana
I have a data set that is incoming as
(str,[[40,74],[50,75],[60,73],[70,43]])
and I need to be able to get this in the output variable using pig:
str, 40, 74
str , 50, 75
str, 60, 73
str, 70, 43
and this could be variable set of elements.
Tried with tokenizing and then flatten, but that doesn't help as it
creates token using comma. and end up being this way..
str , {([[40), (74]), ... }
Would any one suggestions on if I could use built in functions or write a
UDF for this.
many thanks, Ana
Cannot start Jenkins on port 80 on debian 7
Cannot start Jenkins on port 80 on debian 7
I have installed Jenkins on debian 7. Now I would like to run it on port
80 so I can simply type http://jenkins on my local LAN instead of
http://jenkins:8080 (which currently works). I have modified the file
/etc/default/jenkins to:
# port for HTTP connector (default 8080; disable with -1)
#HTTP_PORT=8080
HTTP_PORT=80
But when I restart the jenkins service: sudo service jenkins restart and
try to access http://jenkins:80 I just get a blank/error page. The log
says (/var/log/jenkins/jenkins.log ):
java.io.IOException: Failed to start a listener: winstone.HttpListener
at winstone.Launcher.spawnListener(Launcher.java:229)
at winstone.Launcher.<init>(Launcher.java:181)
at winstone.Launcher.main(Launcher.java:384)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at Main._main(Main.java:288)
at Main.main(Main.java:98)
Caused by: java.io.IOException: Failed to listen on port 80
at winstone.HttpListener.getServerSocket(HttpListener.java:122)
at winstone.HttpListener.start(HttpListener.java:75)
at winstone.Launcher.spawnListener(Launcher.java:220)
... 8 more
Caused by: java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353)
at java.net.ServerSocket.bind(ServerSocket.java:336)
at java.net.ServerSocket.<init>(ServerSocket.java:202)
at java.net.ServerSocket.<init>(ServerSocket.java:158)
at winstone.HttpListener.getServerSocket(HttpListener.java:117)
... 10 more
Sep 11, 2013 9:09:30 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Sep 11, 2013 9:09:30 PM hudson.WebAppMain$3 run
SEVERE: Failed to initialize Jenkins
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:244)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:43)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:906)
at jenkins.model.Jenkins.<init>(Jenkins.java:806)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.model.Hudson.<init>(Hudson.java:77)
at hudson.WebAppMain$3.run(WebAppMain.java:221)
Exception in thread "pool-2-thread-1" java.lang.NullPointerException
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:191)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
I have tried to run sudo netstat -lp but don't see any port info (does not
look like any application is runnning on port 80).
Any suggestions?
I have installed Jenkins on debian 7. Now I would like to run it on port
80 so I can simply type http://jenkins on my local LAN instead of
http://jenkins:8080 (which currently works). I have modified the file
/etc/default/jenkins to:
# port for HTTP connector (default 8080; disable with -1)
#HTTP_PORT=8080
HTTP_PORT=80
But when I restart the jenkins service: sudo service jenkins restart and
try to access http://jenkins:80 I just get a blank/error page. The log
says (/var/log/jenkins/jenkins.log ):
java.io.IOException: Failed to start a listener: winstone.HttpListener
at winstone.Launcher.spawnListener(Launcher.java:229)
at winstone.Launcher.<init>(Launcher.java:181)
at winstone.Launcher.main(Launcher.java:384)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at Main._main(Main.java:288)
at Main.main(Main.java:98)
Caused by: java.io.IOException: Failed to listen on port 80
at winstone.HttpListener.getServerSocket(HttpListener.java:122)
at winstone.HttpListener.start(HttpListener.java:75)
at winstone.Launcher.spawnListener(Launcher.java:220)
... 8 more
Caused by: java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353)
at java.net.ServerSocket.bind(ServerSocket.java:336)
at java.net.ServerSocket.<init>(ServerSocket.java:202)
at java.net.ServerSocket.<init>(ServerSocket.java:158)
at winstone.HttpListener.getServerSocket(HttpListener.java:117)
... 10 more
Sep 11, 2013 9:09:30 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Sep 11, 2013 9:09:30 PM hudson.WebAppMain$3 run
SEVERE: Failed to initialize Jenkins
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:244)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:43)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:906)
at jenkins.model.Jenkins.<init>(Jenkins.java:806)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.model.Hudson.<init>(Hudson.java:77)
at hudson.WebAppMain$3.run(WebAppMain.java:221)
Exception in thread "pool-2-thread-1" java.lang.NullPointerException
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:191)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
I have tried to run sudo netstat -lp but don't see any port info (does not
look like any application is runnning on port 80).
Any suggestions?
How to add an hour to a timespan. C#
How to add an hour to a timespan. C#
I have my timespan for a specific reason so it HAS to be in that format.
Im trying to add an hour on to the current time. Here is what I got which
does not work :/
TimeSpan time1= TimeSpan.FromHours(1); // my attempt to add 2 hours
TimeSpan ts = DateTime.Now.TimeOfDay;
ts.Add(time1);
MessageBox.Show(ts.ToString()); // for showing me what its
resulting..
Can you please advise?
I have my timespan for a specific reason so it HAS to be in that format.
Im trying to add an hour on to the current time. Here is what I got which
does not work :/
TimeSpan time1= TimeSpan.FromHours(1); // my attempt to add 2 hours
TimeSpan ts = DateTime.Now.TimeOfDay;
ts.Add(time1);
MessageBox.Show(ts.ToString()); // for showing me what its
resulting..
Can you please advise?
what is the use of calling jsp init method?
what is the use of calling jsp init method?
After converting JSP into servlet it has to call init method but why it is
calling jspinit method?
After converting JSP into servlet it has to call init method but why it is
calling jspinit method?
System subheadings in Android app
System subheadings in Android app
Like here.
Like those blue phone, email , adress. I've been googling for a while,
havn't found any built-in way to add them :(. Is there any? (Supporting
2.3, preferably)
Like here.
Like those blue phone, email , adress. I've been googling for a while,
havn't found any built-in way to add them :(. Is there any? (Supporting
2.3, preferably)
Tuesday, 10 September 2013
Rails 3.2.8 Application.js and Application.css are not working as expcted
Rails 3.2.8 Application.js and Application.css are not working as expcted
When i try to include
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
The content of the files of the application.css is:
/*
* This is a manifest file that'll be compiled into application.css, which
will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets,
vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here
using a relative path.
*
* You're free to add application-wide styles to this file and they'll
appear at the top of the
* compiled file, but it's generally better to create a new file per style
scope.
*
*= require_self
*= require social_stream
*= require_tree .
*/
And the content of application.js file is
// This is a manifest file that'll be compiled into application.js, which
will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory,
lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here
using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll
appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED,
ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require social_stream-base
//= require social_stream-documents
//= require social_stream-events
//= require social_stream-linkser
//= require social_stream-presence
//= require social_stream-oauth2_server
//= require_tree .
my rails app is not including the css and js files those are required in
the above snippet. but when i update the include tags to the specific file
those are included fine. i.e.
<%= stylesheet_link_tag "socail_stream" %>
<%= javascript_include_tag "jquery" %>
What i think there is issue of sprockets its not working as expected
please advice.
I will be really thankful to you.
When i try to include
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
The content of the files of the application.css is:
/*
* This is a manifest file that'll be compiled into application.css, which
will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets,
vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here
using a relative path.
*
* You're free to add application-wide styles to this file and they'll
appear at the top of the
* compiled file, but it's generally better to create a new file per style
scope.
*
*= require_self
*= require social_stream
*= require_tree .
*/
And the content of application.js file is
// This is a manifest file that'll be compiled into application.js, which
will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory,
lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here
using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll
appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED,
ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require social_stream-base
//= require social_stream-documents
//= require social_stream-events
//= require social_stream-linkser
//= require social_stream-presence
//= require social_stream-oauth2_server
//= require_tree .
my rails app is not including the css and js files those are required in
the above snippet. but when i update the include tags to the specific file
those are included fine. i.e.
<%= stylesheet_link_tag "socail_stream" %>
<%= javascript_include_tag "jquery" %>
What i think there is issue of sprockets its not working as expected
please advice.
I will be really thankful to you.
let annotations fit my MKMapView?
let annotations fit my MKMapView?
First, thank you, and next, it's my problem, the core code:
for(int idx = 0; idx < route0.polyLine.count; idx++)
{
CLLocationCoordinate2D coordinate = [[route0.polyLine
objectAtIndex:idx] coordinate];
minLat = MIN(minLat, coordinate.latitude);
minLon = MIN(minLon, coordinate.longitude);
maxLat = MAX(maxLat, coordinate.latitude);
maxLon = MAX(maxLon, coordinate.longitude);
}
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 1.06f*(maxLat - minLat);
span.longitudeDelta = 1.06f*(maxLon - minLon);
CLLocationCoordinate2D location;
location.latitude = (minLat + maxLat)/2;
location.longitude = (minLon + maxLon)/2;
region.span=span;
region.center=location;
[_mapView regionThatFits:region];
[_mapView setRegion:region animated:false];
My attentio is let the annotations on the mapview just fit screen, but if
the annotations is too close, will appear:
First, thank you, and next, it's my problem, the core code:
for(int idx = 0; idx < route0.polyLine.count; idx++)
{
CLLocationCoordinate2D coordinate = [[route0.polyLine
objectAtIndex:idx] coordinate];
minLat = MIN(minLat, coordinate.latitude);
minLon = MIN(minLon, coordinate.longitude);
maxLat = MAX(maxLat, coordinate.latitude);
maxLon = MAX(maxLon, coordinate.longitude);
}
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 1.06f*(maxLat - minLat);
span.longitudeDelta = 1.06f*(maxLon - minLon);
CLLocationCoordinate2D location;
location.latitude = (minLat + maxLat)/2;
location.longitude = (minLon + maxLon)/2;
region.span=span;
region.center=location;
[_mapView regionThatFits:region];
[_mapView setRegion:region animated:false];
My attentio is let the annotations on the mapview just fit screen, but if
the annotations is too close, will appear:
access loop.index when within another loop in twig
access loop.index when within another loop in twig
How can i access the loop's index when i'm in a second loop? like this:
{% for i in range(0, 3) %}
{% for j in range(0, 9) %}
{{ loop1.index + loop2.index }} // ?
{% endfor %}
{% endfor %}
How can i access the loop's index when i'm in a second loop? like this:
{% for i in range(0, 3) %}
{% for j in range(0, 9) %}
{{ loop1.index + loop2.index }} // ?
{% endfor %}
{% endfor %}
urgent problems with div background loadedd in dynamic way
urgent problems with div background loadedd in dynamic way
I have a problem, I use html2canvas but a div use background-image to load
a background, but in the exported image, this parts shows a black hole
instead the loaded pictures. the picture is loaded directly from the
website address
http://ricitosdeoro.zirculomarketing.com/club-ricitos-juegos-soy-un-osito.php
check this please
I have a problem, I use html2canvas but a div use background-image to load
a background, but in the exported image, this parts shows a black hole
instead the loaded pictures. the picture is loaded directly from the
website address
http://ricitosdeoro.zirculomarketing.com/club-ricitos-juegos-soy-un-osito.php
check this please
Hide div with match ID and Class Using jquery
Hide div with match ID and Class Using jquery
I want hide div which has id 'hide' and class 'test'. It is working fine
with .filter method but I want to is there another method to do this.
fiddle
if($('#hide').hasClass('test')){
$('.test').hide()
}
//$('#hide').filter(function(){
//return this.className=='test'
//}).hide()
I want hide div which has id 'hide' and class 'test'. It is working fine
with .filter method but I want to is there another method to do this.
fiddle
if($('#hide').hasClass('test')){
$('.test').hide()
}
//$('#hide').filter(function(){
//return this.className=='test'
//}).hide()
Storing Exchange server usage statistics into SQL Server DB
Storing Exchange server usage statistics into SQL Server DB
I'm looking for application that could track Exchange server and store
pretty simple data (like User Name, Date, Incoming Messages Count,
Outgoing Messages Count, Unread Messages Count) into SQL Server DB. I know
there are bunch of expensive programs like "Exchange Reporter Plus" from
manage engine with preset reports, but I need something simple to store
data and use it for custom reports.
Thanks in advance!
I'm looking for application that could track Exchange server and store
pretty simple data (like User Name, Date, Incoming Messages Count,
Outgoing Messages Count, Unread Messages Count) into SQL Server DB. I know
there are bunch of expensive programs like "Exchange Reporter Plus" from
manage engine with preset reports, but I need something simple to store
data and use it for custom reports.
Thanks in advance!
Can't able to select an element inside a div loaded using jQuery Ajax call
Can't able to select an element inside a div loaded using jQuery Ajax call
Working with a project, Loading a calender from a php file using ajax
call. When i'm try to trigger an event written on the loaded table it
seems not working.
Please help me.
$.ajax({
url: 'calender.php',
type: 'GET',
success: function(res){
$("#calender").html(res);
}
});
$("#prev").click(function(){
console.log(this);
});
PHP Code here.
*<?php
$monthNames = Array("January", "February", "March", "April", "May",
"June", "July",
"August", "September", "October", "November", "December");
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<table width="300">
<tr align="center">
<td bgcolor="#999999" style="color:#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left"><a id="prev" title="<?php echo
$prev_month."|".$prev_year; ?>" href="javascript:void(0);"
style="color:#FFFFFF">Previous</a></td>
<td width="50%" align="right"><a id="next" title="<?php echo
$next_month."|".$next_year; ?>" href="javascript:void(0);"
style="color:#FFFFFF">Next</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellpadding="5" cellspacing="0" id="calen">
<tr align="center">
<td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo
$monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
</tr>
<tr>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">S</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">M</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">T</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">W</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">T</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">F</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">S</th>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo "<tr>";
if($i < $startday){
echo "<td></td>";
}else{
$currentDay = date("d");
$presentDay = $i-$startday+1;
if($presentDay == $currentDay){
echo "<td class='current' align='center' valign='middle'
height='20px'><a title='".($i - $startday + 1)."'
href='javascript:void(0);'>". ($i - $startday + 1) .
"</a></td>";
}else if($presentDay < $currentDay){
echo "<td align='center' valign='middle' height='20px'>". ($i
- $startday + 1) . "</td>";
}else{
echo "<td align='center' valign='middle' height='20px'><a
title='".($i - $startday + 1)."' href='javascript:void(0);'>".
($i - $startday + 1) . "</a></td>";
}
}
if(($i % 7) == 6 ) echo "</tr>";
}
?>*
What can be the issue ?
Working with a project, Loading a calender from a php file using ajax
call. When i'm try to trigger an event written on the loaded table it
seems not working.
Please help me.
$.ajax({
url: 'calender.php',
type: 'GET',
success: function(res){
$("#calender").html(res);
}
});
$("#prev").click(function(){
console.log(this);
});
PHP Code here.
*<?php
$monthNames = Array("January", "February", "March", "April", "May",
"June", "July",
"August", "September", "October", "November", "December");
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<table width="300">
<tr align="center">
<td bgcolor="#999999" style="color:#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left"><a id="prev" title="<?php echo
$prev_month."|".$prev_year; ?>" href="javascript:void(0);"
style="color:#FFFFFF">Previous</a></td>
<td width="50%" align="right"><a id="next" title="<?php echo
$next_month."|".$next_year; ?>" href="javascript:void(0);"
style="color:#FFFFFF">Next</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellpadding="5" cellspacing="0" id="calen">
<tr align="center">
<td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo
$monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
</tr>
<tr>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">S</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">M</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">T</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">W</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">T</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">F</th>
<th align="center" bgcolor="#FFB102" style="color:#FFFFFF">S</th>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo "<tr>";
if($i < $startday){
echo "<td></td>";
}else{
$currentDay = date("d");
$presentDay = $i-$startday+1;
if($presentDay == $currentDay){
echo "<td class='current' align='center' valign='middle'
height='20px'><a title='".($i - $startday + 1)."'
href='javascript:void(0);'>". ($i - $startday + 1) .
"</a></td>";
}else if($presentDay < $currentDay){
echo "<td align='center' valign='middle' height='20px'>". ($i
- $startday + 1) . "</td>";
}else{
echo "<td align='center' valign='middle' height='20px'><a
title='".($i - $startday + 1)."' href='javascript:void(0);'>".
($i - $startday + 1) . "</a></td>";
}
}
if(($i % 7) == 6 ) echo "</tr>";
}
?>*
What can be the issue ?
Questions about ArrayList
Questions about ArrayList
I need to use an ArrayList, but I am not sure how o do some these things
that would be possible with a normal array.
1) This:
int[][] example1 = new int[10][20];
(an array with two arguments (10, 20)) is possible with normal arrays, but
how to do it with an ArrayList.
2) How to increase the value of an int on the list by 1, like this:
example2[3][4] ++;
I need to use an ArrayList, but I am not sure how o do some these things
that would be possible with a normal array.
1) This:
int[][] example1 = new int[10][20];
(an array with two arguments (10, 20)) is possible with normal arrays, but
how to do it with an ArrayList.
2) How to increase the value of an int on the list by 1, like this:
example2[3][4] ++;
Enabling network connection on .net micro framework device
Enabling network connection on .net micro framework device
I have a (embedded) device which supports .NET micro framework. I plan to
connect a GPRS modem to the device to get network connections. Do you have
any suggestions how to achieve this (programatically)?
I have a (embedded) device which supports .NET micro framework. I plan to
connect a GPRS modem to the device to get network connections. Do you have
any suggestions how to achieve this (programatically)?
Monday, 9 September 2013
Avoid reflow of css3 columns after they have been drawn
Avoid reflow of css3 columns after they have been drawn
I am using css3 columns to display an unordered list in 3 columns. The
list items contain lists as well that can be shown or hidden by clicking
on the title using jQuery.
The html looks like (with class names to describe the layout and
interactions):
<ul class="i-display-in-3-columns">
<li>
<h3 class="slide-toggle-sibling-list-on-click">column title 1</h3>
<ul class="i-am-initially-hidden">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
</li>
<li>
<h3 class="slide-toggle-sibling-list-on-click">column title 2</h3>
<ul class="i-am-initially-hidden">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
</li>
/* some more items */
</ul>
This works, but every time a sub-list is opened or closed, the columns get
redrawn.
I would like to freeze the columns after they have initially been drawn to
avoid this reflow so that every item stays in the column it is initially
drawn in.
I can of course write a masonry-like solution in javascript to convert my
list in 3 lists that are displayed next to each other, but I was hoping
that there was an easier solution, preferably in just css or in javascript
that keeps my list as a list.
Is that possible or would I just have to rewrite the DOM?
I am using css3 columns to display an unordered list in 3 columns. The
list items contain lists as well that can be shown or hidden by clicking
on the title using jQuery.
The html looks like (with class names to describe the layout and
interactions):
<ul class="i-display-in-3-columns">
<li>
<h3 class="slide-toggle-sibling-list-on-click">column title 1</h3>
<ul class="i-am-initially-hidden">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
</li>
<li>
<h3 class="slide-toggle-sibling-list-on-click">column title 2</h3>
<ul class="i-am-initially-hidden">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
</li>
/* some more items */
</ul>
This works, but every time a sub-list is opened or closed, the columns get
redrawn.
I would like to freeze the columns after they have initially been drawn to
avoid this reflow so that every item stays in the column it is initially
drawn in.
I can of course write a masonry-like solution in javascript to convert my
list in 3 lists that are displayed next to each other, but I was hoping
that there was an easier solution, preferably in just css or in javascript
that keeps my list as a list.
Is that possible or would I just have to rewrite the DOM?
JUnit 3 and 4 not working on eclipse 4.2
JUnit 3 and 4 not working on eclipse 4.2
I am trying to learn JUnit and I am not able to make it run. I tried
eclipse 4.2 and Android Developer tools (v22). I am setting up a simple
project with one test case. I tried with JUnit 4 and 3, but whenever I run
the test case as a JUnit test, nothing happens, the console hangs. No
output from setup before class, tear down or any method. No results.
Here's a simple screenshot of the project with JUnit 3 (same thing happens
with JUnit 4).
I looked for solutions on the SO and other places but none of them seem to
fit my case. The most common problem is multiple JDKs, where in fact I
have a single JDK installed, namely 1.7. The second common problem is the
inclusion of JUnit libraries in the project. As you can see, the library
is in fact included. When I go to the run configuration to check the
classpath, I don't see JUnit, like in the following screenshot.
However, even if I add JUnit to the running classpath in the launch
configuration, I still have the same issue.
Is there anything I can do to fix it or see what could be the problem?
I am trying to learn JUnit and I am not able to make it run. I tried
eclipse 4.2 and Android Developer tools (v22). I am setting up a simple
project with one test case. I tried with JUnit 4 and 3, but whenever I run
the test case as a JUnit test, nothing happens, the console hangs. No
output from setup before class, tear down or any method. No results.
Here's a simple screenshot of the project with JUnit 3 (same thing happens
with JUnit 4).
I looked for solutions on the SO and other places but none of them seem to
fit my case. The most common problem is multiple JDKs, where in fact I
have a single JDK installed, namely 1.7. The second common problem is the
inclusion of JUnit libraries in the project. As you can see, the library
is in fact included. When I go to the run configuration to check the
classpath, I don't see JUnit, like in the following screenshot.
However, even if I add JUnit to the running classpath in the launch
configuration, I still have the same issue.
Is there anything I can do to fix it or see what could be the problem?
Subscribe to:
Comments (Atom)