Thursday, 3 October 2013

Get a multiple level dropdown to only appear at a certain browser width

Get a multiple level dropdown to only appear at a certain browser width

I'm trying to create a list of links that are visible on desktop and
tablet but when you resize it down to mobile size it becomes part of a
multilevel drop down. I've got it to work but only when I refresh the
page.
Please bare with me as I am a noob at js.
I've tried working two different pieces of js that I've found on tutorials
and I'm sure there would be a simpler way of accomplishing this.
html
<ul class="accordion">
<li>
<a href="#">America</a>
<ul>
<li><a href="#">New York</a></li>
<li><a href="#">San Fransisco</a></li>
<li><a href="#">Washington</a></li>
</ul>
</li>
<li>
<a href="#">Antarctica</a>
</li>
<li>
<a href="#">Afro-Eurasia</a>
<ul>
<li><a href="#">Amsterdam</a></li>
<li><a href="#">Paris</a></li>
<li><a class="#">Stockholm</a></li>
</ul>
</li>
<li>
<a href="#">Australia</a>
<ul>
<li><a href="#">Melbourne</a></li>
<li><a href="#">Perth</a></li>
<li><a href="#">Sydney</a></li>
</ul>
</li>
<li>
<a href="#">Google</a>
</li>
</ul>
and js
(function($){
$(document).ready(function(){
var current_width = $(window).width();
if(current_width < 480){
jQuery('body').addClass("mobile");
}
});
$(window).resize(function(){
var current_width = $(window).width();
if(current_width < 480){
jQuery('body').addClass("mobile");
}
});
})(jQuery);
$(document).ready(function() {
$('.mobile .accordion ul').hide();
$('.mobile .accordion li a').click(
function() {
var openMe = $(this).next();
var mySiblings = $(this).parent().siblings().find('ul');
if (openMe.is(':visible')) {
openMe.slideUp('normal');
} else {
mySiblings.slideUp('normal');
openMe.slideDown('normal');
}
}
);
});

Wednesday, 2 October 2013

Array Length in VB.NET

Array Length in VB.NET

I wonder when should we include the length of an array in vb.net and when
we don't need to include the length of an array. Because in some cases,
when I don't include the length of the array, there are error messages
that tell "object reference not set to an instance of an object".
Dim ClusterMember(,) As Decimal or
Dim ClusterMember(500,100) As Decimal

MKS Integrity mirror server

MKS Integrity mirror server

Has anybody heard about an MKS mirror server possibility? I need a
solution very similar to that, which I know exists for SVN, or Git (i.e.
WANdisco). It would be helpful because the speed of the current network
connection is not good enough. Thanks.

C++ Remove punctuation from String

C++ Remove punctuation from String

I got a string and I want to remove all the punctuations from it. How do I
do that? I did some research and found that people use the ispunct()
function (I tried that), but I cant seem to get it to work in my code.
Anyone got any ideas?
#include <string>
int main() {
string text = "this. is my string. it's here."
if (ispunct(text))
text.erase();
return 0;
}

How to create database of images using C programming?

How to create database of images using C programming?

I need to create a simple database using C programming to store images.
Then how I can use the database to feed images one by one to another
application. Each image has one ID. If any of the image matches with my
application need. Its corresponding ID must be print as output.
I need to create database for around 350 images. My main application has
been written in C. So can any one help me how to create database and how
to link it with the main application?

Tuesday, 1 October 2013

How to mix two int arrays into unique xy coordinates Map?

How to mix two int arrays into unique xy coordinates Map?

Consider this:
public Map<Integer, Point> setXY(int[] x, int[] y) {
Point point;
Map<Integer, Point> xy = new HashMap<Integer, Point>();
int key = 0;
for (int i = 0; i < x.length; i++) {
for(int j = 0; j < y.length; j++) {
point = new Point(x[i], y[j]);
xy.put(key, point);
key++;
}
}
return xy;
}
I have two int arrays of different length and I try to create unique
coordinates for "n" Point objects. "n" means value of "x.length +
y.length" (e.g. n = x[3] + y[5]). Then I'm adding those objects to my
hashmap. The problem is, that this nested "for" instruction creates for "i
= 2" for example five points with coords: (2, 1), (2, 2), (2, 3), (2, 4)
and (2, 5). What I want to achieve is fully randomization of points
creations with use of those two given "x" & "y" arrays. Do you have any
ideas?

jQuery resize event bug with mobile Chrome & FF

jQuery resize event bug with mobile Chrome & FF

So apparently Google and the employees at Firefox think it's ok to resize
the browser window when the keyboard pops up. Long story short, I have a
resize event in my jquery.
$(window).on('resize', function () {
if($("#wrapper").width() < 568)
{
// Snap content to mobile
}
else
{
// Snap content back to full view
}
});
This works 100% in Mobile Safari, and in all non mobile browsers but IE of
course.
Here's the issue Chrome/FF are causing. When you select a form field the
keyboard pops up and chrome / ff actually resize the window causing the
.resize() event to be triggered which automatically hides the keyboard
back as the field selected loses focus.
Anyone know of a way around this? This BTW is a browser issue, not an
android one.
Thanks!

Metric induced by a norm - what conditions should this metric meet?

Metric induced by a norm - what conditions should this metric meet?

$(I)$
I've been browsing some problems concerning metrics not induced by norms,
and I've found a comment that said that such a metric should be a concave
monotone function. Here is the post I'm reffering to.
Could you tell me why that is?
$(II)$
I know that if a metric $d: X \times X \rightarrow \mathbb{R}$ ($X$ is a
vector space with scalars in $\mathbb{K}$ ) satisfies:
$(1) d(\lambda x, \lambda y) = |\lambda| d(x,y) \ \ \ \forall x,y \in X, \
\lambda \in \mathbb{K}$, in particular
$d(\lambda x,0) = |\lambda| d(x,0) = |\lambda| \ ||x||$
$(2) d(x+w, y+w) = d(x,y) \ \ \forall x,y,w \in X$, in particular
$d(x-y,0)=d(x,y)$
then the function $||u||:= d(u,0)$ is a norm. I have problems proving the
converse, meaning that if a metric defines a norm, then it satisfies the
two conditions $(1), \ (2)$.
Could you help me with that, too?
Is it true to say that if we want a metric to be induced by a norm it
should satisfy both conditions mentioned above?
I would really appreciate all your insight.

Put swap on SSD or HDD=?iso-8859-1?Q?=3F_=96_askubuntu.com?=

Put swap on SSD or HDD? – askubuntu.com

New installation coming up. 120gb SSD for OS and HOME and 1tb HDD for
storage. 16gb of ram which means 16gb of swap if I recall correctly. SSD
space is too valuable for a swap partition right? If my …