Saturday, 31 August 2013

Rails Filter Out Deleted Records in Association

Rails Filter Out Deleted Records in Association

My rails app needs to do a 'soft' delete of certain records so they are
inactivated without actually being removed from the DB. Currently I have
it implemented with an "is_deleted" flag.
My question is whether there's a best practice for handling associations
involving this model. For example:
class Foo
attr_accessible :is_deleted
scope :active, -> { where(is_deleted:false) }
belongs_to :bar
end
class Bar
has_many :foos
end
I'm trying to figure out how to set up the Bar model, knowing that it
usually deals only with 'active' foos.
I have come up with a couple ideas, and would like to know if there are
any pros/cons for using one over the other.
Use a "condition" qualifier on the has_many declaration to filter out
deleted items.
Create a "active_foos" method on Bar to return only the undeleted items.
Just use the "acts_as_paranoid" gem. It feels a little heavyweight for
what I need, but perhaps it's easiest.

BuddyPress - How to display commenter username with displayname in activity comments list

BuddyPress - How to display commenter username with displayname in
activity comments list

For an activity feed entry, I'd like to display each commentors USERNAME
as both;
a) the title= of their avatar link and
b) beside their display name
so that other commentors can @mention each other in the comments.
As you can see I've tried echo bp_get_activity_comment_username() - but it
doesn't seem to work and I can't find any other way to extract the
commentors username???
(This seems like it shold be part of the core. Why is it that you can
@mention someone but there's no way to know their username?? Seems odd.)
<div class="acomment-avatar">
<a href="<?php bp_activity_comment_user_link(); ?>" title="<?php echo
bp_get_activity_comment_username(); ?>">
<?php bp_activity_avatar( 'type=thumb&user_id=' .
bp_get_activity_comment_user_id() ); ?>
</a>
</div>
<div class="acomment-meta">
<?php
printf( __( '<a href="%1$s">%2$s</a> (%3$s) replied <a href="%4$s"
class="activity-time-since"><span class="time-since">%5$s</span></a>',
'buddypress' ), bp_get_activity_comment_user_link(),
bp_get_activity_comment_name(), bp_get_activity_comment_username(),
bp_get_activity_thread_permalink(),
bp_get_activity_comment_date_recorded() );
?>
</div>

COPY command issue

COPY command issue

I'm a novice postgres user and I'm using 9.2: I'm using: COPY tagdata FROM
'C:/Filter112595/QF112595_3.csv' WITH DELIMITER ',' CSV HEADER
FORCE_NOT_NULL;
to read data into the table I created. The data are real, integers and dates.
I get this error:
ERROR: invalid input syntax for type real: "NULL" CONTEXT: COPY tagdata,
line 2, column residual: "NULL"
Before using FORCE_NOT_NULL, I had NULL as '' but changed it because of
the different data types.
Can someone explain what's going on? thanks!

In Jquery dropdown menu

In Jquery dropdown menu

I have develope a program to get selected text from dropdown menu. This
code is working in jsFiddle. but doesn't work in Browser. Is anything
problem in jquery coding?
Dropdown
$(document).ready(function(){ $('#ddl').change(function(){
var text= $('#ddl :selected').text(); $('#ddltext').html(text);
});
});
CSPIT ADIT BVM DDIT Nirma
Thanks in advance.

Dynamically arranging content in a storyboard

Dynamically arranging content in a storyboard

I have a question regarding UI objects and storyboards.
If the same view is going to be populated by multiple different objects
(in my case a recipe display page will be used more than once to display
multiple different recipes) how do you arrange your UI in the storyboard?
Say I have a description string for one recipe that is 4 lines long, and a
description for another which is 9 lines long, how do I move the rest of
the content in the view down, too accommodate for the different sized
strings?
I guess I could develop my page in a webview, but I'd rather not, is there
a way to do this with a normal ios view controller?
Regards,

Rails migrations

Rails migrations

I am newbie with Ruby on Rails and wanted to make something clear.
suppose I want to modify a Model class and of course update the db
accordingly.
Do I have to use a migration for that cause?

Bootstrap dropdown menu changing background on submenu focus

Bootstrap dropdown menu changing background on submenu focus

I have changed the background colors of my Bootstrap menu, but the
background color of the main dropdown item in the list is changing when
the submenu (the menu that opens up when the dropdown item is clicked) is
in focus (ie my mouse is over it).
This is the dropdown on hover (which is behaving as intended):
http://imgur.com/Fb8UjFn
This is the dropdown when I have my mouse over the submenu that opens when
the dropdown is clicked (the background color is not what I want; I want
the background color to remain the same): http://imgur.com/HDL1AZT
Here's the HTML:
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Dropdown <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
And the CSS:
.navbar-mainnav {
background-color: #883333;
background-image: none;
}
.navbar-mainnav a, .navbar-mainnav a:hover {
color: #FFFFFF;
}
.navbar-mainnav .navbar-nav > .active > a, .navbar-nav > .active >
a:hover, .navbar-nav > .active > a:focus {
color: #ffffff;
background-color:transparent;
}
.navbar-mainnav .nav > li > a:hover, .mainnav > li.dropdown.open {
background-image: none;
background-color: #B54646;
}
.navbar-mainnav .dropdown-menu > li > a:hover, .navbar-mainnav
.dropdown-menu > li > a:focus {
background-color: white;
background-image: none;
filter: none;
}
.navbar-mainnav .dropdown-menu > li > a:hover {
background-color: #CC6666;
background-image: none;
}

#EANF#

#EANF#

how i can create linkbucks short link using api? linkbucks added api
feature for shorten link using api and this is the url :
https://www.linkbucks.com/api/createLink/single
but always i received an Blank Screen. this is normal?

Friday, 30 August 2013

SDL 2.0 retina mac

SDL 2.0 retina mac

I have been playing around with SDL 2.0 but after searching I haven't
found anything online about how to support retina macs. When creating a
window using the following code.
gWindow = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 500, 500, SDL_WINDOW_SHOWN);
It creates a window that has an actual size of 1000 * 1000. This isn't
really an issue because it's how apps are supposed to work using a hidpi
screen. However, when loading images I can't seem to find a way to load
images that are 2x as big for retina screens and my images always look
blurry.
I'd appreciate any help. Thanks.

Thursday, 29 August 2013

What video streaming format is supported by windows phone?

What video streaming format is supported by windows phone?

I need to stream video on windows phone.
In what format should I receive the video link in my application in order
to stream it?
Also, does MediaPlayerLauncher support video streaming??
If so, then what format/codec is supported??
I am developing application for Windows Phone 7

How to return id from Insert with libpqtype

How to return id from Insert with libpqtype

I have a c script which writes incoming aircraft data to a postgres db. I
would like to return the new records ID after the INSERT but am having
trouble.
The simplified code is like this:
int new_id;
conn = PQconnectdb("dbname = flight_dev");
PQinitTypes(conn);
PGresult *res = PQexecf(conn,"INSERT INTO aircrafts (hex) VALUES (%text)",
aircraft_hex);
PQgetf(res, 0, "%int4", 0, &new_id);
The INSERT is successful however new_id is not assigned and gives the
error "row number 1 is out of range 0..-1"
Any help would be great thanks.

Wednesday, 28 August 2013

Can a Django application authenticate with MySQL using its linux user?

Can a Django application authenticate with MySQL using its linux user?

The company I work for is starting development of a Django business
application that will use MySQL as the database engine. I'm looking for a
way to keep from having database credentials stored in a plain-text config
file.
I'm coming from a Windows/IIS background where a vhost can impersonate an
existing Windows/AD user, and then use those credentials to authenticate
with MS SQL Server.
As an example: If the Django application is running with
apache2+mod_python on an Ubuntu server, would it be sane to add a
"www-data" user to MySQL and then let MySQL verify the credentials using
its PAM module?
Hopefully some of that makes sense. Thanks in advance!

Ember.js - having a subnav display on application.hbs on click only without rendering a different template

Ember.js - having a subnav display on application.hbs on click only
without rendering a different template

I'm having issues trying to get a subnav to display on click in Ember. In
my application template I have a nav bar, and at the root I have the index
template which is a full browser width template sitting behind the navbar
on application template. Looks like this:

What I want to happen is when 'ABOUT' is clicked, a subnav displays on the
white horizontal bar directly below the main nav. The white horizontal bar
is also part of the application template. That's the only thing on the
page that I want to change though when 'ABOUT' is clicked. Then when when
you click an item on the subnav, say 'STAFF' it renders the about.staff
template.
My problem is getting this to happen on the application template. Because
if the user is currently on the 'PROGRAMS' template, and then they click
about, I want the user to stay on the programs template but the subnav to
still drop down below the main nav.
I've tried nested routes:
Ew.Router.map ->
@.resource "about", ->
@.route "philosophy"
@.route "leadership"
@.route "staff"
@.route "affiliations"
@.route "conditions"
@.route "programs"
@.route "testimonials"
Then I tried rendering a named outlet in application hbs with the
following ApplicationRoute
Ew.ApplicationRoute = Ember.Route.extend(
renderTemplate: ->
@.render
@.render 'about',
outlet: 'about',
into: 'application'
)
But I'm just getting an error:
Error while loading route: TypeError {} ember.js?body=1:382
Uncaught TypeError: Cannot call method 'connectOutlet' of undefined
I would like to do this without having to hack a bunch of jquery into it.
I hope this makes sense, I really appreciate any help.

How to run 5400 xeon series on a pre E11030-202 s5000xvn motherboard

How to run 5400 xeon series on a pre E11030-202 s5000xvn motherboard

I have an Intel s5000xvn (PBA D37261-901) motherboard running dual x5355
xeons. I was able to pick up a matched pair of x5460 xeons. Unfortunately
the x5460's want a s5000xvn (pba E11030-202 or greater) motherboard.
Currently running Bios98_4, BMC66, and FSL48.
So, is there any way to run the x5460's in the D37261-901 board? I'm open
to learning about bios hacks, as this is an old tinker machine, but if
there is a real hardware incompatibility I would like to know.
Thanks.

Tuesday, 27 August 2013

Symfony2 bringing in assets

Symfony2 bringing in assets

Background:
I am creating my first applications in Symfony and have encountered a
problem that I can't seem to get past. Going forward the application that
I'm creating will be the template which I will copy to create my next
application - so the more in the global configuration the better from my
perspective.
The question: Ideally I want my base.html.twig file to include a
/css/style.css and /js/scripts.js from the Resources/public folder in the
specific bundle being used. How do I do this? (Code snippets please!)
I have tried many other ways (guessing that the above wasn't possible)
including block inheritance / overwriting and that has worked for the
stylesheet (albeit I have to hard code the bundle name into the dependency
name, which sucks).
The plan with this application is that I should be able to clone it under
a new name and get going straight away, minimizing how much find & replace
I have to do.
Thank you!

Why does reading from Process' InputStream block altough data is available

Why does reading from Process' InputStream block altough data is available

Java:
Process p = Runtime.getRuntime().exec("myCommand");
final InputStream in = p.getInputStream();
new Thread()
{
public void run()
{
int b;
while ((b = in.read()) != -1) // Blocks here until process
terminates, why?
System.out.print((char) b);
}
}
CPP:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
{
printf("round 1\n");
// At this point I'd expect the Java process be able
// to read from the input stream.
sleep(1);
printf("round 2\n");
sleep(1);
printf("round 3\n");
sleep(1);
printf("finished!\n");
return 0;
// Only now InputStream.read() stops blocking and starts reading.
}
The documentation of InputStream.read() states:
This method blocks until input data is available, the end of the stream is
detected, or an exception is thrown.
And yes, I'm aware of this (thus linux related?):
java.lang.Process: Because some native platforms only provide limited
buffer size for standard input and output streams, failure to promptly
write the input stream or read the output stream of the subprocess may
cause the subprocess to block, or even deadlock.
My questions are:
Why is InputStream.read() blocking although I should already have data
available right after the process starts? Am I missing something on either
side?
If it's linux related, is there any way to read from the process' output
stream without blocking?

Backbone - How to render singular model view from existing List View without fetching again & retaining history

Backbone - How to render singular model view from existing List View
without fetching again & retaining history

I tried to make the title more brief, and I might revise it once I can
think of the proper way to pose the question, here it is:
I have a list view rendering multiple models representing data from a
collection.
I want to be able to click one of the views/models, clear the view, and
display ONLY that view (showing more info) - WITHOUT - fetching the data
again, and retaining the history.

How to mark multiple location from a json file using Google API

How to mark multiple location from a json file using Google API

Essentially I want to build a database with locations I added and my user
would be able to search by categories, i.e food, services, bar, etc, to
find location I recommend! So the user will visit my site and do a search
for my recommendations and it will appear on a google map!

Displaying the time in 12hr format

Displaying the time in 12hr format

I need your help.
If the code below is able to get the date in my requested format of:
dd/mm/yyyy
How do I go about getting the time in a 12hr format ie. 13:53 is 1:53pm
Thank you
<script type="text/javascript">
function test() {
var d = new Date(),
m = d.getMonth()+1,
xdate = [d.getDate(), (m < 10) ? '0' + m : m, d.getFullYear()].join('/');
var t = d.format("h:mm ss");
alert("the date is:"+ xdate +"time is:" + t)
}
</script>

Apache HTTP Components gzip request

Apache HTTP Components gzip request

I'm trying to send a gzipped multipart entity from a simple java
application (code to be used later in Android) to a service built by
RESTEasy. I've tried a few things, but basically it comes down to this:
GZip POST request with HTTPClient in Java
I always get an exception saying the content is not in GZIP format. I
tried removing the gzip content-encoding header and ungzipping the content
myself (not leaving it to RESTEasy), and I get the same exception.
The content I am sending is in JSON format. I am using multipart entities
because there is a lot of it, and the multipart entities are being
buffered to disk while uploaded.
I can use anything else. Is there any proven way for this to work with
Jetty Client for example?

set frame viewcontrollers view in UINavigationController

set frame viewcontrollers view in UINavigationController

I'm trying to change the frame of VC does not work. this is my code:
AZControlViewController *vc = [[AZControlViewController alloc] init];
vc.tableView.frame = CGRectMake(0, 195, 320, 500);
self.vcMaster = [[[UINavigationController alloc]
initWithRootViewController:vc] autorelease];
AZControlViewController is a UITableViewController.
Can anyone help me?
Thanks!

how to add the click attch event dynamically

how to add the click attch event dynamically

I need to attach the click event dynamically using javascript. My sample
code is given below.
require(["dijit/form/ToggleButton", "dojo/dom-construct"], function
(ToggleButton, domConstruct) {
var newButton = new ToggleButton({
showLabel: true,
checked: false,
onChange: function (val) { frame(this); },
label: item.getAttribute('label')
}, item.getAttribute('id'));
});

Conditional include on css file for ipad

Conditional include on css file for ipad

I need to stop inclusion of a specific CSS file only after checking if its
an ipad or not
Can this be done using javascript or css
something like
<!--[if !isAppleProduct()]>
<link href="./css/fluid.css" type="text/css" rel="stylesheet" />
<![endif]-->

Monday, 26 August 2013

Getting sum out of an input array's elements

Getting sum out of an input array's elements

I have multiple rows in a table that look like this.
<tr>
<td>Item 1</td>
<td><input type=TEXT name="item_name[]" /></td>
<td><input type=TEXT name="item_desc[]" /></td>
<td><input type=TEXT name="item_type[]" /></td>
<td><input type=TEXT name="item_price[]" /></td>
<td><input type=TEXT name="item_setup[]" /></td>
<td><input type=TEXT name="item_quant[]" /></td>
</tr>
etc...
Users can dynamically add more rows or delete them.
I'm trying to do the JS part that will display the total sum of all
item_price*item_quant and display it inside of:
<tr><td id=total></td></tr>

How can I anchor a component to the top of the toolbar?

How can I anchor a component to the top of the toolbar?

Using the Ubuntu SDK, how can I get an anchor to the top of the toolbar?
I want something like this:
MyItem {
anchors.bottom: toolbar.top
}
so that I can anchor an item to an omnipresent toolbar in a way that is
suitable for a pointer-driven interface.

jgroups multicast class cast exception

jgroups multicast class cast exception

I am trying to configure ehcache multicasting to cluster it across two
servers. This is what I get.. the error also has the properties I am using
to connect. I am not sure if I am missing any properties.
net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider Failed
to create JGroups Channel, replication will not function.
**JGroups properties:
UDP(mcast_addr=239.255.248.74;mcast_port=9157;):PING:MERGE2:FD_SOCK:VERIFY_SUSPECT:pbcast.NAKACK:UNICAST:pbcast.STABLE:FRAG:pbcast.GMS**
java.lang.ClassCastException: org.jgroups.protocols.UDP
at org.jgroups.stack.Configurator.createLayer(Configurator.java:434)
at org.jgroups.stack.Configurator.createProtocols(Configurator.java:397)
at
org.jgroups.stack.Configurator.setupProtocolStack(Configurator.java:88)
at
org.jgroups.stack.Configurator.setupProtocolStack(Configurator.java:55)
at org.jgroups.stack.ProtocolStack.setup(ProtocolStack.java:449)
at org.jgroups.JChannel.init(JChannel.java:831)
at org.jgroups.JChannel.<init>(JChannel.java:163)
at org.jgroups.JChannel.<init>(JChannel.java:143)
at
net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider.init(JGroupsCacheManagerPeerProvider.java:133)
at net.sf.ehcache.CacheManager.doInit(CacheManager.java:471)
at net.sf.ehcache.CacheManager.init(CacheManager.java:392)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:267)
at
com.loyalty.framework.cache.EhCacheUtil.startupDefaultCache(EhCacheUtil.java:82)
at com.loyalty.framework.cache.EhCacheUtil.<clinit>(EhCacheUtil.java:37)
at
com.loyalty.ws.vppservice.util.SessionUtil.startupSessionCache(SessionUtil.java:53)
at
com.loyalty.ws.vppservice.util.SessionUtil.<clinit>(SessionUtil.java:33)
at
com.loyalty.ws.vppservice.delegate.AccountDelegate.doSignon(AccountDelegate.java:275)
at
com.loyalty.ws.vppservice.VppServiceProxy.doSignon(VppServiceProxy.java:275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at
weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at
com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at
com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at
com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
at
com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:539)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
at
com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:141)
at
weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:172)
at
weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at
weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at
weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at
weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:99)
at
weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:185)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

IIS 7.5 Windows Authentication not working (sometimes)

IIS 7.5 Windows Authentication not working (sometimes)

This is a weird one. We were happily running with Windows Authentication
on our intranet site until I demoted one of our domain controllers. Now
some workstations still work fine and are authenticated automatically, but
others cannot get authenticated at all. The browser prompts for
credentials and it doesn't matter what credentials you put in, it refuses
to authenticate. (401.1) The problem is per workstation. (I cannot get in
from my own workstation, but another works fine for me.) I have not yet
found a pattern of working vs non-working workstations. (Two identical
workstations in the same OU - one works and the other doesn't)
I've followed all the links on this article:
http://stackoverflow.com/questions/12517127/windows-authentication-not-working-in-iis-7-5
and have tried all the solutions suggested, with no luck. (Tried moving
NTLM to the top of the list, tried disabling loopback checking and strict
name checking) I've also compared HTTP headers between a working computer
and a non-working one, and they appear to all be the same. No relevant
entries in the Event Logs, except the Audit Failure in the Security Log
(Unknown user name or bad password, 0xc000006d, 0xc000006a) Kernel-mode
authentication is also disabled and extended protection is turned off.
As a workaround, we're running on Basic authentication which is working
fine. But I'd like to get Windows authentication working again.
Where should I try to look next?
Domain is 2003 with 2003 and 2008 R2 domain controllers. IIS server is
2008 R2 member server. Workstations are XP Professional SP3 32-bit and
Windows 7 Enterprise 64-bit SP1.

DisplayFor is not keeping data in ViewModel on PostBack

DisplayFor is not keeping data in ViewModel on PostBack

This question has been asked before by other, but still don't get it. I am
using MVC3 Razor and I have screen for entering trouble tickets. Once data
(a textarea note) is entered, the controller redirects back to the same
screen. Most of the data is for display only. If I use DisplayFor or
DisplayTextFor, the data is not being posted back. I have used HiddenFor.
That works. However, I keep hearing from others that HiddenFor is not
ideal. I don't want to editorfor because, I want to easily disable the
field. (I follow working says HiddenFor is wrong, but won't say why. :<
lol)
Razor
@Html.DisplayTextFor(m => m.Ticket.Name)
ViewModel
public class TicketDetailsViewModel
{
[DisplayName("Customer Name")]
public string Name { get; set; }
Control
[HttpPost]
public ActionResult Detail(TicketDetailsViewModel viewModel)
return RedirectToAction("Detail");

Setting up Thunderbird to filter email to specified folders based on email address – superuser.com

Setting up Thunderbird to filter email to specified folders based on email
address – superuser.com

Is there a way to set up Thunderbird to send emails to a certain folder
based on the email address? So for instance, I have the folder ME 040. I
want all student emails to go to this folder.

Bibiliography included in ToC but wrong hyperref linking

Bibiliography included in ToC but wrong hyperref linking

I included my bibliography in the tableofcontents as follows
(documentclass report):
\clearpage
\addcontentsline{toc}{chapter}{References}
\phantomsection
\bibliographystyle{IEEEtran}
\bibliography{report}
This generates the correct output, with the correct page number (41) in
the toc. However, clicking References will take me to the page preceding
(40) the page with the references (41). How can I modify this to take me
straight to page 41? Thanks!

How to give a response to client using wso2esb JmsQueue

How to give a response to client using wso2esb JmsQueue

i am using wso2esb4.7.0 and activeMQ 5.8.0 my issue is i am storing
messages into queue If message stores successfully i need to respond to
client with proper message.In wso2esb we have only
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
but i wish to pass the custom message to client my configure is like this
my storing is working fine but response has been failed how to achieve
proper response
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JmsStore"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence onError="fault">
<property name="messageType" value="application/json"
scope="axis2"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<payloadFactory>
<format>
<ResponseJSON xmlns="">
<Body>$1</Body>
</ResponseJSON>
</format>
<args>
<arg evaluator="xml"
expression="get-property('Body')"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address
uri="jms:/jmsProxy?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://127.0.0.1:61616&amp;transport.jms.DestinationType=queue"/>
</endpoint>
</send>
</inSequence>
<outSequence onError="fault">
<property name="RESPONSE" value="true" scope="default"
type="STRING"/>
<payloadFactory>
<format>
<ResponseJSON xmlns="">
<Body>
<Status>200</Status>
<Datalist>
<Message>Success</Message>
</Datalist>
</Body>
</ResponseJSON>
</format>
<args/>
</payloadFactory>
<send/>
</outSequence>
</target>
</proxy>
i have tried with this and tried in some other way also when ever i am
sending i receive in some other sequence from their i am sending response
to client even though that one also not working
config like this
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JmsStore"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence onError="fault">
<property name="messageType" value="application/json"
scope="axis2"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<payloadFactory>
<format>
<ResponseJSON xmlns="">
<Body>$1</Body>
</ResponseJSON>
</format>
<args>
<arg evaluator="xml" expression="get-property('Body')"/>
</args>
</payloadFactory>
<send receive="JmsStore_Seq2">
<endpoint>
<address
uri="jms:/jmsProxy?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://127.0.0.1:61616&amp;transport.jms.DestinationType=queue"/>
</endpoint>
</send>
</inSequence>
<outSequence onError="fault">
<send/>
</outSequence>
</target>
</proxy>
and my sequence is like this but process is not forwarding in to sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="JmsStore_Seq2">
<log>
<property name="log" value="working log"/>
<property name="RESPONSE" value="true" scope="default"
type="STRING"/>
</log>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<payloadFactory>
<format>
<ResponseJSON xmlns="">
<Body>
<Status>200</Status>
<Datalist>
<Message>Success</Message>
</Datalist>
</Body>
</ResponseJSON>
</format>
<args/>
</payloadFactory>
<send/>
</sequence>
how i am achive this i have done all the changes my messges is going well
but my client is not getting response from faisal shaik

Display xtick values with highlighter and tooltipContentEditor

Display xtick values with highlighter and tooltipContentEditor

I use jqplot to display a histogram (bar chart). To have xticks displaying
the values between the bins, I use an other array for the xticks than I
use as input for plotting. For example: x-data: 351, y-data: 2 and for the
ticks an other array with the values 333 and 370 as borders of this bin.
I'd like to use the highlighter plug-in to display the counts of each bin
and the border values. At the moment I'm using tooltipContentEditor with
function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
return "counts: "+ plot.data[seriesIndex][pointIndex][1] + "<br /> " +
"mean of bin: " + plot.data[seriesIndex][pointIndex][0];
}
to display the number of counts and the central x-axis value of the
selected bin (see image).
Is there a similar way to display the border values of the bins with
tooltipContentEditor? I'm going to plot a lot of diagrams per page and so
it would be nice, if I could do it in a similar way than above. I could
use
function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
return "Counts: " + plot.data[seriesIndex][pointIndex][1] + "<br />Lower
Limit " + data_border_value_bin[pointIndex] + "<br />Upper Limit: " +
data_border_value_bin[pointIndex + 1];
}
but then I would have to keep the array data_border_value_bin for each
plot (it is different for each plot). But I guess the xtick-values are
stored somewhere and I just don't know how to access it.
Thank you for your help.

Sunday, 25 August 2013

Algorithm to extract face properties for face recognition neural network

Algorithm to extract face properties for face recognition neural network

i'm doing an project for college, i need to create back propagation neural
network which will recognize the faces. For this purpose i'm allowed to
use an algorithm in C# which will extract the face properties from input
image, which will I later use as inputs of neural network. Can you
recommend me some which is good, or one which is usual for usage with
neural networks?
Just to be clear: i don't need algorithm which will actually recognize
face on the image,just to get the characteristic properties of the face in
image. Images are going to be of same dimensions, faces photographed
frontally.

Why this function won't be fired when trying to use external API?

Why this function won't be fired when trying to use external API?

According to This, I can manipulate many functions using youtube API.
Now, this seek is working perfectly!
<button name="test" onclick="ytplayer.seekTo(30,true)">Start</button>
But these setPlaybackRate won't work somehow.
Why?
<button onclick="ytplayer.setPlaybackRate(+=0.1)">playbackRate+=0.1</button>
<button onclick="ytplayer.setPlaybackRate(-=0.1)">playbackRate-=0.1</button>
I tried these, too. But it didn't work either.
<button onclick="ytplayer.setPlaybackRate(2)">playbackRate+=0.1</button>
<button onclick="ytplayer.setPlaybackRate(0.5)">playbackRate-=0.1</button>

Kendo UI Treeview with check-boxes from remote data

Kendo UI Treeview with check-boxes from remote data

I am trying to use the TreeView widget of kendo-ui. Consider the following
sample data:
[
{ id: 1, text: "Useraccess", items: [
{ id: 2, text: "Roles", items: [
{ id: 3, text: "Access" },
{ id: 4, text: "Edit" }
]},
{ id: 5, text: "Users", items: [
{ id: 6, text: "Access" },
{ id: 7, text: "Edit" }
]},
], ... }]
and the following treeview widget:
$("#treeView").kendoTreeView({
dataSource: dataSource,
checkboxes: {
checkChildren: true
}
});
It works fine but now I need to know which check boxes to have already
checked, depending on what the data I receive is. In the back end I have a
value that indicates which check box to check and I can include that
information in the data.
How do I implement this functionality? Is there anything built in or do I
have to find a workaround?

Returning a class object in java equivalent for objective-C

Returning a class object in java equivalent for objective-C

I have a Java class where I'm returning the class objects using the add
method. I'm trying to write an equivalent Obj-C method. Should I have to
declare the objective C method as void and update the class variables
inside the method?
public class TesCodeRequest{
private String apiKey;
private String apiSecret;
private String endpoint;
public TesCodeRequest(String apiKey, String apiSecret, String
endpoint) {
//initialization done here
}
public TesCodeRequest add(String endpoint, Object... fields) {
//method
}
}
Expected add method in Obj-c
-(void)add:(NSString *)endPoint andObject:(NSArray *field{
//endpoint and other variables to be updated here.
}

Saturday, 24 August 2013

Nodeview how to get the data

Nodeview how to get the data

I am using monodevelop, and did a nodeview, now I want to get the data of
the selected field just clicking the mouse how can ido that? I would like
to try to use target signals. but what should I use?

Automatically change map key based on debug of release version

Automatically change map key based on debug of release version

Sometimes I forget to change over from my debug Google map key when I
compile my app. Is there a way to have it change automatically so that I
don't have to manually change it in the manifest everytime and possibly
forget to change it for the release build again?

Uniform Initialization and default constructor arguments in C++11

Uniform Initialization and default constructor arguments in C++11

I am learning about new C++11 feature - uniform initialization. Wrote
small program:
#include <iostream>
using namespace std;
class C {
public:
C(int a = 1, int b = 2) : a_{a}, b_{b}, n{0,1,2,3,4} {};
int n[5];
int a_,b_;
};
int main()
{
C c = C{}; // should call C(int a = 1, int b = 2) with default arg.
cout << c.a_ << " " << c.b_ << endl;
return 0;
}
However, I am getting unexpected result 0 0. In other words, everything is
initialized to zero. The only way this could have happened: 1. Implicit
default constructor was called, 2. Initialization was not done correctly.

Regex to match words in sentence after a pattern

Regex to match words in sentence after a pattern

I want to capture the group fish egg chicken beef in the sentence How much
is fish egg chicken beef ?. I tried with
how much is ((?>\w+))* \\?
But its only returning fish as the second group. What am I doing wrong here?

can't execute function in getJson

can't execute function in getJson

I'm just beginning to learn jQuery, but I'm stuck at the beginning.
I am not able to execute any function in getJson. I tried to write
seperate function to execute, but it didn't work, so now I tried to
execute simplest possible code but I still can't make it work.
What am I doing wrong?
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
<script
src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div id="displayed_data">
</div>
<script>
$(document).ready(function() {
$.getJSON("http://ks3353689.kimsufi.com:5000/v1/closest_pointlng=19.0&lat=50",
function(data){
alert("test");
});
});
</script>
</body>
</html>

Getting Warning while installing flink on MacBook "There is no C compiler on your system"

Getting Warning while installing flink on MacBook "There is no C compiler
on your system"

To get support I am installing fink on my MacBook Pro. After execute
bootstrap script I am getting following error log
Checking package... looks good (fink-0.35.1).
Checking system... i386-apple-darwin12.4.0
This system is supported and tested.
Distribution: 10.8
Architecture: x86_64
Checking cc... not found.
ERROR: There is no C compiler on your system. Make sure that the Developer
Tools are installed.
I didn't find gcc in /usr/bin/ directory.
After reading here, I am guessing x-code provide default support for gcc
compiler.
any one have idea what I should to get support of fink or if have any
other way to get support of apt-get.

converting android program to iOS using j2objc: some headers not found

converting android program to iOS using j2objc: some headers not found

I use following commands to convert non-UI android classes to objective c:
$ ../j2objc-0.8.5/j2objc -use-arc -sourcepath src -classpath android.jar
src/ir/negin/decompiler/*.java
Source generation was successfully done, but when I want to compile it, I
deal with missing some header files:
$ ../j2objc-0.8.5/j2objcc -I./ -I../j2objc-0.8.5/include -c
ir/negin/decompiler/*.m ir/negin/decompiler/AvaaBook.m:21:10: fatal error:
'java/io/RandomAccessFile.h' file not found
include "java/io/RandomAccessFile.h"
^
1 error generated.
I searched entire j2objc-0.8.5 folder and not found any RandomAcceessFile.h
I tried to change the generated source code to eliminate the use of
RandomAccessFile.h and related classes, but some other files such as
org/json/JSONArray.h also cause same problem.
My Xcode version is:4.6
The j2objc version is: 0.8.5
Android.jar version is: 2.3.3

Tell compiler to not generate debug info for standard libraries.

Tell compiler to not generate debug info for standard libraries.

I have a project where I am analyzing DWARF information from C++ files. My
system works well for simple C++ files, but gets messed up when I start
adding #includes because the #includes dump in tons of extra (and
generally unnecessary) code. Is there a way I can tell the compiler (g++)
to not generate debug info for standard libraries? I would think so since
when you debug code there are chunks where the IDE will says "source code
not available."

Friday, 23 August 2013

Android: Modify algorithm to resize .gif images

Android: Modify algorithm to resize .gif images

I have been trying to display every kind of gif images in android. I don't
want to use the Movie class nor WebView, this is because I need display
any kind of gif images. I finally found a class that does exactly that I
want (GifDecoder.java). The only problem is that if the image resolution
is too big, this will take a lot of time to decode it. Currently I'm using
a bitmap disk cache to improve the performance and I'm making the decoding
the gif images in a service in background. But still, this takes a lot of
time. Someone have an idea of how modify the algorithm to skip some frames
or read the gif to an smaller bitmap?. The thing that I need change is in
the readBitmap method in the readContents method.

Error Hudson with new Plugins

Error Hudson with new Plugins

I tried to install a new plugin in Hudson and now not open a say this..
org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at hudson.model.Hudson$4.runTask(Hudson.java:698)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
What can't i do is urgent, not is my machine and not cant update to
Jenkins .. i need restart all the old configurations before this error

TinyMCE dropdown menu item text is unintentionally overlapped by keyboard shortcuts

TinyMCE dropdown menu item text is unintentionally overlapped by keyboard
shortcuts

I'm using TinyMCE to allow my users to edit some HTML in a WYSIWYG manner,
and it works well, however there's one problem.
The dropdown menu item text (i.e. File > New Document) is being overlapped
by its accompanied keyboard shortcut.
Here's a screenshot:

You can see that the Undo, Redo, Cut, Copy, and Paste items are all being
overlapped.
I'm not sure what's causing this. Can anybody help me figure out how to
fix this?
Thanks!

Application qos involving priority and bandwidth

Application qos involving priority and bandwidth

Our manager wants us to do applicaiton qos which is quite different from
the well-known system qos. We have many services of three types, they have
priorites, the manager wants to suspend low priority services requests
when there are not enough bandwidth for high priority services. But if the
high priority services requests decrease, the bandwidth for low priority
services should increase and low priority service requests are allowed
again.
There should be an algorithm involving priority and bandwidth. I don't
know how to design the algorithm, is there any example on the internet?
Somebody can give suggestion?
Thanks.
UPDATE All these services are within a same process. We are setting the
maximum bandwidth for the three types of services via ports of services
via TC (TC is the linux qos tool whose name means traffic control).

Why I can't upgrade to vim 6.3 or above using yum on CentOS 6.0

Why I can't upgrade to vim 6.3 or above using yum on CentOS 6.0

I'm trying to upgrade to vim 6.3 so I can improve my vim skills using an
online vim book
(http://learnvimscriptthehardway.stevelosh.com/chapters/00.html). I'm
trying to update my vim package (which is currently at version 6.2.411).
why can't I upgrade ?
[foo@bar ~]# yum update vim-enhanced
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: mirror-fpt-telecom.fpt.net
* extras: mirror.nbrc.ac.in
* updates: mirror-fpt-telecom.fpt.net
Setting up Update Process
No Packages marked for Update
[foo@bar ~]#
[foo@bar ~]#
[foo@bar ~]#
[foo@bar ~]#
[foo@bar ~]# yum update vim
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: mirror-fpt-telecom.fpt.net
* extras: mirror.nbrc.ac.in
* updates: mirror-fpt-telecom.fpt.net
Setting up Update Process
No Packages marked for Update
[foo@bar ~]#
[foo@bar ~]#

Show JFrames on client side

Show JFrames on client side

I'm a newbie in Java, I've created an upload file functionality on my
system. This is made by using JFrames.
Here's the first Frame: http://i.imgur.com/znrUWaw.jpg?3
Second Frame: http://i.imgur.com/dBQZ0cZ.jpg?1
My problem is I need this to show on the client side. hahaha I know it
will show on the server side. I also know that I need to use applet
instead of this, but how?
I want it to be like Oracle E-business suite. When I click a link a java
application window will pop-out. Do Oracle E-business suite using applet?
or something else?
Thanks in advance!!

Thursday, 22 August 2013

Is there a max file size when uploading as a Multipart File

Is there a max file size when uploading as a Multipart File

HttpPost post = new HttpPost(properties.getPropert("system.api.url"));
post.setHeader("Accept", "application/json");
MultipartEntity entity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("file", new FileBody(file, event.getMIMEType()));
post.setEntity(entity);
This is how I upload the file as a Multipart file to my rest controller.
Is there a max file size that can be uploaded or is there any way that I
can define a max file size foe this kind of uploading. I use this code in
my Vaadin client side.

Sign of Firebase's clock skew

Sign of Firebase's clock skew

Firebase's docs about presence say that the "client's clock skew" is a
value "that Firebase will add to the local reported time (epoch time in
milliseconds) to estimate the server time".
Then, in the examples, it says for example:
@Override
public void onDataChange(DataSnapshot snapshot) {
double offset = snapshot.getValue(Double.class);
double estimatedServerTimeMs = System.currentTimeMillis() + offset;
}
On one Android device that I use for testing, I have changed the clock so
that it fast by 4 minutes (roughly). Now when I get the clock skew via the
Java SDK, the value I get is the following:
232599.0
As this is in milliseconds, it corresponds to 3.87665 minutes.
But to get an estimation for the server's time, I would have to add it to
the local timestamp (System.currentTimeMillis()). Is that right?
If the client's clock is already fast by 4 minutes, and I add those 3.9
minutes, don't I get an estimation that is fast by about 8 minutes?
By the way, it would be perfect if I could use the server timestamp in
setPriority(). Currently, ServerValue.Timestamp is only available for
setValue() as it is not a primitive value. As I want to use the time in
setPriority(), I have to calculate the server's time by using
System.currentTimeMillis() and the clock skew.

which is better Bonfire or Codeigniter?

which is better Bonfire or Codeigniter?

First i want to say,I am absolute rookie in terms of codeigniter and
bonfire both. recently had a taste of MVC framework and how it works.
Currently i was about to work on a website.I was working over codeigniter
till now and apparently i was doing great but a friend suggested me to use
bonfire instead of codeigniter which uses HMVC architecture and is built
over codeigniter. I just want to know would bonfire be better to use over
codeigniter itself considering the time to load page and all the other
custom features they offer along with built in Admin panel.
would it be more beneficial if i make the classes required myself so that
i don't have to adjust on loading time of page ?
Please help me out.

Very basic javascript function call

Very basic javascript function call

I have been doing leaflet API since 2 days. I have been stuck in a
function call which gives me unexpected behaviour. the code is as follows
var it=0;
var map = L.map('map1', {
center:[51.505,-0.09],
zoom: 2,
});
L.tileLayer('http://{s}.tile.cloudmade.com/c77b2fb7bfb74f74998061abda20d58f/997/256/{z}/{x}/{y}.png',{
attribution: '2013 &copy @ Rajat/Akshat',
maxZoom: 18
}).addTo(map);
var marker = L.marker([51.5,-0.09], {draggable: true, opacity:
0.8}).addTo(map);
function onDragEnd(e) {
var lat_marker = e.target._latlng.lat;
var lng_marker = e.target._latlng.lng;
}
var i=6;
marker.on('dragend',onDragEnd(event));
The map1 div id has been created on HTML page.
Now the problem is this function:
marker.on('dragend',onDragEnd(event));
It shows this error
ReferenceError: event is not defined
marker.on('dragend',onDragEnd(event));
But when I pass it without any argument marker.on('dragend',onDragEnd());,
it works.
Also, I want to add my own parameter in the function:
marker.on('dragend',onDragEnd(i));
Where i is some simple variable. But something is wrong in this function,
it doesn't work as expected.

Testing ASP.NET Web API POST Routes with WebApiContrib.Testing

Testing ASP.NET Web API POST Routes with WebApiContrib.Testing

I am trying to set up some route tests using the WebApiContrib.Testing
library. My get tests (like this) work fine...
[Test]
[Category("Auth Api Tests")]
public void TheAuthControllerAcceptsASingleItemGetRouteWithAHashString()
{
"~/auth/sjkfhiuehfkshjksdfh".ShouldMapTo<AuthController>(c =>
c.Get("sjkfhiuehfkshjksdfh"));
}
I am rather lost on the post test - I currently have the following which
fails with a NotImplementedException...
[Test]
[Category("Auth Api Tests")]
public void TheAuthControllerAcceptsAPost()
{
"~/auth".ShouldMapTo<AuthController>(c => c.Post(new
AuthenticationCredentialsModel()), "POST");
}
Here's the setup and teardown for completeness...
[SetUp]
public void SetUpTest()
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
WebApiConfig.Register(GlobalConfiguration.Configuration);
}
[TearDown]
public void TearDownTest()
{
RouteTable.Routes.Clear();
GlobalConfiguration.Configuration.Routes.Clear();
}
The route I am trying to test is the default POST route, which maps to
this method call...
[AllowAnonymous]
public HttpResponseMessage Post([FromBody]
AuthenticationCredentialsModel model)
{ *** Some code here that doesn't really matter *** }

Wednesday, 21 August 2013

Codeigniter: Is a view supposed to be reusable

Codeigniter: Is a view supposed to be reusable

in MVC pattern, does the view need to be reusable. Are there any
principles or points to be noted while outputting data via views.
So if i have a view with certain amount of text and a table with 3
columns, and if i would need another view with minute changes like the
text would be a little different and a table with 4 columns, so should i
use variables to store the table structure in the model itself and then
pass it to the view via the controller, or use variables to change the
flow of execution in the view, or best define a new view?
Moreover what if i have an object with the table data, is it good to use
the object in the view, use a for loop and display the data or are there
better ways? Thanks
P.S I'm new to codeigniter

What is the way photos been saved in iphone?Does photos been saved in camera sandbox?

What is the way photos been saved in iphone?Does photos been saved in
camera sandbox?

I want to export photos from my iPhone by ssh,where can i found the
photos?What is the way photos been saved in iPhone?Does photos been saved
in camera sandbox?

OS Command Injection and Silverlight?

OS Command Injection and Silverlight?

A Veracode analysis of one of our assemblies finds that use of
System.Windows.AssemblyPart.Load(Stream) is a "severe" security flaw
because it allows for an OS command injection, or CWE-78.
We use AssemblyPart.Load when dynamically loading XAP modules: reading the
AppManifest from the resource stream, parsing out the AssemblyParts, and
then loading them.
First, it's not clear to me why the Load(stream) is a security flaw, as I
can't find anything describing this flaw as it relates to Silverlight.
If it is potentially dangerous to the OS, how can it be mitigated?

different between pyscripter and python shell?

different between pyscripter and python shell?

when I wrote this program in python shell i could see the result easily:
import numpy as np
a = np.array([0,1,2,3])
a
and the output is array([0,1,2,3]) but when I do it in pyscripter and I
run the program nothing happen!I should to write it in this form
print(a)and the I saw the [0,1,2,3] what's the problem?

Allocations using AFNetworking request

Allocations using AFNetworking request

I'm using AFNetworking to send requests but when the request finishes its
job I'm getting this memory allocations in instruments and they stay there
forever... If I try to start another request the application receives
memory warning several times and thus it's forced to close.
Graph Category Live Bytes # Living # Transitory Overall Bytes
# Overall # Allocations (Net / Overall)
1 CFString (store) 4,86 MB 29 3595 30,78 MB 3624
<XRRatioObject: 0x7ffd1c5dc3f0> %0.00, %0.17
1 Malloc 3,91 MB 3,91 MB 1 1 7,83 MB 2 <XRRatioObject:
0x7ffd1c5dc3f0> %0.00, %0.00
And the inner allocations for each one:
First
# Address Category Timestamp Live Size Responsible Library
Responsible Caller
0 0x4d28000 CFString (store) 01:12.165.450 • 4923392 CFNetwork
_ZL19_cacheKeyForRequestPK13_CFURLRequest
1 0x36b8000 CFString (store) 00:54.705.461 • 172032 CFNetwork
_ZL19_cacheKeyForRequestPK13_CFURLRequest
2 0x1e3f5a00 CFString (store) 01:12.326.108 • 1024 CFNetwork
_ZL19_cacheKeyForRequestPK13_CFURLRequest
Second
# Address Category Timestamp Live Size Responsible Library
Responsible Caller
0 0x6903000 Malloc 3,91 MB 01:01.583.198 • 4104192 Foundation
-[NSConcreteMutableData initWithLength:]
Thanks!

mysql cursor taking long to execute

mysql cursor taking long to execute

I have written a procedure which uses cursor to loop through the rows. It
is taking too long to execute.

CREATE PROCEDURE test_port()
BEGIN
declare done BOOL default FALSE;
declare I,J,C,P,NOB int default 0;
declare n,k,t int default 0;
declare Lid int default 0;
declare inTS timestamp;
select max(id) into n from MAIN_TBL;
select ctrValue into k from ID_CNT;
set k=k+1;
WHILE k<=n
do
select SourcePort,DestPort,LinkID,NoOfBytes,insertTime into
I,J,Lid,NOB,inTS from MAIN_TBL where id=k;
select count(*) into t from APP_PORTMAP_MSTR where Port in (I,J);
IF(t=1) THEN
select Port into P from APP_PORTMAP_MSTR where Port in
(I,J);
SET C=0;
select count(*) INTO C from LINK_APP_TBL where
LinkID=Lid and Port=P;
insert into
TRAFFIC_HIST_TBL(LinkID,Port,NoOfBytes,Time_1)
values(Lid,P,NOB,inTS);
IF(C=0) THEN
insert into LINK_APP_TBL(Port,LinkID)
values(P,Lid);
END IF;
ELSE
if(I>J && J<>0) THEN
SET C=0;
select count(*) INTO C from LINK_APP_TBL where
LinkID=Lid and Port=J;
IF(C=0) THEN
insert into LINK_APP_TBL(Port,LinkID)
values(J,Lid);
insert into
TRAFFIC_HIST_TBL(LinkID,Port,NoOfBytes,Time_1)
values(Lid,J,NOB,inTS);
END IF;
ELSE
SET C=0;
select count(*) INTO C from LINK_APP_TBL where
LinkID=Lid and Port=I;
IF(C=0) THEN
insert into LINK_APP_TBL(Port,LinkID)
values(I,Lid);
insert into
TRAFFIC_HIST_TBL(LinkID,Port,NoOfBytes,Time_1)
values(Lid,I,NOB,inTS);
END IF;
END IF;
END IF;
SET k=k+1;
END WHILE;
END$$
\d ;


The possible reason for being slow is the "Insert" statements but can we
improve the performance in any ways ? It is processing around 10K records
at a time.

unable to infer compiler target triple for clang

unable to infer compiler target triple for clang

I have modified the clang. It was working properly. But then I had some
git related issues so I cleaned the git and checked out again. Now when I
try to run make clean in clang I am getting the following error. How can I
fix this?
warning: clang_darwin.mk: dropping arch 'i386' from lib 'eprintf'
warning: clang_darwin.mk: dropping arch 'i386' from lib '10.4'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib '10.4'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'ios'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'ios'
warning: clang_darwin.mk: dropping arch 'armv7' from lib 'ios'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'osx'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'osx'
warning: clang_darwin.mk: dropping arch 'armv7' from lib 'cc_kext'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'cc_kext'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'cc_kext'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'cc_kext_ios5'
warning: clang_darwin.mk: dropping arch 'armv7' from lib 'cc_kext_ios5'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'profile_osx'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'profile_osx'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'profile_ios'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'profile_ios'
warning: clang_darwin.mk: dropping arch 'armv7' from lib 'profile_ios'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'asan_osx_dynamic'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'asan_osx_dynamic'
warning: clang_darwin.mk: dropping arch 'i386' from lib 'ubsan_osx'
warning: clang_darwin.mk: dropping arch 'x86_64' from lib 'ubsan_osx'
make[5]: Entering directory `/home/test/llvm/projects/compiler-rt'
make/platform/clang_linux.mk:16: *** "unable to infer compiler target
triple for clang". Stop.
make[5]: Leaving directory `/home/test/llvm/projects/compiler-rt'
make[4]: *** [CleanRuntimeLibraries] Error 2
make[4]: Leaving directory `/home/test/llvm/tools/clang/runtime/compiler-rt'
make[3]: *** [compiler-rt/.makeclean] Error 2
make[3]: Leaving directory `/home/test/llvm/tools/clang/runtime'
make[2]: *** [clean] Error 1
make[2]: Leaving directory `/home/test/llvm/tools/clang'
make[1]: *** [clang/.makeclean] Error 2
make[1]: Leaving directory `/home/test/llvm/tools'
make: *** [clean] Error 1

Tuesday, 20 August 2013

How to import and index mongodb data in solr 4

How to import and index mongodb data in solr 4

I am new user to solr and mongodb. I have created the database and
collection in mongodb. Now i want to import and index that mongodb
collection in solr for the application which is going to search large
amount of data in database. I have searched a lot on internet but,i did
not got satisfactory information. Can anyone tell how to do indexing in
solr wit steps ?
Following is my created collection: db.stud.find().pretty() { "_id" : 1,
"roll" : 59, "name" : "sachin", "class" : "MCA" } { "_id" : 2, "roll" :
57, "name" : "jay", "class" : "MCA" } { "_id" : 3, "roll" : 101, "name" :
"akash", "class" : "BCA" } { "_id" : 4, "roll" : 11, "name" : "amit",
"class" : "MCS" } { "_id" : 5, "roll" : 55, "name" : "shiv", "class" :
"MCA" }

setting document heigth for infinite scrolling ./ infinite scroll not working properly

setting document heigth for infinite scrolling ./ infinite scroll not
working properly

This is my test code which I will use for achieving infinite scrolling.
Problem is that the alert comes up when the scroll is at the top not at
the bottom...
Can any one tell me where I am doing wrong.
The alert box should come up when the I scrolled the full page i.e the
scroll is at the bottom.
I think I need to set document height by any other method but i have no
idea how to do it
Thanks in advance..
$(window).scroll(function () {
if($(window).scrollTop() + $(window).height() == $(document).height() ) {
alert("abc");
}
});

Right name to these arrays

Right name to these arrays

I would like to know what is the right names for these 2 arrays:
//html
<div></div>
<div></div>
<div></div>
// javascript/jquery
var all = $('div');
console.log(all); //array 1
console.log(all.get()); //array 2
Array 1 - Array of objects?
Array 2 - Array of elements?
Fiddle (if needed)

I get invalid syntax on this program I started

I get invalid syntax on this program I started

I started programming a few days ago and started this, a simple program
which will open a file if a passwor dis entered correctly. Whenever I run
I get syntax error. Please tell me where I have gone wrong :) import time
import sys import os
def Start():
passwordcount = 0
print("Hello There")
print("To get started, please enter your password")
print("If you forget your password, enter CLUE")
print("If you have never used this before, please press [N] then enter")
PasswordKnown()
def AuthComplete():
pass
def PWNK():
pwmake1 = input("Please enter a new password")
pwmake2 = input("Please re-enter your password")
if pwmake1 == pwmake2:
password_file = open('c:\\Documents and
Settings\Adam\Desktop\NewProgram\Resources\Launcher\pw.txt',
'w')
password_file.write(pwmake1)
password_file.close()
clue = input("Please enter a Password Clue")
clue_file = open('c:\\Documents and
Settings\Adam\Desktop\NewProgram\Resources\Launcher\clue.txt',
'w')
clue_file.write(clue)
print("Thank You very much...")
AuthComplete()
def PasswordKnown():
password_file = open('c:\\Documents and
Settings\Adam\Desktop\NewProgram\Resources\Launcher\pw.txt')
realpassword = password_file.read()
passwordg = input("Please enter your password")
if passwordg == realpassword:
print("Password Correct")
elif passwordg == 'CLUE':
clue_file = open ('c:\\Documents and
Settings\Adam\Desktop\NewProgram\Resources\Launcher\clue.txt')
pwclue = clue_file.read()
print(pwclue)
PasswordKnown()
elif passwordg == 'N':
PWNK()
elif passwordg != realpassword:
passwordcount = (passwordcount + 1)
print("That was incorrect. Please try again.")
elif passwordcount == 3 or >3:
print("Maximum password attempts reached. Sorry. :-)")
sys.close()
Start()

Adding space after equation numbering

Adding space after equation numbering

How can I add space after the equation numbering?
MWE:
\documentclass{book}
\usepackage{amsmath}
\begin{document}
\begin{align}
a = b + c
\end{align}
\end{document}
So I want to move the equation number a little bit more to the left:
a = b + c (1) <-- (1)
For your interest, I have already tried:
\makeatletter
\def\tagform@#1{\maketag@@@{(#1)\hspace{2em}\unskip\@@italiccorr}}
\makeatother

How can I check through command-line the computer form(Desktop, notebook or All-in-one)?

How can I check through command-line the computer form(Desktop, notebook
or All-in-one)?

For a very specific reason I need to check the computer form
factor(Desktop, Notebook or All-in-one) remotelly, using a command through
the command-prompt, powershell or vbs(Windows 7/8 systems).
There is any way to do such thing?
Thanks in advance.

What is the best way to extend a Java Exception in Scala properly?

What is the best way to extend a Java Exception in Scala properly?

I'm trying to find the simplest yet proper way to extend a Java Exception
in Scala. For example, the following is not correct because new
Exception(null, cause) and new Exception(cause) have different behavior
according to Throwable.java:
class InvalidVersionException(message: String = null, cause: Throwable =
null)
extends IllegalArgumentException(message, cause) {
def this(message: String) = this(message, null)
// This is not same with super(cause)
def this(cause: Throwable) = this(null, cause)
}
Because I know Throwable(cause) sets the message to cause.toString(), I
came up with the following:
class InvalidVersionException(message: String = null, cause: Throwable =
null)
extends IllegalArgumentException(if ((message eq null) && (cause ne
null)) cause.toString else message, cause) {
def this(message: String) = this(message, null)
def this(cause: Throwable) = this(null, cause)
}
However, this still has:
if ((message eq null) && (cause ne null)) cause.toString`
which was duplicated from Throwable.java.
Is there a better way to extend an Exception without any code duplication?

Monday, 19 August 2013

Install apk file progrmatically

Install apk file progrmatically

I have downloaded apk file from localhost server using download Manager
api and also displaying which i have downloaded file but the thing is if i
click that .apk file, unable to install,it is give parsing package error.
This is my xml page
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Start Download" >
</Button>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="showDownload"
android:text="View Downloads" >
</Button>
and here my code
BroadcastReceiver broad = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
long downloadId = intent.getLongExtra(
DownloadManager.EXTRA_DOWNLOAD_ID, 0);
Query query = new Query();
query.setFilterById(enqueue);
Cursor c = dm.query(query);
if (c.moveToFirst()) {
int columnIndex = c
.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL == c
.getInt(columnIndex)) {
// ImageView view = (ImageView)
// findViewById(R.id.imageView1);
final String uriString = c
.getString(c
.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
// search.setImageURI(Uri.parse(uriString));
}
}
}
}
};
registerReceiver(broad, new IntentFilter(
DownloadManager.ACTION_DOWNLOAD_COMPLETE));
public void showDownload(View view) {
Intent i = new Intent();
i.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
startActivity(i);
}
what are the procdure there to install apk file which is there in
downloadmanager? please suggest me, Thanks in advance. sorry for my
grammer mistake.

How to make a collapsible Div collapsed by default on page load using Twitter Bootsrap

How to make a collapsible Div collapsed by default on page load using
Twitter Bootsrap

I have a collapsible div on my web page which works fine when toggling
between collaplse:
The problem is when the web page loads the "Plcollapse" Div is opened by
default.
How can I closed the Div on page load
<button type="button" class="btn btn-success" data-toggle="collapse"
data-target="#plcollapse">
Create list
</button>
<br/>
<br/>
<div id="plcollapse" class="collapse in">
<form >
<fieldset>
<div class="control-group">
<label for="Title">Title</label>
<input type="text" class="form-control" ng-model="plTitle"
value="{{plTitle}}" id="titleInput" placeholder="Enter
title">
</div>
<div class="control-group">
<label for="Description">Description</label>
<input type="text" class="form-control"
ng-model="plDescription" value="{{plDescription}}"
id="descriptionInput" placeholder="Enter description">
</div>
<div class="control-group">
<label>Add one or more ...</label>
<textarea id="videolist" ng-model="videolist" value=""
style="width:40%"></textarea>
<a ng-click="arrangePlaylistVideos()">Click here to
arrange videos</a>
</div>
<button type="submit" class="btn btn-success"
ng-click="CreatePlaylist()">Submit</button>
</fieldset>
</form>
</div>

Collapse navbar on navigate (link click) in mobile mode

Collapse navbar on navigate (link click) in mobile mode

I'm using bootstrap 3 with angular. When I click a link the page isn't
reloaded, causing the menu to stay open when in mobile mode.
How do I make the menu close automatically when I click a menu item?

get int value from array of char in c language

get int value from array of char in c language

I need your help, hope you can help me. I have array of charts just like
this example below.
char bytes[8]={2, 0, 1, 3, 0, 8, 1, 9};
So I want to take the first four chars from this array below, and put them
into a new integer variable. How can I do this? I am trying to shift them,
but this logic is not working. Any idea? Thanks.
Example: from this array to get: year month day
char bytes[8]={2, 0, 1, 3, 0, 8, 1, 9};
int year = 2013, mount = 8, day = 19

How to return to page after button press

How to return to page after button press

I used the following link to be able to set up UI Page control.
http://www.wannabegeek.com/?p=168
On each of my child views i have a button which segues to another page,
however to be able to get the scroll view working again i have had to
segue it back to the Page controller for when i press the back button.
Because i do this it always takes me back to the first child view, how can
i make it return to the page that the button was pressed.
I'm fairly new to using xcode and don't really know what to search to help
me find a way to be able to make this happen.

Sunday, 18 August 2013

How do I access a PHP file hosted on a server?

How do I access a PHP file hosted on a server?

I have an android app which connects to a hosted db to fetch data.
When testing on localhost, it was working all fine.
I moved the db to a hosted server, a couple of days back and while trying
to run the app, it is throwing error while fetching data from db.
ERROR:
08-19 06:57:28.579: E/JSON Parser(32067): Error parsing data
org.json.JSONException: Value
'
The url being used by the app is: ipaddress/filename.php.
While reading the documentation provided by the web hosting company, I
remember reading something which said that 'the server treats the
index.html as the home page or default page for this directory'. Basically
when I type 'www.someaddress.com' or its IP, it returns index.html. I am
guessing that when the app pings the IP address provided in the url,
index.html file is being returned (is it even possible?).
The question is, how do I go around this problem? Has anyone encountered
the same issue?
Thanks in advance.

Mocha JS: Within a test, how to retrieve the current test's name?

Mocha JS: Within a test, how to retrieve the current test's name?

For additional logging, I need to be able to print the current test's
description. How can I do this (with Mocha bdd)?

Static structure - definitions, objects, members

Static structure - definitions, objects, members

1.What is the use of static structure other than linkage?
static struct test //THIS ONE
{
int a;
};
2.What is the use of using static like this one? When i create this and
try use the static member (either through the structure object) it shows
"undefined reference to `test::a'"
struct test
{
static int a; //THIS ONE
};
3. What is the use of creating a static structure object?
struct test{
int a;
};
int main()
{
static test inst; //THIS ONE
return 0;
}

what is the word for "contributing honestly sincerely for betterment"?

what is the word for "contributing honestly sincerely for betterment"?

Can anybody please suggest a word for "contributing honestly sincerely for
betterment" ?

Put viewers location on my site

Put viewers location on my site

I'd like to put the location of the viewer on my website, I also need the
result to be customized by css.
EXAMPLE: The viewer lives in "Sydney, NSW, Australia", so on the site it
says "Sydney, NSW, Australia"
or
The viewer lives in "Washington, DC, United States", so on the site it
says "Washington, DC, United States"

Cygwin tcsh not able to recognize aliases when calling from VB.NET but works manually

Cygwin tcsh not able to recognize aliases when calling from VB.NET but
works manually

Yes. Ive gone through the other similar posts.None of them solves my
problem. My issue is something like this:
I have my Cygwin installed properly.I have $HOME set to some other
directory in my environment variable.Have placed an .cshrc file in
$HOME.The csh.chrc file in /etc has been updated. Now,when i launch tcsh
from my desktop shortcut, and type in any alias, it is working! Now, i
invoke tcsh and call a .csh script from my VB.NET program.The code looks
something like this in VB.NET: Shell("C:\cygwin\bin\mintty.exe --hold
always /bin/tcsh D:/test.csh") It invokes the shell correctly.Executes all
the commands in the script D:/test.cash EXCEPT for the aliases present in
it.When it comes to aliases, it says - Command not found. But after that,
if i manually execute the alias in the same window, it recognizes it.
Other Observations: 1. If i do env in the same window after script
execution, i can see all the custom environment variables set in
$HOME/.cshrc which means it is reading the ~/.cshrc file. 2.If i start
tcsh from desktop shortcut, it starts in $HOME directory, but if invoked
through VB.NET it starts in /usr/bin.
Whacking my brains from a couple of days to figure out where its going
wrong! Could anybody out here chip in with some help?
Thanks in advance!
Cheers!
What i tried: Adding source ~/.cshrc at the start of the script file didnt
help me.

Saturday, 17 August 2013

Google maps API for flex - any alternatives?

Google maps API for flex - any alternatives?

Does anyone here uses Google maps flash API in a flex app? I know it is
deprecated but it is suppose to be available till spt 2014 and I know for
a fact that if you have a key, it works, we have one for a testing domain
we own. However, I think it is close to impossible to generate a new key
for a new domain, so I'm a bit stuck here... Would appreciate any
experience you might have, and any idea or Alternative.
To my knowledge, it is either finding a way to get a new key for a new
domain, or re-write the mapping module, which is quite extensive... and if
I will have no choice but to re-write the MapQuest is the only API for
flex which looks like having a decent functionality and hopefully - a
future, their maps however are different significantly in the fact they
present street names in the native language of the country you look at, so
if you have a travel related site and you want to offer English speaking
tourists maps in non-English speaking countries, it will look a bit
weird...
any thoughts? cheers Ajar

Search xml for text and return element/node

Search xml for text and return element/node

I'd like to be able to search an xml formatted file by the text value and
return the id it is part of. I've looked through the python library at the
xml commands but only saw examples for searching by elements/nodes. I have
a simplified xml sample below and I'd like search for "3x3 Eyes" for
example and return "2". It should also search for the exact text minus
case. There will normally be multiple entries for title under each anime
so the search can stop at the first match. Thanks
<?xml version="1.0" encoding="UTF-8"?>
<animetitles>
<anime aid="1">
<title type="official" xml:lang="fr">Crest of the Stars</title>
<title type="official" xml:lang="fr">Crest of the Stars</title>
</anime>
<anime aid="2">
<title type="official" xml:lang="en">3x3 Eyes</title>
</anime>
<anime aid="3">
<title type="official" xml:lang="en">3x3 Eyes: Legend of the Divine
Demon</title>
</anime>
</animetitles>

i'm trying to make a php code that return the result of graph.facebook.com/facebook_page

i'm trying to make a php code that return the result of
graph.facebook.com/facebook_page

I'm trying to to make a php code that return the ID of the page when I do
graph.facebook.com/facebook_page
For example I have a my_file.txt file that contain the facebook pages that
I want to get the code of them.
I know the code of looping inside my_file.txt
<?php
$lines = file('my_file.txt');
foreach ($lines as $line)
{
echo htmlspecialchars($line) . '<br>';
}
?>
but I can't find a way to return the ID of each page in the txt file.

Avoid table view didSelectRowIndexPath action while main thread is blocked

Avoid table view didSelectRowIndexPath action while main thread is blocked

I have a problem. In my app action sheet with picker opens when table's
row tapped. My problem is that action sheet dose not opens while main
thread is blocked but touch event are added in run loop therefore,
whenever main thread gets a change it completes all touches action as a
result action sheet opens according to the number of times we tapped on
table row. But I want this only once.
How to fix this problem???

Use Android Annotations in custom dialog class

Use Android Annotations in custom dialog class

I'm using android annotations, I'm trying to annotate this class so that I
can save a value into my shared preferences (annotated) class using @pref.
I've managed to find a work around with an intent and a broadcast receiver
however this is not ideal and now that I want to fetch a value from the
shared preferences in this class to show as the default item selected in
the spinner it's starting to leave a smell on my code.
Is there any way to annotate this class?
public class SelectNewsFeedDialog extends Dialog {
private Context context;
private Button confirmButton;
private Spinner spinnerTeams;
public SelectNewsFeedDialog(final Context context, ArrayList<Team>
listTeams) {
super(context,R.style.cust_dialog);
this.context = context;
setContentView(R.layout.dialog_choose_news_feed);
spinnerTeams = (Spinner)
findViewById(R.id.dialog_news_feed_spinner_teams);
confirmButton = (Button)
findViewById(R.id.dialog_news_feed_button_confirm);
confirmButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Team team = (Team)spinnerTeams.getSelectedItem();
Intent intent = new Intent(context, IntentCenter_.class);
intent.putExtra(context.getString(R.string.extra_update_team_news_feed),
team.url.toString());
intent.setAction(context.getString(R.string.action_update_team_news_feed));
context.sendBroadcast(intent);
dismiss();
}
});
SpinnerTeamsAdapter adapter = new SpinnerTeamsAdapter(context,
listTeams);
spinnerTeams.setAdapter(adapter);
}
}

read color boxes from ECG image in android

read color boxes from ECG image in android

i want to read boxes from an ECG image which are pink in color. but i
don't know how to do that. my code cannot find the pink color boxes from
the image. thanks in advance.

How to create procedure in msql

How to create procedure in msql

create procedure test
BEGIN
select *
from User
END
;
Can someone tell me what is wrong in this and can you show me a simple
create procedure?

Thursday, 8 August 2013

Get full path image into input file

Get full path image into input file

I want get the full path image from input file for show image preview and
use for example attr of jquery for insert this into scr to this temporal
image path , for example i think in that
var filePath = $(this).val();
console.log(filePath);
jQuery('#preview').attr("src",""+img_p);
The problem i don´t know how i can get this temporal path from input file
for show and insert this path for the preview image until send to upload
in the system
Thank´s , Regards

How to configure nginx + Unicorn to avoid timeout errors?

How to configure nginx + Unicorn to avoid timeout errors?

I have a Rails (v3.2.13, Ruby 2.0.0) application running on nginx +
Unicorn (Ubuntu 12.04). All is working well, except when an admin user is
uploading users (thousands) via a CVS file. The problem is that I have set
timeout to 30 seconds and the import process takes much more time. So,
after 30 seconds I get an nginx 502 Bad Gateway page (Unicorn worker is
killed).
The obvious solution is to increase timeout, but I don't want this because
it'll cause another problems (I guess), because it's not a typical
behavior.
Is there a way to handle this kind of problems?
Thanks a lot in advance.
PS: Maybe a solutions is to modify the code. If so, I want to avoid the
user to perform another request.
nginx-app.conf
upstream xxx {
server unix:/tmp/xxx.socket fail_timeout=0;
}
server {
listen 80;
...
location / {
proxy_pass http://xxx;
proxy_redirect off;
...
proxy_connect_timeout 360;
proxy_send_timeout 360;
proxy_read_timeout 360;
}
}
unicorn.rb
worker_processes 2
listen "/tmp/xxx.socket"
timeout 30
pid "/tmp/unicorn.xxx.pid"

Catchable fatal error: Object could not be converted to string - but var_dump says it IS a string

Catchable fatal error: Object could not be converted to string - but
var_dump says it IS a string

I have a problem that was already asked by a lot of people here: when
trying to echo a string, "Catchable fatal error: Object of class Struct
could not be converted to string in
D:\Programy\XAMP\htdocs\e-history\test.php on line 30". For most related
questions, trying var_dump() function was suggested. However, I tried this
and everything seems to be OK, except for it throws the error.
My code (testing version):
$place = Struct::factory('gid','lat','lon','radius');
$places = loadPlaces('', 50, 14);
$j = 0;
var_dump($places[$j]->gid);
echo "$places[$j]->gid";
The output of var_dump and echo is as follows:
string(1) "6"
Catchable fatal error: Object of class Struct could not be converted to
string in D:\Programy\XAMP\htdocs\e-history\test.php on line 30
Usually there are no problems with $object->value notation, and I don't
know why it doesn't work in this case. I had some problems with
array/object mismatches, but I'm almost sure it's not this case. Any idea
how to solve it?

How to sort files by list elements by date modified, in Python?

How to sort files by list elements by date modified, in Python?

I have a list something like the following:
[{'modified': 'Thu, 08 Aug 2013 18:28:13 +0000', 'path': '/test4.txt'},
{'modified': 'Thu, 06 Aug 2013 18:28:17 +0000', 'path': '/test5.txt'}
and so on. I want to sort the list by 'modified', in chronological (or
reverse chronological) order What is the best way of doing this?

Why can we create new classes derived from sealed(scala) in java?

Why can we create new classes derived from sealed(scala) in java?

Consider two classes A and B:
// A.scala
object A {
sealed abstract class Nat
case object Zero extends Nat
case class Succ(n : Nat) extends Nat
def pp(n : Nat) = n match {
case Zero => println("Zero")
case Succ(m) => println("Succ")
case _ => println("WTF")
}
def main(args : Array[String]) =
pp(B.f())
}
// B.java
public class B {
static A.Nat f() {
return new A.Nat() {};
}
}
Compile, run:
$ scala A
WTF
As said in the documentation, "A sealed class may not be directly
inherited, except if the inheriting template is defined in the same source
file as the inherited class."
I thought it implies pattern-matching through subclasses defined in the
same file is enough to cover all cases, but as we can see from this
example it's not true.
Here is a question: is there a way to write really sealed classes or I
need to write dummy last case in every pattern match to ensure code
safety?

How to set SSL_connect on non blocking socket with select on linux platform

How to set SSL_connect on non blocking socket with select on linux platform

I am trying to use the select function to have non-blocking connection
from a client to server.I found a tutorial with some code and tried to
adapt to this:
...
sockfd = socket(AF_INET, SOCK_STREAM, 0);
err = connect(sockfd,(struct sockaddr*)&sa,sizeof(sa));
...
SSL_set_fd(pssl,sockfd);
err = SSL_connect_nonb(pssl,sockfd,60);
if(err <=0 ){
printf("SSL_connect:%s\n",ERR_error_string(SSL_get_error(pssl,err),NULL));
return -1;
}
...
The SSL_connect_nonb function is defined as bellow:
int SSL_connect_nonb(SSL*pssl,int sockfd, int nsec)
{
int flags, error;
socklen_t len;
fd_set rset, wset;
struct timeval tval;
flags = fcntl(sockfd, F_GETFL, 0);
fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
int err = SSL_connect(pssl);
int err2 = SSL_get_error(pssl,err);
switch(err2) {
default:
printf("SSL_connect err=%s\n",ERR_error_string(err2,0));
return -1;
break;
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
break;
}
FD_ZERO(&rset);
FD_ZERO(&wset);
FD_SET(sockfd, &rset);
FD_SET(sockfd, &wset);
tval.tv_sec = nsec;
tval.tv_usec = 0;
if (select(sockfd+1, &rset, &wset, NULL,nsec ? &tval:NULL) == 0) {
return -1;
}
if(FD_ISSET(sockfd,&rset) || FD_ISSET(sockfd, &wset )) {
len = sizeof(error);
if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0){
return -1;
}
}else{
printf("sockfd not set\n");
return -1;
}
fcntl(sockfd, F_SETFL, flags);
if (error) {
return -1;
}
return 1;
}
The sockfd is correct with connectCthe problem is that in
SSL_connect_nonb the select funtion return avalue=1 (actually the
condition FD_ISSET(sockfd, &wset) is successful all time),but if I use
blocking method as this :
....
SSL_set_fd(pssl,sockfd);
err = SSL_connect(pssl);
if(err <=0 ){
printf("SSL_connect:%s\n",ERR_error_string(SSL_get_error(pssl,err),NULL));
return -1;
}
...
the value of err is 0 because the SSL_connect is not successful, so, how
to do with SSL_connect on non blocking socket by calling select function?