Saturday, 31 August 2013

gmail Sidebar gadget is not showing

gmail Sidebar gadget is not showing

i am following this tutorial
https://developers.google.com/gmail/sidebar_gadgets when i am trying to
add a Hello World sidebar gadget to my gmail. i first hosted it on
http://cloudfactor9.appspot.com/ after that i added it in gadgets as you
can see in screen shot after that when i signout and signin into my gmail
there is no Hello World widget.can any one please tell why i am not able
to see Hello World widget ?? screenshot of gmail is

jQuery ui autocomplete inside dialog

jQuery ui autocomplete inside dialog

I have this code:
$.ajax({
url: '/products/edit',
type: 'post',
data: {id: id},
success: function( data ) {
$( '#divDialog' ).html( data );
$( '#divDialog' ).dialog({
autoOpen: false,
height: 300,
width: 400,
modal: true,
resizable: false,
title: 'Edit Product',
closeOnEscape: false,
open: function() {
$( this ).parent().css( 'overflow', 'visible' );
$$.utils.forms.resize();
}
})
.find( 'button#cancelButton' ).click( function() {
var $form = $(this).parents( '.ui-dialog-content' );
$form.find( 'form' )[0].reset();
$form.dialog( 'close' );;
$form.dialog( 'destroy' );;
})
.end().find( 'button#saveButton' ).click( function() {
var $form = $(this).parents( '.ui-dialog-content' );
$form.validate({
submitHandler: function( form ) {
$.ajax({
url: '/products/edit',
type: 'post',
data: form.serialize(),
success: function( data ) {
$.jGrowl( data );
$form.dialog( 'close' );;
}
});
}
});
});
// show dialog
$( '#divDialog' ).dialog( 'open' );
}
});
So, I append a form to my div $('#divDialog'). My question is how to use
jQuery autocomplete to any input of my form?

haskell program to remove part of list and print the rest

haskell program to remove part of list and print the rest

How do i remove part of a list in haskell. This is what i have done so
far.Please tell me what are the changes that can be made:
enter code here
import Data.Lists
import Data.List.Split
removePrefix :: Eq t => [t] -> [t] => Maybe [t]
removePrefix [][] = Nothing
removePrefix ts[] = Just t's
removePrefix(t:ts)(y:ys) = if inTnFixOf(y:ys)(t:ts) == True
then SrtipPrefix(y:ys)(t:ts)
else Just [(x:xs)]
Example output : input"toyboat" output "boat"

umbraco 6 creating database 5%

umbraco 6 creating database 5%

I am new to Umbraco and I am trying it out. I am running Windows Server
2012 with iis 8. I am installing manually. I am getting stuck on the page
after you input your database information. I inter the information and
then the page comes up after I hit continue. This page says connecting to
database and shows 5% and just stays stuck there and does not move on. The
database tables are being created but the page does not move on to the
next step. Anyone have any ideas what could be wrong or how to solve this
problem? I am trying to install Umbraco 6.1.4 and I am using SQL server.

PHP Division with variables, not working

PHP Division with variables, not working

I am having some difficulties dividing a cart total on an e-commerce site,
in order to create a deposit amount for a customer to pay.
As you'll see below, I am trying to display 25% of the order total as a
deposit amount. however, I have tried many variations of this, and all
return "0".
If I echo any of the variable independently, they echo the correct value,
but when dividing one by the other the result is "0" everytime.
Any help is appreciated, I feel like I am missing something very simple..
Thanks
<?php $amount = $woocommerce->cart->get_total(); ?>
<?php $percent = 4; ?>
<?php $deposit = $amount / $percent; ?>
<strong><?php echo $deposit; ?></strong>

What is the difference between private and private[Class] declaration in scala?

What is the difference between private and private[Class] declaration in
scala?

The class below compiles. How can I see the difference between those two
scopes if there is any?
class C1 {
private val p = 0
private[C1] val pClass = 1
def m1(other: C1) {
println(other.p)
println(other.pClass)
}
}

Conversion of program from JAVA to C++

Conversion of program from JAVA to C++

Here's a program I have written in JAVA and I need to convert it to C++.
This program converts a prefix expression to postfix expression using
STACK. All I need is the equivalent of this program in c++ with same
logic.
package ExpressionConvert;
import java.util.Scanner;
class STACK{
//Private Declarations
private int top, MAX;
private String a[] = new String [1000];
//Public Declarations
public STACK(){
top = -1;
MAX = 1000;
a[0] = "";
}
public void push(String x){
if (top <= MAX-1){
a[++top] = x;
}
else{
System.out.println("Stack overflow");
}
};
public String pop(){
if (top == -1){
System.out.println("\nStack empty!");
return "\n";
}
else{
return a[top--];
}
};
public int getTop(){
return top;
};
}
public class Prefix2Postfix_revised_stack {
static boolean isOperator (char ch){
switch (ch){
case '+':
case '-':
case '*':
case '/':
case '$':
return true;
default :
return false;
}
}
public static void main(String[] args) {
//declarations
Scanner in = new Scanner (System.in);
String exp;
int i, j=-1;
STACK s = new STACK ();
String temp[] = new String[100];
String postfix_exp = "\n";
//input
System.out.println("Enter prefix expression (No spaces or
brackets) : ");
exp = in.next();
//converting string exp into stack of characters converted to strings
for (i=0; i<exp.length(); i++){
s.push(Character.toString(exp.charAt(i)));
}
//Using stack to remove convert and re-insert strings
while(s.getTop() >= 0){
temp[++j] = s.pop();
if (isOperator(temp[j].charAt(0))){
temp[j] = temp[j-1].concat(temp[j-2].concat(temp[j]));
postfix_exp = temp[j];
temp[j-2]=temp[j];
j = j-2;
for(int x=j; j>0; j--)
s.push(temp[x]);
}
}
//Output
System.out.println("After converting to postfix : " + postfix_exp);
in.close();
}
}
Here's what I tried to create but it does not work.
#include<iostream.h>
#include<conio.h>
#include<string.h>
class STACK{
private:
int top, MAX;
char a[100][100] ;
//Public Declarations
public:
STACK(){
top = -1;
MAX = 100;
a[0][0] = ' ';
}
void push(char x[]){
if (top <= MAX-1){
strcpy(a[top++],x);
}
else{
cout << "Stack overflow";
}
};
public char* pop(){
if (top == -1){
cout << "\nStack empty!";
return "\n";
}
else{
return a[top--][];
}
};
public int getTop(){
return top;
};
}
int isOperator (char ch){
switch (ch){
case '+':
case '-':
case '*':
case '/':
case '$':
return 1;
default :
return 0;
}
}
int main() {
//declarations
char exp[100];
int i, j=-1;
STACK s;
char temp[100][100];
char postfix_exp[100] = "\n";
//input
cout << "Enter prefix expression (No spaces or brackets) : ";
cin.getline(exp,100);
//converting string exp into stack of characters converted to strings
for (i=0; i<strlen(exp); i++){
s.push(&exp[i]);
}
//Using stack to remove convert and re-insert strings
while(s.getTop() >= 0){
strcpy(temp[++j],s.pop());
if (isOperator(temp[j].charAt(0))){
strcat (temp[j][],strcat(temp[j-2][].concat(temp[j]));
strcpy(postfix_exp,temp[j]);
strcpy(temp[j-2],temp[j]);
j = j-2;
for(int x=j; j>0; j--)
s.push(temp[x]);
}
}
//Output
cout << "After converting to postfix : " << postfix_exp;
return 0;
}
Please help.

Singly Linked List swap not working

Singly Linked List swap not working

I have been trying for some time now to achieve to swap pointers of nodes
in a singly Linked List without a lot of success, so any help would be
totally acceptable ( I have already read and tried to use in my code a lot
of answers from previous questions but it seems that i am doing something
wrong..)
Here is the code:
public void implementation() {
count = new long[5];
for (int i = 0; i <= 4; i++) {
count[i] = count2++;
}
Link[] nodeList2 = LinkList.Insert_Link(count,count.length);
for (int i = 0; i < nodeList2.length - 1; i++) {
nodeList2[i].next = nodeList2[i + 1];
}
for (int i = 0; i < nodeList2.length - 1; i += 2) {
LinkList.Swap_Node_Pointers(nodeList2[i], nodeList2[i + 1]);
}
// LinkList.Swap_Node_Pointers(nodeList2[1],nodeList2[1+1]);
LinkList.display(nodeList2);
}
And the code of the Insert, Swap_Node_Points and display is:
public Link[] Insert_Link(long[] value, int countlength) {
final Link[] nodeList = new Link[countlength] ;
for (int i = 0; i < nodeList.length; i++) {
nodeList[i] = new Link();
nodeList[i].value2 = value[i];
}
return nodeList;
}
public void display(Link[] b) {
Link[] nodeList2 = b;
for (int i = 0; i < nodeList2.length; i++) {
System.out.println("The value is" +nodeList2[i].value2);
System.out.println("");
}
}
public void Swap_Node_Values( final Link n1, final Link n2) {
long value;
// Link temp = null;
value = n1.value2;
n1.value2 = n2.value2;
n2.value2 = value;
}
public void Swap_Node_Pointers(Link n1,Link n2) {
Link temp = n1.next;
n1.next = n2.next;
n2.next = temp;
}

Friday, 30 August 2013

MySQL Syntax error? Strange error

MySQL Syntax error? Strange error

I need some help finding an error in my code. I'm trying to create a
database with Xammp. It's giving me this error:
You have an error in you SQL syntax; check the manual that corresponds to
you MySQL server version for the right syntax to use near ",'787') at line
1 (787 is what I entered in the ResearchCost section)
Here is my code:
<?php/*mysql_connect(servername,username,password); */
mysql_connect("localhost","root","admin") or die(mysql_error());
mysql_select_db("EndlessSpace") or die(mysql_error()); $NodeName =
$_POST["ResearchCost"]; $Quadrant = $_POST["BestPrerequisiteNode"];
$ResearchOpts = $_POST["BestRace"]; $Effects = $_POST["NodeName"];
$Influence = $_POST["ResearchOpts"]; $query=mysql_query("INSERT INTO
Requirements
(ResearchCost,BestPreRequisiteNode,BestRace,NodeName,ResearchOpts) VALUES
('$ResearchCost','$BestPrerequisiteNode','$BestRace',
'$NodeName','$ResearchOpts')") or die(mysql_error()); ?>

Thursday, 29 August 2013

Android - check for incoming SMS in a certain amount of time

Android - check for incoming SMS in a certain amount of time

I am new to Android development and I am developing an app that
communicates with a remote GSM phone via SMS. I have been able to send the
SMS request from Android to the remote phone.
Now what I would like to do is to check if the remote phone sends back an
SMS within 20 seconds. Within this 20s, if the SMS is received the app
will immediately proceeds to processing the data sent via SMS, otherwise
it will give the user a timeout notification.
I have read the documentation on BroadcastReceiver but it seems that the
system only allows about 10s before it kills the receiver. Also there
doesn't seem to be a way to kill the receiver as soon as the SMS is
received.
I am pretty clueless as to how this can be done.
Any help is greatly appreciated.

Lauterbach always steps into timer isr

Lauterbach always steps into timer isr

I am new to the Lauterbach debugger (Trace32) and seem to have made some
unintended changes that complicates my debugging.
In the Lauterbach debugger is it possible to disable tracing and debugging
for parts of the code?
In my case, every time I step from a breakpoint I jump into a timer-isr.
This makes it very hard to single-step the code. Is it possible to disable
timer when a breakpoint is hit?
The same with the Trace.List where I almost only see timer-isr code.
I'm not interested in the timer-isr at all and would like to step and
trace the application code.
If I remember correct I didn't have this problem before and I might have
changed some configuration in Trace32.

Eclipse Java build path

Eclipse Java build path

I am using RAD 7.5. In window->Preferences ->Java->Installed JREs I have
mentioned all the Jar files from the RAD JDK (location: C:\Program
Files\IBM\SDP\jdk - RAD install in C:\Program Files\IBM location). Now in
my Java Project's JRE System Library some of the Jars from mentioned
Install JRE location missing.
If anybody has any Idea of it please help me out.

Wednesday, 28 August 2013

Error: Database server connection limit exceeded in SQL Anywhere. Does this error has anything to do with calling dispose()?

Error: Database server connection limit exceeded in SQL Anywhere. Does
this error has anything to do with calling dispose()?

As the title suggesting, I've been doing some research on the cause of
this error. Then I saw this which primarily suggesting that it is most
likely related to license number. However, at the very bottom there was a
reply suggesting that calling dispose() for connection object would also
be a solution. Is this true?
Note: we are using Entity Framework 4.0 and SQLAnywhere 16

How to start special init event in a backing bean before JSF page loads?

How to start special init event in a backing bean before JSF page loads?

PF 3.5.10, Mojarra 2.1.21, Omnifaces 1.5
How to call special init()-method of some (CDI)SessionScoped bean before I
load a .xhtml JSF page ? Now I call init() if user select the page from
site menu (with p:menutitem). But what to do if the user use browser
address line to type url directly?

Trouble trying to restart my Java program

Trouble trying to restart my Java program

After looking up numerous ways to restart a Java program within itself, a
while loop seemed like the easiest option. Here's an example of a basic
calculator program I'm trying this with:
import java.util.Scanner;
class a {
public static void main(String args[]){
boolean done = false;
int oper;
Scanner input = new Scanner(System.in);
System.out.println("McMackins Calc v2.0 (Now with fewer crashes!)");
while (!done)
{
System.out.println("What operation? (0 for quit, 1 for add, 2 for
subtract, 3 for multiply, 4 for divide, 5 for divide with remainder, 6
for average, 7 for account interest):");
while (!input.hasNextInt()){
System.out.println("Enter a valid integer.");
input.next();
}
oper = input.nextInt();
switch (oper){
case 0:
done = true;
break;
case 1:
add addObject = new add();
addObject.getSum();
break;
case 2:
sub subObject = new sub();
subObject.getDifference();
break;
case 3:
times multObject = new times();
multObject.getProduct();
break;
case 4:
divide divObject = new divide();
divObject.getQuotient();
break;
case 5:
remain remObject = new remain();
remObject.getRemainder();
break;
case 6:
avg avgObject = new avg();
avgObject.getAvg();
break;
case 7:
interest intObject = new interest();
intObject.getInterest();
break;
default:
System.out.println("Invalid entry.");
break;
}
}
input.close();
}
}
However, this seems to throw out a NoSuchElementException at the end of
the first time through the loop, and crashes the program. The function of
this class is to take the initial input from the user to determine which
class to use, which will determine which mathematical operation to
perform. Everything works fine without the while (!done) loop.
I've also tried just having the other classes refer back to this one, but
since main is a static method, I cannot access it the way I intended.
Note that I'm a bit of a beginner at Java, which is why my program is
pretty simple, so try to keep it simple if it can be, or post code and
then in DETAIL explain what it means so I can not only fix this problem,
but future ones as well.
Thank you!

set system date and time within c++ program in linux

set system date and time within c++ program in linux

In my program user selects date and time in an extjs form and then data
will be send to the server side (c++ program). In the server program date
and time will be applied to the system as below:
int main(){
string date = "2013-08-28T00:00:00";
string newtime = "09:12";
time_t mytime = time(0);
struct tm* tm_ptr = localtime(&mytime);
if (tm_ptr)
{
tm_ptr->tm_mon = atoi(date.substr(5,2).c_str()) - 1;
tm_ptr->tm_mday = atoi(date.substr(8,2).c_str());
tm_ptr->tm_year = atoi(date.substr(0,4).c_str());
tm_ptr->tm_min = atoi(newtime.substr(3,2).c_str());
tm_ptr->tm_hour = atoi(newtime.substr(0,2).c_str());
printf("%d\n%d\n%d\n%d\n%d\n",
tm_ptr->tm_mon,tm_ptr->tm_mday,tm_ptr->tm_year,tm_ptr->tm_min,tm_ptr->tm_hour);
const struct timeval tv = {mktime(tm_ptr), 0};
settimeofday(&tv, 0);
}
return 0;
}
But when running this code system crashes! I have another code for
applying date and time:
int main(){
string date = "2013-08-28T00:00:00";
string newtime = "09:12";
string newdate = "";
string monthnum = date.substr(5,2);
string month = "";
if(strcmp(monthnum.c_str(),"01") == 0) month = "Jan";
else if(strcmp(monthnum.c_str(),"02") == 0) month = "Feb";
else if(strcmp(monthnum.c_str(),"03") == 0) month = "Mar";
else if(strcmp(monthnum.c_str(),"04") == 0) month = "Apr";
else if(strcmp(monthnum.c_str(),"05") == 0) month = "May";
else if(strcmp(monthnum.c_str(),"06") == 0) month = "Jun";
else if(strcmp(monthnum.c_str(),"07") == 0) month = "Jul";
else if(strcmp(monthnum.c_str(),"08") == 0) month = "Aug";
else if(strcmp(monthnum.c_str(),"09") == 0) month = "Sep";
else if(strcmp(monthnum.c_str(),"10") == 0) month = "Oct";
else if(strcmp(monthnum.c_str(),"11") == 0) month = "Nov";
else if(strcmp(monthnum.c_str(),"12") == 0) month = "Dec";
newdate = "\"" + month + " " + date.substr(8,2) + " " +
date.substr(0,4) + " " + newtime + "\"";
system("date --set newdate");
return 0;
}
when running this code an error was occurred as below: date: invalid date
"newdate"
I can't understand the problem of these codes!

Tuesday, 27 August 2013

Should I include both package.json and bower.json?

Should I include both package.json and bower.json?

I already have a bower.json because my project is registered in it, are
there differences between the bower.json file and the package.json file
that grunt.js uses? Could this possibly work?
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('bower.json'),
...
});
...
};

Fast projectiles don't always hit

Fast projectiles don't always hit

So for my game, a have a fast moving Bullet object, with a sprite that's
5x5 (roughly). Moving at about a speed of 30, it needs to impact a
relatively thin Enemy object with a thickness of only about 5 pixels. At
certain regular intervals of distance, the Bullets pass through the enemy
without a collision.
I think its because the bullet is moving so fast that it happens to "jump"
over the enemy, hence the regular intervals. other than increasing the
width of the Bullet or Enemy, is there a way to guarantee that a collision
is properly detected?

How to make google chrome work after a host name change

How to make google chrome work after a host name change

This is the code i get when i try and launch gooogle chome. "The profile
appears to be in use by process 2137 on host Brandon PC. If you are sure
no other processes are using this profile, delete the file
/home/brandon/.config/google-chrome/SingletonLock and relaunch Google
Chrome." How do i fix this.

Twitter Stream API to get 1000 users tweets

Twitter Stream API to get 1000 users tweets

I am using twitter stream API to get tweets from user. I have list of user
Id How would i add this as input in the TwitterStream API. I have analyzed
the following sample but no idea to add user id to get user tweets
https://github.com/yusuke/twitter4j/blob/master/twitter4j-examples/src/main/java/twitter4j/examples/stream/PrintUserStream.java
How would i add similar to this
FilterQuery fq = new FilterQuery();
String keywords[] = {"France", "Germany"};
fq.track(keywords);
twitterStream.addListener(listener);
twitterStream.filter(fq);

Different versions of python-requests on identical systems

Different versions of python-requests on identical systems

I have two VMs, both running Ubuntu 12.04.3 LTS
$ cat /etc/issue
Ubuntu 12.04.3 LTS \n \l
And I have installed python-requests through apt-get on both systems.
However, on one VM I have version 1.2.3 and the other 0.8.2..
>>> requests.__file__
'/usr/local/lib/python2.7/dist-packages/requests/__init__.pyc'
>>> requests.__version__
'1.2.3'
The other system:
>>> requests.__file__
'/usr/lib/python2.7/dist-packages/requests/__init__.pyc'
>>> requests.__version__
'0.8.2'
How can this be? What might I have done that caused this?
I can see that the file indicates that the newer version is located in
/usr/local, can that give any hint of the problem?

Convert string to TimeSpan doesn't work

Convert string to TimeSpan doesn't work

i'm trying to convert a string into timeSpan but i can't seem to do it.
i'm using c++ managed code:
TimeSpan timeSpan;
if (TimeSpan::TryParse("01.55", timeSpan))
{
int minute = timeSpan.Minutes;
int hours= timeSpan.Hours;
//do some work here
}
the TryParse is returning flase. what am i doing wrong ?
Thank you,

Generic class issues when typecasting in constructors base() call c#

Generic class issues when typecasting in constructors base() call c#

I'm having issues in understanding how to typecast an object into its
parent that was using a generic.
I get the error
Cannot convert type 'TeamTrackerExposure.TTFileUploadDict' to
'JadeSoftware.Joob.MemberKeyDictionary<JadeSoftware.Joob.JoobDictionaryKey,JadeSoftware.Joob.JoobObject>'
in the constructor
public AC_TTFileUploadDict(DbJoobContext proc, TTFileUploadDict obj,
TTPage page)
: base(proc, (MemberKeyDictionary<JoobDictionaryKey,JoobObject >)
obj, page)
{
TTFileUploadDict has the following class definition
public partial class TTFileUploadDict :
MemberKeyDictionary<TTFileUploadDictKey, TTFileUpload>
{
.....
}
TTFileUploadDictKey's class definition is
public class TTFileUploadDictKey : JadeSoftware.Joob.JoobDictionaryKey
{
.....
}
and lastly TTFileUpload's
public partial class TTFileUpload : JoobObject
{
.....
}
I'm struggling to figure out how to typecast to a generic parent class,
any assistance on how to do this would be highly appreciated!!

Monday, 26 August 2013

C - Pop from Linked-list

C - Pop from Linked-list

I've implemented a Linked-List with a Pop function in C:
Node * pop (Node * head) {
Node * temp = head;
printf("Temp is: %s\n", temp->val);
if (head->next != NULL) {
*head = *head->next;
}
printf("Temp is: %s\n", temp->val);
return temp;
}
And the output when I pop would be something like:
Temp is: node1 value
Temp is: node2 value
That is to say that temp is becoming temp->next when I assign *head =
*head->next.
So how can I get the value of the current head and return it while also
moving the head of the Linked-list to head->next?
Doing head = head->next does NOT remove the reference to the first node.
(i.e. When I print the list, the first node is still there).
Thanks.

powershell combine column in CSV

powershell combine column in CSV

I am trying to automate a CSV file that contains lots of rows of data.
Here is a sample:
==========================
= ID = Last Name =User ID=
= 22 = Smith = 0077 =
= 22 = Smith = 0078 =
= 22 = Smith = 0079 =
= 22 = Jones = 0081 =
and the list goes on.
What I want to do is Combine Column ID with Column Last Name and put it in
a new CSV file using Powershell. I tried the following:
@{n='ID';e={$.ID + "-" + $.Last Name}}
Not much luck with this though.
Any help would be appreciated.

How to center a webpage and make it expand to fit browser

How to center a webpage and make it expand to fit browser

I'm trying to get my webpage to expand horizontally to fit any browser
window but still have the content centered in the middle of the page. I
managed to do one or the other but cannot for the life of me figure out
how to make both work at the same time. If I set width and height to 100%
and have the body margins set to 0 auto it works great but then my content
is no longer centered and all the divs end up overlapping each other.
However, if I set the width to 900px then it's all centered and looks
great. But there's white space around it because it's not expanding to fit
the browser window.
Can anyone let me know the trick to making this work? I want it to look
like this page where the sides expand to fit the browser but all the
content remains centered in the middle:
Also, here is my CSS:
<style type="text/css">
body {
text-align:center;
margin:0px;
padding:0px;
width:100%;
height:100%;
}
body#home a#nav-home,
body#resume a#nav-resume,
body#portfolio a#nav-portfolio,
body#contact a#nav-contact
{
color: #dfadec;
text-decoration:none;
}
#container {
background-color:#eae5e5;
width:900px;
text-align:left;
margin: 0 auto;
height:auto;
}
#main {
padding-top:200px !important;
padding-bottom:120px !important;
width:900px;
margin-left: auto;
margin-right:auto;
}
#header {
position:fixed;
border-top:solid 15px #4d4d4f;
font-family:Open Sans;
font-size:30px;
color:#4d4d4f;
background-color:#FFF;
width:900px;
padding-bottom:45px;
}
#title {
padding-top:30px;
position:absolute;
margin-left:60px;
}
#footer {
color:#FFF;
position:fixed;
font-family:Open Sans;
font-size:12px;
background-color:#dfadec;
width:900px;
padding-bottom:45px;
padding-top:45px;
margin: 0 auto;
height: auto;
}
#nav {
padding-top:70px;
font-size:12px;
color:#CCC;
margin-left:570px;
}
#nav a:link {
color:#CCC;
text-decoration:none;
}
#nav a:hover {
color:#dfadec;
text-decoration:none;
}
h1 {
font-size:60px;
font-family:Open Sans;
color:#4d4d4f;
margin-top:-150px;
}
h2 {
font-size:40px;
font-family:Open Sans;
color:#4d4d4f;
font-weight:normal;
margin-top:-40px;
}
#resume {
background:#5c5c54;
width:130px;
height:130px;
font-family:Open Sans;
color:#FFF;
margin-left:5px;
text-align:center;
position:absolute;
-webkit-transition-property:color, background;
-webkit-transition-duration: 0.5s;
-webkit-transition-timing-function: linear, ease-in;
}
#resume p {
vertical-align:middle;
padding-top:45px;
font-size:12px;
}
#resume:hover {
background-color:#373732;
color:#FFF;
}
#work {
background:#dfadec;
width:130px;
height:130px;
font-family:Open Sans;
color:#FFF;
margin-left:150px;
text-align:center;
position:absolute;
-webkit-transition-property:color, background;
-webkit-transition-duration: 0.5s;
-webkit-transition-timing-function: linear, ease-in;
}
#work p {
vertical-align:middle;
padding-top:45px;
font-size:12px;
}
#work:hover {
background-color:#705676;
color:#FFF;
}
#skills {
background:#4d4d4f;
width:130px;
height:130px;
font-family:Open Sans;
color:#FFF;
margin-left:295px;
text-align:center;
position:absolute;
-webkit-transition-property:color, background;
-webkit-transition-duration: 0.5s;
-webkit-transition-timing-function: linear, ease-in;
}
#skills p {
vertical-align:middle;
padding-top:45px;
font-size:12px;
}
#skills:hover {
background-color:#262628;
color:#FFF;
}
img#icon {
background-color:#4d4d4f;
padding:12px;
}
#intro {
width: 400px;
font-family: Open Sans;
font-size: 12px;
color: #4d4d4f;
margin-left: 320px;
position: absolute;
left: 500px;
top: 522px;
text-align:justify;
}
</style>
Any suggestions? Please let me know. And let me know if I need to post the
HTML too.. I just figured the problem was in the CSS since that's where
I'm defining width, etc.
Thanks!
Pooja

ISAPI Rewrite with Query String

ISAPI Rewrite with Query String

On my website I have URLs like this:
http:// www.domain.com/something-like-page-title-4en
With ISAPI Rewriter (Ionics Isapi Rewrite Filter) I have following rule:
RewriteRule ^/([^.?]+[^.?/])$ /index.php?URL_string=$1 [L,U]
That means, above rule is transforming above URL to:
http://www.domain.com/index.php?URL_string=something-like-page-title-4en
If someone likes above URL on Facebook, Facebook adds additional tracking
parameters into my URL and it looks like:
http://www.domain.com/something-like-page-title-4en?fb_action_ids=2159471566173547&fb_action_types=og.likes&fb_source=712&action_object_map=%7B%2780201701278628651%22%3A10110880521592526%7D&action_type_map=%7B%2210201714908651773%22%3A%22og.likes%22%7D&action_ref_map=%5B%5D
My above rule is not able to process such URL (with a query string). What
I need is rule which will be able to catch both URLs, with query strings
and without them, and to process URLs as follows:
Example 1 (URL with Query String):
Original URL:
http://www.domain.com/something-like-page-title-4en?param1=value1&param2=value2
Rewritten URL:
http://www.domain.com/index.php?URL_string=something-like-page-title-4en&param1=value1&param2=value2



Example 2 (URL without Query String):
Original URL:
http://www.domain.com/something-like-page-title-4en
Rewritten URL:
http://www.domain.com/index.php?URL_string=something-like-page-title-4en



Thanks a lot.

Template Usage Error : used without template parameters

Template Usage Error : used without template parameters

Im not so strong in templates. I tried searching for similar questions but
was unable to figure out this compiler error for this piece of code.
$ Code
template < typename T >
struct pred_t
{
enum type_t { type1, type2 };
pred_t ( T & container, type_t type )
: m_container ( container ), m_type ( type )
{
}
~pred_t ( )
{
}
private:
T m_container;
type_t m_type;
};
$
$ Execute
int main ( )
{
typedef std::vector < int > buffer_t;
buffer_t buf ;
pred_t < buffer_t > pred ( buf, pred_t::type1 );
}
$
$ Output
error: 'template<class T> struct pred_t' used without template parameters
pred_t < buffer_t > pred ( buf, pred_t::type1 );
$

Mocha tests unable to

Mocha tests unable to

I'm writing some very simple unit tests in Coffeescript for a Meteor app
using Mocha and getting an error when testing any model which inherits
from another. The simplest example of this can be seen here:
https://gist.github.com/IanWhalen/6342206
When running mocha ./test_class.coffee -r coffee-script I get a successful
result. But when running mocha ./test_subclass.coffee -r coffee-script I
get the following stack trace:
/path_to_app/subclass.coffee:3
unction ctor() { this.constructor = child; } ctor.prototype =
parent.prototype
^
TypeError: Cannot read property 'prototype' of undefined
at __extends (/path_to_app/subclass.coffee:3:199)
at /path_to_app/subclass.coffee:6:5
at Object.<anonymous> (/path_to_app/subclass.coffee:12:5)
at Object.<anonymous> (/path_to_app/subclass.coffee:14:4)
at Module._compile (module.js:456:26)
at Object.loadFile
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19)
at Module.load
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous (/path_to_app/example.coffee:16:14)
at Object.<anonymous> (/path_to_app/example.coffee:24:4)
at Module._compile (module.js:456:26)
at Object.loadFile
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19)
at Module.load
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /usr/local/lib/node_modules/mocha/lib/mocha.js:152:27
All of which I assume stems from Mocha not being able to find @Class when
it goes to instantiate @SubClass. Should I be doing something different to
allow me to unit test these models?

Mysql Server on Ubuntu

Mysql Server on Ubuntu

How to synchronize or replicate two mysql server that were not host on the
web, the system were usually connected to the internet and they were
reside main and mini campus. any advise will be appreciated

An 502 error in Nginx while using ruby(php work well on it)

An 502 error in Nginx while using ruby(php work well on it)

here is my configfile under flow:
127.0.0.1/bin/index.rb upstream prematurely closed FastCGI stdout while
reading response header from upstream, client: 127.0.0.1, server:
127.0.0.1, request: "GET /bin/ HTTP/1.1", upstream:
"fastcgi://unix:/var/run/fcgiwrap.socket:", host: "127.0.0.1"
server{ listen 80;
server_name 127.0.0.1;
root /home/ang/website;
index index.rb index.html;
location /otrs-web {
gzip on;
alias /opt/otrs/var/httpd/htdocs;
}
location ~ \.rb$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.rb;
fastcgi_param SCRIPT_FILENAME /home/ang/website/bin$1;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}
}

Sunday, 25 August 2013

where to code business logic in nodejs with expressjs, mongoosejs and redis

where to code business logic in nodejs with expressjs, mongoosejs and redis

My business logic includes mongodb operations and redis operations on one
request. I do not know where we should put logic code to. In Java project,
we have DAO, service and controler objects. but in nodejs projects, I
don't know where to put my code. shall I put logic code to
routes/index.js?
app.post('/deal', function(req, res) {
... //TODO: here
});
or create a kind of service objects such as what we do in Java proejct?

Avoid deadlock of ruby open4

Avoid deadlock of ruby open4

If we keep reading both stdout and stderr using ruby and open4, there
might be change that deadlock happen when data reach the buffer limit.
What should be the code to avoid the situation?
status = Open4::popen2e(command) do | pid, stderr|
logger.info("Executing: #{command}")
errors = stderr.readlines
unless errors.empty?
logger.error( "Error: stderr: #{errors}")
end
end

Source code save plot R; gWidgets

Source code save plot R; gWidgets

where can i find the source of the "save" function in the pop up menu in a
ggraphics() please ? I can't find it.
Thank You

Update Statement With Where Clause To Other Tables

Update Statement With Where Clause To Other Tables

Basically I have an update statement which needs to update two fields of a
table but is dependent on its where clause which references other tables
within the database.
For example.
UPDATE TABLE_ONE
SET VALUE_ONE=1,VALUE_TWO=2
WHERE TABLE_TWO.ID = 1818 AND TABLE_TWO.POSITION = TABLE_THREE.ID AND
TABLE_ONE = TABLE_THREE.VALUE = TABLE_ONE.ID;
I hope this is clear. Any help would be greatly appreciated.

Saturday, 24 August 2013

JQgrid multiselect load value from jsonmap

JQgrid multiselect load value from jsonmap

I have a grid , which one of it's coulmns is a checkbox custom foramtter.
I load my data from server side with json. I want to create a multiselect
column that will replace the column I created so that it will have a
checkbox in the header and all other multiselect functionalty.
My question is how can I load data into the multiselect column? can it
have an ID so that the json will know how to map it's values ? Is it
possible to load data into multiselect column ?
Thank's In Advance.

how to identify the input is backspace

how to identify the input is backspace

see the following code
stty cbreak -echo
input==`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty -cbreak echo
if [ "$input" = "a" ];then
echo "the input is a"
fi
how I can ensure the input is backspace. In other words,what is the symbol
of backspace.

Strange alignment when using tilde as the not operator in logic

Strange alignment when using tilde as the not operator in logic

I wish to use ~ which has latex symbol: \sim for the negation sign in
logic. \sim and \neg are the two most frequent symbols for negation in
logic.
However, I get a strange looking result if I use \sim. The spacing with
the variables is odd as the \sim is further from the variable. Compare the
alternative using \neg and you will see what I mean.
How can I fix the spacing/alignment?
How can I show the results of my LateX code on SE?
Thanks in advance!

List shared between threads: build a new list in a specific thread referencing elements of the shared list?

List shared between threads: build a new list in a specific thread
referencing elements of the shared list?

Let's say I have this static list which is shared between different threads:
public static List<myClass> fooList = new List<myClass>();
Now, I want to access this shared list in a thread to build its own
private list, I would like to do the following:
List<myClass> newFooList = new List<myClass>();
lock (fooList)
{
foreach (myClass element in fooList)
{
newFooList.Add(element);
}
}
But if I do so, I'm building a new list which is referencing the same
elements as the shared list, so if later I access the newFooList without
any lock (as it should be) I'm actually accessing the same elements of the
shared list, hence violating the lock, right?
So, the solution is to make new elements in newFooList with the same
content as the ones in fooList instead of passing the references?

php script not running in WAMP server

php script not running in WAMP server

I have installed WAMP server and using port# 81. All works fine!
http://localhost:81/phpmyadmin/ and even http://localhost:81/?phpinfo=1.
I have placed my website under C:\wamp\www\ folder. On submit button I'm
calling checklogin.php which chwcks for user details from DB, but all i
see is the following script in browser instead of running the php code :(
Need help to resolve this problem!
<?php
$host="http://localhost:81/";
$username="root";
$password="";
$db_name="guru_dakshina";
$tbl_name="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and
password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>

How to set settings.LOGIN_URL to a view function name in Django 1.5+

How to set settings.LOGIN_URL to a view function name in Django 1.5+

As of Django 1.5, you can set LOGIN_URL to a view function name, but I
haven't been able to figure out how to specify it correctly.
LOGIN_URL = my_app.views.sign_in
...does not work.

A question about a linear algebra proof

A question about a linear algebra proof

Consider following statement:
Every positive operator $T:V\to V$ where $V$ is a finite dimensional
complex innner product space has a unique positive square root.
The proof in my notes is this: use previous theorems to write $V$ as
direct sum of eigen spaces for eigenvalues of $T$, to get existence of
square root $S$ and to write $V$ as direct sum of eigen spaces of $S$.
Etc.
It is not so long. But I wonder if it could be proved like this: (can you
tell me if following is a valid proof?)
On complex vector spaces $V$ every operator $T$ has an eigen basis.
Represented in the eigen basis $T$ is a diagonal matrix $D$. Then
$S=\sqrt{D}$ is a square root of $T$. By assumption $T$ is positive and
therefore has only non negative real eigen values. Therefore $S$ is a
positive square root.
Please can you tell me if this is a valid proof of the theorem?

move DOM elements inside one accordion part

move DOM elements inside one accordion part

I want to move some elements to right position inside one jquery's
accordion part because i'm cloning parts and appears just down
See the image, please
Now my program is ugly but i'm working in it! It's possible to move these
parts?
Thanks you!!!!

If MULTIPLE is enabled for , how is searching based on that field affected?

If MULTIPLE is enabled for , how is searching based on that field affected?

In my question in Unexpected entry in a <select> field! How did this
happen? , I had asked about an unexpected 01,05 entry in a field that
stored values from a <FORM><SELECT>. The input did not have MULTIPLE
enabled and should have had the default of single select.
Yet it allowed a user to make multiple selections. I have now realized
that in my current scenario, there are several users who would need to
select more than one option. So now I am faced with another question.
What if, I were to need to query the database for values in that same
field? Would multiple entries stored in the field screw up the results?
Let us say that the <SELECT> asked the user to select between 01 and 04.
My expectation would be that the field will store either 01, or 02, or 03,
or 04 and I might query the table to return all rows that contained '02'.
What if one of the users has made multiple selections - say 02 and 04. In
the database there would now be an entry like 02,04 in that field. If I
were to query for 02 (or 04 for that matter), would I get the 02,04 entry
in the result along with the ones that contained only '02' in that column?
What are the conditions under which I could face a select query that did
not return all the rows I need?

Friday, 23 August 2013

SQL Query Sum and total of rows

SQL Query Sum and total of rows

I have a table that has three columns:

LOCATION | ITEM | QUANTITY
--------------------------------
001 RED CAR 1
002 RED CAR 3
003 BLUE CAR 5
002 BLUE CAR 2
001 RED CAR 2
002 RED CAR 5


Im trying to run a query that will tell me how many of each unique item
each location has. The reason I have multiple lines for the same location
is that each location might have multiple people inputting the records at
the same time.
The goal is to get the total number of items and the total that each
location entered.


ITEM | LOCATION 001 | LOCATION 002 | LOCATION 003 | TOTAL
--------------------------------------------------------------
RED CAR 3 8 0 11
BLUE CAR 0 2 5 7


I can not come up with a single SELECT query that will get me both the
total for each location and the total for each item. Im trying to complete
this with a single query rather than running two separate query requests.
Any help would be greatly appreciated.
I have test link to try out some different queries on.
http://www.sqlfiddle.com/#!2/c33cee/1/0

Eclipse complaining about Javadoc even after Disabling javadoc in compiler options, and inconsistent

Eclipse complaining about Javadoc even after Disabling javadoc in compiler
options, and inconsistent

I've got some open source code using the {@Code annotation that Eclipse is
complaining about. Since I don't care I turned off Javadoc in the compiler
options, but it's still complaining and will not compile compile.
Error is: "Javadoc: Missing closing brace for inline tag"
Actually the closing brace IS present. In some cases it's just a few lines
down, but in others it's even on the same line!
Even stranger: The same code in a smaller project in a different workspace
works OK. I've compared the 2 projects' settings a couple times and they
appear to be the same. In many cases options are set to not allow project
specific settings.
I also did other things like doing a project clean, and trying Java 1.5
vs. 1.7 compiler options, etc.
Other details:
Java 7 on Mac
Eclipse Kepler
Code is Guice 2.0 (I know that's old, and normally should use jar, long
story)
one example is Key.java line 107, see below
Example from Guice code (though I normally wouldn't care since it's just
comments)
/**
...
* <p>{@code new Key<Foo>() {}}.

Oracle SQL - Average Time Between Dates By Subject

Oracle SQL - Average Time Between Dates By Subject

I'm working in Oracle SQL. I have a table with IDs and Dates, and I'm
trying to find the average time between dates by subject. It would look
something like this.
TABLE
SubjectID Date
1 8/01/2013 12:00:00 AM
1 8/31/2013 12:00:00 AM
1 9/10/2013 12:00:00 AM
2 1/01/2010 12:00:00 AM
2 1/21/2010 12:00:00 AM
I need to write a query that goes through that table by SubjectID, records
the time between dates, and outputs the average of averages, so to speak.
In this example, it would be time between the first and second rows (30
days) + the time between the second and third rows (10 days) / 2 (to get
the average for subject 1, which = 20), and then the time between rows 4
and 5 (20 days) / 1 (to get the average for subject 2), and the output
should be the average between those (20 + 10) / 2 = 15.

Array slice doesn't seems to work

Array slice doesn't seems to work

I'm trying to have the first file in a directory ordered by name asc. Here
is the code I use (php):
$dir = "fichiers/123/files_backup";
$premfic = array_slice(array_filter(scandir($dir), 'is_file'), 0, 5);
print_r($premfic);
But the array is empty... The directory contains 18 files and scandir
alone sees them. Any idea? Thanks

Tricky thing : Proxy app through wine ?

Tricky thing : Proxy app through wine ?

I am able to use my socks5 proxy ( squid ) to proxy everything I want, but
an app I'm running trough wine. Do you know if Wine supports it ?

How to get control reference that register routed event

How to get control reference that register routed event

I have an application with NavBar(WPF TreeView) and TabControl. Tab items
contain DataGrid and search TextBox in the top. I want to handle Ctrl+F
key independently which control is focused(NavBar, Menu and etc.) and
focus search-box of active tab control.
I define a global command, and KeyGasture for window, and from my control
I register to that command using this code
var commandBinding = new CommandBinding(MyCommands.FindRowCommand, (s, e) =>
{
//How to get my search TextBox hear?
}, (s, e) => e.CanExecute = true);
CommandManager.RegisterClassCommandBinding(typeof(Window), commandBinding);
The question is, that I need search box reference inside the
CommandBinding action, how can I get my SearchBox inside it? Note that
there might be a lot of TextBoxes, so I think looking logical tree for
TextBox is not a case.

Thursday, 22 August 2013

Using text box value as PHP variable

Using text box value as PHP variable

i am using a java script calender date picker in my php form,
it gives date in a text box. I want to use the text box value as a
variable in php so that to use it in echo
for example:
my date picker is :-
echo "<input type=text id=exampleV name=dateIV maxlength=10 />";
the date picker is working fine
i want that date which comes in text box should be used as php variable
plz help

Install and Configure Oracle 11g using c# program

Install and Configure Oracle 11g using c# program

I need to create a windows application program using c# which will allow
me to install oracle client 11g and also configure ODBC automatically with
just one click, as my customers have limitations in technology and hence
the installation and configuration is very difficult.
Is it possible and also if you could help with some code reference?
Thanks

Trying to figure out how to do math in sql queries related to time stamps

Trying to figure out how to do math in sql queries related to time stamps

I need to do some math around a time stamp in a column in a mysql
database. I am using these queries within PHP to extrapolate values, then
using them as variables to feed into another function that generates a
highcharts graph.
So for example:
SELECT COUNT(blah) FORM blah WHERE start_stamp >=now() - interval 1 day
but then I need to subtract from another value from a similar query to get
the the count from the previous day, like:
SELECT COUNT(blah) FORM blah WHERE start_stamp >=now() - interval 2 day
So let's say these two become variables $today and $yesterday, how can I
do this most effectively within a SQL query? Obviously I can do the math
within PHP but I am sure there is a better way to do this within the query
itself.

poll on xss possibility

poll on xss possibility

I know the real answer but i'm just interested into what people think. So,
having in mind the following characters are not
allowed:%,!,",:,;',@,#,&,(,),\,',>,{,}.[,],?,-. and the following keywords
are not allowed (case insensitive):
alert,confirm,prompt,href,/script,eval,throw. All those disallowed
characters are replaced with the symbol |. Now the xss will be in a get
variable which when entered will echo back the input once filtered, the
output will be as it is, it will not be in any attributes. Any other
encoding types like utf-7 will not be possible. Only utf-8. Is xss in this
case possible? If so, how?

gvim: any way to switch to text mouse cursor?

gvim: any way to switch to text mouse cursor?

Is there anyway to change the mouse cursor to the text one when it is over
a buffer? Like this:
http://0.tqn.com/d/webdesign/1/0/4/I/1/cursor_text.gif

Ajax doesn't response

Ajax doesn't response

I'm trying again - I'm trying to create simple code: when I change the
value in the SELECT BOX ajax will run and print "HELLO AJAX" in the second
DIV tag
But I don't get any respond.
What do I do wrong?
index.php file
<script>
$(document).ready(function(){
$("#first").click(
function(){
// var area_id=$("#first").val();
$.ajax({
type: "GET",
url: "recs.php",
// data: "area_id="+area_id,
dataType:'text',
cache:false,
success:
function(data){
$("#second").html(data);
}
});
return false;
});
});
</script>
<form method="post" action="#">
<select id="first" name="area_id">
<option value="1">1</option>
<option value="2">2</option>
</select>
<div id="second"></div>
</form>
recs.php file:
HELLO AJAX

PHP getting an automated sql data to be deleted

PHP getting an automated sql data to be deleted

I've been asked to create a Timesheet based on PHP and mySQL.
I've created a page to insert the data and another page to show the data
and edit/delete the data shown.
Here is the page to show the data and edit/delete them:
<?php
require_once("config/config.php");
$data = mysql_query("SELECT * FROM jobs")
or die(mysql_error());
?>
<form method="post" action="admin_job_edit.php" id="admin_job_edit"
name="admin_job_edit">
<table>
<?php
while($info = mysql_fetch_array( $data )) {
?>
<tr>
<td> <input type="checkbox" name="job[]" id="<?php echo
$info['job_code']?>" value="<?php echo $info['job_code']?>"
/></td>
<td><?php echo $info['job_code'] ?></td>
<td><?php echo $info['job_desc'] ?> </td>
<td><?php echo $info['job_client'] ?> </td>
<td><?php echo $info['job_year'] ?> </td>
<td><?php echo $info['job_month']?> </td>
<td><?php echo $info['job_date']?> </td>
<td><?php echo $info['job_category']?> </td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
<?php } ?>
</table>
<input type="submit" name="a_delete_job" value="Delete Job" />
and here's the deleting process
$this->db_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$admin_data_query = mysql_query("SELECT * FROM jobs")or
die(mysql_error());
$job_code_query = $_POST['job[]'];
while ($admin_data = mysql_fetch_array($admin_data_query)) {
if (isset($_POST['job_code'])) {
$admin_sql ="DELETE FROM jobs WHERE job_code =
'$job_code_query'";
$admin_query = mysql_query($admin_sql) or die(mysql_error());
$this->messages[] = "Job deleted.";
} else {
$this->messages[] = "Failed to delete job.";
}
}
When I tried this on my machine, it gave me
Notice: Undefined index: job[] in
C:\xampp\htdocs\seclog\classes\JobModification.php on line 29
From my understanding, the variable of job[] in the 2nd page didn't catch
the user submitted checkbox in page 1, or the first page didn't send the
data because the checkbox value(maybe i wrote it wrong)
Is there anyway around this? Thank you for anyone who has read/try to help.

Wednesday, 21 August 2013

how can i replaced Key Value with value keys of a Map

how can i replaced Key Value with value keys of a Map

I want to write a method which will take a map as parameter and replace
the keys and values of that map by values and keys. I am trying to do like
this
`public class HashMapKeyValueInterchange{
public static Map<String, String> getMyMap(ConcurrentHashMap<String,
String> m){
Map<String, String> map2 = new HashMap<String, String>();
for(Entry<String, String> e:m.entrySet()){
map2.put(e.getValue(), e.getKey());
}
return map2;
}
public static void main(String[] args) {
ConcurrentHashMap<String, String> map1 = new ConcurrentHashMap<String,
String>();
map1.put("ajay", "btech");
map1.put("manas", "mca");
map1.put("ashu", "mba");
} }`

Linux device driver: stream data into a single register

Linux device driver: stream data into a single register

I'm trying to stream a piece of data as fast possible into a single
register in hardware and would appreciate some advice. That is, write
every word of the data into the register in sequence.
I imagine streaming the data in by redirecting into the device file:
data.bin > /dev/stream_df0
I know this is vague, but it's the first time I'm doing something like
this and will appreciate anything you have to throw at me:
? What type of considerations should I take before I start on this project
to make this as fast as possible?
? Would a character device driver handle streaming well/be suitable for
this task?
? Is the way I'm going about this entirely inefficient/inpractical?
Thanks in advance.

MySQL IF Function not recognizing characters with integers

MySQL IF Function not recognizing characters with integers

The issue I am having is that the IF function in MySQL is not correctly
telling me if an ID is or is not located in the second table. Here is
where you can view what I am doing
http://sqlfiddle.com/#!2/501513/4'
SELECT c.id AS clientID, IF (e.id, 'yes', 'no') AS hasID
FROM Table1 c LEFT JOIN Table2 e ON (c.id = e.id)
WHERE c.id IN ("123456","H100512","94061","OW59556","OR37615");
If you notice that the values "H100512" and "w76789" should both say 'yes'
and not 'no' because they are found in the second table. I notice that if
I take away the letter from the id in the query and in the table then it
will correctly say whether it is there present in the table or not. Am I
doing something wrong in the IF Function?

SAS replace variable with the variable's value before sending to remote server

SAS replace variable with the variable's value before sending to remote
server

I'm new to SAS and I'm trying to retrieve data from a remote server.
Below is the code that I am trying to execute on the remote server:
rsubmit;
libname abc'server/sasdata'; *This is where the datasets are located;
data all2009;
set abc.file_2007:;
by index date time;
where index in (var1) and time between '8:30:00't and '12:00:00't;
run;
endrsubmit;
Currently, I am trying to pass along the variable var1 which contains the
string index that the "query" needs. var1 is evaluated on my local machine
and contains the value 'abc'.
But, since var1 is evaluated locally, trying to refer to the variable on
the remote server produces an error since var1 does not exist there.
If I run the code as follows (with the explicit value of 'abc') it runs fine:
...
set abc.file_2007:;
by index date time;
where index in ('abc') and time between '8:30:00't and '12:00:00't;
...
I need to run this "query" dynamically. Is there a way to force var1 to be
replaced by its actual value (ie. 'abc') before trying to execute the code
enclosed in rsubmit and endrsubmit?

Using flask_login session with jinja2 templates

Using flask_login session with jinja2 templates

I have simple jinja2 template with registration/login links, I should hide
them when user logged in, I also use flask_login module for this stuff.
Question is: How should I identify is user logged in in jinja2 templates?

Is there any way I can delete individual text messages?

Is there any way I can delete individual text messages?

I have a Huawei U8850 running Android 2.3.7 and want to manage my text
messages more efficiently. At the moment the only delete options I can see
are to delete all thread or the current thread.
However, what I want to be able to do is delete individual text messages
(both received and sent). The conversation with my wife (say) will include
messages that are just acknowledgements of other messages being received
or ones that are no longer relevant (shopping lists, say) and I would like
to get rid of those, but keep the more important messages (at least for
the time being).
Is there any way to do this or am I stuck with either keeping the entire
conversation or deleting it all?

width() issue in jQuery Slideshow while switching

width() issue in jQuery Slideshow while switching

So I found nice example on internet to make a jQuery Slideshow, I've made
everything properly and checked with final prduct the only thing I've
changed was width and height in css. And now when slides <li></li> are
switching a 1px gap appears to the rgiht of slide and then when next slide
is fully visible, the image stretches and gap disappears.
By the way what is the easiet way to make "circles" that show how many
slides are there and use them as navigation aswell?
I use follwoing HTML:
<div id="slideshow">
<ul id="nav">
<li id="prev"><a href="#">Förra</a></li>
<li id="next"><a href="#">Nästa</a></li>
</ul>
<ul id="slides">
<li><img src="image-1.jpg" width="950" height="390" alt="Image 1"
/></li>
<li><img src="image-2.jpg" width="950" height="390" alt="Image 2"
/></li>
<li><img src="image-3.jpg" width="950" height="390" alt="Image 3"
/></li>
</ul>
</div>
CSS:
div#slideshow {
position: relative;
width: 950px;
height: 390px;
overflow: scroll;
z-index: 5;
}
div#slideshow ul#nav {
position: relative;
display: none;
list-style: none;
top: 150px;
z-index: 15;
}
div#slideshow ul#nav li#prev {
float: left;
margin: 0 0 0 50px;
}
div#slideshow ul#nav li#next {
float: right;
margin: 0 50px 0 0;
}
div#slideshow ul#nav li a {
display: block;
width: 80px;
height: 80px;
text-indent: -9999px;
background-repeat: no-repeat;
background-position: center;
}
div#slideshow ul#nav li#prev a {
background-image: url("img/slider_prev.png");
}
div#slideshow ul#nav li#next a {
background-image: url("img/slider_next.png");
}
div#slideshow ul#slides {
list-style: none;
}
div#slideshow ul#slides li {
width: 950px;
}
div#slideshow ul#slides li img {
width: 950px;
}
jQuery: (together with jquery.cycle.all.min.js)
$(document).ready(function() {
$("#slideshow").css("overflow", "hidden");
$("ul#slides").cycle({
fx: 'fade',
pause: 5,
prev: '#prev',
next: '#next'
});
$("#slideshow").hover(function() {
$("ul#nav").fadeIn();
},
function() {
$("ul#nav").fadeOut();
});
});

Tuesday, 20 August 2013

Bootstrap 3 run slowly in Phonegap

Bootstrap 3 run slowly in Phonegap

I load plain Bootstrap starter app
(http://getbootstrap.com/examples/starter-template/) on PhoneGap (latest
version, 3.0.0). Somehow it takes 8-10 seconds just to load the
application (run on Samsung S3). Does anyone encounter the same issue? How
to improve?
I believe it's not PhoneGap nor my Samsung S3 issue as plain HTML without
Bootstrap load very fast.

What is the explanation for rubeque prime factors?

What is the explanation for rubeque prime factors?

So this is my code, the thing that is bugging me is this line " { |i| (num
% i) == 0}.length == 0? "can someone eloborate calling .length on a block?
I am trying to answer a rubeque problem prime factors
divisors = Array.new
for d in 2..(num)
divisors << d if (num % d) == 0
end
primes = divisors.select do |num|
(2..(num-1)).select { |i| (num % i) == 0}.length == 0
end

How to get the all the raw touch points at a particular instant for a tap?

How to get the all the raw touch points at a particular instant for a tap?

When the touchscreen is tapped once, the finger touches multiple x,y
positions on the screen by virtue of the finger being fat. But android
only gives me one x,y position at a time (For example, if I use adb shell
getevent, it gives me only one x-y coordinate at a time. Of course for a
tap it gives multiple x,y positions since the tap lasts for some time and
it gives the x-y position for each fraction of that time if x-y slightly
changes.) At each instant there are more than 50-100 pixels that I am
touching - presumably android uses some algorithm to reduce all the touch
signals into one x-y position. Is there a way I can get those multiple raw
touch signals at every pixel I am touching at the same time? I have a
rooted device and am willing to delve into android source code if
required.

What type of function satisfies f(x,y)=f(-x,1/y)?

What type of function satisfies f(x,y)=f(-x,1/y)?

Is there a name for functions satisfying this condition?

How to read data like this from a text file?

How to read data like this from a text file?

The text file is like
101 # an integer
abcd # a string
2 # a number that indicates how many 3-line structures will there be below
1.4 # some float number
2 # a number indicating how many numbers will there be in the next line
1 5 # 2 numbers
2.7 # another float number
3 # another number
4 2 7 # three numbers
and the output should be like [101,'abcd',[1.4,[1,5]],[2.7,[4,2,7]]]
I can do it line by line, with readlines(), strip(), int(), and for loop,
but I'm not sure how to do it like a pro.
P.S. there can be spaces and tabs and maybe empty lines randomly inserted
in the text file. The input was originally intended for C program where it
doesn't matter :(

Unable to open a published MVC Project

Unable to open a published MVC Project

I'm a total beginner so sorry in advance.
I used VS13 to build a MVC project and published it to my webspace. Now
I'm unsure which file or path I need to specify in my forwarding config in
order to open the website.
I tried
/Views/Shared
to get _Layout.cshtml and
/Views/Home
to get Index.cshtml but none of these are working. I also changed some
admissions but it always shows me this
Forbidden - You don't have permission to access / on this server.
when I'm trying to open the website.
Any ideas on what I'm doing wrong?

How to Turn off ARC for a framework?

How to Turn off ARC for a framework?

i have compiled Pantomime framework and when i add it to my project it
shows the following error:
Pantomime.framework/Versions/A/Headers/CWCacheManager.h:40:13: ARC forbids
Objective-C objects in structs or unions
How can i turn off ARC or solve this issue because this file
CWCacheManager is not showing in compile sources.
All Suggestions are welcome. Thanx in Advance

Monday, 19 August 2013

Timing for loop changes when using other functions in the computer Jquery

Timing for loop changes when using other functions in the computer Jquery

I have a pulsing animation in this JSFiddle
http://jsfiddle.net/upBdw/8/
When you use it on its own, it works just fine. The problem I'm having is
when I start browsing the web, open iTunes or whatever else you would do
while that window is still open, the timings of the pulses start to
fluctuate.
The function for the pulses is this:
function fadeItIn() {
window.setInterval(function(){
// Fade Ins
$('#child4,#child4C').fadeIn(175);
setTimeout(function () {
$('#child3,#child3C').fadeIn(175);
}, 175);
setTimeout(function () {
$('#child2,#child2C').fadeIn(175);
}, 350);
setTimeout(function () {
$('#child1,#child1C').fadeIn(175);
}, 525);
setTimeout(function () {
$('#child,#childC').fadeIn(175);
}, 700);
// Fade Outs
setTimeout(function () {
$('#child,#childC').fadeOut(175);
}, 875);
setTimeout(function () {
$('#child1,#child1C').fadeOut(175);
}, 1050);
setTimeout(function () {
$('#child2,#child2C').fadeOut(175);
}, 1225);
setTimeout(function () {
$('#child3,#child3C').fadeOut(175);
}, 1400);
setTimeout(function () {
$('#child4,#child4C').fadeOut(175);
}, 1575);
}, 3000);
};
I feel like the issue is happening during the 3 second interval within the
function. I need the pulses to repeat, so I need it in there.
What do you all think is causing this problem and how can I fix it?

nodejs / express / socket.io site that Facebook crawler can't find

nodejs / express / socket.io site that Facebook crawler can't find

My site ideas.modernassemb.ly isn't getting found by the Facebook crawler,
it just comes back saying "URL returned a bad HTTP response code."
I'm somewhat new to NodeJS, but this is how I've set up my main file to
serve the index file:
var app = express.createServer();
var io = require('socket.io').listen(app, {log: false});
var publicDir = __dirname.replace(/\/server\/bin$/, '') + '/public_html';
app.use(express.bodyParser());
app.use('/', express.static(publicDir));
app.listen(process.env.PORT || 8080);
I know I'm missing something, not sure how to send back a response code
that will make the Facebook crawler happy?
And my og:meta tags are all there on the index.html page:
<meta property="og:image"
content="http://modernassemb.ly/assets/img/src/facebooklogo.png"/>
<meta property="og:title" content="Open Source Ideas"/>
<meta property="og:description" content="We believe our ideas should roam
free, whether they are silly, practical, functional, or conceptual. They
will live here, with the hopes that you'll see something you'd like to
collaborate with us on."/>
<meta property="og:url" content="https://ideas.modernassemb.ly"/>
<meta property="og:site_name" content="Open Source Ideas"/>

Entity Framework - Updating relationship by changing foreign key

Entity Framework - Updating relationship by changing foreign key

I have the two following models and DbContext:
public class TestDbContext : DbContext
{
public IDbSet<Person> People { get; set; }
public IDbSet<Car> Cars { get; set; }
}
public class Person
{
public Person()
{
ID = Guid.NewGuid();
}
public Guid ID { get; set; }
public string Name { get; set; }
public virtual List<Car> Cars { get; set; }
}
public class Car
{
public Car()
{
ID = Guid.NewGuid();
}
public Guid ID { get; set; }
public string Name { get; set; }
public virtual Person Owner { get; set; }
}
I then declare a list of people and a list of cars, setting the owner of
the first car to the first person in the list:
List<Person> People = new List<Person>()
{
new Person() {Name = "richard", ID = new
Guid("6F39CC2B-1A09-4E27-B803-1304AFDB23E3")},
new Person() {Name = "nicola", ID = new
Guid("3EAE0303-39D9-4FD9-AF39-EC6DC73F630B")}
};
List<Car> Cars = new List<Car>() { new Car() { Name = "Ford",
Owner = People[0], ID = new
Guid("625FAB6B-1D56-4F57-8C98-F9346F1BBBE4") } };
I save this off to the database using the following code and this works fine.
using (TestDbContext context = new TestDbContext())
{
foreach (Person person in People)
{
if (!(context.People.Any(p => p.ID == person.ID)))
context.People.Add(person);
else
{
context.People.Attach(person);
context.Entry<Person>(person).State =
System.Data.EntityState.Modified;
}
}
foreach (Car caar in Cars)
{
if (!(context.Cars.Any(c => c.ID == caar.ID)))
context.Cars.Add(caar);
else
{
context.Cars.Attach(caar);
context.Entry<Car>(caar).State =
System.Data.EntityState.Modified;
}
}
context.SaveChanges();
}
If I then change the owner of the car to the second person and run the
code again, the Car owner property doesn't get updated.
Cars[0].Owner = People[1];
Any ideas to what I'm doing wrong? Thanks for any help.

DOM traversing for a searched keyword is not showing as expected?

DOM traversing for a searched keyword is not showing as expected?

I am trying to implement filtering mechanism using JavaScript in the UI by
traverse through the DOM and find for a searched word. This is how my HTML
and UI looks like.
So the idea is that once the data(which is dynamic) get loaded from the
back-end(through java) i want to traverse the DOM in HTML for a particular
keyword they searched. this is how i am writing the JS in Jquery
$(document).ready(function() {
jQuery('#txtSearch').keyup(function(event){
if (event.keyCode == 27) {
resetSearch();
}
if (jQuery('#txtSearch').val().length > 0) {
jQuery('.list-group-item').hide();
jQuery('.list-group-item span.assignee-style:Contains(\'' +
jQuery('#txtSearch').val() + '\')').
parent('li').parent('ul').parent('li').show();
}
if (jQuery('#txtSearch').val().length == 0) {
resetSearch();
}
});
function resetSearch(){
jQuery('#txtSearch').val('');
jQuery('.list-group-item').show();
jQuery('#txtSearch').focus();
}
});
The behavior i am expecting is that when i search for "john" i want only
the data(in all 3 columns) that contains "John" to appear. just as a start
i am just traversing the DOM by Assignee name only. but the results are
not as i wanted. What am i doing wrong?

Returning variable keys via public static function within a class

Returning variable keys via public static function within a class

I've been having a bit of trouble doing, what I believe is possible
(although I'm not sure). What I do know is that what I'm attempting to do
is a bit nonsensical and not the best way to do it.
class myClass {
public static function myData() {
$data = [
'index' => 'key';
];
}
}
What I'm attempting to do is to return the value of key via static
function. I've been trying to view (via var_dump()) what's inside of my
static function (myClass::myData();) however, it comes up NULL.
I'm still pretty new to PHP, but I've been working around trying to find
things to work on (even if they're pretty nonsensical) to get better
acquainted. If this is at all possible, I'd like to complete it this way.
I've been searching for an answer to this for about 2 hours, so yes, I
have looked around to try and fix this issue myself first, but to no
avail.
Additionally, if this simply can't be done, what is the best way to do
something like this? I appreciate any responses!

Sunday, 18 August 2013

Jquery HTML Tokens replacement

Jquery HTML Tokens replacement

Im looking for the most effective way of creating a client side "HTML
Token" replacement tool. The dea is that a user will add content to a
content editor area on a page. Should they wish to add dynamic content
they will do something like this:
<div>This is my content. Quick Brown fox {{dynamic_token_1}} over the
fence</div>
When jquery fires, itll look up the token and replace it with the correct
content.
Users don't type in HTML so I couldn't do a find all tags. The jquery
would need to iterate to find the "html tokens" (basically html begining
with "{{" and ending with "}}")
Whats the most effective way of doing this?

What commands can you send to LocationManager

What commands can you send to LocationManager

What commands can you send to locationManager.sendExtraCommands(provider,
command, bundle); I've been searching through the source code for the
LocationManager class and i can't find other commands.

Why using Magenta?

Why using Magenta?

I am interested in why magenta is used in many png tilesets as background?
Why isn't it simply transparent? And also, how could one display just the
image itself and show the magenta background as transparent in Java?
Thanks in advance

sql query is not working in case of number is in decimal

sql query is not working in case of number is in decimal

I am using the following query, it is showing the empty result but the
record exist in table. Please let me know how can do it
select * from wp_rg_lead_detail where lead_id=5047 and field_number=1.6
select * from wp_rg_lead_detail where lead_id=5047 and field_number=1.6
in both case query return the empty result.but data exist in table.
data type of the field_number is float in database.

Deliver an image with sensitive data

Deliver an image with sensitive data

I have a website where I want users to be able to configure authentication
using Google Authenticator(TOTP). This is done by presenting the user with
an QR code containing the secret key.
The naive approach right now is to generate the key and put it in an url
like this.
<img src="https://example.com/QRGenerator?key=....
I have two concerns with this. First the image might be cached and found
later, is the appropriate http no-cache headers enough to mitigate this?
Second is there a risk that the URL with the key parameters to be stored
in history. It appears to not be in history unless I open the image itself
in a new tab.
Are the above secure enough or are there better ways to present an image
with sensitive data.

Wamp databses to xampp

Wamp databses to xampp

So I stored my mysql data from wamp in the dropbox folder, and now I
started using XAMPP, I have put the path for the mysql to the dropbox
folder, but it doesn't see the tables inside the databases.
I had this problem once I guess, has something to do with InnoDB or
so...but I'm not sure, do you guys have any ideas?

Seting up Perspective projections using GLM in Open GL es

Seting up Perspective projections using GLM in Open GL es

I have problem setting up Perspective matrix in OpenGL ES
I use GLM math lib for perspective projection matrix creation and pass the
matrix to vertex shader.
code created matrix is given as
glm::mat4(glm::perspective(45.0f, 1.0f, 1.0f, 200.0f))
and shader processes vertex using simple code
gl_Position = projection * scale * translate * vPosition;
but the result seems my object was cut off by viewing volume by "far side"
The matrix data created for projection matrix is
2.41421, 0, 0, 0
0, 2.41421, 0, 0
0, 0, -1.10526, -1
0, 0, -2.10526, 0
Thanks

Saturday, 17 August 2013

What is the difference between c# and visual c#?

What is the difference between c# and visual c#?

I am an intermediate Java programmer and want to shift to C#. I am totally
new to this Microsoft language. In books, they are using both terms Visual
C# and C#. Can anyone please tell the real difference between the terms?

Mysql Coding to apply limit on users in website

Mysql Coding to apply limit on users in website

OKey Guys So I Have A Website And It Contains a Login system and in it
there is a sms api intregated now i have to limit a user to only use 10
message from it like i have a database and there in user i add a new table
msgs and input the value 10 now when ever a user click on send button the
value from msgs decrease from 10 to 9 is there any way to do that .? can
anyone guide me .? em very Novice to it
Thanks

how to find out older version of the queue

how to find out older version of the queue

I came across this question and thought of asking what is the best
possible way to achieve this.
Given a queue. Every time an insertion or deletion happens, a new version
of the queue is created. At any time, you have to print any older version
of the queue with minimal time and space complexity.

Multiple easyXDM in one page

Multiple easyXDM in one page

I am trying to use two easyXDM sockets on a single parent page without
success. Both the sockets connect to the same remote domain but different
endpoints. The parent page has two divs false_app_div and
dummy_app_div.The following shows the code snippets -
On the parent page I have two JS functions activate_false_app() and
activate_dummy_app().
window.loadScript = function(src, onload, onerror) {
var head = document.getElementByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
if (script.readyState) {
script.onreadystate = function() {
var state = this.state;
if (state === 'loaded' || state === 'complete') {
script.onreadystate = null;
onload();
}
};
}
};
window.activate_false_app = function() {
var exdm_url = 'http://localhost:8000/js/easyXDM/easyXDM.min.js';
on_load_fn = function() {
window.init_false_app_communication();
};
on_error_fn = function() {
return false;
};
window.loadScript(exdm_url, on_load_fn, on_error_fn);
};
window.init_false_app_communication = function() {
var false_app_socket = new easyXDM.Socket({
remote : 'http://localhost:8000/false_app',
swf : 'http://localhost:8000/js/easyXDM/easyXDM.swf',
container : 'false_ap_div',
onMessage : function(message, origin) {
alert('false_app onMessage');
alert(message);
}
});
};
window.activate_dummy_app = function() {
var exdm_url = 'http://localhost:8000/js/easyXDM/easyXDM.min.js';
on_load_fn = function() {
window.init_dummy_app_communication();
};
on_error_fn = function() {
return false;
};
window.loadScript(exdm_url, on_load_fn, on_error_fn);
};
window.init_dummy_app_communication = function() {
var dummy_app_socket = new easyXDM.Socket({
remote : 'http://localhost:8000/dummy_app',
swf : 'http://localhost:8000/js/easyXDM/easyXDM.swf',
container : 'dummy_app_div',
onMessage : function(message, origin) {
alert('dummy_app onMessage');
alert(message);
};
});
};
If in the parent page, I call either activate_dummy_app() or
activate_false_app(), it works - that is both work completely fine in
isolation. But if I call both, then only one of them works and I get an
error on the JS console, that something is undefined (which I could not
find).
Also, I know that the problem has something to do with loading two
easyXDMs because if I put init_dummy_app_communication in the on_load_fn
of activate_false_app() (in addition to init_false_app_communication
already present), then both works.
However, I cannot be sure that easyXDM is already loaded, so both
activate_false_app and activate_dummy_app has to load easyXDM, so that
they work in isolation as well as together. I tried working with
noConflict function, but the documentation there is poor and ended up with
nothing concrete there.
Has someone faced a similar problem or knows what I am missing here?

Java - Handle indentation in "getTextContent()" of DOM parsed XML

Java - Handle indentation in "getTextContent()" of DOM parsed XML

I've written some java code that parses an XML using DOM for loading data
in a program of mine. Formatting the XML with Eclipse "format" function,
I've encountered a problem: the previous working getTextContent() from a
document element, now returns a string that contains the whitespaces (or
whatelse) added from Eclipse's formatting. I'm looking for a solution that
given:
<myElement> some text
of mine
</myElement>
when I code-select the element <myElement> from the document, I want the
getTextContent() to behave like:
myElement.getTextContent().equals("some text of mine");
while it actually fails.
If I'm being too non-specific, tell me, thanks.

How to redited mydomain.com/topic/12345/widget to mydomain.com/topic/widget

How to redited mydomain.com/topic/12345/widget to mydomain.com/topic/widget

How Can I Redirect This..
http://mydomain.com/topic/12345/widget to http://mydomain.com/topic/widget

Friday, 16 August 2013

rails app mongodb index clarification

rails app mongodb index clarification

In ROR and mongoid as a mapper , i came across this class in model:
class StockPrice
include Mongoid::Document
include Mongoid::Timestamps
field :stock_id, type: String
field :price, type: Float
index :stock_id => +1, :updated_at => -1
def self.price(stock_id)
where(stock_id: stock_id).desc(:updated_at).first.price
end
def self.crawl(stock_id)
# I am stock price from internet using a web crawler
end
end
As a novice to mongodb, I have following doubts:
1)what index is basically used for?
2)what does this line convey in code:
where(stock_id: stock_id).desc(:updated_at).first.price

Thursday, 8 August 2013

Change cursor for Slash

Change cursor for Slash

i have richtextbox and button for change text in italic. Now i'm trying
change the cursor for "slash" ascii code 47. How can i do it ?
In the class Cursor not contain this type.
tnks ;)

How to stop a javascript function from within another function?

How to stop a javascript function from within another function?

I'm developing a simple slideshow system. I've got the slideshow wrapped
in a hidden div, which is shown when a thumbnail from the gallery is
clicked.
The slideshow works through a function called commence(), which is
executed when the play button is clicked.
at the moment i've got it set to hide to whole div again when stop is
clicked, but I would like to keep the div shown, simply stop the
slideshow, in other words, stop the 'commence()' function.
Can anyone tell me how to do this? Thanks.
Here is my JS.
function commence() {
hidden = document.getElementById("hidden");
hidden.style.display = 'block';
pause = document.getElementById("pause");
pause.style.display = 'block';
play = document.getElementById("play");
play.style.display = 'none';
pic = document.getElementById("picbox"); // Assign var pic to the html
element.
imgs = []; // Assign images as values and indexes to imgs array.
/* --------------------------- IMAGE URLS FOR IMGS ARRAY
-------------------------*/
imgs[0] = "/snakelane/assets/images/thumb/_1.jpg"; imgs[10] =
"/snakelane/assets/images/thumb/_19.jpg";
imgs[1] = "/snakelane/assets/images/thumb/_2.jpg"; imgs[11] =
"/snakelane/assets/images/thumb/_20.jpg";
imgs[2] = "/snakelane/assets/images/thumb/_3.jpg"; imgs[12] =
"/snakelane/assets/images/thumb/_21.jpg";
imgs[3] = "/snakelane/assets/images/thumb/_4.jpg"; imgs[13] =
"/snakelane/assets/images/thumb/_22.jpg";
imgs[4] = "/snakelane/assets/images/thumb/_5.jpg"; imgs[14] =
"/snakelane/assets/images/thumb/_23.jpg";
imgs[5] = "/snakelane/assets/images/thumb/_6.jpg"; imgs[15] =
"/snakelane/assets/images/thumb/_24.jpg";
imgs[6] = "/snakelane/assets/images/thumb/_7.jpg"; imgs[16] =
"/snakelane/assets/images/thumb/_25.jpg";
imgs[7] = "/snakelane/assets/images/thumb/_8.jpg"; imgs[17] =
"/snakelane/assets/images/thumb/_26.jpg";
imgs[8] = "/snakelane/assets/images/thumb/_9.jpg"; imgs[18] =
"/snakelane/assets/images/thumb/_27.jpg";
imgs[9] = "/snakelane/assets/images/thumb/_10.jpg"; imgs[19] =
"/snakelane/assets/images/thumb/_28.jpg";
/*
-----------------------------------------------------------------------------------------------------*/
var preload = []; // New array to hold the 'new' images.
for(i = 0 ; i < imgs.length; i++) // Loop through imgs array
{
preload[i] = new Image(); // Loop preload array and declare
current index as a new image object.
preload[i].src = imgs[i]; // Fill preload array with the images
being looped from ims array.
}
i = 0; // Reset counter to 0.
rotate(); // Execute rotate function to create slideshow effect.
}
// Function to perform change between pictures.
function rotate() {
pic.src = imgs[i]; // Change html element source to looping images
(i === (imgs.length -1))?(i=0) : (i++); // counter equals imgs array
length -1.
setTimeout( rotate, 4000); // Sets the time between picture changes.
(5000 milliseconds).
}
function init() {
[].forEach.call(document.querySelectorAll('.pic'), function(el) {
el.addEventListener('click', changeSource);
});
function changeSource() {
hidden = document.getElementById("hidden");
hidden.style.display = 'block';
newpic = this.src;
var pic = document.getElementById("picbox");
pic.src = newpic;
}
}
document.addEventListener("DOMContentLoaded", init, false);
function stopSlide() {
var hidden = document.getElementById("hidden");
hidden.style.visibility = 'hidden';
pause.style.display = 'none';
var play = document.getElementById("play");
play.style.display = 'block';
}
The 'pause' and 'play' statements are not relevant to my question, they
simply hide the play button and show the pause button if the slideshow is
running, and vice versa.
Hope this makes sense!
:)

Preventing execution of sudo rm -rf /*

Preventing execution of sudo rm -rf /*

Do any Linux distros prevent the execution of sudo rm -rf /* so that
people do not accidentally delete their hard drives if they did not know
what they are doing?

What DBCollection WriteConcern suits for this operation

What DBCollection WriteConcern suits for this operation

I am using MonogoDB in my application .
I am performing a big insert operation for all the symbols present in the
arraylist as shown below
I am afraid that while this insertion is big , it may block another
operations , is there anyway that i can tell MongoDB that perform this
insert operation in background (that is asynchronosly ) means dont let
other executions stop for this .
Is this possible to do ??
public void insert(ArrayList<QuoteReportBean> quotelist)
{
BasicDBList totalrecords = new BasicDBList();
for (QuoteReportBean reportbean: quotelist) {
BasicDBObject dbrecord = new BasicDBObject();
dbrecord.append("custid", reportbean.getCustomerId());
dbrecord.append("symbol", reportbean.getUniqueSymbol());
dbrecord.append("exch", reportbean.getExchange());
totalrecords.add(dbrecord);
}
WriteResult result = coll.insert(totalrecords);
logger.error(" - " + result.toString());
}
my requiremnt is that this opeartion should be completed , but at the same
time this should not block other operations . I have seen the WriteConcern
can improve perfromance in this case .
WriteConcern.NONE No exceptions are raised, even for network issues.
WriteConcern.NORMAL Write operations that use this write concern will
return as soon as the message is written to the socket.
WriteConcern.UNACKNOWLEDGED Write operations that use this write concern
will return as soon as the message is written to the socket.
collected from
http://api.mongodb.org/java/current/com/mongodb/WriteConcern.html
I am planning to use WriteConcern.UNACKNOWLEDGED , please let me know if
this is best or are there any isssues i need to take care of
Or is there any other way for completing it asynchonously
please share your ideas . Thank you very much in advance .