Thursday, 3 October 2013

Propel toArray Mechanics in Doctrine?

Propel toArray Mechanics in Doctrine?

I was using Propel for a long time and now I want to try Doctrine. In My
Propel days I used PropelObjectCollection::toArray (for a collection) or
PropelObject::toArray() for a single record to convert the PropelObject
via array to json.
In my company we override the toArray method to store virtual columns in
the array and then the json string. For example:
public function toArray() { $arr = parent::toArray(); $arr['full_name'] =
$this->getFullName(); // full_name isnt part of the table, it's just a
getter return $arr; }
When I turn this into json i have my full_name property in my json and
then in my Extjs store Object (we use extjs).
Now I wanna try doctrine, but doctrine doesn't seem to allow this. Can i
override a function or property in my doctrine class, or can I do this by
annotations, is it possible to generate a json with propertys
('first_name', 'last_name', 'full_name') if my Doctrine class only has the
properties $first_name, $last_name and no $full_name or is there a work
around to achiev the same?
Thanks for your help

Wednesday, 2 October 2013

Execute a event manually in javascript

Execute a event manually in javascript

I have a class:
function x()
{
this.initialize = function () { }
this.filterSelection = function (event, ui) { /* code */ }
}
I hook filterSelection method to other items through:
$(item).on("click", this, this.filterSelection );
When filterSelection is called, the event.data points to the instance of
my class.
Now I need to call filterSelection manually from within the initialize()
method.
How can I do this which setting the correct parameters?

Numbering Theorems and subsections

Numbering Theorems and subsections

I want the numbering of theorems to follows the section/subsection
counters so I use
\newtheorem{thm}{Theorem}[subsection]
But when I write a theorem in a section before any subsection the
numbering follows the numbering of theorems in the previous section.
Here is an example. I would like the numbering to be as written in the
body of the theorems.
\documentclass[11pt,a4paper]{article}
\usepackage{amsthm}
\renewcommand{\thesubsection}{\arabic{subsection}}
\newtheorem{thm}{Theorem}[subsection]
\begin{document}
\section{Section 1}
\subsection{Subsection 1.1}
\begin{thm}Thm 1.1.1.\end{thm}
\section{Section 2}
\begin{thm}Thm 2.0.1.\end{thm}
\subsection{Subsection 2.1}
\begin{thm}Thm 2.1.1.\end{thm}
\end{document}

Tuesday, 1 October 2013

Checking if a User's Input is in Range and is an Integer (Java)

Checking if a User's Input is in Range and is an Integer (Java)

I am working on a project (a game) and one of the requirements is to have
warnings if they enter an option outside of the range (1-8) and if they
enter a character. If the user enters an invalid number, the menu appears
and asks them again which option they would like. If they enter a
character, the program should ask them to enter an integer and ask for
input again. This is what I have so far. It correctly identifies a number
out of range and recalls the menu. It also identifies a character (invalid
input), but does open input for the user to enter a correct option. How
can I check both conditions?
Thanks, Tyler
int userChoice = scnr.nextInt();//<-- use this variable
if (userChoice.hasNextInt() == false)
{
System.out.println("Error: Menu selection must be an
integer! Please try again:");
}
// Variable used for storing what the user's main menu choice
if (0 > userChoice || userChoice > 8)
{
System.out.println("Error: Invalid Menu Selection.");
System.out.println("");
System.out.println("Available Actions:");
System.out.println("(1) Print Market Prices");
System.out.println("(2) Print Detailed Statistics");
System.out.println("(3) Buy Some Sheep");
System.out.println("(4) Buy a Guard Dog");
System.out.println("(5) Sell a Sheep");
System.out.println("(6) Sell a Guard Dog");
System.out.println("(7) Enter Night Phase");
System.out.println("(8) Quit");
System.out.println("What would you like to do?");
userChoice = scnr.nextInt();
}

Microsoft Fakes Crashes On Build

Microsoft Fakes Crashes On Build

I'm trying to add Stubs using Microsoft Fakes to an internal project.
Every time I build, I get a popup saying fakes.x86.exe has stopped
working. When I tell it to "debug the project", it shows me that it's
hanging on a call to StringHelper.ToHexString.
I've tried searching Microsoft.com, but all I found was a year-old thread
where someone else had the same issue.
I've got VS 2012 update 2, but I'm upgrading to update 3 at the moment to
see if that makes a difference.

Kali Linux Install Error [on hold]

Kali Linux Install Error [on hold]

I just downloaded Kali Linux Mini. I am trying to install it but keep
getting this error./p pimg src=http://i.stack.imgur.com/CtLEs.png
alt=enter image description here/p pNow I know what your thinking...How
can this idiot not know this? Well I do know the answer, but the file
cabinet in my brain is locked and I lost the key. So for now the answer
escapes me. /p pAs you can see from the image above, my courser is
pointing to the file in question. It is clearly right there... So please,
can someone tell me what I am doing wrong... /p pThanks, and if you find
my key, strongPLEASE/strong return it!/p

Searching for a mile counter / wide-square numbers font – graphicdesign.stackexchange.com

Searching for a mile counter / wide-square numbers font –
graphicdesign.stackexchange.com

I am in need of a font with numbers that look like this: Does anyone know
of a font with numbers like these?

Monday, 30 September 2013

$\mathbb{RP}^3$ is homeomorphic to the solid ball with antipodal points identified

$\mathbb{RP}^3$ is homeomorphic to the solid ball with antipodal points
identified

I am reading the book Application of Path integrals by Schulman, which has
a chapter on applications of homotopy theory to path integrals. In that he
says we can geometrically describe $SO(3)$ by a solid (3 -dimensional)
ball with radius $\pi$,and with antipodal points identified. Each point in
the ball at distance $\phi$ from the centre, represents a rotation about
the axis passing through that point and origin, and angle of rotation
$\phi$. Later he writes "Projective 3 space is homeomorphic to the solid
ball described earlier." I imagine $\mathbb{RP}^3$ to be the 3-sphere with
antipodal points identified.
How is this homeomorphic to the solid ball described above?

Help with offlineimap misadventures

Help with offlineimap misadventures

After deciding to bite bullet and have mutt stop doing an imap connection
directly to gmail, I installed offlineimap. I decided that I only wanted
to the inbox, sent mail, and archives, so I proceeded to remove all of the
labels to that I didn't end up with a million maildir directories.
Probably not the best idea that I had on the issue.
When I started the initial download of my mail, things looked well, but I
noticed that there was a lot of deletion going on. When everything was
finished, my sent fold on the mutt side (as well as the gmail web
interface side) showed that I had no sent mail at all... Imagine my shock
to go from thousands of response email to absolutely nothing. Upon a
little playing on the web side of gmail, all of the messages were there,
but it just didn't show up in the sent messages. Also, I noticed that when
I sent a message under mutt, after the message was sent, the message would
say in the sent box for a couple of minutes, and then disappear. Again, if
I go to the web version of gmail, although it is gone from the sent box,
if I do a search for mail, the sent message shows up.
[general]
General information. See the fully annotated example more information
https://github.com/jgoerzen/offlineimap/blob/master/offlineimap.conf
metadata = ~/.offlineimap accounts = foobar maxsyncaccounts = 2
socktimeout = 60 ui = Basic
[Account foobar] localrepository = foobar-Local remoterepository =
foobar-Remote status_backend = sqlite postsynchook = notmuch new
This helper file lets you use gnome-keyring to store usernames / passwords
pythonfile = ~/.mail/lib/offlineimap-helper.py
[mbnames]
Create a list of available mailboxes for mutt
enabled = yes
filename = ~/.mail/mutt/muttmailboxes
header = "mailboxes "
Exclude these mailboxes from the above mailbox list
folderfilter = lambda accountname, foldername: not
re.search('(^bak.*|.*drafts$|.*spam$|.*sent$|.*trash$)', foldername)
peritem = "+%(accountname)s/%(foldername)s" sep = " " footer = "\n"
[Repository foobar-Local] type = Maildir
cert_fingerprint=f3043dd689a2e7dddfbef82703a6c65ea9b634c1 localfolders =
~/.mail/foobar-gmail.com # Note the nametrans below in remote-gmail: it
undoes this one nametrans = lambda foldername: re.sub ('Inbox', 'INBOX',
re.sub ('Drafts', '[Gmail].Drafts', re.sub ('Sent', '[Gmail].Sent Mail',
re.sub ('Flagged', 'Starred', re.sub ('_', ' ',
foldername.capitalize())))))
[Repository foobar-Remote] type = Gmail maxconnections = 2
remotehost = imap.gmail.com
remoteusereval = get_username("imap.gmail.com")
remotepasseval = get_password("imap.gmail.com")
remoteuser = foobar@gmail.com remotepass = mypassword
If using ssl, you will need to specify certificates to use with them
ssl = yes sslcacertfile = /etc/ssl/certs/ca-certificates.crt realdelete = no
Note the nametrans above in local-gmail: it undoes this one
nametrans = lambda foldername: re.sub ('^[gmail]/', '', re.sub
('sent_mail', 'sent', re.sub ('starred', 'flagged', re.sub (' ', '_',
foldername.lower()))))
We don't want to sync all mail, it would pull everything again
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail']
So any ideas what I might be doing wrong?

Can we get a data from a url using cURL without reloading the page

Can we get a data from a url using cURL without reloading the page

Can we use cURL for getting the data from a php page using cURL without
reloading the page.
or I have to use AJAX for getting the data without reloading.

php imap - get body and make plain text

php imap - get body and make plain text

i am using the php imap function to get emails from a pop3 mailbox and
insert the data into a mysql database.
here is the php code:
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect:
' . imap_last_error());
$emails = imap_search($inbox,'ALL');
if($emails)
{
$output = '';
rsort($emails);
foreach($emails as $email_number)
{
$header=imap_headerinfo($inbox,$email_number);
$from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
$toaddress=$header->toaddress;
$replyto=$header->reply_to[0]->mailbox."@".$header->reply_to[0]->host;
$datetime=date("Y-m-d H:i:s",$header->udate);
$subject=$header->subject;
//remove the " from the $toaddress
$toaddress = str_replace('"','',$toaddress);
echo '<strong>To:</strong> '.$toaddress.'<br>';
echo '<strong>From:</strong> '.$from.'<br>';
echo '<strong>Subject:</strong> '.$subject.'<br>';
//get message body
$message = (imap_fetchbody($inbox,$email_number,1.1));
if($message == '')
{
$message = (imap_fetchbody($inbox,$email_number,1));
}
}
it works fine, however on some emails in the body i get = in between
words, or =20 in between words. and other times the emails will just be
blank even though they are not blank when sent.
This only happens when coming from certain emails.
how can i get round this and just make the email completely plain text?

Sunday, 29 September 2013

Changing xv6 kernel:ERROR: expected declaration or statement at end of input in C

Changing xv6 kernel:ERROR: expected declaration or statement at end of
input in C

I receive the following error:
kernel/proc.c:516: error: expected declaration or statement at end of input
Can you please help me figure out how to fix this error? Here is the code:
#include "types.h"
#include "defs.h"
#include "param.h"
#include "mmu.h"
#include "x86.h"
#include "proc.h"
#include "spinlock.h"
struct {
struct spinlock lock;
struct proc proc[NPROC];
} ptable;
static struct proc *initproc;
static int num_tickets=0; //mona2
unsigned long winner;
int nextpid = 1;
extern void forkret(void);
extern void trapret(void);
///// mona2 lcg invariant //not working because of uint32_t
/*
static uint32_t temper(uint32_t x)
{
x ^= x>>11;
x ^= x<<7 & 0x9D2C5680;
x ^= x<<15 & 0xEFC60000;
x ^= x>>18;
return x;
}
uint32_t lcg64_temper(uint64_t *seed)
{
*seed = 6364136223846793005ULL * *seed + 1;
return temper(*seed >> 32);
}
*/
static
unsigned long
lcg_rand(unsigned long a)
{
return (a * 279470273UL) % 4294967291UL;
}
static void wakeup1(void *chan);
void
pinit(void)
{
initlock(&ptable.lock, "ptable");
}
// Look in the process table for an UNUSED proc.
// If found, change state to EMBRYO and initialize
// state required to run in the kernel.
// Otherwise return 0.
static struct proc*
allocproc(void)
{
struct proc *p;
char *sp;
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
if(p->state == UNUSED)
{
goto found;
p->tickets=CREATION_TICKET; //mona2
num_tickets+=CREATION_TICKET; //mona2
}
release(&ptable.lock);
return 0;
found:
p->state = EMBRYO;
p->pid = nextpid++;
release(&ptable.lock);
// Allocate kernel stack if possible.
if((p->kstack = kalloc()) == 0){
p->state = UNUSED;
return 0;
}
sp = p->kstack + KSTACKSIZE;
// Leave room for trap frame.
sp -= sizeof *p->tf;
p->tf = (struct trapframe*)sp;
// Set up new context to start executing at forkret,
// which returns to trapret.
sp -= 4;
*(uint*)sp = (uint)trapret;
sp -= sizeof *p->context;
p->context = (struct context*)sp;
memset(p->context, 0, sizeof *p->context);
p->context->eip = (uint)forkret;
return p;
}
// Set up first user process.
void
userinit(void)
{
struct proc *p;
extern char _binary_initcode_start[], _binary_initcode_size[];
p = allocproc();
acquire(&ptable.lock);
initproc = p;
if((p->pgdir = setupkvm()) == 0)
panic("userinit: out of memory?");
inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
p->sz = PGSIZE;
memset(p->tf, 0, sizeof(*p->tf));
p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
p->tf->es = p->tf->ds;
p->tf->ss = p->tf->ds;
p->tf->eflags = FL_IF;
p->tf->esp = PGSIZE;
p->tf->eip = 0; // beginning of initcode.S
safestrcpy(p->name, "initcode", sizeof(p->name));
p->cwd = namei("/");
p->state = RUNNABLE;
p->tickets=CREATION_TICKET;
release(&ptable.lock);
}
// Grow current process's memory by n bytes.
// Return 0 on success, -1 on failure.
int
growproc(int n)
{
uint sz;
sz = proc->sz;
if(n > 0){
if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
} else if(n < 0){
if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
}
proc->sz = sz;
switchuvm(proc);
return 0;
}
// Create a new process copying p as the parent.
// Sets up stack to return as if from system call.
// Caller must set state of returned proc to RUNNABLE.
int
fork(void)
{
int i, pid;
struct proc *np;
// Allocate process.
if((np = allocproc()) == 0)
return -1;
// Copy process state from p.
if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){
kfree(np->kstack);
np->kstack = 0;
np->state = UNUSED;
return -1;
}
np->sz = proc->sz;
np->parent = proc;
*np->tf = *proc->tf;
// Clear %eax so that fork returns 0 in the child.
np->tf->eax = 0;
for(i = 0; i < NOFILE; i++)
if(proc->ofile[i])
np->ofile[i] = filedup(proc->ofile[i]);
np->cwd = idup(proc->cwd);
pid = np->pid;
np->state = RUNNABLE;
safestrcpy(np->name, proc->name, sizeof(proc->name));
return pid;
}
// Exit the current process. Does not return.
// An exited process remains in the zombie state
// until its parent calls wait() to find out it exited.
void
exit(void)
{
struct proc *p;
int fd;
if(proc == initproc)
panic("init exiting");
// Close all open files.
for(fd = 0; fd < NOFILE; fd++){
if(proc->ofile[fd]){
fileclose(proc->ofile[fd]);
proc->ofile[fd] = 0;
}
}
iput(proc->cwd);
proc->cwd = 0;
acquire(&ptable.lock);
// Parent might be sleeping in wait().
wakeup1(proc->parent);
// Pass abandoned children to init.
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->parent == proc){
p->parent = initproc;
if(p->state == ZOMBIE)
wakeup1(initproc);
}
}
// Jump into the scheduler, never to return.
proc->state = ZOMBIE;
sched();
panic("zombie exit");
}
// Wait for a child process to exit and return its pid.
// Return -1 if this process has no children.
int
wait(void)
{
struct proc *p;
int havekids, pid;
acquire(&ptable.lock);
for(;;){
// Scan through table looking for zombie children.
havekids = 0;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->parent != proc)
continue;
havekids = 1;
if(p->state == ZOMBIE){
// Found one.
pid = p->pid;
kfree(p->kstack);
p->kstack = 0;
freevm(p->pgdir);
p->state = UNUSED;
p->pid = 0;
p->parent = 0;
p->name[0] = 0;
p->killed = 0;
release(&ptable.lock);
return pid;
}
}
// No point waiting if we don't have any children.
if(!havekids || proc->killed){
release(&ptable.lock);
return -1;
}
// Wait for children to exit. (See wakeup1 call in proc_exit.)
sleep(proc, &ptable.lock); //DOC: wait-sleep
}
}
// Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up.
// Scheduler never returns. It loops, doing:
// - choose a process to run
// - swtch to start running that process
// - eventually that process transfers control
// via swtch back to the scheduler.
void
scheduler(void)
{
struct proc *p;
int seed=0;
for(;;){
// Enable interrupts on this processor.
sti();
seed++;
// winner = lcg64_temper(seed) % num_tickets;
winner = lcg_rand(seed) % num_tickets;
// Loop over process table looking for process to run.
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state != RUNNABLE)
continue;
// Switch to chosen process. It is the process's job
// to release ptable.lock and then reacquire it
// before jumping back to us.
proc = p;
switchuvm(p);
p->state = RUNNING;
swtch(&cpu->scheduler, proc->context);
switchkvm();
// Process is done running for now.
// It should have changed its p->state before coming back.
proc = 0;
}
release(&ptable.lock);
}
}
// Enter scheduler. Must hold only ptable.lock
// and have changed proc->state.
void
sched(void)
{
int intena;
if(!holding(&ptable.lock))
panic("sched ptable.lock");
if(cpu->ncli != 1)
panic("sched locks");
if(proc->state == RUNNING)
panic("sched running");
if(readeflags()&FL_IF)
panic("sched interruptible");
intena = cpu->intena;
swtch(&proc->context, cpu->scheduler);
cpu->intena = intena;
}
// Give up the CPU for one scheduling round.
void
yield(void)
{
acquire(&ptable.lock); //DOC: yieldlock
proc->state = RUNNABLE;
sched();
release(&ptable.lock);
}
// A fork child's very first scheduling by scheduler()
// will swtch here. "Return" to user space.
void
forkret(void)
{
// Still holding ptable.lock from scheduler.
release(&ptable.lock);
// Return to "caller", actually trapret (see allocproc).
}
// Atomically release lock and sleep on chan.
// Reacquires lock when awakened.
void
sleep(void *chan, struct spinlock *lk)
{
if(proc == 0)
panic("sleep");
if(lk == 0)
panic("sleep without lk");
// Must acquire ptable.lock in order to
// change p->state and then call sched.
// Once we hold ptable.lock, we can be
// guaranteed that we won't miss any wakeup
// (wakeup runs with ptable.lock locked),
// so it's okay to release lk.
if(lk != &ptable.lock){ //DOC: sleeplock0
acquire(&ptable.lock); //DOC: sleeplock1
release(lk);
}
// Go to sleep.
proc->chan = chan;
proc->state = SLEEPING;
sched();
// Tidy up.
proc->chan = 0;
// Reacquire original lock.
if(lk != &ptable.lock){ //DOC: sleeplock2
release(&ptable.lock);
acquire(lk);
}
}
// Wake up all processes sleeping on chan.
// The ptable lock must be held.
static void
wakeup1(void *chan)
{
struct proc *p;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
if(p->state == SLEEPING && p->chan == chan)
p->state = RUNNABLE;
}
// Wake up all processes sleeping on chan.
void
wakeup(void *chan)
{
acquire(&ptable.lock);
wakeup1(chan);
release(&ptable.lock);
}
// Kill the process with the given pid.
// Process won't exit until it returns
// to user space (see trap in trap.c).
int
kill(int pid)
{
struct proc *p;
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->pid == pid){
p->killed = 1;
// Wake process from sleep if necessary.
if(p->state == SLEEPING)
p->state = RUNNABLE;
release(&ptable.lock);
return 0;
}
}
release(&ptable.lock);
return -1;
}
// Print a process listing to console. For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
int
lottery(int tickets, int pid)
{
int i;
struct proc *p;
//acquire(&proc_table_lock);
acquire(&ptable.lock); //mona2
for(i = 0; i < NPROC; i++){
p = &proc[i];
if(p->pid != pid)
continue;
if(p->state == UNUSED)
return -1;
if(p->state == RUNNING || p->state == RUNNABLE)
num_tickets += (tickets - p->tickets);
p->tickets = tickets;
//release(&proc_table_lock);
release(&ptable.lock); //mona2
return 0;
}
}
void
procdump(void)
{
static char *states[] = {
[UNUSED] "unused",
[EMBRYO] "embryo",
[SLEEPING] "sleep ",
[RUNNABLE] "runble",
[RUNNING] "run ",
[ZOMBIE] "zombie"
};
int i;
struct proc *p;
char *state;
uint pc[10];
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state == UNUSED)
continue;
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
state = states[p->state];
else
state = "???";
cprintf("%d %s %s", p->pid, state, p->name);
if(p->state == SLEEPING){
getcallerpcs((uint*)p->context->ebp+2, pc);
for(i=0; i<10 && pc[i] != 0; i++)
cprintf(" %p", pc[i]);
}
cprintf("\n");
}

Send android event from php

Send android event from php

I'm trying to create intranet PHP application that communicates with
android phones. So I was wondering is it possible to trigger android event
from PHP and I don't need push messages. Thanks.

Paypal sandbox, nothing works

Paypal sandbox, nothing works

I can login to developer.paypal.com
After that, nothing works today.
Can't login to sandbox.paypal Can't create trial accounts Can't edit
existing trial accounts
Everything was working fine last week. Now nothing works.
Tried clearing cache and deleting cookies. Tried a different browser.
I'm 1000% sure something is wrong with paypal today .... what should I do?

DateTime constructor in php

DateTime constructor in php

I have done a little experiment on php's DateTime class. In the
documentation they have suggested the syntax for creating the object of
DateTime class as given.
Object oriented style
public DateTime::__construct() ([ string $time = "now" [, DateTimeZone
$timezone = NULL ]] )
Procedural style
DateTime date_create ([ string $time = "now" [, DateTimeZone $timezone =
NULL ]] )
Returns new DateTime object.
Here the first argument they have specified as mandatory, as a date/time
string as specified in Date and Time Formats section. Or we have to pass
NULL here to obtain the current time when using the $timezone parameter.
But my problem is when I am giving following code -
date_default_timezone_set('America/Los_Angeles');
$d_ob = new DateTime('x');
echo $d_ob->format('Y-m-d');
It's supposed to generate exception, but it's generating the echoing the
current date time like -
2013-09-29
I am not getting the point, how it's working?

Saturday, 28 September 2013

mySQL joined tables no duplicates

mySQL joined tables no duplicates

I have two tables: One table contains poetry submitted by members. The
other is the member's table. Both tables contain The Member's ID (MID and
SubMID). I want to display the last 15 poems that have been updated.
However, I want to display ONLY one work for any one author.
This works but it if an author updates a few works then they get displayed
many times:
$query="SELECT * FROM submits, members WHERE submits.SubMID = members.MID
AND submits.sub_approved = 'T' ORDER BY submits.sub_Last_Update DESC LIMIT
15 ";
You can see the results of that query here in the rolling marquee on the
right: http://www.Prose-n-Poetry.com
The problem is that one author can take over the marquee by updating a few
poems.

CSS Dropdown Menu overflow problems

CSS Dropdown Menu overflow problems

I have a blog http://fraldasdamaria.blogspot.pt/ and I would like to put
the submenus apearing in a rollover mode. I can put the subsubmenu working
properly; but when I put the condition overflow:hidden on the submenu, the
subsubmenu disapear. Can anyone help me, please?
The CSS code is:
`#menuWrapper {
width:100%; /* Ancho del menú */
height:35px; /* Altura da barra principal */
padding-left:15px;
background:#1F151E; /* Color de fondo */
border-radius:20px; /* Bordes redondeados de la barra principal */
}
.menu {
padding:0;
margin:0;
list-style:none;
height:35px;
position:relative;
z-index:5;
font-family:"Lucida Sans Unicode", "Trebuchet Unicode MS", "Lucida
Grande",sans-serif;
}
.menu li a:hover{background:#2580a2; color:#fff; /* Cor do Separador
principal ao passar cursor */
transition: background 0.5s linear 0s;
}
.menu li.top {display:block; float:left;}
.menu li a.top_link {
display:block;
float:left;
height:35px;
line-height:34px;
color:#FFFFFF;
text-decoration:none;
font-family:"Lucida Sans Unicode", "Trebuchet Unicode MS", "Lucida
Grande",sans-serif;
font-size:13px; /* Tamaño de la fuente */
font-weight:none;
padding:0 0 0 12px;
cursor:pointer;
}
.menu li a.top_link span {
float:left;
display:block;
padding:0 24px 0 12px;
height:35px;
}
.menu li a.top_link span.down {
float:left;
display:block;
padding:0 24px 0 12px;
height:35px;
}
.menu li a.top_link:hover, .menu li:hover > a.top_link {color:#fff; }
.menu li:hover {position:relative; z-index:2;}
.menu ul,
.menu li:hover ul ul,
.menu li:hover ul li:hover ul ul,
.menu li:hover ul li:hover ul li:hover ul ul,
.menu li:hover ul li:hover ul li:hover ul li:hover ul ul
{position:absolute; left:-9999px; top:-9999px; width:0; height:0;
margin:0; padding:10px 5px 10px 10px; list-style:none;}
.menu li:hover ul.sub {
left:0;
top:35px;
background:#1F151E; /* Color de fondo del submenú */
padding:3px;
white-space:nowrap;
width:200px; /* Largura do submenu */
height:auto;
max-height:900px;
z-index:100;
font-size:12px; /* Tamanho fonte submenu */
border-radius: 0px 0px 20px 20px; /* Bordes redondeados del submenú */
transition-property: max-height;
transition: max-height 2s ease;
}
.menu li:hover ul.sub li {
display:block;
height:36px; /* Altura de cada linha do submenu */
position:relative;
float:left;
width:200px;
font-weight:9px;
}
.menu li:hover ul.sub li a{
display:block;
line-height:30px;
text-indent:5px;
color:#FFFFFF;
text-decoration:none;
padding:4px 0px 4px 8px; /* Margem interna de cada linha do submenu */
border-radius: 0px 0px 20px 20px; /* Bordes redondeados del submenú */
}
.menu li ul.sub li a.fly {
/* Color de fondo del submenú */
background:#1F151E
url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHok3RNg7DTASoChCKMtgHTqeGQpFVBfMgl1ukgjZUXtq2T9HwO2Ml5bNdepEc8TZoteZprVOrk-mEgNKMfGStXBbSvKdRpGoKKAnrc7f5VxFgpj7L2S6VRSDYn5FZePk7HP2XxSs_HdOa/)
185px 10px no-repeat;}
.menu li:hover, .menu li:hover ul.sub li a:hover {
background:#2580a2; /* Color de fondo al pasar el cursor */
transition: background 0.5s linear 0s;
color:#FFFFFF;
border-radius: 0px 0px 20px 20px;
text-shadow: 3px 3px #1F151E;
}
.menu li:hover ul.sub li a.fly:hover, .menu li:hover ul li:hover > a.fly {
/* Color de fondo al pasar el cursor */
background:#2580a2
url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHok3RNg7DTASoChCKMtgHTqeGQpFVBfMgl1ukgjZUXtq2T9HwO2Ml5bNdepEc8TZoteZprVOrk-mEgNKMfGStXBbSvKdRpGoKKAnrc7f5VxFgpj7L2S6VRSDYn5FZePk7HP2XxSs_HdOa/)
185px 10px no-repeat; color:#fff;}
.menu li:hover ul li:hover ul,
.menu li:hover ul li:hover ul li:hover ul,
.menu li:hover ul li:hover ul li:hover ul li:hover ul,
.menu li:hover ul li:hover ul li:hover ul li:hover ul li:hover ul {
left:200px;
top:0px;
background: #1F151E; /* Color de fondo del submenú */
padding:3px;
white-space:nowrap;
width:200px; /* Largura do subsubmenu */
z-index:4;
height:auto;
max-height:900px;
overflow:hidden;
border-radius: 0px 0px 20px 20px; /* Bordes redondeados del subsubmenú */
transition-property: max-height;
transition: max-height 2s ease;
}

how to define two primary keys Hibernate JPA

how to define two primary keys Hibernate JPA

I have a class in java that has a numerical Id and username (a nature
primary key). I want to define two primary key in hibernate somthng like
that with SQL
Create table X(
Int ID PK,
String name PK,
String adress,
.....
)
And i have already this :
@Entity
@Table(name="Xtable")
public class Xclass{
@Id
@GeneratedValue
@Column(name="ID_X", length=100)
private long ID_X;
@Column(name="Name_X", length=100)
private String Name_X;
}

Scala mutable.BitSet intersection performance

Scala mutable.BitSet intersection performance

I am trying to write a backtracking algorithm that keeps state using
mutable BitSets, it works fine but I want it to go faster!
The crux is given two mutable.BitSet alpha and beta I need to calculate if
any of the bits of alpha are set in beta, i.e. bitwise AND. I do not need
the resulting set just need to know if the intersection isNonEmpty
(alpha intersect beta).nonEmpty
or
(alpha & beta).nonEmpty
but both of these construct a set which is then tested for size... I
really just need a boolean and would like to avoid the cost of
constructing the intermediate set.
Is there a better way?
TIA Nivag

Friday, 27 September 2013

How did Vesper show users wallpaper without UIApplicationIsOpaque key?

How did Vesper show users wallpaper without UIApplicationIsOpaque key?

An app named Vesper was updated for iOS 7 and shows the user's wallpaper
on iOS 7. I have found that using UIApplicationIsOpaque key and
UIBackgroundStyleLightBlur can show the users background but will not pass
validation. Vesper passed validation and passed Apple. I did upload this
question to the dev forums, but apple has taken it down.

How to add a IF statement to change an element to another (example locale: English to Portuguese)

How to add a IF statement to change an element to another (example locale:
English to Portuguese)

MY research shows that:
One can extend Selenium IDE user-extensions which is not what I aiming for
now. Secondly, I know that one could use a storeEval command and write 2
lines of javascript code. and use conditional statement instead of if
statement. (See Example below) But how can I use that to change from
English locale to Portuguese locale for instance? How will the Selenium
IDE Command, Target and Value look like?
storeEval selenium.isElementPresent('Element I
control')?selenium.doClick('Element which will be clicked if the element
present'):seleniumdoClick('Element which will be clicked if the element
NOT present')

Catching Terminal Output in Python

Catching Terminal Output in Python

I want to do something similar to the second answer here (but not quite
similar): Simulate Ctrl-C keyboard interrupt in python while working in
Linux
It's much simpler and I think I'm just missing something. Say, from a
python script, I just want to call 'ping' and terminate it after the 10th
time. I'm trying to do it like from the link above:
p = subprocess.Popen(['ping', 'google.com'], stdout=subprocess.PIPE)
for line in p.stdout:
print line
if re.search('10', line):
break
os.kill(p.pid, signal.SIGINT)
But it doesn't work.
And I also want the regular output of 'ping' to be displayed. How do I do
this?

Match a variable to part of another variable in batch

Match a variable to part of another variable in batch

I want to match a variable to part of the contents of another variable in
batch. Here is some pseudo code for what I want to do.
set h= Hello-World
set f= This is a Hello-World test
if %h% matches any string of text in %f% goto done
:done
echo it matched
Does anybody know how I could accomplish this?

MySQL query with COUNT and join column from another table

MySQL query with COUNT and join column from another table

I have 2 tables with multiple fields.
Table1:
+--------+---+---------------+
| month | id| VERDICT_id |
+--------+------+------------+
| 201307 | 1 | 1 |
| 201307 | 2 | 4 |
| 201307 | 3 | 2 |
| 201307 | 4 | 2 |
| 201307 | 5 | NULL |
| 201307 | 6 | 1 |
+--------+------+------------+
Like this for every new 'month', for each unique 'id' the 'VERDICT_ID' is
set according to the value in Table2.
Table2:
+----+----------------------------------+
| id | title |
+----+----------------------------------+
| 1 | Passed |
| 2 | Failed (Component Fault) |
| 3 | Failed (User Fault) |
| 4 | Failed (Hardware Issue) |
+----+----------------------------------+
I make a query which gives below output
Actual Output:
+--------+------------+----------+
| month | VERDICT_id | COUNT(*) |
+--------+------------+----------+
| 201307 | 1 | 2 |
| 201307 | 2 | 2 |
| 201307 | 4 | 1 |
+--------+------------+----------+
What I want is,
+--------+------------+----------+
| month | VERDICT_id | COUNT(*) |
+--------+------------+----------+
| 201307 | 1 | 2 |
| 201307 | 2 | 2 |
| 201307 | 3 | 0 |
| 201307 | 4 | 1 |
+--------+------------+----------+
The difference between these 2 output is, if any VERDICT_id doesn't exist
for a month, then I want to print the VERDICT_id and COUNT as '0'.
But with the below query it's not possible.
select month,VERDICT_id, COUNT(*) FROM Table1
where (month = 201307) AND (VERDICT_id BETWEEN 1 AND 4) GROUP BY month,
VERDICT_id;
Q. Is this possible to make query to print the non existing VERDICT_id and
COUNT as '0'?

Silverlight list box deosnot scroll on mouse wheel movement on Mac

Silverlight list box deosnot scroll on mouse wheel movement on Mac

I have silver light based web app where.I found the list box doesn't
scroll on mouse wheel scroll.I am able to scroll by clicking vertical
scroll bar.When I use mouse wheel or 2 finger scroll it doesn't work. Here
in Mouse Wheel scroll in List box 2 is working fine but Listbox 1 it
doesnot work.
Listbox 1
<Border CornerRadius="6,6,0,0" Grid.Row="1" Margin="2,5,2,0"
BorderThickness="1,1,1,0" BorderBrush="#FFC4C4C4">
<Grid>
<ListBox x:Name="filterListBox" Grid.Row="0" Grid.Column="1"
Background="Transparent" SelectedIndex="{Binding
SelectedFilterIndex, Mode=TwoWay}" SelectedItem="{Binding
SelectedFilterItem, Mode=TwoWay}"
SelectionChanged="ListBox_SelectionChanged" BorderThickness="0"
VerticalAlignment="Center" Margin="5,3"
ItemContainerStyle="{StaticResource FilterListBoxItemStyle}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<ei:CallMethodAction TargetObject="{Binding}"
MethodName="FilterSelectionChanged"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem Padding="7,2"
VerticalContentAlignment="Center" Tag="Popular"
Visibility="{Binding Path=IsPopularChannelTab,
Mode=TwoWay, Converter={StaticResource
BoolToVisibilityConverter}}">
<TextBlock Text="{Binding
Path=PopularChannelsText,
Source={StaticResource PageStrings}}"
FontSize="13" FontWeight="SemiBold"
FontFamily="Arial" VerticalAlignment="Center"
/>
</ListBoxItem>
<ListBoxItem IsEnabled="False"
VerticalContentAlignment="Center" Visibility="{Binding
Path=IsPopularChannelTab, Mode=TwoWay,
Converter={StaticResource
BoolToVisibilityConverter}}">
<StackPanel Orientation="Horizontal">
<Border BorderBrush="#FFBDBDBD"
BorderThickness="0,2,2,2"
HorizontalAlignment="Center"
VerticalAlignment="Center" Height="20"/>
<Border BorderBrush="#FFF8F8F8"
BorderThickness="0,2,2,2"
HorizontalAlignment="Center"
VerticalAlignment="Center" Height="20"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Padding="7,2"
VerticalContentAlignment="Center" Tag="All">
<TextBlock Text="{Binding Path=AllChannelsText,
Source={StaticResource PageStrings}}"
FontSize="12" FontWeight="SemiBold"
FontFamily="Arial" VerticalAlignment="Center"/>
</ListBoxItem>
<ListBoxItem IsEnabled="False"
VerticalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<Border BorderBrush="#FFBDBDBD"
BorderThickness="0,2,2,2"
HorizontalAlignment="Center"
VerticalAlignment="Center" Height="20"/>
<Border BorderBrush="#FFF8F8F8"
BorderThickness="0,2,2,2"
HorizontalAlignment="Center"
VerticalAlignment="Center" Height="20"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Padding="7,2"
VerticalContentAlignment="Center" Tag="Favorites">
<TextBlock Text="{Binding Path=FavoritesText,
Source={StaticResource PageStrings}}"
FontSize="13" FontWeight="SemiBold"
FontFamily="Arial" VerticalAlignment="Center"/>
</ListBoxItem>
</ListBox>
</Grid>
ListBox 2
<Grid Visibility="{Binding Path=IsHavingProvider,
Converter={StaticResource BoolToVisibilityConverter}}" Margin="0,20,0,0"
Grid.Row="4">
<Grid.RowDefinitions>
<RowDefinition Height="18"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<core:MagicTextBlock Grid.Row="0"
TextBlockStyle="{StaticResource TextBlock_Style}"
Text="{Binding Path=WatchTVActivity,
Source={StaticResource PageStrings}}" />
<ListBox Margin="0,10,0,0" Grid.Row="1" x:Name="Provider"
Width="480" Height="195" HorizontalAlignment="Left"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding Providers,Mode=TwoWay}"
SelectedItem="{Binding SelectedProvider,Mode=TwoWay}"
ItemContainerStyle="{StaticResource
Table_ListBoxItem_Style}"
DisplayMemberPath="name">
</ListBox>
</Grid>

Javascript substracting numbers is not accurate - why

Javascript substracting numbers is not accurate - why

I have a fiddle here: http://jsfiddle.net/94wQJ/1/ - but probably someone
can advise just by looking below.
<button type="button" id="allocate">Calc</button>
$('#allocate').click(function () {
val1 = 25.00;
val2 = 16.37;
val3 = val1-val2;
alert(val3);
});
25 - 16.37 = 8.63 - however, the alert for val3 = 8.62999999999
Why is it not accurate?
Thank you,
Mark

Thursday, 26 September 2013

textViewShouldBeginEditing called continuously in ios 7

textViewShouldBeginEditing called continuously in ios 7

I am using xcode 5 and ios7 simulator. In which textViewShouldBeginEditing
called continuously, rather then once when textview becomes active.
Is there any solution to call textViewShouldBeginEditing method only once.
Thank you in advance for your help and consideration.

Wednesday, 25 September 2013

invoking ios installed app from safari

invoking ios installed app from safari

I want to invoke a ios application from browser. If the app is installed,
it should redirect to the app. Otherwise, it should continue in the
browser it self, with out showing an error pop up message. I tried
setTimeOut() in javascript, it not working.
Help me please...

Thursday, 19 September 2013

removing spell syntax highlighting in vim

removing spell syntax highlighting in vim

This question is a sequel question of this one. I have the following
script that removes capitalized words from vim spell check.
syn match myExCapitalWords +\<\w*[A-Z]\K*\>+ contains=@NoSpell
But it works only if I do syn clear first. But then all other highlighting
(e.g. markdown) gets lost. I went through syn list to see what might be
causing the conflict, but now I am out of clue.

What is difference in implementation of SunJCE 1.6 and SunJCE 1.5?

What is difference in implementation of SunJCE 1.6 and SunJCE 1.5?

I am migrating from JDK 1.5 to JDK 1.6. I've encountered difficult
problem. Here is piece of code:
SecretKeyFactory factory =
SecretKeyFactory.getInstance("PBEWithMD5AndTripleDES");
SecretKey key = factory.generateSecret(keySpec);
Cipher ecipher = Cipher.getInstance(key.getAlgorithm());
The created Cither instances produce different results for JRE 1.5 and JRE
1.6 (jce is installed in both cases).
Why JDKs produce different results? What is the difference in java
security implementation between versions 1.5 and 1.6?

Oracle Apex Pie Chart SQL Statement

Oracle Apex Pie Chart SQL Statement

i'm not really much into SQL & Apex, but i need one statement and I would
really appreciate your help on this. The syntax of Apex pie charts is
this:
SELECT link, label, value
My table looks like these simple sketch:
+------+-----------+---------+
| ID | Company | Item |
+------+-----------+---------+
| 1 | AAA |Some |
| 2 | BB |Stuff |
| 3 | BB |Not |
| 4 | CCCC |Important|
| 5 | AAA |For |
| 6 | DDDDD |Question?|
+------+-----------+---------+
I want to show the percentage of the companies.
Problem: All companies with less than 5 items should combine to one colum
"other". The difficulty for me is to combine the "unimportant" companies.
Until now my statement looks like this:
SELECT null link,
company label,
COUNT(ID) value FROM table HAVING COUNT(ID) > 5 GROUP BY company
Thank you for your ideas!

How to register PAYPAL_BASE.dll in Windows 2012 or Windows Server 2012?

How to register PAYPAL_BASE.dll in Windows 2012 or Windows Server 2012?

sorry if the title isn't specific, well, i've got a problem when i try to
register this dll: "paypal_base.dll", in Windows Server 2012. I tried by
regsvr32 "path\paypal_base.dll", in SysWow64 and System32 too, but not
work. I am working with a web site developed in VB6 and ASP CLASSIC, i
don't know if there is other component (dll) from Paypal for Windows
Server 2012. Thanks.

My do/while loop is not working Java,eclipse

My do/while loop is not working Java,eclipse

So i got a Do while loop thats supposed to read user input , if user types
J then it should ask the user to type in 2 numbers to calculate them but
if the user Types N then it should stop the loop or kinda stop the program
any idea why it isnt working?
if (input.equalsIgnoreCase("J")) {
do
{
status=true;
}
while (status);{
if (input.equalsIgnoreCase("N"))
status = false;
}
}

How to anonymize all passwords in a file in bash

How to anonymize all passwords in a file in bash

Assume you have a large configuration file containing passwords and other
classified data. The file may change in the future. I would like to
substitute this kind of data with placeholders, e.g. *** using bash to
create a version of the current config without containing the classified
information.
The file does has the form:
user_foo="Foo"
foo_pwd=12345
user_bar="Bar"
bar_password_x=42
a.passwd=asdf
and should be transformed to
user_foo="Foo"
foo_pwd=***
user_bar="Bar"
bar_password_x=***
a.passwd=***
Some script accepting a blacklist of strings being contained on the left
side of the assignents is maybe the way to do it.
Unfortunately I am no expert in bash but maybe there is an elegant
solution based on sed or awk.

Wednesday, 18 September 2013

jQuery event won't work on dynamically fetched HTML

jQuery event won't work on dynamically fetched HTML

Suppose I want to change the innerHTML of all span tags when they are
clicked that have the attribute 'data-change':
$('span[data-change]').click(function(){
$(this).text('Text was changed dynamically');
});
Now, if I add a new span tag with data-change attribute inside my html
document using jQuery on javascript, the onclick event won't work on the
newly added span tags. Why? And how can I make them work? Thanks!

Dealing with TFS branches in TeamCity

Dealing with TFS branches in TeamCity

Over the years I've used three different strategies to build from seperate
TFS branches in TeamCity builds:
used different VCS roots for the two branches, each pointing to the full
TFS path of the branch
used a shared VCS root, and parameterized some of the path
used a shared VCS root pointing at the root of the source tree, and used
different checkout rules per project (eg +:MyBranch => . )
My question is: what is the 'best' one, and what are the pros and cons of
the three approaches?

Migrate WordPress users (with passwords) to DotNetNuke

Migrate WordPress users (with passwords) to DotNetNuke

We are thinking about moving a site from WordPress to DNN. The WP site has
81 users and I'm wondering if I can avoid having them create new passwords
when the DNN site goes live. I don't know what plug-in (or if I need one)
I'll be using for DNN user management yet (I'm new to DNN). I know the WP
site is just using the built-in user list, with the "Members Only" plugin
to require log-in.
I imagine I can get access to whatever format WP saves the passwords as...
but is this likely to be the same hash algorithm that DNN (or a popular
plugin) would use, and do I have easy access to any salt used?
It isn't too hard for users to reset their passwords, and is good practice
for them to change them from time to time anyway... Mostly, if it is easy
for me to avoid it, then I would like to try. If not a simple process, not
going to bother.

Wrapping arrays in Boost Python

Wrapping arrays in Boost Python

I have a series of C++ structures I am trying to wrap using boost python.
I've run into difficulties when these structures contain arrays. I am
trying to do this with minimal overhead and unfortunately I can't make any
modifications to the structs themselves. So for instance say I have
struct Foo
{
int vals[3];
};
I would like to be able to access this in python as follows:
f = Foo()
f.vals[0] = 10
print f.vals[0]
Right now I am using a series of get/set functions which works but is very
inelegant and inconsistent with accessing the other non-array members.
Here is my current solution:
int getVals (Foo f, int index) { return f.vals[index]; }
void setVals (Foo& f, int index, int value) { f.vals[index] = value; }
boost::python::class_< Foo > ( "Foo", init<>() )
.def ( "getVals", &getVals )
.def ( "setVals", &setVals );
I am fine with having the get/set functions (as there are certain cases
where I need to implement a custom get or set operation) but I am not sure
how to incorporate the [] operator to access the elements of the array. In
other classes which themselves are accessible with the [] operator I have
been able to use _getitem_ and _setitem_ which have worked perfectly, but
I'm not sure how I would do this with class members if that would even be
possible.

Mysql Java string get value of reference

Mysql Java string get value of reference

I have a result from a MySQL call in Java...
When I try to compare the string in an If statement, it does not
compare... because the operator == compares the string objects rather than
the value they contain (references)...
Is there a way to return the value rather than the reference to the value
in the following code?
while(rs.next())
{
String name = rs.getString( "name" );
if( name == "whatever" )
{
// Do something
}
}
The thing is, I understand the equal function does this, I was just
wondering if it's possible to get to the value of the referenced memory.
"pointer to value" kind of thing?

Bluetooth library in C#

Bluetooth library in C#

I recently downloaded 32Feet.NET library to work with Bluetooth Radio
Device in C#. When i tried to run a sample program included with 32feet
library set up file i am getting this error message
"Error 1 The type or namespace name 'InTheHand' could not be found (are
you missing a using directive or an assembly reference?) C:\Program Files
(x86)\32feet.NET\Samples\ObjectPush\DesktopListener\ListenerForm.cs 8 7
DesktopListener "

Value intialized before main() disappears

Value intialized before main() disappears

Can not understand weird program behavior - hopefully someone can explain.
dummy.h:
#ifndef DUMMY_H
#define DUMMY_H
#include <iostream>
class Dummy
{
int val;
public:
int Init(int new_val)
{
return val = new_val;
}
int Get()
{
return val;
}
Dummy():
val(-1)
{
std::cout << "constructed" << std::endl;
}
~Dummy()
{
std::cout << "deconstructed" << std::endl;
}
};

How to update contents of rich text box in form1 with values coming from form2 without closing form2?

How to update contents of rich text box in form1 with values coming from
form2 without closing form2?

I want to pass values between two Forms (c# both in active states). How
can I do it?
I have two forms: Form1 and Form2.
Form1 contains a rich text box and a button. When I click on that button,
Form2 should open and a text in rich text box should be sent to a textbox
in Form2 and Form1 should remain opened as well being on back of Form2.
Form2 contains a text box and a button where user edits a text in textbox
and when user clicks on a button then the edited text should be sent back
to the rich text box in Form1 and the Form2 should close/ stay opened and
Form1 should highlight the updated text in rich text box.
How can i do it? Can somebody help me to do this with a simple example?

Tuesday, 17 September 2013

How to load registers on emacs startup?

How to load registers on emacs startup?

Is there anyway to load a list predefined registers on emacs startup
instead of crazily inserting them manually?

How to debug coffeescript on the server with node

How to debug coffeescript on the server with node

I've got below code that is run with Coffeescript, NodeJS PhantomJS and
SpookyJS
try
Spooky = require 'spooky'
mysql = require 'mysql'
catch e
console.log e
Spooky = require 'node_modules/spooky/lib/spooky'
spooky = new Spooky(
casper: ->
logLevel: 'debug',
verbose: true
(err) ->
if (err)
e = new Error('Failed to initialize SpookyJS')
e.details = err
throw e
spooky.on 'error', (e) ->
console.error e
spooky.on 'log', (log) ->
if (log.space == 'remote')
console.log log.message
spooky.on 'console', (line) ->
console.log line
spooky.start 'http://www.website.com/'
spooky.thenEvaluate ->
console.log 'Hello, from', document.title;
spooky.run;
)
In the console when I run with coffee command, it comes up with [info]
[phantom] Starting... and hangs there.
Is there a way to debug this to find out what is going on or are there
something wrong with the syntax itself?

Monitor Number of Requests in Sinatra

Monitor Number of Requests in Sinatra

If I have a specific link in my sinatra, for instance say /requests, how
can I monitor the number of times the page is loaded. Ideally, I want to
be able to get a hit count for how many times a specific page on my server
is accessed. Thanks.

Best way to use Rand() when creating dummy data

Best way to use Rand() when creating dummy data

I'm making up some dummy data for some tables. For columns that are ints
this is easy enough. I have a few columns that are just enums, and I'm
trying to figure out how to randomize them. I'm trying to replicate this
kind of logic, but for SQL
CASE RAND()
WHEN BETWEEN (0,.3) THEN 'A'
WHEN BETWEEN (.31, .6) THEN 'B'
WHEN BETWEEN (.61, 1) THEN 'C'
What is the correct way to actually do this? I assume there's a much
better way, but I have very limited SQL experience.

Extracting lat/long from a BeautifulSoup object in python

Extracting lat/long from a BeautifulSoup object in python

I just started working with python's BeautifulSoup package for scraping.
In my code I get the following soup object
>>> soupObj
[u'$(function(){SEAT.PG.initDialog(".generate-popup-3030",[{msez:"3030",c:"#333",o:0.5,f:false,html:SEAT.PG.getImgPopHtml}]);SEAT.PG.mappaInterattiva({longitude:13.37489,latitude:42.36009,sito:"pgol",zoomLevel:"1",lng:1,mirino:"http://img.pgol.it/pgol/img/mk_pallino.png",allowFoto:true,mapType:null,streetView:false,dr:false,addMobile:false,ums:"sorellenurzia"});var
a=SEAT.commenti({__2011_commento_click_stella:"Clicca su una stella per
dare il tuo voto",__2011_commento_da_evitare:"Da
evitare",__2011_commento_di_meglio:"C\'\xe8 di
meglio",__2011_commento_non_male:"Non male",__2011_commento_mi_piace:"Mi
piace",__2011_commento_consigliato:"Consigliato",__2011_commento_scrivi:"Scrivi
una recensione per condividere la tua esperienza con gli altri
utenti",__2011_commento_breve:"Scrivi almeno 120 caratteri per dare
informazioni utili e complete a chi legger\xe0 la
recensione.",__2011_commento_manca_voto:"Ti sei dimenticato di dare un
voto",__2011_commento_servizio_non_disponibile:"Il servizio al momento non
\xe8 disponibile",__2011_commento_segnala:"Segnala la
recensione",__2011_commento_segnala_msg1:"Ritieni che questa recensione
sia offensiva o inappropriata a
PagineGialle.it?",__2011_commento_segnala_msg2:"La nostra redazione si
occuper\xe0 di controllarne il contenuto e, se necessario, di rimuoverlo
dal
sito",__2011_conferma:"conferma",__2011_annulla:"annulla",__2011_ha_scritto_il:"ha
scritto
il",__2011_pubblica:"pubblica",__2011_commento_modifica_recensione:"Modifica
recensione",__2011_conferma_notifica:"Aggiornamento via email
attivo",__2012_commenti_relatedopec:"Conosci anche queste
attivit\xe0?",__2011_elimina_notifica:"Aggiornamento via email non
attivo"});a.enableAbuse();a.enableRating()});']
I want to extract the lat/long part of from th object which is
longitude:13.37489,latitude:42.36009. I cannot use soupObj.string, so I
can use the re package to extract the lat/long from the string, so I am
not sure how to do this

What is that? Deserialization tries to invoke compiler?

What is that? Deserialization tries to invoke compiler?

Check out this stack trace:
http://pastebin.com/Xy5zgQgi
With this exception message:
Timed out waiting for a program to execute.
The command being executed was
"C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe"
/noconfig /fullpaths
@"C:\Users\administrator\AppData\Local\Temp\lfbuk35v.cmdline".
Can someone care to explain?

Sunday, 15 September 2013

Nesting CSS based on class of body

Nesting CSS based on class of body

I have multiple themes for my website, such as a light or dark theme. This
is applied via a class to body. I would like to apply certain styling if
body has dark.
I have tried this:
body.dark {
.sidebar {
background-color: #444;
}
.intro {
background-color: #CCC;
}
/* etc */
}
However, none of the styles are applied. What would be the correct way to
this condition?
I can do .sidebar.dark, however the current dark CSS file is in .intro,
.sidebar, etc.

Be sure that an input parameter fulfills multiple type criteria

Be sure that an input parameter fulfills multiple type criteria

I have two interfaces, A and B. I'm writing a function, and I want it to
only take in objects that use both interfaces. This is some of the things
I've been trying. I hope my question is clear.
public void function((? implements A,B) thing) {
// do things
}
public <T extends A, T extends B> void function(T thing) {
// do things
}
public <T extends A,B> void function(T thing) {
// do things
}
None of these attempts worked though. Thanks in advance for any insight
into this.

CSS in the html tags, text not staying in box

CSS in the html tags, text not staying in box

I'm sending emails within my PHP application. I know it's not recommended
but to keep things simple I just want to put the CSS style in the tags.
I've tried this:
<div style=\"width: 500px; height: 600px; background-color: green;\">
<h1>Title</h1>
<div style=\"width: 460px; height: 540px; background-color: white;
margin-top: 10px; margin-left: auto; margin-right: auto;\">
$content
</div>
</div>
The styling works fine but the $content string is quite long and the text
just flows out of the box instead of neatly going to the next line. Is
this something particular when you use the style attribute in tags? Or
does it have to do with the way email clients read the email out?
Is there a way I can fix this without using an external CSS file?

Writing a script to download a file at a particular time from a server/site?

Writing a script to download a file at a particular time from a server/site?

I would like to write a script, a python script which will download a
particular video that will be up at a particular time(mostly live stream
download). How to go about it?
Say I am downloading a video file from projectfree tv, an episode. How to
start it? Any ideas that can be shared?

How to add footer to gridview

How to add footer to gridview

I have a grid with 3 columns - Edit, ID, Movie. I would like to add a
footer with an Insert link button, 2 textboxes respectively, but unable to
do so. Is it possible.
ASPX:
<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="False"
OnRowEditing="gridview1_RowEditing"
OnRowCancelingEdit="gridview1_RowCancelingEdit"
ShowFooter="true" >
<Columns>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
<asp:BoundField DataField="id" HeaderText="ID" />
<asp:BoundField DataField="movie" HeaderText="MOVIE" />
</Columns>
</asp:GridView>
When I try the following, there is an error for commandfield which says,
this element is not supported.
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lnkInsert" runat="server"
Text="Insert"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</columns>
The other way would be to use itemTemplate & EditTemplate for each column
control. But I find this simple and would like to proceed this way. So Can
I add a footer to this structure.

confusion on delegation by using the new on method

confusion on delegation by using the new on method

I have a li (<li>) that contain a checkbox, and the li I used on() with an
event, like this:
$('li').on('click', 'li', function(){
});
what happen if I don't put the 2nd parameter which is li?
I click on my checkbox which I also apply to click(), the li's event fire..
how delegation work? I'm confused with the uses of on() since the delegate
method had been deprecated..

Grouping Data in a Matrix in MATLAB

Grouping Data in a Matrix in MATLAB

I've got a really big matrix which I should "upscale" (i.e.: create
another matrix where the elements of the first are grouped 40-by-40). For
every 40-by-40 group I should evaluate a series of parameters (i.e.:
frequencies, average and standard deviation).
I'm quite sure I can make such thing with a loop, but I was wondering if
there was a more elegant vectorized method...

Saturday, 14 September 2013

Canvas text looks horrible

Canvas text looks horrible

I have the following code to draw text
ctx.fillStyle="red";
ctx.fillRect(player.x, player.y, 10, 10);
ctx.fillStyle="white";
ctx.font="bold 20px sans-serif"
ctx.fillText(player.name,player.x,player.y)
Unfortunately, it looks horrible. Really blocky.

I attempted to shrink it down to 10px, which is the size of the red box,
but then it looks even worse. What am I doing wrong?

Regex select the last numbers after the /

Regex select the last numbers after the /

in this example
BIOLOGIQUES
3433 130906 / 3842
to select 3433 I use
BIOLOGIQUES\s+(\d+)
But what changes should I do to select the last one 3842?

pure AS3 project:dynamically create 2 graphic object sprites instead of using SWC's

pure AS3 project:dynamically create 2 graphic object sprites instead of
using SWC's

I've been trying to learn to code in pure AS3 instead of using Flash Pro
CS6, with IntelliJ IDEA 12 as an IDE (BTW, a really nice tool!), Flex/AIR
SDK's to compile. Found a good learning tutorial:nodes game in AS3,
including source code and FLA. The 2 graphic objects (DraggableNode and
Target, both circles made into sprites in the source files attached to the
tutorial) could be done in my copy of CS6 and exported as SWC's, then
included in the IntelliJ project library. Instead, to avoid depending on
the SWC's, what I have tried unsuccessfully to do is write the 2 objects
in pure AS3 that can be used in the tutorial's script, instead of the
SWC's. Not as difficult just to create 2 new sprites, set a linestyle,
start and end fill, add child. But where/how to add in the existing script
and avoid errors? Tried for a couple of days, always errors, no joy. Am
stuck. If someone can take a look at the tutorial's script at the link,
suggest where/how to add the 2 circles, would be a big help. Thank you in
advance.

How can use feedforward network to predict a sequence of time series without recurrent

How can use feedforward network to predict a sequence of time series
without recurrent

I want to use NARX to predict a future value of time series, then draw
result of 100 predict value. I don't want to use close loop because It's
recurrent network.I just use feed-forward network. And I also don't know
how to find the best number of neuron in hidden layer. Please help me
solve this proplem. Do you mind, please give me a sample code( just need a
simple network 1 hidden layer, 1 output neuron).

Why program is running in infinite loop?

Why program is running in infinite loop?

Hi have written a piece of java code which is running in infinite loop.
Below is the code :
public class TestProgram {
public static void main(String[] args){
Integer i = new Integer(0);
Integer j = new Integer(0);
while(i<=j && j<=i && i!=j){
System.out.println(i);
}// while loop ends
}// main ends
}//class ends
In the above code while seeing the condition in while loop, at first it
looks like that program will not go inside while loop. But actually it is
an infinite loop and keeps printing the value.
Can anybody clarify that what is happening here ?

How to keep playing YouTubePlayer in Android

How to keep playing YouTubePlayer in Android

Now I'm creating an Android application witch use YouTube api to play
Video. But the player stop when I change Activity. I want to keep Playing
like a Music Player even when Activity will change. I try to solve that by
adding Static on YouTubePlayer.(But cannot solve.)
I mean I want to Keep it's playing when the Activity or the Application
itself move to Background.
So if you have any ideas, please share with me :)
-----------------Code-----------------
public class PlayActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener,YouTubePlayer.PlayerStateChangeListener{
public static final String DEVELOPER_KEY = "My_Dev_Key";
private LinearLayout yPos;
private static YouTubePlayer yt;
private YouTubePlayerView ytp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.play);
yPos = (LinearLayout)findViewById(R.id.youtube_pos);
try{
ytp = new YouTubePlayerView(this);
ytp.initialize(DEVELOPER_KEY, this);
}catch(Exception e){
finish();
}
yPos.addView(ytp);
}
@Override
public void onAdStarted() {
// TODO Auto-generated method stub
}
@Override
public void onError(ErrorReason arg0) {
// TODO Auto-generated method stub
}
@Override
public void onLoaded(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onLoading() {
// TODO Auto-generated method stub
}
@Override
public void onVideoEnded() {
// TODO Auto-generated method stub
}
@Override
public void onVideoStarted() {
// TODO Auto-generated method stub
}
@Override
public void onInitializationFailure(Provider arg0,
YouTubeInitializationResult arg1) {
// TODO Auto-generated method stub
}
@Override
public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1,
boolean arg2) {
// TODO Auto-generated method stub
if(!arg2){
if(yt == null){
yt = arg1;
yt.setPlayerStateChangeListener(this);
yt.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
yt.loadVideo("u0v5A6cQOhs");
}
}
}
}

Android: Scrolling to slow on gridview?

Android: Scrolling to slow on gridview?

i have trouble to speed up the scrolling on gridview when I show the
thumbnail on the phone with getThumbnail. I know it's create a thumbnail
if not existed. I think of using AsyncTask to create the thumbnail in the
background. In my knowledge we can only have limited parallel execution of
the AsyncTask.
Does anyone know how to create a smooth scrollable gridvie? Please help.
Using cache is good but only if the thumbnail has been cached, but it
won't give a smooth scrolling for the new data.

How to show and hide DIV in angular

How to show and hide DIV in angular

I have two div(s)
<div id = 'a'>
</div>
<div id = 'b'>
</div>
click on "add" button i want to hide div a and show div b

Friday, 13 September 2013

Use twig in asset sentence

Use twig in asset sentence

It's possible to use a Twig result in asset sentence? See what I'm trying
below:
{% for entity in entities %}
<li title="{{ entity.getName }}" data-id="{{ entity.getId }}"
class="categories-first"><img src="{{
asset('bundles/dashboard/img/categories/{{
entity.getName|lower|replace("ó":"o") }}.gif') }}"></li>
{% endfor %}
But it's not loading the image since this {{
entity.getName|lower|replace("ó":"o") }} isn't evaluated, it's possible?
How?
Also related to this same topic, it's possible to remove special
characters from output? Let said á, é, í, ó, ú and so on?

MySQL error #1227 - Access denied; you need the SUPER privilege for this operation from godaddy to 1and1

MySQL error #1227 - Access denied; you need the SUPER privilege for this
operation from godaddy to 1and1

I exported my MySQL database from Godaddy and was getting ready to
transfer them to 1and1 and when I uploaded them to 1and1 I got this error
in the SQL query
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`cedsajoomla`@`%` SQL SECURITY
DEFINER VIEW `dnbhf_jf_languages` AS select `l`.`lang_id` AS
`lang_id`,`l`.`lang_code` AS `lang_code`,`l`.`title` AS
`title`,`l`.`title_native` AS `title_native`,`l`.`sef` AS
`sef`,`l`.`description` AS `description`,`l`.`published` AS
`published`,`l`.`image` AS `image`,`lext`.`image_ext` AS
`image_ext`,`lext`.`fallback_code` AS `fallback_code`,`lext`.`params` AS
`params`,`lext`.`ordering` AS `ordering` from (`dnbhf_languages` `l` left
join `dnbhf_jf_languages_ext` `lext` on((`l`.`lang_id` =
`lext`.`lang_id`))) order by `lext`.`ordering` */
Can someone tell me what I am doing wrong. I have also uploaded the error
to pastebin http://pastebin.com/WPr813RH Thank You in advance for your
help

Implementation issue: Not able to get a list of dicts (Json obj)

Implementation issue: Not able to get a list of dicts (Json obj)

I am not being able to retrieve the ids and nicknames of friends when the
client tries to retrieve a location. id and nickname (along with other
content fields) stored in User table and friend relation stored in Friend
table. I am new to SQLAlchemy and python in general so any help will be
appreciated.
obj = encoders.to_json(self, Loc.LOC_JSON_ATTRS)
my_friend_ids = user.Friend.select_friend_ids(requestor_id)
friend_creators = session.query(user.User). \
join(bc.Bc). \
filter(and_(
user.User.id.in_(my_friend_ids),
requestor_id == bc.Bc.creator_id,
self.id == bc.Bc.location_id)). \
all()
obj['friend_list'] = [{'id': friend.id, 'nickname': friend.nickname} \
for friend in friend_creators]
#print obj
if not obj['friend_list']:
print "empty"
else:
obj['num_created'] = 0
obj['num_phollowing'] = 0
obj['num_collected'] = 0
obj['friend_list'] = []

Convert time between UTC and specific timezone - New Internationalization API

Convert time between UTC and specific timezone - New Internationalization API

I am trying to use new Internationalization API .I use chrome Version
31.0.1623.0 canary
What I want is
Convert Date Time between UTC and specific time zone (America/New_York in
the example)
To check whether the conversion is Daylight Savings changes aware.
So, is it possible with the current level of support to convert between
these two timezone, when
a. Daylight savings is active
//EDT: 11/2/2013 01:04:05
//UTC: 11/2/2013 05:04:05
b. Not active
//EST: 11/3/2013 01:04:05
//UTC: 11/3/2013 06:04:05
Also why is it December, when I specify month 11 in the below example.
http://jsfiddle.net/kr8FW/2/
console.clear();
var dtf = new Intl.DateTimeFormat('en-US', {timeZone: 'America/New_York'});
//EDT: 11/2/2013 01:04:05
//UTC: 11/2/2013 05:04:05
var utc1 = new Date(Date.UTC(2013, 11, 2, 5, 4, 5))
console.log(dtf.format(utc1));
console.log(utc1.toLocaleString("en-US", {timeZone: "America/New_York"}));
//EST: 11/3/2013 01:04:05
//UTC: 11/3/2013 06:04:05
var utc2 = new Date(Date.UTC(2013, 11, 3, 5, 4, 5))
console.log(utc2.toLocaleString("en-US", {timeZone: "America/New_York"}));
The output was
Console was cleared (index):21
12/2/2013 (index):29
12/2/2013 12:04:05 AM (index):30
12/3/2013 12:04:05 AM

How would i create a custom dynamic url in codeigniter

How would i create a custom dynamic url in codeigniter

I hate the codeigniter custom urls where it's:
domain.com/controller/action/username
How can I have it like a normal website like: domain.com/username
Please give me a suggestion.

Thursday, 12 September 2013

XML to XML conversion - Modifying multiple words within a text

XML to XML conversion - Modifying multiple words within a text

I have been taking help from here often on various technologies. Asking
question for the first time though. Recently started using XML technology
at workplace. Stuck up at a crucial point. Actually I was working on XML
to XML conversion using XSLT 1.0.
The input xml looks like this:
<front>
<funding-group>
<award-group id="award1">
<funding-source id="GS1">A</funding-source>
<award-id rid="GS1">1</award-id>
</award-group>
<award-group id="award2">
<funding-source id="GS2">B</funding-source>
<funding-source id="GS3">C</funding-source>
<award-id rid="GS2 GS3">2</award-id>
</award-group>
</funding-group>
</front>
<body>
<p>This work was supported by the 9 Program Grant 1, A 309 and 311, and B,
C Grant 2.</p>
</body>
I need to convert this to below(note:funding-source becomes grant-sponsor,
award-id becomes grant-num and "funding-group" has been removed):
Output xml:
<body>
<p>This work was supported by the 9 Program Grant
<grant-num>1</grant-num>, <grant-sponsor>A</grant-sponsor> 309 and 311,
and the <grant-sponsor>B</grant-sponsor>, <grant-sponsor>C</grant-sponsor>
Grant <grant-num>2</grant-num>.</p>
</body>
Tried using string-replace as well as regex but couldn't succeed fully.
Really need your help guys.. Thanks..

Django CASE in queryset.extra with COUNT

Django CASE in queryset.extra with COUNT

I'm trying to use the COUNT'ed value of a joined table in a CASE statement
to tell whether a user has added content or not.
def get_queryset(self):
q = super(UserIndex, self).get_queryset()
q = q.annotate(story_count=Count('story'))
q = q.extra(select={
'added_content': '''
CASE
WHEN "story_count" > 0 THEN 1
ELSE 0
END
'''})
return q
Which blows up at the database level misuse of aggregate: COUNT(). Is
something like this even possible without having to resort to an extra
column that would require keeping track of?

How to get LGWR lag from oracle database

How to get LGWR lag from oracle database

I have to collect the lgwr process lag overtime. This information is in
the lgwr trace file, but I don't want to parse the trace files. Is there
any database table or view that stores this information and I can remotely
access it using DB connection. It would be great if anyone can provide me
with the query.

HOW TO CHANGE FROM CALENDAR TO DATE IN JAVA?

HOW TO CHANGE FROM CALENDAR TO DATE IN JAVA?

WHEN CHANGE CALENDAR OBJECT TO DATE FORMAT, IT PRINTS ONLY THE SYSTEM
DATE. IT DOES NOT PRINT THE USER GIVEN DATE....
public CalTest() {
super();}
public Date CaltoDate(Calendar myCal) {
myCal = Calendar.getInstance();
Date last_date_date=new Date();
try{
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
String TimeStop_Str = sdf.format(myCal.getTime());
last_date_date = new
SimpleDateFormat("dd-MM-yyyy").parse(TimeStop_Str);
}
catch(Exception e){
System.out.println(e);
}
return last_date_date;
}
public static void main(String[] args) {
CalTest t=new CalTest();
Date expectedDate=new Date();
try{
Calendar myCal=Calendar.getInstance();
myCal.set(2013,2,25);
System.out.println(myCal);
expectedDate=t.CaltoDate(myCal);
}
catch(Exception e){
System.out.println(e);
}
System.out.println(expectedDate);
}
}
THIS IS THE CODE...PLS HELP ME....I WANT TO CHANGE CALENDAR TO DATE WITH
THE USER GIVEN DATE...NOT THE SYSTEM DATE....

Python Metaclasses -- attributes not visible

Python Metaclasses -- attributes not visible

I'm trying to create 2 objects, 1) A by defining as a regular Python class
2) B by dynamically creating properties.
Once both the classes are created, Im trying to print their dictionary and
noticed that for Class B which is dynamically created the attribute "X" is
not listed.
class A(object):
def __init__(self,x,y):
self.x = 0
self.y = 0
x = A(1,2)
print "Class A directory =",dir(x)
class B:pass
B().x = 5
y = B()
print "Class A directory =",dir(y)
OUtput
Class A directory = ['__class__', '__delattr__', '__dict__', '__doc__',
'__format__', '__getattribute__', '__hash__', '__init__', '__module__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'x', 'y']
Class B directory = ['__doc__', '__module__']

More control over what is printed out when an exception is caught

More control over what is printed out when an exception is caught

Is there a way to grab specific information from an exception when an
exception occurs?
For example when I call printStackTrace I get a lot of information...but
sometimes I get too much information and most of it is not things I need
to see since it's always the same information anyways.
At least when it comes to Selenium Webdriver, it first tells me what the
problem is
com.thoughtworks.selenium.SeleniumException: Element blah not found
at
org.openqa.selenium.internal.seleniumemulation.ElementFinder.findElement(ElementFinder.java:92)
at
org.openqa.selenium.internal.seleniumemulation.Click.handleSeleneseCommand(Click.java:35)
at
org.openqa.selenium.internal.seleniumemulation.Click.handleSeleneseCommand(Click.java:1)
at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:35)
at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:40)
at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:140)
...
Caused by: org.openqa.selenium.WebDriverException: ...
...
...
...
/code/pre
pAnd then it goes on to tell me things about the my environment,
capabilities (with another list of messages), and more caused by
information./p
pIt's a pretty long message, and I don't want it cluttering my log file.
Is there a way to omit all of the caused by related messages?/p
pI tried codegetMessage/code but it only says/p
precodeElement blah not found
/code/pre
pWhich is not useful. I would like to at least see which line it came from./p

URL Rewriting don't work in my apache2

URL Rewriting don't work in my apache2

I have a problem with my apache2, the url rewriting don't work and I don't
know why...
In my phpinfo(), I have:
Loaded Modules: mod_rewrite
My .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^test\.html$ /test.php [L]
My Apache config:
<VirtualHost>
ServerAdmin mail@gmail.com
ServerName www.site.com
ServerAlias site.com
DocumentRoot /var/www/site.com/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/site.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I think my config is right, but I really don't know why my rewriting don't
work... Have you an idea ?
Thanks you so much !

How to track new commits with Git?

How to track new commits with Git?

I'm writing an external Git plugin. It should process commits in Git and
create some entity in another system if commit contains some text.
I clone Git repository locally and fetch it periodically. During fetch I
want to discover which new commits were added since last synchronization.
Is there any easy way to do this?
One solution is to create local branches, and after fetch discover the
difference between local branch and origin branch. But what to do if there
was forced update on remote branch? In that case difference can be huge,
and the same commits can be processed twice.
Git 'fetch' command definitely can do this. So I hope there is some easy way.

Wednesday, 11 September 2013

Postgresql: how statistics are collected in the histogram_bounds

Postgresql: how statistics are collected in the histogram_bounds

The documentation of Postgresql is the explanation that this
histogram_bounds field in pg_stats.
The histogram divides the range into equal frequency buckets, so all we
have to do is locate the bucket that our value is in and count part of it
and all of the ones before.
But I still can not understand how the algorithms based on this field. I
would like to describe in more detail how ANALYZE puts value in this
field.

dynamically display pdf to user

dynamically display pdf to user

Please i realy need help with this
I'm try to convert pdf to swf using this codes This is the working one
code explanation:
//docs: is the location the pdf is located.
echo exec("D:\wamp\www\dspzlibrary\converter\pdf2swf.exe docs/book.pdf -o
docs/book.swf -f -T 9 -t -s storeallcharacters");
why this one is not working
//file name $file = "vsomaths";
echo exec("D:\wamp\www\dspzlibrary\converter\pdf2swf.exe docs/$files.pdf
-o docs/$file.swf -f -T 9 -t -s storeallcharacters");
I want to execute the the exe function dynamically using selected file name.
Thanks alot.

Changing MVC Razor Img src with javascript

Changing MVC Razor Img src with javascript

This is a MVC application. I have a IEnumberable(Of T) viewmodel that is
passed in to the partial view. There will be a next and prev. image button
on the lower part of the page. The Idea is simple. When the user clicks
the Next Button it shows the next image and when they click the prev.
button it shows the previous image. I have started working on the below
javascript to achieve this. However as I am totally new to javascript I
feel that I am missing something here.
<script type="text/javascript">
var c = 0;
function PreviousImage() {
c -= 1;
if (!c < 0) {
('@m')=c
document.getElementById("photoBox").src =
('@Url.Content(String.Format("~/PropertyImages/{0}/{1}",
Model(m).PropertyImageFolder, Model(m).PhotoName))')
}
}
the div container for the image and the buttons is as follows:
<div>
<img src="" id="photoBox" />
<input type="button" id="NextImage" value="Next Image" /><input
type="button" id="PrevImage" value="Previous Image"
onclick="PreviousImage()" />
</div>
m is just a vb local variable in the view that gets set when c is
incremented. So that I can get the model item by index.
Any suggestions? Am I on the right Track? Or is this a total fail of an
attempt at what I am after?

How do I resolve Labview load conflicts

How do I resolve Labview load conflicts

I am developing a data acquisition program in Labview that uses multiple
translation stages, cameras, a high speed digitizer, and other
instrumentation. I'm developing the application on one computer, and will
be deploying it to another computer. The development computer has labview
2013, and computer the application will be deployed on currently has
Labview 2012, but we will be upgrading it to Labview 2013 when we move the
application over there. Some of the drivers need different versions of the
driver to function under Labview 2012 than they do for Labview 2013. I'm
trying to keep all of the vi's, subvi's, and drivers for the
instrumentation in one directory tree so that I can move the whole tree
over to the computer it will be deployed on.
When I load the project in Labview I'm getting a lot of "Resolve Load
Conflict" dialog boxes popping up. When I go to investigate, Labview says
it can't find one of the files that is causing the conflict, but yet it
popping up the dialog. An example is below:

This happens every time I load this project - saving all doesn't enter the
new paths into Labview. I also tried creating a new project, and pulling
these vi's in, but the new project has the same load conflicts.
Evidently Labview or these vis think that these vi's that no longer exist
are still there.
How do I fix my project, vi's, or Labview so that it only uses the vi's
that it should, and I don't get all of these conflicts, many of which are
with nonexistent files?

Piping matrix to file/only numbers are piped

Piping matrix to file/only numbers are piped

I have a Matrix which I got through
l = cutree (clus, k = 1:j)
which looks about like:
bs 1 1 1 1 2
x 1 1 2 2 3
v 1 1 2 2 3
e 1 1 2 2 3
nn 1 1 1 3 4
j 1 2 3 4 5
Now, I wanted to write l to a file, using:
write(l, file = "datia", ncolumns = 6)
However, only the Numbers are piped to the file, not the labels.
How can I change this?

How can I return the key of the last item in an array matching a value?

How can I return the key of the last item in an array matching a value?

How do you recommend fetching the key of the last matching value in an array?
$arr = array(
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 5,
7 => 5,
8 => 5,
9 => 5, // <--- this is the key I'm after!
10 => 6,
11 => 7,
12 => 8,
13 => 9,
14 => 10,
15 => 11);
function returnLastMatching($haystack,$needle) {
// return 9
}
echo returnLastMatching($arr,5); // "9"

Tuesday, 10 September 2013

How to combine two different strings in one string in c#

How to combine two different strings in one string in c#

I have checked most of the questions might contain my solution but I
couldn't find any. Or maybe I didn't understand. So, here is my question:
I want to combine two strings in one and keep using it alone.
My strings:
static string name = ""; (for example: John or Jane)
static string gender = ""; (for example: Mr. or Mrs.)
and I want to combine these two in one like this:
static string player = gender+name;
Console.writeline("Hello "+player);
and I want to see it in my console like this:
Hello Mr.John or Hello Mrs.Jane
I didn't want to mention console.readline parts. There will be entries
where I will type name and gender. Thanks
EDIT:
This is what I did (Sorry, it take too long):
static string name = "";
static string gender = "";
static string player = name + gender;
static void Main(string[] args)
{
Console.WriteLine("Welcome. What is your name?");
name = Console.ReadLine();
Console.WriteLine("Sex?\n-Male\n-Female");
gender = Console.ReadLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.WriteLine("Welcome"+player);
Console.ReadLine();
}
These result like "Welcome __"

HTML Input Type Date - Select and Collapse

HTML Input Type Date - Select and Collapse

When using an input type date in HTML5, after the user clicks on a date,
the calendar stays expanded forcing them to click away from the calendar
to make it collapse. I'd like for this to happen in a single click (i.e.
when they click on the calendar, the date is recorded, the calendar
collapses and they can get on to other business). Can anyone tell me how
to do this? Thanks!
<label>Date</label>
<input type="date" id="my_date">

Perl Regex to get a substring between two of the same characters

Perl Regex to get a substring between two of the same characters

Given some string originalString = "#SomeWord# More words" I want to be
able to get the substring "SomeWord" from the originalString.

Serve Key: "Key" & Value: "Value" as Key: Value

Serve Key: "Key" & Value: "Value" as Key: Value

I have dynamic keys and values that I get from db and then parse with
Newtonsoft Json.NET but I don't know how can I serve them as static ones.
Example
This is what I have
{
"Id": 1,
"IsPublic": false,
"Notes": "",
"Values": [
{
"Key": "1",
"Value": "12.02.1991"
}
]
}
This is what I want
{
"Id": 1,
"IsPublic": false,
"Notes": "",
"Values": [
{
"1": "12.02.1991"
}
]
}
What I have tried
I tried to do it manually inside my query itself but it didn't work since
it's trying to assign the value.
return _db.Archives.Single(x => x.Id == id).Batches.SelectMany(x =>
x.Items).Select(item => new
{
item.Id,
item.IsPublic,
item.Notes,
Values = item.ArchiveFieldValues.Select(value => new
{
/*
This works just fine
Key = value.ArchiveField.Key,
Value = value.Value
*/
// This is what I tried but it does not work
value.ArchiveField.Key = value.Value
})
}).AsQueryable();