Monday, 30 September 2013

Openvpn, forward packets very slowly

Openvpn, forward packets very slowly

I rebooted my server, and an odd issue just came out. I am running on
ArchLinux, the clients are Ubuntu, Android and Mac.
The problem is that accessing the internet via the clients is slow, about
2ko/s and slowly stop. But downloading something from the server to the
client directly is made at full speed. And, obviously, internet from the
server is at his full speed (40mo/s).
I don't know what happened from the reboot, but this issue is here on all
clients, and is only related to the traffic that openvpn forward to
internet.
EDIT: Tried with tcp, did not solve. EDIT: mtu-test give me 1538, which is
close to the used value by default.
Here are all my confs:
¨q©¤<root@Alduin>-</etc/openvpn>-<1:45:07>-¡ó
¨t©¤&#10148; cat Alduin.conf ccd/Thunderaan
local 212.83.129.104
port 1194
proto udp
dev tun
;tun-ipv6
;ifconfig-ipv6 2001:bc8:300a:dead::1337:1/64 2001:bc8:300a:dead::1337:0
;ifconfig-ipv6-pool 2001:bc8:300a:dead::1337:42/64
ca keys/ca.crt
cert keys/Alduin.crt
key keys/Alduin.key # This file should be kept secret
dh keys/dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 10.8.0.1"
;push tun-ipv6
client-to-client
keepalive 5 60
ping-timer-rem
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 3
client-config-dir ccd
topology subnet
ccd from here +++++++++++++++
ifconfig-push 10.8.0.2 255.255.255.0
;ifconfig-ipv6-push 2001:bc8:300a:dead::1337:2/64 2001:bc8:300a:dead::1337:0
push "redirect-gateway def1"
Client conf:
client
dev tun
proto udp
remote 212.83.129.104 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert name.crt
key name.key
ns-cert-type server
comp-lzo
verb 3
and some output that might help you:
¨q©¤<cubox@Alduin>-<~>-<1:49:43>-¡ó
¨t©¤&#10148; ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen
1000
link/ether b8:ac:6f:94:e2:4e brd ff:ff:ff:ff:ff:ff
inet 88.190.15.135/24 scope global eno1
valid_lft forever preferred_lft forever
inet 212.83.129.104/32 scope global eno1
valid_lft forever preferred_lft forever
inet6 2001:bc8:300a:dead::b12d/64 scope global
valid_lft forever preferred_lft forever
inet6 2a01:e0b:1000:15:baac:6fff:fe94:e24e/64 scope global dynamic
valid_lft 2592000sec preferred_lft 604800sec
inet6 fe80::baac:6fff:fe94:e24e/64 scope link
valid_lft forever preferred_lft forever
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether b8:ac:6f:94:e2:4f brd ff:ff:ff:ff:ff:ff
6: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
¨q©¤<cubox@Alduin>-<~>-<1:49:47>-¡ó
¨t©¤&#10148; route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 88-190-15-1.rev 0.0.0.0 UG 0 0 0 eno1
10.8.0.0 * 255.255.255.0 U 0 0 0 tun0
88.190.15.0 * 255.255.255.0 U 0 0 0 eno1
¨q©¤<cubox@Alduin>-<~>-<1:49:51>-¡ó
¨t©¤&#10148; route -6
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
::1/128 :: U 256 0 0 lo
2001:bc8:300a:dead::/64 :: U 256 0 0
eno1
2a01:e0b:1000:15::/64 :: UAe 256 0 0
eno1
fe80::/64 :: U 256 0 0
eno1
::/0 fe80::225:45ff:fef6:947f UGDAe 1024 2
0 eno1
::/0 :: !n -1 1 1891 lo
::1/128 :: Un 0 2 5227 lo
2001:bc8:300a:dead::/128 :: Un 0 1 0 lo
2001:bc8:300a:dead::b12d/128 :: Un 0 1 131 lo
2a01:e0b:1000:15::/128 :: Un 0 1 0 lo
2a01:e0b:1000:15:baac:6fff:fe94:e24e/128 :: Un 0
3 29356 lo
fe80::/128 :: Un 0 1 0 lo
fe80::baac:6fff:fe94:e24e/128 :: Un 0 1 311 lo
ff00::/8 :: U 256 0 0
eno1
::/0 :: !n -1 1 1891 lo
-A POSTROUTING -s 10.8.0.0/24 -o eno1 -j SNAT --to-source 88.190.15.135 #
The iptables rule
The iptables rule here is the only that is active on the server.
¨t©¤&#10148; tc qd
qdisc mq 0: dev eno1 root
qdisc pfifo_fast 0: dev tun0 root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0
0 1 1 1 1 1 1 1 1
EDIT: Here is a tcpdump of the server downloading directly a file:
http://sprunge.us/aaJX Here is the client downloading this ressource:
http://sprunge.us/WUCC and here is a normal client from another openvpn
(working) server: http://www4.slashusr.com/57552.tcpdump
Thanks! A beer for the one who help me to fix this!

How can I test TSO/LRO functionality ? What are the test cases for this?

How can I test TSO/LRO functionality ? What are the test cases for this?

I want to test tcp offload functionality (segmentation/large receive
offload) on my network.
What are the possible test cases for this? What kind of tools are
available. Are there already any test cases available, and can someone
please provide any reference of that?
Thanks in advance

Given URL is not allowed by the Application configuration Facebook application error

Given URL is not allowed by the Application configuration Facebook
application error

Please see this site here
Given URL is not allowed by the Application configuration.: One or more of
the given URLs is not allowed by the App's settings. It must match the
Website URL or Canvas URL, or the domain must be a subdomain of one of the
App's domains.
I have researched the most popular questions on SO already (Question 1,
Question 2, Question 3, Question 4, and Question 5)... None of them help
with my situation.
I have the application settings laid out like this...
App Domains: azeverything.com
Sandbox Mode: Disabled
Website with Facebook Login
Site URL: http://azeverything.com
*App Domains requires that no protocol be identified and Site URL requires
that a protocol be identified.*
I have tried using www.azeverything.com and that didn't work either.
Everything seems to match up. By the way, this is a WP site. I'm not
developing locally either. It's all live.

why margin does not work in between div of 'bootstrap col'?

why margin does not work in between div of 'bootstrap col'?

http://bootply.com/84073
<div class"col-lg-12"="">
<header class="clearfix">
<section id="branding">
<a href="index.php"><img
src="https://www.google.com/images/srpr/logo4w.png"
alt=""></a>
</section>
</header></div>
I tried to add #branding{margin: 0 auto} to style the logo to the middle,
but it doesn't work

Sunday, 29 September 2013

Wildcard subdomain rewrites in nginx

Wildcard subdomain rewrites in nginx

I'm trying to get nginx to rewrite
http://subdomain.example.com
to
http://example.com?username=subdomain
And not having any luck. Its important that the user sees the former URl
in their browser but that nginx interprets it as the latter URL.
Thanks in advance for any help.

Whats the point of a move-constructor taking a constans rvalue?

Whats the point of a move-constructor taking a constans rvalue?

According to http://en.cppreference.com/w/cpp/language/move_constructor;
"A class can have multiple move constructors, e.g. both T::T(const T&&)
and T::T(T&&)"
When would one want to pass a constant rvalue to the move-constructor?

Efficient way to combine intersecting bounding rectangles

Efficient way to combine intersecting bounding rectangles

I'm trying to simplify the following image using OpenCV:

What we have here is lots of red shapes. Some of them completely contain
others. Some of them intersect their neighbors. My goal is to unify all
intersecting shapes by replacing any two intersecting shapes with the
bounding box of their union's polygon. (repeating until there are no more
intersecting shapes).
By intersecting I mean also touching. Hope this makes it 100% clear:

I'm trying to do this efficiently using standard morphology operations;
obviously it can be done naively in O(N^2), but that'll be too slow.
Dilation doesn't help because some shapes are only 1px apart and I don't
want them merged if they're not intersecting.

How write linq query for this scenario

How write linq query for this scenario

I have two tables one is datacenter and subnet data center is having
primary key and subnet table having foriegn key values of datacenter id. I
need the result like, different lists for each datacenterid from subnet
table.
Id DatacenterId name xxx 1 1 kishore kumar 2 1 .. .. 3 1 .. .. 4 2 .. .. 5
2 .. .. 6 2 .. ..
I need to get two list one is having datacenterId=1 another is datacenterId=2

Saturday, 28 September 2013

Recording a link click then saving to local storage

Recording a link click then saving to local storage

Is this the correct code for recording a link click then saving to local
storage and then displaying the image with link in a div?



<script>
var links = [ 'one': 1, 'two': 2, 'three': 3 ];
function saveLink(that){
links[links.length] = that.element.src;
document.getElementById('linkList').innerHTML +=
that.element.src+"<br>";
localStorage.setItem('links', JSON.stringify(testObject));
}
</script>
<img src="http://domain.com/image.png" onclick="saveLink(this);" />
<div id='linkList'>
<script>
var retrievedObject = localStorage.getItem('links');
console.log('retrievedObject: ', JSON.parse(retrievedObject));
</script></div>

Displaying the date an app was opened for the first time

Displaying the date an app was opened for the first time

I want to display the date, the app I make was opened for the first time
in view (which is the only view in the whole app for now).
What kind of object do I use best in my view to display the date and how
do I get it in there?

Crystal Report integrated in Visual Studio 2010

Crystal Report integrated in Visual Studio 2010

I work with crystal report integrated in visual studio 2010 professional.
I want to see my report without running with the preview window.
How can I add the preview window in a report?

Ruby References

Ruby References

When I have the following method:
def n_times(thing)
lambda { |n| thing * n }
end
and I call it like that:
x = [:a]
p1 = n_times(x)
x = [:b]
p p1.call(3) # => [:a, :a, :a]
x will not be changed, the output will be [:a]. Why?
Because when doing something like .pop instead, x will be changed:
x = [:a]
p1 = n_times(x)
x.pop
p p1.call(3) # => []
Is it because [:b] is a new object?

Friday, 27 September 2013

PHP Insert with foreign key relation

PHP Insert with foreign key relation

first at all thank you very mucho for read it.
I have a problem making insert sentences.
I have the connection making right and all those things cause i can insert
that in other table
BUUUUUT in this table i have a foreign key relation with another table
called langs
so the language_id is a foreign key from langs table and i have data in
langs tabla and the information match...
but i dont know if i'm making right the query, the only int is the
language_id, others are varchar
$query = "INSERT INTO users (user_name,
user_password,name,lastname,mail,language_id) VALUES
('test','test','test','test','test',1)";
I have made this query to test if any data is inserted :( but doesnt work
Maybe someone have an ideA?
Regards

WPF: Cannot bind to a custom controls dependency property

WPF: Cannot bind to a custom controls dependency property

I've created a custom control with a dependency property for databinding.
The binded value should then be displayed in a text box. This binding
works properly.
The problem occurs when I implement my custom control. The grid's data
context is a simple view model which contains a String property for
binding.
If I bind this property to a standard wpf controls text box everything
works fine.
If I bind the property to my custom control nothing happens.
After some debugging I found out that SampleText is searched in
CustomControl. Of course it doesn't exist there. Why is my property
searched in CustomControl and not taken from the DataContext as it happens
in scenario 1.
<Window x:Class="SampleApplicatoin.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:SampleApplication"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.DataContext>
<controls:ViewModel/>
</Grid.DataContext>
<TextBox Text="{Binding SampleText}"/>
<controls:CustomControl TextBoxText="{Binding SampleText}"/>
</Grid>
</Window>
Below the XAML code of the custom control. I use DataContext = Self to get
the dependency property from code behind:
<UserControl x:Class="SampleApplication.CustomControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<TextBox HorizontalAlignment="Left" Height="23"
Margin="87,133,0,0" TextWrapping="Wrap" Text="{Binding
TextBoxText}" VerticalAlignment="Top" Width="120"/>
</Grid>
</UserControl>
The xaml.cs file just contains the dependency property:
public partial class CustomControl : UserControl
{
public static readonly DependencyProperty TextBoxTextProperty =
DependencyProperty.Register("TextBoxText", typeof (String), typeof
(CustomControl), new PropertyMetadata(default(String)));
public CustomControl()
{
InitializeComponent();
}
public String TextBoxText
{
get { return (String) GetValue(TextBoxTextProperty); }
set { SetValue(TextBoxTextProperty, value); }
}
}
Thanks for any help on this. It really drives me crazy now.

ActiveMQ converting `/` to `.` in queue names when using curl

ActiveMQ converting `/` to `.` in queue names when using curl

My ActiveMQ queue is named queue/andburn. Using
curl -u admin:admin -d 'body="Aardvark"'
"http://localhost:8161/api/message/queue/andburn?type=queue"
creates a new queue queue.andburn. When I escape / like \/ I get
queue\.andburn. When I omit type=queue I don't see my message added to my
existing queue. Same when I use &#47; to represent slashes.
Note: all escaping was done after queue in the URI, e.g.
"http://localhost:8161/api/message/queue\/andburn?type=queue"
The ActiveMQ REST page was not helpful in addressing this.

Video inside iframe inside lightbox wordpress

Video inside iframe inside lightbox wordpress

I'm using wordpress.
I'm trying to get a video inside iFrame, inside a lightbox. And display it
as the (iFrame) video file.
I want to use a video file, as display (instead of a thumbnail). Then,
when you click the video file, it opens up in a lightbox, where you have
the ability to play it.
I have no trouble embeding the video inside the iFrame, but I cant get it
to behave as I want, because I cant get iFrame to work inside a lightbox/
I havent found a lightbox plugin that lets me do this.
I cant get this to work. Also, I cant use "Form Lightbox"-plugin, as it
clashes with Optimizepress.
Thanks a bunch.

QTabWidget how to hide pane only?

QTabWidget how to hide pane only?

I have added a QToolButton as corner widget in QTabWidget which is
checkable. I want to hide all tabs (panes only) when the tool button is
unchecked. I tried to connect button's signal clicked(bool) with all tab's
setVisible(bool) slot not working but. I also connected tabwidget's
setvisible to the signal but complete widget became invisible(it was a
silly trial). Is there any way to make only pane invisible and tab bar
will not disappear ?

Thursday, 26 September 2013

Fixed Image size for different resolution -iOS

Fixed Image size for different resolution -iOS

I have an image of 5.64mm and i want to show the image in center of the
view.the problem is if i checked that image with different resolution and
device mean the image size should be same.(IMAGE IS E with height and
width 5.64mm).Whether it may b in native or html.image size should not
vary at any device and resolution.please help me.Thanks in Advance.

Thursday, 19 September 2013

Javascript avoid 0.2 + 0.4 = 0.6000000000000001 other than Math.round()

Javascript avoid 0.2 + 0.4 = 0.6000000000000001 other than Math.round()

Is there any better way other than
Math.round(0.2+0.4) = 0.6
Actually, I have a series of index 0, 0.02, 0.04, 0.06, 0.08, 0.10 ---- I
have to convert it to Array Index 0,1,2,3,4,5-- by dividing by 0.02
JavaScript provides
0.28/0.02 = 14.000000000000002
I solve this problem by Math.round(0.28/0.02). I am curious is there any
other or better way to solve this problem

Finding È for an algorithm

Finding È for an algorithm

I have the below pseudocode that takes a given unsorted array of length
size and finds the range by finding the max and min values in the array.
I'm just learning about the various time efficiency methods, but I think
the below code is È(n), as a longer array adds a fixed number of actions
(3).
For example, ignoring the actual assignments to max and min (as the
unsorted array is arbitrary and these assignments are unknown in advance),
an array of length 2 would only require 5 actions total (including the
final range calculation). An array of length 4 only uses 9 actions total,
again adding the final range calculation. An array of length 12 uses 25
actions.
This all points me to È(n), as it is a linear relationship. Is this correct?
Pseudocode:
// Traverse each element of the array, storing the max and min values
// Assuming int size exists that is size of array a[]
// Assuming array is a[]
min = a[0];
max = a[0];
for(i = 0; i < size; i++) {
if(min > a[i]) { // If current min is greater than val,
min = a[i]; // replace min with val
}
if(max < a[i]) { // If current max is smaller than val,
max = a[i]; // replace max with val
}
}
range = max – min; // range is largest value minus smallest

Android and iPhone

Android and iPhone

I am creating an android application for the first time and learning.
When I updated something to a website, could those updated one reflected
on the android automatically?
And another question is, are Android and iPhone related? or they have
their own software to design individually?
Thanks, your responds are appreciated.

visual studio no asp.net possibility

visual studio no asp.net possibility

so i just installed microsoft visual studio express 2012 for windows 8
(virtual machine) and i noticed there is no option of creating .asp files
normally, i should be able to file -> new web site, c#, empty. And then
add a new web form to create an aspx file, but i dont get these options.
i only get file -> new project which creates javascript (javascript) or
XAML files (visual basic, visual C#, visual C++)
i assume there is something wrong with installation. i tried installing
ASP.NET from the asp.net website but doesnt change anything.
please hold in mind i am a beginner, any help is much appreciated

How to get the o/p in exactly 4 digits in python by adding zeros?

How to get the o/p in exactly 4 digits in python by adding zeros?

I want to print the output in 4 digit For eg : if 16/2, the o/p should be
0008
How can I do it?

I commented out a method , yet Xcode still remembers it and is giving me an error

I commented out a method , yet Xcode still remembers it and is giving me
an error

Here is the error message I am getting:
2013-09-19 07:02:39.405 SimpleTable[26665:c07] -[test1ViewController
tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
0x8a3e300
However, I commented out 'numberOfRowsInSection'... why is xcode still
remembering it?
I tried to look through documentation but could not find any thing...
I cleaned the project I clicked on 'build'
still same problem.

Avalon Dock 2 Open Dialog-Window as Floating Pane via Caliburn

Avalon Dock 2 Open Dialog-Window as Floating Pane via Caliburn

I have WindowView and a WindowViewModel, where WindowView is simply
derived from Window.
I open this Non-Model dialog via Caliburn's Window Manager; i.e.
_windowManager.ShowWindow(_windowView);
How can I make 'WindowView' a floating pane that can be used by Avalon
Dock [Version 2] ?
I've thought about deriving the window from
LayoutAnchorableFloatingWindowControl but its constructer is internal, and
I'm not sure how to implement LayoutFloatingWindowControl (which is
protected ctor).
A nudge in the right direction would be much appreciated. :)

Pagination Not working properly in FF VB.Net

Pagination Not working properly in FF VB.Net

On selecting certain page number GridView returns error
"TypeError: FTB_API.TabContainer1_TabPanel7_FreeTextBox1 is undefined"
While this is working fine in IE, Chrome and Safari.

Wednesday, 18 September 2013

an example for encryption for java data types

an example for encryption for java data types

Can anyone show me (or provide a link to) an example of how to do
encryption in Java using bouncy castle? or similar API for data types
other than String I want to encrypt other java types like Integer, Double
and Date etc. I've looked over bouncycastle.org but cannot find any
documentation of their API.

Annotation Callout Action Not Working

Annotation Callout Action Not Working

This is my code for my action that should take place when the annotation
callout is clicked. It is supposed to take me to a new ViewController but
does not. Is there a small error in this code or is it a bigger problem?
- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control {
NSLog(@"calloutAccessoryControlTapped");
det = [[UIViewController alloc]init];
[self.navigationController pushViewController:det animated:YES];
}

combining c++ and java projects

combining c++ and java projects

I would like suggestions on how to combine two projects. They are both
open source, and I want to implement some of the features from one to the
other. Do I need to use some sort of "code converter".

Perfect forwarding and ambiguity of function-parameter binding

Perfect forwarding and ambiguity of function-parameter binding

I am experimenting with the perfect forwarding feature of C++11. Gnu g++
compiler reports an ambiguity issue of function-parameter binding (the
error is shown after the source code below). My question is why is it so,
as following the function-parameter binding process I don't see the
ambiguity. My reasoning is as follows: call to tf(a) in main() binds to
tf(int&) since a is an lvalue. Then function tf forwards the lvalue
reference int& a to function g hence the function void g(int &a) should be
uniquely invoked. Thus I do not see the reason for ambiguity. The error
disappears when the overloaded function g(int a) is removed from the code.
This is strange as g(int a) cannot be a candidate for binding with int &a.
Here is my code:
void g(int &&a)
{
a+=30;
}
void g(int &a)
{
a+=10;
}
void g(int a) //existence of this function originates the ambiguity issue
{
a+=20;
}
template<typename T>
void tf(T&& a)
{
g(forward<T>(a));;
}
int main()
{
int a=5;
tf(a);
cout<<a<<endl;
}
Compilation g++ -std=c++11 perfectForwarding.cpp reports the following
errors:
perfectForwarding.cpp: In instantiation of 'void tf(T&&) [with T = int&]':
perfectForwarding.cpp:35:7: required from here
perfectForwarding.cpp:24:3: error: call of overloaded 'g(int&)' is ambiguous
perfectForwarding.cpp:24:3: note: candidates are:
perfectForwarding.cpp:6:6: note: void g(int&&) <near match>
perfectForwarding.cpp:6:6: note: no known conversion for argument 1 from
'int' to 'int&&'
perfectForwarding.cpp:11:6: note: void g(int&)
perfectForwarding.cpp:16:6: note: void g(int)

SEO friendly Ajax nagivation with fallback?

SEO friendly Ajax nagivation with fallback?

I'm building a single page application with knockout js and .NET MVC 4 and
have now come to the point where I need to get navigation work properly.
Is there a easy way to get SEO friendly navigation with history pushstate
and fallback to old browsers? This is a real simle example of how my page
looks like:
<div id="Master">
... List of products ...
</div>
<div id="Detail">
... Product info ...
</div>
When clicking on a product I will load the product details and bind it to
the Detail div with knockout js. I'm not loading a separate html file,
everything is on the same page.
I'm thinking of a library called jquery address, but I'm a bit unsure
about SEO and making urls work. Entering product/xxx in the address bar
wouldn't work. How do people do this, do they route all incoming requests
to the "index" page with a parameter "product/xxx" which can be read by
the javascript, which will load the correct content?
And what about fallback for users with old browsers?
Any help is highly appreciated.

Formating of a MySql Field

Formating of a MySql Field

I am trying to move data over to a mysql database and one of the fields
(Which is a primary Key) is set like this. Format &&-###[&] I am unsure as
to what type of databse it has come from but i have a feeling it may my MS
Sql
Many thanks P

Tuesday, 17 September 2013

jquery change single div based on two dropdown selections

jquery change single div based on two dropdown selections

I'm quite new to jquery. I've tried searching for this but can't find any
good examples.
I'm trying to create a selection process using two dropdown lists. Each
list has three options. The user will select an option from list 1, then
an option from list 2. The combination of these options will then make a
particular div show.
If the user then changes one of the list selections, the div changes to
reflect the new combination.
I've tried with just at least getting one of the combinations to work, but
can't. So far I have:
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.boxy').hide();
$('#option1option3').show();
$("#selectField1, #selectField2").on("change", function(){
$('.boxy').hide();
$('#'+$('#selectField1')+$('#selectField2').val()).show();
});
});
</script>
<select id="selectField1">
<option value="option1">option1</option>
<option value="option2">option2</option>
</select>
<select id="selectField2">
<option value="option3">option3</option>
<option value="option4">option4</option>
</select>
<div id="option1option3" class="boxy">Content 1 and 3</div>
<div id="option1option4" class="boxy">Content 1 and 4</div>
<div id="option2option3" class="boxy">Content 2 and 3</div>
<div id="option2option4" class="boxy">Content 2 and 4</div>
I can do this using a single list and div (like here), but can't figure
out how to implement as I've described above.
Thanks for any help

Android, Image auto resize after clean&build

Android, Image auto resize after clean&build

I am writing an android apps and i put all my image in the "drawable-hdpi"
folder,
After i clean & build the apps, nearly all my images are resized!!
I have search for some result and i now know that i need to put the
different images into different drawable folder, but is there any way to
just turn back into the state before the clean and build? since i have
lots of images and i dont have much time to fix this...
please,please help me a bit if you know the answer...

Debug Query Cache JBoss/MyBatis/MySql

Debug Query Cache JBoss/MyBatis/MySql

I have a cache issue where any updates that are done directly done on the
database are not reflected on my application.
My java application is on jboss 5 and I have mybatis 3.1 that accesses the
mysql database.
On Mybatis in my mapper I have the following cache declared.
<cache eviction="FIFO" flushInterval="60000" size="512" readOnly="false"/>
And My MyBatis SQL Statements have useCache="true" and flushCache="true"
as specified in the documentation.
And MySqlMap Configuration has
<settings>
<setting name="cacheEnabled" value="true"/>
<setting name="lazyLoadingEnabled" value="false"/>
<setting name="aggressiveLazyLoading" value="false"/>
<setting name="multipleResultSetsEnabled" value="false"/>
<setting name="localCacheScope" value="SESSION"/>
<setting name="defaultExecutorType" value="REUSE"/>
</settings>
All these configurations are supposed to cache, but when we call
clearCache on the sqlSession from mybatis the cache is not cleared.
Jboss 5:
We are using Jboss 5 not sure if that is caching anything.
MySql Proxy:
I am using Mysql proxy and pointing my mysql-ds to the proxy and printing
the sql result set, even the proxy is returning the cached resultset.
MySQL:
I tried running reset query cache , flush tables none of them seemed to
impact.
MySql Command Line Client
I tried to query via this and it is reflecting the new values every time.
Any help is greatly appreciated to help to debug this issue.

How to lock the service and prevent the service from being fully deleted?

How to lock the service and prevent the service from being fully deleted?

Need to test cases when uninstall could not delete service and will set a
DeleteFlag for this service . Application is on a C# so the following
method is in use:
http://msdn.microsoft.com/en-us/library/ms682562(v=vs.85).aspx
How to lock the service and prevent the service from being fully deleted?

You Tube API Calls

You Tube API Calls

I have cut and pasted a python code sample from Google API to access You
Tube video viewing data of my companies videos. The application will be
scheduled and get usage data then write to a database on the server (
CENTOS ). I have tried both Simple API and installed application types. Is
there a solid samle type that you know of or anyone else having issues
with the API calls? My latest error is that the JSON file is not organized
correctly ( which I got from the API page unaltered ).

wfresh parameter causing ADFS login to fail

wfresh parameter causing ADFS login to fail

I am using ADFS to do federated logins with a number of different RPs,
including our own custom web app, Office 365 and some other third-party
services. I have run into a problem where logins silently fail when the
wfresh=0 is specified in the URL. It just keeps asking for my password
over and over again. When I click the "Login" button, it doesn't log you
in and redirect you to back to the RP, nor does it fail and give you an
error message. Instead, it redirects you back to the STS login page, so it
looks to the user like it's silently failing.
I found this question: wfresh not working with WS-Federation via ADFS,
which seems to be on the right track. However, while I am definitely
seeing issues with integrated logins, I am getting similar issues with
Forms logins as well. The outward symptoms are different, but the behavior
seems to be the same: If you specify wfresh=0, it sends you directly to
/adfs/ls.
Is there any way to configure ADFS to treat wfresh correctly, or at least
to ignore it?

Sunday, 15 September 2013

Does JS code contain an opening to hidden data? (Yes or no, probably)

Does JS code contain an opening to hidden data? (Yes or no, probably)

I would like to know, as one with very little JS experience, wether or not
this code contains a way for me to access more information. Here is an
example of a page which I am trying to scrape.
http://www.hannaford.com/product/8-piece-Mini-Sweet-Pepper-Carton/841589.uts?
I want the nutritional information. I could go to every food page on the
website and get every piece of data from the nutrition tables, but that
would take ages. I already have all of the other information from the
foods that I want, having done that by scraping from pages where there
were longer lists. (I could scrape in bulk)
So I am asking if anyone sees anything here that might grant me access to
wherever it is they are calling their nutrition data from, so I could load
up that one page and scrape from there, en masse.
<script type="text/javascript">
$(function() {
$('#primaryNutrition dd').each(function(){
var that = $(this);
var txt = $.trim(that.html());
if (txt.length > 0){
var values = txt.split(' ');
if ( values.length > 1 ){
if ( values[1].indexOf("%") === -1){
values[0] += values.pop();
}
}
if ( values.length > 1 ){
that.html(values[0]);
var newDD = document.createElement('dd');
newDD.innerHTML = values[1];
this.parentNode.appendChild(newDD);
} else {
that.addClass('one');
}
} else {
that.parent().hide();
}
});
});
</script>
My read on the situation is that the "#primary..." tells it to write to
that particular div id somehow. I do find interesting the "
$.trim(that.html()); " bit. I don't know enough to tell what is defined
and what is just part of javascript.
I picked that little snippet because it is what I thought was likely to
yield a positive result for me, but if someone sees something else on the
page, then that would be good too.

how to remove find the mode of an array in c#?

how to remove find the mode of an array in c#?

i know there are a lot of threats of this question but non of them has
help me the way i want. so here is my problem: i have this array: int []
array={1,1,1,2,2,4} i want to show the mode of that array but when i do
it, it shows three ones and one two and it should be one 1 and one 2, i
want to save the 2 numbers (1 and 2) in a list box and the number 4 in
another list box i just started programming (first semester) so i don't
know a lot of it
i found this code but i didn't fully understand it i don't know how to use
a dictionary and i can not use it because i do not know how it works sorry
for my bad English
int[] numsArr = { 1, 1, 1, 2, 2, 3, 4, 5, 6 };
Dictionary<int, int> dic = new Dictionary<int, int>();
for (int i = 0; i < numsArr.Length; i++)
{
if (dic.ContainsKey(numsArr[i]))
{
dic[numsArr[i]] = ++dic[numsArr[i]];
}
else
dic.Add(numsArr[i], 1);
}
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<int, int> kvp in dic)
sb.AppendLine(String.Format("Number {0} has {1} repetitions.",
kvp.Key, kvp.Value));`enter code here`
Console.WriteLine(sb.ToString());
Console.ReadLine();

PHP & PDO Page Lists

PHP & PDO Page Lists

I wrote the php and pdo page listing system but it isn't working. I wrote
some codes with pdo and php. But I understand to problem? Where is the
problem?
Code:
<?php
$sorgu = $baglan->prepare('SELECT * FROM `uye` ORDER BY `uye_id`');
$sorgu->execute();
$ksayisi = $sorgu->rowCount();
$limit = 10;
$ssayisi = ceil($ksayisi/$limit);
$baslangic = ($sayfa * $limit) - $limit;
$sorgu = $baglan->prepare('SELECT * FROM `uye` ORDER BY `uye_id` DESC
LIMIT $baslangic, $limit');
$sorgu->execute();
if($sorgu->rowCount() > 0){
while ($uyebilgi = $sorgu->fetch()){
?>
<tr>
<td><?php echo $uyebilgi['uye_id']; ?></td>
<td><?php echo $uyebilgi['uye_adi']; ?></td>
<td><?php echo $uyebilgi['uye_tarih']; ?></td>
<td>
<a href="user.html"><i class="icon-pencil"></i></a>
<a href="#myModal" role="button" data-toggle="modal"><i
class="icon-remove"></i></a>
</td>
</tr>
<?php }} ?>
Where is the problem?

Sort an array of objects PHP

Sort an array of objects PHP

I have this class:
class competitor{
public $name;
public $tops;
public $bonus;
public $tries_top;
public $tries_bonus;
}
I have an array with competitors classes objects in it and I would like
sort the array in the next order:
The greatest number of tops.
The greatest number of bonus.
The least number of tries_top.
The least number of tries_bonus.

Problems with elements order in JSP

Problems with elements order in JSP

Several days ago I started to learn Java EE and web development (firstly:
Tomcat, Servlets, JSP).
So now I have this JSP page code. As you can see, the header Hello World
with JSP stay before <% ... %> block.:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<html>
<body>
<h1 align="center">Hello World with JSP</h1>
<br>
<%
List styles = (List)request.getAttribute("styles");
for(Object style: styles){
response.getWriter().println("<br>try: " + style);
}
%>
</body>
</html>
But in result web page result from <% ... %> stay before the Hello World
with JSP header. Why?

P.S. Sorry for terminology but I'm really new in web development.

Creating a software for research

Creating a software for research

Hello I am a beginner programmer. I've been learning how to use Python,
JavaScript from Codecademy and little bit of C# from school. Since I have
never programmed any real programs and feel like what I really need to do
to learn how to code is actually to build simple programs.
So I thought it would be a good idea to build a simple graphing program.
Like this: http://www.youtube.com/watch?v=Cn3ogzLzxuM (skip to 4:05)
I've done some research and I could not find any relevant information so
here I am posting a question. So how would I tackle this problem? (I am
most confident using Python and for C# I would be able to get some help
from the teacher)

Get Current Identity through Linq while adding a new entry to my database

Get Current Identity through Linq while adding a new entry to my database

public class Person {
int Id{get;set;}
string Name{get;set;}
}
and set Id as Itentity Feed
ARMSEntity _entities=new ARMSEntity();
_entities.AddObject('Person',obj);
Now I want to get the current Id that is inserted into the database.
Thanks for any help in Advance

Saturday, 14 September 2013

How to implement a pictureBox.MoveHover

How to implement a pictureBox.MoveHover

Event handlers are still a bit new to me. I want to call this method that
will change the value of a member in a jagged list from 0 to 1 if the
mouse hovers over a certain part of the pictureBox.
public void onMouseUp(MouseEventArgs e, List<List<int>> walls,
List<List<int>> positions)
{
for (int i = 0; i < walls.Count; i++)
{
int[] mapData = mapController.getMapData(i, walls, positions);
int column = mapData[0];
int row = mapData[1];
int right = mapData[2];
int bottom = mapData[3];
if (e.X == column * mapController.map.squareSize)
{
mapController.map.cellWalls[i][0] = 1;
}
}
}
The method may be wrong, but i just want to call it first, then i can test
it. It's in a class called mapConstructor. I have a form class called
mapDesignerView that has the picture box.
To call it i tried this from within the form:
private void pbxMap_MouseHover(object sender, System.EventArgs e)
{
mapConstructor.onMouseUp(e, map.cellPositions, map.cellPositions);
}
It won't accept a mouseEvntArgs parameter so says invalid arguments as my
method needs the mouseEventArgs. I've tried a few different things too but
would like to hear a solution rather than tell you all the wrong things i
have tried.
I would like to call it continuously while the mouse is hovering over the
picturebox, i think, and when it changes a value of the list, the
picturebox will need to redraw itself.
Thanks.

How do you add a character to a variable without a space in Java?

How do you add a character to a variable without a space in Java?

I have this program that displays the cost per gallon of gasoline.
System.out.printf("%10s %.2f %s %n", "At", cost , "per gallon,");
The output displays
At 5.12 per gallon,
but I want it to display
At $5.12 per gallon,
I have tried to add the $ right after "At" but it displays a space before
showing the cost. Is there a way to remove the space between "$

how to compile c program using php script in ubuntu

how to compile c program using php script in ubuntu

I am developing an online testing system through which we can conduct
online programming contests. For the same i want to invoke the C compiler
from the php script using the functions like system(), shell_exec(),
exec() etc. But the function is not creating a.out file when i wrote g++
a.cpp -o a using terminal it worked.
But this is not working system("g++ a.cpp -o a",$as); //a.cpp is inside
www folder

ending "+" prompt in R

ending "+" prompt in R

I'm fairly new to R and I made a type-o while entering some code and now
instead of getting the ">" prompt I get a "+" prompt. I appear to be stuck
in some kind of function that is looking for input, but I can't seem to
get out of it. I figure that there must be a better way to fix this
problem then closing R and rerunning my script but I haven't been able to
find anything on google (likely because I don't know the right search
terms).
Thanks for your help, sorry it's a trivial question
The code I entered was as follows:
fit = lm(x~`y) + fit = lm(x~y) + fit + summary(fit) + + + end + ; + break
+ ) + + + + &#8232;&#8232; + &#8232; + quit() + + quit + break() +
abline(b0hat,b1hat) + return(null) +

need a program for the arithmetic (negation=?iso-8859-1?Q?=2C_addition=2C_subtraction_and_multiplication_of_two_inte?=gers) of integers using 3’s complement...

need a program for the arithmetic (negation, addition, subtraction and
multiplication of two integers) of integers using 3's complement...

need a program for the arithmetic (negation of an integer, addition,
subtraction and multiplication of two integers) of integers using 3's
complement representation .The integers will use 8-ternary digit
positions, in which the left-most position will be used for sign.

count failed login attempts in Cakephp

count failed login attempts in Cakephp

i am working on a cakephp 2.x. i am using auth component .. i want to ask
if that possible in auth component to track the user fail login attempts
and also i have searched on google and i found this component
http://bakery.cakephp.org/articles/aep_/2006/11/04/brute-force-protection
should i use this in my cakephp 2.3 .is that component is compatible for
2.3 ?i want to prevent my app from brute force attact. so is this
component is perfect for me ? or if there is any else good component there
too or a better approach to handle the brute force?

Friday, 13 September 2013

Connection to SharePoint APIs using Hybrid Mobile application

Connection to SharePoint APIs using Hybrid Mobile application

I am working on a mobile hybrid application, where am trying to connect to
a sharepoint website using apis it provide. Basically I want to connect
and access some sharepoint data. After so much of googling I am atlast
able to login to Office 365 using below piece of code.
$.ajax({
'url': 'https://login.microsoftonline.com/extSTS.srf',
dataType: 'text',
type:'POST',
'data': '<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action
s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action><a:MessageID>urn:uuid:40c1407d-b2a4-4e05-8248-8a92b71102b6</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To
s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To><o:Security
s:mustUnderstand="1"
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp
u:Id="_0"><u:Created>2012-07-26T16:13:00.622Z</u:Created><u:Expires>2012-07-26T16:18:00.622Z</u:Expires></u:Timestamp><o:UsernameToken
u:Id="uuid-69882db9-2d6b-45d3-b016-c2156cb6c01d-1"><o:Username>myusernameisinhere</o:Username><o:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mysharepointpasswordisinhere</o:Password></o:UsernameToken></o:Security></s:Header><s:Body><t:RequestSecurityToken
xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"><wsp:AppliesTo
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><a:EndpointReference><a:Address>https://somethingonline.sharepoint.com/_forms/default.aspx?wa=wsignin1.0</a:Address></a:EndpointReference></wsp:AppliesTo><t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType><t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType><t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType></t:RequestSecurityToken></s:Body></s:Envelope>',
headers: {
Accept : "application/soap+xml; charset=utf-8"
},
success: function(result, textStatus, jqXHR) {
document.body.innerHTML = result;
var xmlDoc = $.parseXML( result );
var xml = $( xmlDoc )
var binToken = xml.find("BinarySecurityToken").text();
callsomeFunction(binToken);
},
error:function (jqXHR, textStatus, errorThrown){
console.log(errorThrown+'error login:' + jqXHR.responseText);
},
complete:function(jqXHR, textStatus) {
console.log('login completed ' + textStatus);
}
});
Now I have a binToken (which I am getting successfully) and I am using it
to call an api, as this,
function callsomeFunction(binToken) {
var domain = "myurlishere";
var url = domain + "_api/web/GetFolderByServerRelativeUrl('PDF')";
$.support.cors = true;
$.ajax({
'url': url,
dataType: 'text',
type:'POST',
'data':binarysecurityToken,
headers: {
Accept : "application/x-www-form-urlencoded"
},
success: function(result, textStatus, jqXHR) {
alert('done wsignin ' + result);
},
error:function (jqXHR, textStatus, errorThrown){
alert('error wsignin:' + jqXHR.responseText);
},
complete:function(jqXHR, textStatus) {
alert('complete wsignin ' + textStatus); }
});
}
So, the output of this is an error with no responseText. Can anybody
please tell me what I am doing wrong in here?

Input string is not in correct format - C#

Input string is not in correct format - C#

I've written another GUI like this one that works fine, but this one is
not working properly. Throughout the many other questions I have looked
through on StackOverflow, I didn't see one similar to my issue. Can you
help me, please and thanks? :)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TestsInteractiveGUI
{
public partial class averageTestScoreCalculator : Form
{
// Begin the form
public averageTestScoreCalculator()
{
InitializeComponent();
}
// Textbox 1
private void testScoreTextBox1_TextChanged(object sender,
EventArgs e)
{
// Declare the variables
string scoreTB1;
// Have the user enter the test score for Test Score 1
scoreTB1 = testScoreTextBox1.Text;
}
// Textbox 2
private void testScoreTextBox2_TextChanged(object sender,
EventArgs e)
{
// Declare the variables
string scoreTB2;
// Have the user enter the test score for Test Score 2
scoreTB2 = testScoreTextBox2.Text;
}
// Textbox 3
private void testScoreTextBox3_TextChanged(object sender,
EventArgs e)
{
// Declare the variables
string scoreTB3;
// Have the user enter the test score for Test Score 3
scoreTB3 = testScoreTextBox3.Text;
}
// Textbox 4
private void testScoreTextBox4_TextChanged(object sender,
EventArgs e)
{
// Declare the variables
string scoreTB4;
// Have the user enter the test score for Test Score 4
scoreTB4 = testScoreTextBox4.Text;
}
// Textbox 5
private void testScoreTextBox5_TextChanged(object sender,
EventArgs e)
{
// Declare the variables
string scoreTB5;
// Have the user enter the test score for Test Score 5
scoreTB5 = testScoreTextBox5.Text;
}
// Button
private void calculateTestScoresButton_Click(object sender,
EventArgs e)
{
// Declare the variables
const int NUMBER_OF_TESTS = 5;
int scoreTB1Int = Convert.ToInt32(testScoreTextBox1.Text);
int scoreTB2Int = Convert.ToInt32(testScoreTextBox2.Text);
int scoreTB3Int = Convert.ToInt32(testScoreTextBox3.Text);
int scoreTB4Int = Convert.ToInt32(testScoreTextBox4.Text);
int scoreTB5Int = Convert.ToInt32(testScoreTextBox5.Text);
// Declare variables to hold results and calculate the average
test score
double averageScore = (scoreTB1Int + scoreTB2Int + scoreTB3Int
+ scoreTB4Int + scoreTB5Int) / NUMBER_OF_TESTS;
// Enable and display the results
resultLabel.Enabled = true;
resultLabel.Visible = true;
resultLabel.Text = string.Format("The average test score
{0n2}%", averageScore);
}
// Result label
private void resultLabel_Click(object sender, EventArgs e)
{
}
}
}

UNIX timestamp comparison

UNIX timestamp comparison

I am using fallowing schema for my database to store messaging threads.
CREATE TABLE threads(_id INTEGER PRIMARY KEY AUTOINCREMENT,
date_sent_or_received INTEGER, read INTEGER, count INTEGER, body TEXT,
address TEXT, error_code INTEGER);
I have the fallowing trigger that gets activated whenever I insert values
into a SMS table.
CREATE TRIGGER update_thread_id AFTER INSERT ON sms
WHEN
0 <> (select count() from threads where
length(address)>=length(new.address) and substr(address,
length(address)-length(new.address)+1) like new.address)
BEGIN
UPDATE threads SET
address = new. address where substr(address,
length(address)-length(new.address)+1) like new.address;
UPDATE threads SET
date_sent_or_received=new.date_sent_or_received,
read = new.read,
body = new.body where date_sent_or_received<=new.date_sent_or_received and
address like new.address;
UPDATE sms SET
thread_id= (select _id from threads where address like new.address) where
_id = new._id;
UPDATE threads SET
count = (select count() from sms where thread_id=(select _id from threads
where address like new.address)) where address like new.address;
END;
I am encountering problem statement where I am trying to change content of
thread only when it is older than the newer one. It goes like this.
UPDATE threads SET
date_sent_or_received=new.date_sent_or_received,
read = new.read,
body = new.body where date_sent_or_received<=new.date_sent_or_received and
address like new.address;
However, it doesn't works. Content of the table remains same even when
newly inserted row is larger in timestamp, this trigger updates the
address according to newly added row.
I am storing seconds in Integer. Any ideas where I am wrong ?

alternative

alternative

I am developing Jax-ws web service using Metro. I want to deploy this
service on Weblogic 10.3.0. I followed the steps as described here section
2.9.1.
But weblogic 10.3.0 does't allow <prefer-application-resources> tag. So I
am not able to load files inside Jax-ws META-INF/services/javax.xml.ws.*
directory. Is there any alternative of <prefer-application-resources> in
weblogic 10.3.0.

remove the black underline on hover for an image link

remove the black underline on hover for an image link

I'm havins some difficulty with my image links in google chrome. the
images get a black underline when they have been hovered over, how do i
remove this I've tried
a {
color: #000;
&:visited {
color: #666;
}
&:hover {
outline-style:none;
box-shadow:none;
border-color:transparent;
}
}
and
a {
color: #000;
&:visited {
color: #666;
}
&:hover {
border-style:none;
}
}
along with loads of other things but nothing seems to work, the css does
effect it but not how i want it to, Any help would really be appreciated.

CSS Flex boxes not working fine with Chrome

CSS Flex boxes not working fine with Chrome

I try to use flexbox CSS to implement a some stuff. I just want
compatibility in Chrome & Firefox. I do the job with success in FF but
doesn't work in Chrome. What I want, It's insert vertical boxes center,
recursively. You can have a look here : http://jsfiddle.net/GuDcM/
div.contenaireBlc {background:#FFF; border:1px solid #ddd;
width:250px; height:250px;margin:0 30px 0 0;}
.contenaireHori {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
-webkit-flex-direction: column;
-webkit-flex-wrap: nowrap;
background:#777;
height:100%;
width:100%;
}
.innerTop{
-webkit-flex: 1 1 50%;
flex: 1 1 50%;
background: green;
width: 100%;
}
.traversHori{
flex: 0 0 20px;
-webkit-flex: 0 0 20px;
background: blue;
width: 100%;
}
.innerBottom{
-webkit-flex: 1 1 50%;
flex: 1 1 50%;
background: red;
width: 100%;
}
In chrome, the second red & green box have height = 0px, in place to take
left space (50% each).
Thanks for helping. Anthony

very strange issue; different results from same table

very strange issue; different results from same table

I am binding a gridview with some column from a database table, but it
shows different results in Pane and in Gridview. see the attachted images.


see the marked records why they are different, although they are comming
from the same table.
But yes for binding gridview I am using this query
SELECT mtblbuilding_budget_data.building_id,
mtblbuilding_budget_data.building_name,
mtblbuilding_budget_data.sanctioned_dpr,
mtblbuilding_budget_data.sanctioned_contract,
mtblblock.block_name
FROM mtblbuilding_budget_data
LEFT JOIN mtblblock
ON mtblblock.block_id = mtblbuilding_budget_data.block_id
WHERE mtblbuilding_budget_data.sfti_id = @SFTI_Id
AND mtblbuilding_budget_data.spmu_id = @SPMU_Id
ORDER BY mtblbuilding_budget_data.block_id

Thursday, 12 September 2013

What is MVC4 in asp.net?

What is MVC4 in asp.net?

What are new feature in MVC and Entity framework 5.0? How we can use the
MVC4 in our allocation and architecture for that

Copy and pasted Microsoft example of Javascript to check value in cell, but fails to work

Copy and pasted Microsoft example of Javascript to check value in cell,
but fails to work

I have been staring at the code below for hours, and I am not sure where
to begin on how to fix the problem. In advance, I believe this is more of
a javascript problem on my end then a Microsoft Web API problem, since I
am literally copying and pasting their code.
I am trying to use Microsoft Excel's Web API to embed an embed an excel
sheet on my web page. More specifically, I am trying to have, when
highlighted on a cell, it displays the value of the selected cell.
Here is their working example with code
http://www.excelmashup.com/APIBrowser#example105
Simply change the tab from "Output" to "HTML" in the bottom right to see
the same code as below:
<html>
<head>
<script type="text/javascript"
src="http://r.office.microsoft.com/r/rlidExcelWLJS?v=1&kip=1"></script>
<script type="text/javascript">
// run the Excel load handler on page load
if (window.attachEvent) {
window.attachEvent("onload", loadEwaOnPageLoad);
} else {
window.addEventListener("DOMContentLoaded", loadEwaOnPageLoad, false);
}
function loadEwaOnPageLoad() {
var fileToken =
"SDBBABB911BCD68292!110/-4923638281765748078/t=0&s=0&v=!ALTlXd5D3qSGJKU";
var props = {
uiOptions: {
showGridlines: false,
selectedCell: "'Sheet1'!C9",
showRowColumnHeaders: false,
showParametersTaskPane: false
},
interactivityOptions: {
allowTypingAndFormulaEntry: false,
allowParameterModification: false,
allowSorting: false,
allowFiltering: false,
allowPivotTableInteractivity: false
}
};
Ewa.EwaControl.loadEwaAsync(fileToken, "myExcelDiv", props,
onEwaLoaded);
}
function onEwaLoaded() {
document.getElementById("loadingdiv").style.display = "none";
}
// This sample gets the value in the highlighted cell.
// Try clicking on different cells then running the sample.
function execute()
{
// Get unformatted range values (getValuesAsync(1,...) where 1 =
Ewa.ValuesFormat.Formatted)
ewa.getActiveWorkbook().getActiveCell().getValuesAsync(1,getRangeValues,null);
}
function getRangeValues(asyncResult)
{
// Get the value from asyncResult if the asynchronous operation was
successful.
if (asyncResult.getCode() == 0)
{
// Get the value in active cell (located at row 0, column 0 of the
// range which consists of a single cell (the "active cell")).
alert("Result: " + asyncResult.getReturnValue()[0][0]);
}
else
{
alert("Operation failed with error message " +
asyncResult.getDescription() + ".");
}
}
</script>
</head>
<body>
<input type="button" onclick="execute();">Execute Sample</input>
<<<<<Here is the problem
<div id="myExcelDiv" style="width: 402px; height: 346px"></div>
</body>
</html>
When I change the above to onclick="alert('hello')" it works fine, but it
does not alert the value of the cell when I click execute(); . Maybe
someone could copy and past the code into an .html file and see if it is
just a problem on my end and whether the Microsoft code works for them.
I truly appreciate any help.

Detect keyup event of contenteditable child whose parent is a contenteditable div

Detect keyup event of contenteditable child whose parent is a
contenteditable div

Goal: Attach a keydown event handler to a contenteditable span that is the
child of a contenteditable div.
Problem: If you type in the span the parent event is triggered not the
childs. What I want is the child to trigger so I can grab the text. I only
want THAT contenteditable child as there will be many.
HTML/JS is below and the fiddle link is here: http://jsfiddle.net/aBYpt/4/



HTML
<div class="parent" contenteditable="true">
Parent div text.
<span class="child" contenteditable="true">First child span text.</span>
<span class="child" contenteditable="true">Second child span text.</span>
<span class="child" contenteditable="true">Third child span text.</span>
</div>
<div id="console"></div>
JavaScript/jQuery
$(document).on( 'keyup', '.parent', function() {
$('#console').html( 'Parent keyup event fired.' );
//do stuff
});
$(document).on( 'keyup', '.child', function(e) {
$('#console').html( 'Child keyup event fired.' );
//do stuff
});
**Note: Event handling is delegated to document because elements are
dynamically added.

Using Laravel DB object to run postgresql functions with input parameters

Using Laravel DB object to run postgresql functions with input parameters

I have some postgresql functions that I run in the form:
SELECT * FROM pgfunction(1,2,3);
This enables me to filter / order / group the results:
SELECT * FROM pgfunction(1,2,3) WHERE value > 10;
How could I pass the parameters to the postgresql function in laravel
using prepared statements in order to filter the results in laravel.
Example:
DB:RAW('pgfunction',array(1,2,3))->where('value','>','10');
Is this possible?

Looping through sheets finding values and saving them values on another sheet

Looping through sheets finding values and saving them values on another sheet

I have a spreadsheet which has many different sheets which is growing and
reducing all the time.
There will be multiple sheets that look identical but with different data.
Cell c1 holds a date Column a holds record id Column B holds a percentage
I need to save the % against the record id and create a column with the
date as a heading in a separate sheet. If the date already exists I need
to overwrite the data in that column with the new data in the different
sheets. The date will be consistent across all spreadsheets
Any help would be appreciated
Thanks in advance

Wednesday, 11 September 2013

Sague connection tab bar controller

Sague connection tab bar controller

Objective: i am trying to create an application which looks like this, on
each button click seprate tab should open in tab bar controller. Problem
However when i create the sague connection from home screen to the tab bar
controller it always takes me to the first tab. Question How do i link
each button from root secene to different tab, if i do it by pointing
sague to different tab item it shows blank view instead of showing a tab
bar. please help.
http://postimg.org/image/54h3giqnt/
P.S i have tried to do this programmatically by using the
selectedindex=0 etch
it doesn't work either. if any one can provide me with tutorial which
looks similar to this image would be really appreciated

Wordpress sidebar menu. Show one div and hide all others

Wordpress sidebar menu. Show one div and hide all others

I would appreciate your help on this.
The following code is for a wordpress sidebar vertical menu. For now, when
a user clicks on items with submenus, all of them would stay opened unless
he clicks on items again.
I would need only one submenu to be opened at a time when a user click .
Thank you.
Here is my code:
HTML-->
<nav id="top-menu">
<ul class="nav et_disable_top_tier" id="menu-main-menu">
<li class="menu-item menu-item-type-custom
menu-item-object-custom current-menu-item current_page_item
menu-item-home menu-item-756" id="menu-item-756">
<a
href="http://graphic-redsoyu.com/andretschan/"><span
class="link_bg"></span><span
class="link_text">ACCUEIL</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-982" id="menu-item-982">
<a class="" href="#"><span
class="link_bg"></span><span class="link_text">L'ECOLE
DE DANSE<span>+</span></span></a>
<ul class="sub-menu" style="display: none;">
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-795"
id="menu-item-795">
<a
href="http://graphic-redsoyu.com/andretschan/lecole-de-danse/presentation-de-notre-centre/"><span
class="link_bg"></span><span
class="link_text">PRESENTATION DE
NOTRE CENTRE</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-791"
id="menu-item-791">
<a
href="http://graphic-redsoyu.com/andretschan/lecole-de-danse/objectifs-valeurs-du-centre/"><span
class="link_bg"></span><span
class="link_text">OBJECTIFS &amp;
VALEURS DU CENTRE</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-792"
id="menu-item-792">
<a
href="http://graphic-redsoyu.com/andretschan/lecole-de-danse/compagnie-element-terre/"><span
class="link_bg"></span><span
class="link_text">COMPAGNIE ELEMENT
TERRE</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-790"
id="menu-item-790">
<a
href="http://graphic-redsoyu.com/andretschan/lecole-de-danse/les-succes-des-eleves/"><span
class="link_bg"></span><span
class="link_text">LES SUCCES DES
ELEVES</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-789"
id="menu-item-789">
<a
href="http://graphic-redsoyu.com/andretschan/lecole-de-danse/nos-studios/"><span
class="link_bg"></span><span
class="link_text">NOS
STUDIOS</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-788"
id="menu-item-788">
<a
href="http://graphic-redsoyu.com/andretschan/lecole-de-danse/la-boutique/"><span
class="link_bg"></span><span
class="link_text">LA
BOUTIQUE</span></a>
</li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-889" id="menu-item-889">
<a class="et_clicked" href="#"><span
class="link_bg"></span><span class="link_text">NOS
DISCIPLINES<span>+</span></span></a>
<ul class="sub-menu et_active_dropdown"
style="display: block;">
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-884"
id="menu-item-884">
<a
href="http://graphic-redsoyu.com/andretschan/nos-disciplines/cursus-general/"><span
class="link_bg"></span><span
class="link_text">CURSUS
GENERAL</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-885"
id="menu-item-885">
<a
href="http://graphic-redsoyu.com/andretschan/nos-disciplines/disciplines-academiques/"><span
class="link_bg"></span><span
class="link_text">DISCIPLINES
ACADEMIQUES</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-886"
id="menu-item-886">
<a
href="http://graphic-redsoyu.com/andretschan/nos-disciplines/cursus-passion/"><span
class="link_bg"></span><span
class="link_text">CURSUS
PASSION</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-887"
id="menu-item-887">
<a
href="http://graphic-redsoyu.com/andretschan/nos-disciplines/disciplines-annexes/"><span
class="link_bg"></span><span
class="link_text">DISCIPLINES
ANNEXES</span></a>
</li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-952" id="menu-item-952">
<a
href="http://graphic-redsoyu.com/andretschan/nos-professeurs/"><span
class="link_bg"></span><span class="link_text">NOS
PROFESSEURS</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-1024" id="menu-item-1024">
<a
href="http://graphic-redsoyu.com/andretschan/informations-pratiques-et-plannings/"><span
class="link_bg"></span><span class="link_text">INFOS
PRATIQUES ET PLANNINGS</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-19" id="menu-item-19">
<a class="et_clicked" href="#"><span
class="link_bg"></span><span class="link_text">LA
GALERIE<span>+</span></span></a>
<ul class="sub-menu et_active_dropdown"
style="display: block;">
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-1925"
id="menu-item-1925">
<a
href="http://graphic-redsoyu.com/andretschan/la-galerie/visuels-les-spectacles/"><span
class="link_bg"></span><span
class="link_text">Visuels – Les
Spectacles</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-1924"
id="menu-item-1924">
<a
href="http://graphic-redsoyu.com/andretschan/la-galerie/visuels-les-stages/"><span
class="link_bg"></span><span
class="link_text">Visuels – Les
Stages</span></a>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-2103"
id="menu-item-2103">
<a
href="http://graphic-redsoyu.com/andretschan/la-galerie/videos/"><span
class="link_bg"></span><span
class="link_text">Vidéos</span></a>
</li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type
menu-item-object-page menu-item-18" id="menu-item-18">
<a
href="http://graphic-redsoyu.com/andretschan/contact-renseignement/"><span
class="link_bg"></span><span
class="link_text">RENSEIGNEMENTS &amp;
CONTACT</span></a>
</li>
</ul>
</nav>



-> JAVASCRIPT
var $comment_form = $('#commentform'),
$mobile_nav = $('#mobile-nav'),
$info_area = $('#info-area'),
$top_menu = $('#top-menu');
$top_menu.find('a').each( function(){
var $this_link = $(this),
link_text = $this_link.text(),
dropdown_sign = '';
if ( $this_link.siblings('ul').length ) dropdown_sign =
'<span>+</span>';
$this_link.html( '<span class="link_bg"></span>' + '<span
class="link_text">' + link_text + dropdown_sign + '</span>' );
} ).click( function(){
var $this_link = $(this);
if ( $this_link.attr('href') == '#' &&
$this_link.hasClass('et_clicked') ) {
$this_link.removeClass('et_clicked');
$this_link.siblings('ul').slideUp( 500
).removeClass('et_active_dropdown');
return false;
}
if ( $this_link.siblings('ul').length ){
if ( $this_link.hasClass('et_clicked') ) {
return;
} else {
$this_link.addClass('et_clicked');
$this_link.siblings('ul').slideDown( 500
).addClass('et_active_dropdown');
return false;
}
}
} );

Calculating the starting size of a length, when it grows per iteration and must remain within a limit

Calculating the starting size of a length, when it grows per iteration and
must remain within a limit

Ok so, obviously from the way I've worded my question; I'm no
mathematician. I'm currently experimenting with fractals, and this
specific question refers to the 'TSqare' fractal. (See bottom of question
for explanation).
Basically I want to calculate the size of the initial square, so the
resulting fractal of depth(n) never extends beyond the limit of the
drawing surface. I've tried to figure it out myself, but I'm getting no
where.
All I have figured out is the rate the square grows:
Assuming an initial size of 100, total length of fractal is as follows
Depth(0) = 100
Depth(1) = 150
Depth(2) = 175

Unfortunately I can't even figure out the formula for that, even though
the pattern is obvious. D:
TSquare Definition: An initial square S0 is drawn with size x2. Each
iteration 4 Squares half the size of the original (x2/2) are drawn with
their centers on the 4 vertices of the square before it. See
http://www.smokycogs.com/blog/t-square-fractals/ for more details.

How to Set the Parameters in Managed Bean from java script in Primefaces

How to Set the Parameters in Managed Bean from java script in Primefaces

I have two autocomplete fields as below. I swap the autocomplete values
using a command button. I need to persist the swapped values.
<p:column colspan="2" rendered="#{empty
contactController.selectedContact}">
<p:autoComplete id="contactName1" value="#{newContactRs.contact}"
completeMethod="#{contactRelationshipController.completeContacts}"
var="contact" itemLabel="#{contact.fullName}"
itemValue="#{contact}"
converter="#{contactConverter}"
forceSelection="true" size="35" scrollHeight="200"
panelStyle="width:10px;">
<p:ajax event="itemSelect" update="contactName1" />
</p:autoComplete>
<p:commandButton icon="ui-icon-arrow-2-e-w" id="flipButton"
styleClass="ui-panel-titlebar-icon"
oncomplete="swapInput()"
update="addNewContactRelationshipPanel"
immediate="true"/>
<smith:contactSelector value="#{newContactRs.contact}"
update=":addContactRelationshipForm:addNewContactRelationshipPanel"
triggerId="existingContactSelector1"
resultList="#{contactRelationshipController.selectAllContact1}"/>
</p:column>
<p:column colspan="2">
<p:autoComplete id="contactName2"
value="#{newContactRs.relatedContact}"
completeMethod="#{contactRelationshipController.completeContacts}"
var="contact" itemLabel="#{contact.fullName}"
itemValue="#{contact}"
converter="#{contactConverter}"
forceSelection="true" size="35" scrollHeight="200"
panelStyle="width:10px;">
<p:ajax event="itemSelect" update="contactName2" />
</p:autoComplete>
<smith:contactSelector value="#{newContactRs.relatedContact}"
update=":addContactRelationshipForm:addNewContactRelationshipPanel"
triggerId="existingContactSelector2"
resultList="#{contactRelationshipController.selectAllContact2}"/>
</p:column>
On clicking the commandbutton with id "flipButton" following javascript is
called and it swaps the values of the autocomplete fields
function swapInput()
{
var input_a
=document.getElementById('addContactRelationshipForm:contactName1_input').value;
var input_b
=document.getElementById('addContactRelationshipForm:contactName2_input').value;
document.getElementById('addContactRelationshipForm:contactName1_input').value
= input_b;
document.getElementById('addContactRelationshipForm:contactName2_input').value
= input_a;
}
After swapping the values am trying to persist the swapped values but
original values are persisting instead of swapped values. I have to set
the swapped values in the backing bean but am not sure how to do it, using
javascript or primefaces.

Nothing showing up in QScrollArea

Nothing showing up in QScrollArea

I have a nice widget that basically looks like a dialog box with a bunch
of QSliders on it. The number of sliders varies depending on the situation
when the dialog (not an actual QDialog; just a QWidget) is invoked.
Since the varying number of sliders causes the box to be different sizes
at different times, I now want to clean things up a bit by confining the
sliders to a QScrollArea. If I understand things correctly, such a scroll
area would display however many sliders fit within its height, and one
could scroll down to see the rest if there were more.
Anyway, I tried a (somewhat complicated) procedure like this:
In constructor of custom QWidget class (m_variableName = member variable):
CustomScrollBox::CustomScrollBox(QWidget* _parent){
setWindowTitle(...);
...
m_scrollArea = new QScrollArea(this);
m_scrollAreaBox = new QGroupBox(m_scrollArea);
m_layout = new QGridLayout();
m_scrollAreaBox->setLayout(m_layout);
m_scrollArea->setWidget(m_scrollAreaBox);
m_scrollArea->setFixedHeight(250);
m_bottomButton = new QPushButton(this); //probably irrelevant
...
[connect calls, etc.]
}
After the constructor, the real, situation-dependent set-up of sliders
occurs:
void
CustomScrollBox::SetUpWidgets(){
for([however many sliders the situation calls for]){
CustomSlider* s = new CustomSlider(this, label); //just a QWidget
consisting of a
//QSlider and a
QLabel to
//the left of it
..
m_layout->addWidget(s, [grid dimensions as needed]);
}
...
[set text on bottom button, etc., and add it as well]
}
This process causes nothing to show up on the overall dialog, except for
an immobile scroll bar on the left. What, if possible, is the proper order
of initialization steps to make this work? My guess is that I might have
given something the wrong parent or set a layout at the wrong time, but
the rearrganements I've tried so far haven't worked...

Show original element after clicking outside of the secondary element

Show original element after clicking outside of the secondary element

I want hide secondary image when user clicks anywhere else like somewhere
in the page so if you look at the jfiddle, black box should become red
again after user clicks outside of the black box.
I got the hiding code from this source: Use jQuery to hide a DIV when the
user clicks outside of it.
Thanks
HTML:
<img id="language_arrow_bottom" src="http://placehold.it/32/ff0000"
width="13px" height="13px" alt="" />
<img id="language_arrow_up" src="http://placehold.it/32/000000"
width="13px" height="13px" alt="" style="display:none;" />
JS:
$(document).ready(function ()
{
$('#language_arrow_bottom').click(function(event)
{
$('#language_arrow_bottom').hide();
$('#language_arrow_up').show();
});
$('#language_arrow_up').click(function(event)
{
$('#language_arrow_up').hide();
$('#language_arrow_bottom').show();
});
var container = $('#language_arrow_up');
if (!container.is(e.target) && container.has(e.target).length === 0)
{
container.hide();
$('#language_arrow_bottom').show();
}
});

Persistently bugging someone about updating their profile, the 'Rails way'?

Persistently bugging someone about updating their profile, the 'Rails way'?

In my Rails application, I wanted a user to be persistently shown a
warning notice to update their profile, until they do it. Specifically I
want them to fill in their name ASAP, but I don't want them to do that
during signup. So I wrote the following in a partial that is loaded in my
application layout:
<% if user_signed_in? && current_user.profile.name == nil %>
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
Please fill in your Profile as soon as possible. This information is
important for you to use the application properly.
<%= link_to "Do it now", edit_profile_path(current_user) %>
</div>
<% end %>
However I feel like this is a really clunky way to do it. Firstly this
means that every time a signed in user accesses a page, there's a database
check for their profile as well. Secondly it's logic in the view.
So my question is, what would be a more 'Rails way' to do this? Somehow
move the logic into the application controller? Load the result of the
logic into a session variable or something so that the database doesn't
need to be checked every page load?

Android SurfaceView video player Black screen

Android SurfaceView video player Black screen

I'm new at android and i'm trying to make a simple video player using
surfaceView.
My xml:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="800dp"
android:layout_height="800dp"
android:orientation="vertical" >
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</AbsoluteLayout>
My code:
public class MainActivity extends Activity
implements SurfaceHolder.Callback {
MediaPlayer mediaPlayer;
SurfaceView surfaceView;
SurfaceHolder surfaceHolder;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFormat(PixelFormat.UNKNOWN);
surfaceView = (SurfaceView)findViewById(R.id.surfaceview);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setFixedSize(176, 144);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mediaPlayer = new MediaPlayer();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
mediaPlayer.setDisplay(holder);
play();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
void play(){
try {
mediaPlayer.setDataSource("android.resource://"+getPackageName()+"/"+R.raw.video);
mediaPlayer.prepare();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
}
My problem is that the video dont start only apears a black screen no
video or sound. I'm doing something wrong? Any ideas? Thx for the help.

Rsync replaces files newer

Rsync replaces files newer

I'm using rsync to migrate data from a server to another. Normaly it must
replace files on new server only if they are older than source files. But
i my cas it does the opposite! If I modifie a file on the source server,
so the date is newer after, and I lanch my rsync command, it replaces only
this file with the old one from the source...?? What am I missing??
Here is my command:
rsync -e ssh -avz --exclude="cache/*.*" --exclude="cache_*"
--exclude="annuair/" --exclude="homes/" --exclude=".spamassassin/"
--exclude=".usermin/" --exclude="cgi-bin/" --exclude="etc/"
--exclude="fcgi-bin/" --exclude="logs/" --exclude="Maildir/"
--exclude="tmp/" /home/mysite/ root@5.39.72.228:/home/mysite
Thanks

Tuesday, 10 September 2013

java.lang.IllegalArgumentException in Android with DateFormat

java.lang.IllegalArgumentException in Android with DateFormat

Here is my code fragment
here date in 10-Sep-2013 09:53:37 format
TextView tvDate = (TextView) convertView.findViewById(R.id.entered_date);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
tvDate.setText(dateFormat.format(salesReportItems.getDate().toString()));
TextView tvCardType = (TextView) convertView.findViewById(R.id.card_type);
tvCardType.setText(salesReportItems.getCardType().toString());
Please help me to sort out this issue.here is my error.

Convert code from c# to javascript

Convert code from c# to javascript

I did some validations in code behind, but i want to do it in client side
with javaScript or jQuery, I'm learning it but this is really hard for me
to do it quickly... and it's a bit pressing!
I need only to convert the function : private bool Cbs_Validating()
private const int MIN_RESERVATION_HOUR = 8;
private const int MAX_RESERVATION_HOUR = 18;
private const int FIRST_LOCAL_NB = 1;
private const int LAST_LOCAL_NB = 4;
protected List<string> choiceList = new List<string>();
protected bool[,] ChoosenTabBool = new bool[MAX_RESERVATION_HOUR + 1,
LAST_LOCAL_NB + 1];
protected List<string> contiguousRanges = new List<string>();
protected int cbsCounter = 0;
protected void GenerateTable()
{
for (int i = MIN_RESERVATION_HOUR; i <= MAX_RESERVATION_HOUR; i++)
{
TableRow row = new TableRow();
this.resTab.Controls.Add(row);
TableHeaderCell headerCell = new TableHeaderCell();
headerCell.Text = i + "h";
row.Controls.Add(headerCell);
for (int j = FIRST_LOCAL_NB; j <= LAST_LOCAL_NB; j++)
{
TableCell cell = new TableCell();
CheckBox cb = new CheckBox();
cb.ID = "cb" + i.ToString() + j.ToString();
cell.Controls.Add(cb);
row.Controls.Add(cell);
}
}
}
protected void CheckCheckedCbs()
{
for (int i = MIN_RESERVATION_HOUR; i <= MAX_RESERVATION_HOUR + 1;
i++)
{
for (int j = FIRST_LOCAL_NB; j <= LAST_LOCAL_NB + 1; j++)
{
Control cont = FindControl("cb" + i.ToString() +
j.ToString());
if (cont != null)
{
if (cont is CheckBox)
{
CheckBox cbox = (CheckBox)cont;
if (cbox.Checked)
{
this.ChoosenTabBool[i, j] = true;
cbsCounter++;
}
}
}
}
}
}
private bool Cbs_Validating()
{
bool retValid = true;
bool flagHoursError = false;
for (int i = MIN_RESERVATION_HOUR; i < MAX_RESERVATION_HOUR + 1; i++)
{
for (int j = FIRST_LOCAL_NB; j < LAST_LOCAL_NB + 1; j++)
{
if (this.ChoosenTabBool[i, j] == true)
{
for (int remainingLoc = 1; remainingLoc <
LAST_LOCAL_NB; remainingLoc++)
{
if (remainingLoc != j)
{
if (this.ChoosenTabBool[i, remainingLoc] == true)
{
retValid = false;
}
}
}
}
}
}
if (retValid)
{
this.lblErrorResTable.Text = "";
int threeNextHours = 0;
for (int i = MIN_RESERVATION_HOUR; i < MAX_RESERVATION_HOUR +
1; i++)
{
for (int j = FIRST_LOCAL_NB; j < LAST_LOCAL_NB + 1; j++)
{
if (this.ChoosenTabBool[i, j] == true)
{
threeNextHours = i + 1;
if (threeNextHours < 19)
{
if (this.ChoosenTabBool[threeNextHours, j] ==
true)
{
threeNextHours = i + 2;
if (threeNextHours < 19)
{
if
(this.ChoosenTabBool[threeNextHours,
j] == true)
{
threeNextHours = i + 3;
if (threeNextHours < 19)
{
if
(this.ChoosenTabBool[threeNextHours,
j] == true)
{
retValid = false;
flagHoursError = true;
}
}
}
}
}
}
}
}
}
}
else
{
this.lblErrorResTable.Text = "Une personne ne peut réserver
plus d'un local pour une plage horaire donnée.";
}
if (flagHoursError)
{
this.lblErrorResTable2.Text = "Un local peut être réservé pour
un maximum de 3 heures consécutives par la même personne.";
}
else
{
this.lblErrorResTable2.Text = "";
}
return retValid;
}`