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 …

Monday, 30 September 2013

Looking for discrete skewed gaussian(-like) probability distribution function

Looking for discrete skewed gaussian(-like) probability distribution function

I'm faced with a modelling task in which I have a frequency that can vary
in a certain range. The variation is discrete and resembles a (skewed)
gaussian distribution. What I need is a function that takes an input value
(the nominal frequency value) x and a uniform distributed value u=[0,
1.0], two parameters ([a, b]) which represent the range of the variation
and returns y (y will be within this range).
For instance, take a value of 100Hz as x and a range of [40, 110], I'd
like to obtain a random y that lies in the range with a median of 100.
Is there a suitable probability distribution function that I could use?
I've looked at the binomial distribution, but thought it's unsuitable, as
it doesn't have a skew parameter. Any help is appreciated.

Why would enabling keepalives in Nginx increase my response time?

Why would enabling keepalives in Nginx increase my response time?

I've got nginx servers behind an Amazon ELB, and recently began testing
enabling keepalives between the nginx server and ELB. Once I enabled
keepalive, I saw response times double from 25ms to 50ms. I'd expect them
to decrease since the connection is staying open and theres less overhead
for the handshake and new socket opening.
All other server metrics improved with enabling keepalive, number of tcp
timeouts decreased, CPU usage decreased, but response time took a hit.
I tried disabling postpone_output as I thought maybe theres some sort of
buffering issue going on, but that had no effect.
Some additional info. The nginx servers are proxying to upstreams, when
graphing the upstream response time, it appears that the upstream response
is the value thats actually increasing when keep alives get enabled
between the ELB and Nginx which is affecting the overall response time.

Create and show View in a WizardPage

Create and show View in a WizardPage

i'm developing a plugin that create a menu with a command in the Eclipse
toolbar that start a simple wizard. I need to add a View (like in eclipse
Workbench), in particular the Package Explorer View, in a precise
WizardPage. How can i do this? Thanks for helping.

In CUDA, do non-coalesced memory accesses cause branch divergence?

In CUDA, do non-coalesced memory accesses cause branch divergence?

I always thought that branch divergence is only caused by the branching
code, like "if", "else", "for", "switch", etc. However I have read a paper
recently in which it says:
" One can clearly observe that the number of divergent branches taken by
threads in each first exploration-based algorithm is at least twice more
important than the full exploration strategy. This is typically the
results from additional non-coalesced accesses to the global memory.
Hence, such a threads divergence leads to many memory accesses that have
to be serialized, increasing the total number of instructions executed.
One can observe that the number of warp serializations for the version
using non-coalesced accesses is between seven and sixteen times more
important than for its counterpart. Indeed, a threads divergence caused by
non-coalesced accesses leads to many memory accesses that have to be
serialized, increasing the instructions to be executed. "
It seems like, according to the author, non-coalesced accesses can cause
divergent branches. Is that true? My question is, how many reasons exactly
are there for the branch divergence? Thanks in advance.

Sunday, 29 September 2013

Rendering custom geometry in Three.js

Rendering custom geometry in Three.js

I am trying to draw a quad between four vertices in the space using
three.js. I have written the following code but it doesn't work:
var a = { x:10,
y:10}
var b = {x:50,
y:50}
var geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( a.x, a.y, 2 ) );
geometry.vertices.push( new THREE.Vector3( b.x, b.y, 2 ) );
geometry.vertices.push( new THREE.Vector3( b.x, b.y - 60, 2 ) );
geometry.vertices.push( new THREE.Vector3( a.x, a.y, 2 ) );
geometry.faces.push( new THREE.Face3(0,1,2) );
geometry.computeFaceNormals();
var material = new THREE.MeshBasicMaterial({ color: "0xff1100"});
var mesh = new THREE.Mesh( geometry, material );
scene.add(mesh);
where am I making a mistake? By the way, to render quads, can I use Face4
or do I have to use Face3? Is there any good source for learning webgl
features all in one place? Three.js documentation is very well organized
and complete.

Can I exercise java programming in my iPhone?

Can I exercise java programming in my iPhone?

I am wondering is there an app that support java programming in iPhone? As
we use eclipse to practise java in windows system, what app can I find to
get me run java in iPhone? Thank you for your suggestions!

Detect HUNG UP in VOIP application using android.net.rtp package?

Detect HUNG UP in VOIP application using android.net.rtp package?

Good day!
Wrote the application on the basis of this here How implement the VOIP
application using android.net.rtp package
But unfortunately there was a problem, to determine when one of the
devices stop talking. On the second is still in progress.
How does the right to end the conversation on the first device, and how to
identify it on the second device?

Blender material from URL with python script

Blender material from URL with python script

Hi I'm fresh new with Blender and Python Scripting.
I need a python script which gets a dynamically created image file from
given URL and create a material with that image file.
Than I will apply that material to my blender object.
The python code below works for local image files
import bpy, os
def run(origin):
# Load image file from given path.
realpath = os.path.expanduser('D:/color.png')
try:
img = bpy.data.images.load(realpath)
except:
raise NameError("Cannot load image %s" % realpath)
# Create image texture from image
cTex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
cTex.image = img
# Create material
mat = bpy.data.materials.new('TexMat')
# Add texture slot for color texture
mtex = mat.texture_slots.add()
mtex.texture = cTex
# Create new cube
bpy.ops.mesh.primitive_cube_add(location=origin)
# Add material to created cube
ob = bpy.context.object
me = ob.data
me.materials.append(mat)
return
run((0,0,0))
I tried : import urllib, cStringIO
file = cStringIO.StringIO(urllib.urlopen(URL).read())
img = Image.open(file)
But I had no luck with it. First error I got was ImportError: No module
named 'StringIO'.
Does python scripting API in Blender use restirictive Modules or what?
Thank you for your help.

Saturday, 28 September 2013

How to prove $F(x,y)=(x^2+y^2)^{1/2}$ is continuous in $\Bbb{R}^2$?

How to prove $F(x,y)=(x^2+y^2)^{1/2}$ is continuous in $\Bbb{R}^2$?

Please, I need the continuity demonstration of the function $F(x,y)=
(x^2+y^2)^{1/2}$. Thanks!

Does Wifi Direct support a mesh/tree topology for P2P or does it only support one Access Point with multiple clients?

Does Wifi Direct support a mesh/tree topology for P2P or does it only
support one Access Point with multiple clients?

I'm currently reading the Android docs on WiFi Direct. I know a WiFi
Direct access point can have multiple clients, but can WiFi Direct support
a tree or mesh topology? For example, if I have a conference hall and
everyone turns on their phone, can I send data from node 1 to node n, even
if the two nodes are k branches away?

Java New Session For Each Request?

Java New Session For Each Request?

I have been having an issue with session variables not being available
when a request has come from a domain name as opposed to localhost. For
instance, if I set a user variable:
request.getSession(true).setAttribute("user", user);
//Redirects to another html page or something...
When the client makes another request and I attempt to access the user
session variable it returns null.
//Client makes another request to the server
request.getSession(true).getAttribute("user"); //returns null
I've noticed that on each request, a new JSESSIONID cookie is set and the
ID value changes. Does this mean that a new session is being created each
time the client accesses the server? How do I maintain the same session
between the client so I can store objects in the HttpSession and have
access to them?
I don't know if this has anything to do with anything either, but when
viewing the application from the tomcat manager, the sessions count
continues to grow regardless of the fact that I am using the application
from the same browser window, not refreshing the page or anything. Another
sign that a new session is being created on each request to the server?
This only happens when accessing the application from a domain name ex:
example.com/app. When coming from localhost, the session variables work
fine.
Update
I tested without using response.sendRedirect and the session variable is
available until I switch pages and make another request to the server.
This confirms my suspicions that a new session is being created with each
request. Its not the redirect thats killing the session, its any new
request. How do I prevent this?

File copy hooking

File copy hooking

How can I write a program with c#/c++/c (c# prefered) for Windows about
hooking. when someone want to copy file to usb drive then the program
starts and adds some information to the file and then copy the file.

Friday, 27 September 2013

positioning popups on partial views

positioning popups on partial views

I have a partial view that I would like to incorporate my
popup/notifications into. I would like to position these notifications
around the two "buttons". However, I'm not actually sure how to position
these popups around the buttons. In the documentation examples, it states
to use the id of the popup div in the href of where the popup should
occur.
example:
<a href="#popupPadded" data-rel="popup" data-role="button">Popup with
padding</a>
<div data-role="popup" id="popupPadded" class="ui-content">
<p>This is a popup with the <code>ui-content</code> class added to the
popup container.</p>
</div>
But my partial view is being used somewhere else with href="#". How can I
position my popups in the partial view and also reuse them on other pages?
Here is the HTML for my partial view:
<a href="#" data-icon="GhCsStatus-Red" data-position-to="origin"
data-inline="true" data-mini="true" data-role="button" id="GhCsStatus_CS"
style="pointer-events: none;">CS</a>
<a href="#" data-icon="GhCsStatus-Red" data-position-to="origin"
data-inline="true" data-mini="true" data-role="button" id="GhCsStatus_GH"
style="pointer-events: none;">GH</a>
<div id="GH_popup" data-role="popup">
<p> Get History is OFF! </p>
</div>
<div id="CS_popup" data-role="popup">
<p> Communication Service is OFF! </p>
</div>
<div id="GHCS_popup" data-role="popup">
<p> Get History and Communication Service are OFF! </p>
</div>

Allow users to search other user profiles based on profile information

Allow users to search other user profiles based on profile information

Rails newbie here, seeking help implementing a search function in my site.
I have created a "Pinterest-style" site using the One Month Rails
tutorials, however, for my purposes, I need to implement a search function
so that users can search for others users based on information they have
provided for their personal profiles, such as City, Job Function, etc. My
repository on GitHub is https://github.com/drakehoffman/DKENetwork
Please forgive me, I am still very new to Rails, and have tried
ElasticSearch, Sphinx, and Solr, but continue to struggle. Any help is
greatly appreciated!
Thank you.

VB.NET Deobfuscator in Treeview

VB.NET Deobfuscator in Treeview

I wrote a sub which opens an exe (.net) and renames it's symbols,
basically this just renames the exe, but it opens it and renames all it's
methods, types, modules, fields, parameters, properties and namespace. All
with help if MonoCecil library.
Private Sub RenameSymbols(ByVal asmDef As AssemblyDefinition)
Dim modd As Integer = 0
Dim type As Integer = 0
Dim method As Integer = 0
Dim param As Integer = 0
Dim field As Integer = 0
Dim propertyy As Integer = 0
Dim namespacee As Integer = 0
Dim namespaceList = New SortedList(Of String, List(Of TypeDefinition))()
For Each moDef In asmDef.Modules
For Each typeDef In moDef.Types
If namespaceList.Keys.Contains(typeDef.Namespace) Then
namespaceList(typeDef.Namespace).Add(typeDef)
Else
namespaceList.Add(typeDef.Namespace, New List(Of
TypeDefinition)() From {typeDef})
End If
Next
Next
For Each member In namespaceList
namespacee += 1
Dim newName = "ns_" & namespacee
For Each typeDef In member.Value
typeDef.Namespace = newName
Next
Next
namespaceList.Clear()
For Each moDef In asmDef.Modules
modd += 1
moDef.Name = "mod_" & modd
For Each typeDef In moDef.Types
type += 1
typeDef.Name = "type_" & type
For Each mDef In typeDef.Methods
If mDef.IsConstructor And mDef.IsRuntimeSpecialName <> 0 Then
method += 1
mDef.Name = "method_" & method
End If
For Each paramDef In mDef.Parameters
param += 1
paramDef.Name = "param_" & param
Next
Next
For Each mField In typeDef.Fields
field += 1
mField.Name = "field_" & field
Next
For Each propDef In typeDef.Properties
propertyy += 1
propDef.Name = "property_" & propertyy
Next
Next
asmDef.Write("C:\Test.exe")
End If
Next
End Sub
Is there a way to get the before renamed data and show it in one tree
view? Like the programm called "Reflector" or "ILSpy" ?

replace one div with another on hover

replace one div with another on hover

I want to replace one div with another when hovering over it. Specifically
there will be an average in words, such as "struggling", "exceeding
expectations", and I want to replace this with the numerical average when
the user hovers over the average in words.
#html
<div class="switch avg_words float_left">
A+ (hover to see score)
</div>
<div class="avg_num">
AVG = 98.35%
</div>
#css
.avg_num {
display: none;
}
#jquery
$('.switch').hover(function() {
$(this).closest('.avg_words').hide();
$(this).next('div').closest('.avg_num').show();
}, function() {
$(this).next('div').closest('.avg_num').hide();
$(this).closest('.avg_words').show();
});
It's easy enough to hide the first div and replace it with the second, but
the trouble is with the code to set things back to normal when hover ends.
Now on hover, the divs just blink back and forth between each other.
http://jsfiddle.net/uXeg2/1/

Thursday, 26 September 2013

compare two dates in oracle

compare two dates in oracle

(I am using Oracle10g & Java(JDBC & Servlets))
Following is my query to compare ETIME with sysdate.
If ETIME+7days is greater than sysdate then I want to select Y and if
ETIME+7days is less than sysdate I want to select N.
select USER,
CASE WHEN to_date(ETIME+7, 'YYYY-MON-DD HH24:MI:SS') >=
to_date(sysdate, 'YYYY-MON-DD HH24:MI:SS')
THEN 'Y' ELSE 'N' END THE_TIME
from TABLE_NAME
where THE_KEY='123456789'
[Note: In database value of ETIME for THE_KEY is 27/09/2013]
Above query returns N today. Few days back it was returning Y. So I think
I am doing comparison of two dates wrong way.
Any suggestion will be appreciated.

Wednesday, 25 September 2013

Using iOS 6 theme for iOS 7 app

Using iOS 6 theme for iOS 7 app

I am curious: is there a way to set an iOS 7 app to run with the old
fashion iOS 6 visual appearance? I am aware of the UIAppearance protocol
but setting the appearance for each individual element seems to be a bit
of hassle.

Thursday, 19 September 2013

xcode 5 changes? proper way to pass data along table views?

xcode 5 changes? proper way to pass data along table views?

I have a stack of table view controllers. a subject-->category-->group-->card
I'm using core data. In the first table view controller I fetch all
'subjects'. the user selects a subject and the subject is passed to the
next table view controller using a 'didSelectSegue' and a
'prepareForSegue', setting a property from the category view in the
'prepare' method.
this works fine for this segue! In the category table view I populate the
table with the categories in the subject, instead of fetching data from
the sqlite database I use 'subjects.categories' as it is a one to many
relationship.
I then want to perform the segue to the Group table view. I get this error
unrecognized selector sent to instance
This is confusing to me, as the same exact mechanism of passing an object
to the next table view works fine the first time. I believe its a problem
with ARC, but the whole subject is pretty vague for me.. Here is my
'prepare for segue' method,
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"groupView"]){
NSIndexPath * indexPath = [self.tableView indexPathForSelectedRow];
AHCategory *cellCategory = [self.categories
objectAtIndex:indexPath.row];
NSLog(@"%@",cellCategory.name);
[segue.destinationViewController setCategoryForGroups:cellCategory];
}
}
does anybody have any suggestions as to what this error means? thanks a lot..

My WCF service is using the wrong binding

My WCF service is using the wrong binding

serviceModel section of my web.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="default" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" useDefaultWebProxy="true"
messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="templateMgr">
<endpoint
address="http://edocengine.localtest.me/services/templateMgr.svc"
name="templateMgr.svc" binding="wsHttpBinding"
contract="ItemplateMgr"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"
aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
Note that I've specified wsHttpBinding here, and a large
MaxReceivedMessageSize. Yet when I breakpoint in the code
?
System.ServiceModel.OperationContext.Current.Host.Description.Endpoints(0).Binding.Name
"BasicHttpBinding"
?
ctype(System.ServiceModel.OperationContext.Current.Host.Description.Endpoints(0).Binding,System.ServiceModel.BasicHttpBinding).MaxReceivedMessageSize
65536
What gives?
EDIT: This is obviously the server web.config. My client is referencing
the service with an old fashioned SOAP web service (wsdl.exe proxy) rather
than a WCF service reference (svcutil.exe). Therefore the client has no
serviceModel section in its app.config. Here are the headers being sent
when the client makes a call:
POST http://edocengine.localtest.me/services/templateMgr.svc HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 4.0.30319.18052)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.edocbuilder.com/ItemplateMgr/setAssets"
Host: edocengine.localtest.me
Content-Length: 12192
Expect: 100-continue

when allocate memory to variables defined in the namespace

when allocate memory to variables defined in the namespace

For example, assume a is a public static member in ClassA.
namespace SPACE{
ClassA::a=NULL;
ClassA::ClassA()
{
ClassA::a="initialized here";
}
}
So two questionF
when is a=NULL being invoked? Before main() or after that?
since a is a static member, why it can be defined twice with NULL and
ginitialized here"H

mySQL joining data from a diffrent table

mySQL joining data from a diffrent table

Alright, I'm pulling a list of users from a mySQl database then I'm
looking for group assignment in a different table. if they are assigned to
multiple groups multiple rows are returned as they should.
My question is how can I concat the group names into one column of the
results.
SELECT `u`.`ID`,CONCAT(`First-Name`," ",`Last-Name`) as
`Name`,`g`.`Group-Name` FROM `application-users` AS `u`JOIN `groups` AS
`g` ON (`g`.`Assigned-Users` LIKE CONCAT("%|",`u`.`ID`,"|%") )WHERE
`u`.`Status` = "Active" && `u`.`Type` = "Business Development" ORDER BY
`First-Name` ASC
Thanks in advance!

stop form submit if javascript is blocked

stop form submit if javascript is blocked

Is there any way to stop a form being submitted if javascript is blocked
by browser?
I'm a lazy coder and do not want to validate data on server side.

Using rm with extended globbing in node js

Using rm with extended globbing in node js

I need to do daily cleanup of a folder for my app, so I ve made a bash
script (with some help of superuser) to do so.
It work well from the console, but it is not interpreted correctly from node.
Here the working script:
rm ./app/download/!("test1"|"test4");
Which I ve thought would work like this in node.js:
var spawn = require('child_process').spawn,
PATH = process.argv[1].substr(0, process.argv[1].lastIndexOf('/') +
1), //Get the full path to the directory of the app
arg = [PATH + 'download/!(\"', 'test1', '\"|\"', 'test4', ('\")'],
child = spawn ('rm', arg);
child.stderr.on('data', function(data) {
console.log('stderr:' + data);
});
But I get rm interpret them by being different files:
stderr:rm: cannot remove '/home/user/app/download("' : No such file or
directory
rm cannot remove 'test1' : No such file or directory
...
So I ve tried by changing arg to this:
arg = [PATH + 'download/!("' + 'test1' + '"|"' + 'test4' + '")']
But I get
stderr:rm: cannot remove '/home/user/app/download/!("test1"|"test2")' :
No such file or directory
I m trying with exec, but I don t think this is the problem since it seems
the spawned rm don t interpret the extended glob thing, which is active by
default...

Javascript:JSllint regular expression literal can be confuse with /=

Javascript:JSllint regular expression literal can be confuse with /=

I have wrote some javascript to split string if "=" sign is there
For example. key=value string="id=abc=xyz" In the above example I have to
split string base on "=" sign, and store them into key and value pair. In
this example I am going to store key as "id" and value as a "abc=xyz". to
split this I have added following code to store value. It working fine.
but my Jslint says "regular expression literal can be confuse with /=".
var value=string.split(/=(.+)/)[1];
Any pointer for this.

Wednesday, 18 September 2013

Valgrind... 4 bytes inside a block of size 8 free'd

Valgrind... 4 bytes inside a block of size 8 free'd

I'm getting this error in Valgrind after attempting to free a list.
print_list dumps the list to the syslog. I'm pretty confident that output
is correct.
Valgrind:
==7028== 1 errors in context 1 of 10:
==7028== Invalid read of size 4
==7028== at 0x8049603: free_list (list.c:239)
==7028== by 0x80488B5: m61_close_for_valgrind (m61.c:36)
==7028== by 0x8048825: main (mytest.c:19)
==7028== Address 0x420006c is 4 bytes inside a block of size 8 free'd
==7028== at 0x4028F0F: free (vg_replace_malloc.c:446)
==7028== by 0x804960C: free_list (list.c:239)
==7028== by 0x80488B5: m61_close_for_valgrind (m61.c:36)
==7028== by 0x8048825: main (mytest.c:19)
==7028==
mytest.c:
15 char *temp = malloc(10);
16 char *temp2 = malloc(10);
17 free(temp);
18 free(temp2);
19 m61_close_for_valgrind();
list.h
typedef struct lnode {
ACTIVE_ALLOCATION *value;
struct lnode *next;
} lnode;
list.c (Called by m61_close_for_valgrind()
void free_list(LIST *s) {
lnode **nptr = &s->head;
print_list(s);
while (*nptr) {
lnode **tmp = nptr;
tmp = nptr;
if ((*tmp)->value) {
syslog(LOG_NOTICE,"Freeing (*tmp)->value=%p\n", (*tmp)->value);
//printf("%p\n",(*nptr)->value);
free((*tmp)->value); //Free active allocation metadata
}
nptr = &(*nptr)->next;
syslog(LOG_NOTICE,"New *nptr value=%p\n", (*nptr));
syslog(LOG_NOTICE,"Freeing (*tmp)=%p\n", (*tmp));
free(*tmp); //Free node
}
}
syslog
Sep 19 00:37:02 appliance mytest[7759]: -- Start List Dump --
Sep 19 00:37:02 appliance mytest[7759]: (*nptr)=0x903f220
(*nptr)->value=0x903f208 (*nptr)->next=0x903f260
(*nptr)->value->ptr=0x903f1f0
Sep 19 00:37:02 appliance mytest[7759]: (*nptr)->value->ptr=0x903f1f0
Sep 19 00:37:02 appliance mytest[7759]: (*nptr)=0x903f260
(*nptr)->value=0x903f248 (*nptr)->next=(nil)
(*nptr)->value->ptr=0x903f230
Sep 19 00:37:02 appliance mytest[7759]: (*nptr)->value->ptr=0x903f230
Sep 19 00:37:02 appliance mytest[7759]: -- End List Dump --
Sep 19 00:37:02 appliance mytest[7759]: Freeing (*tmp)->value=0x903f208
Sep 19 00:37:02 appliance mytest[7759]: New *nptr value=0x903f260
Sep 19 00:37:02 appliance mytest[7759]: Freeing (*tmp)=0x903f220
Sep 19 00:37:02 appliance mytest[7759]: Freeing (*tmp)->value=0x903f248
Sep 19 00:37:02 appliance mytest[7759]: New *nptr value=(nil)
Sep 19 00:37:02 appliance mytest[7759]: Freeing (*tmp)=0x903f260

How do I split two divs 50/50 horizontally so it fit every browser 50 50? Responsive design

How do I split two divs 50/50 horizontally so it fit every browser 50 50?
Responsive design

I want the two divs to split 50/50 so the two divs cover the visible area.
As you can see its two columns and they will stack on each other when it
goes to mobile, but I don't know how i can split the columns 50 50 to
cover the phone screen.
A full-service agency
that focuses on casino brands.
A project-based creative
group exploring the digital world.

Filter ForeignKey in Django Model

Filter ForeignKey in Django Model

class Wod(models.Model):
title = models.CharField(max_length=50)
workout = models.CharField(max_length=250)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.title
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
class Score_Choice(models.Model):
wod = models.ForeignKey(Wod)
choice_text = models.CharField(max_length=200)
def __unicode__(self):
return self.choice_text
class Score(models.Model):
wod = models.ForeignKey(Wod)
user = models.ForeignKey(User)
performed_date = models.DateTimeField('date performed')
**type = Score_Choice.objects.filter(Score_Choice__wod = 'wod')**
score = models.IntegerField()
I have a model with Wods, which is referenced by Score_Choice to assign
different kinds of possible scores to each Wod.
When recording the score, I wish to be able to reference the available
kinds of scores available for that wod.
The desired functionality is such that when entering a score I select the
wod I will be entering score(s) for, then I will have available the
different kinds of scores needed for that wod.

How can I get Visual Studeo CTRL-K-D to not unroll getters and setters

How can I get Visual Studeo CTRL-K-D to not unroll getters and setters

The style guides in my shop suggests formatting simple getters and setters
like this:
string foo { get; set; }
I find the CTRL-K + CTRL-D unrolls them like this
string foo
{
get;
set;
}
Is there a way to tel VS not do do this, specifically for getters and setter?

SSMS: List of frequenly used queries

SSMS: List of frequenly used queries

Does anyone know if there is an add-in or if there is a place where you
can save frequently used SQL queries, besides keyboard shortcuts? I would
want to save a query like this one to a "Favorites" location so I can
reference it when I need it. I would want to change the 'Where' criteria
for c.name LIKE '%%'. Which is why keyboard shortcuts wouldn't work.
PS: I don't have SA or admin rights on my DB.
SELECT
t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM
sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE
c.name LIKE '%%'
ORDER BY schema_name, table_name;

Asynchronous HTTP response Android

Asynchronous HTTP response Android

I am trying to do the following and am looking into other people's
experiences:
I want to have an HTTP server running on Android that receives GET
requests from a client. From there, the server must deliver the query
parameters to a Service that will do some processing (sometimes quite
heavy). When the service is done, it sends back the data to the server
that will then return the response.
Of course, the startService(intent) call is asynchronous so I'm wondering
how to tell the server to wait for the processing to be done before
sending back the response. At the moment, the inter process messaging is
done with the Messenger and Message classes.
What sort of design would be able to achieve that?

Java Edit Text with certain rules

Java Edit Text with certain rules

I have to edit text with certain rules :
The repetitive letters in the same word will be reduced to single letter.
("Questions" instead of "QuestionssSsS")
More than one gaps between words will be reduced to a single space("go to
the cinema" instead of "go to the cinema")
Single letter which separated from the word will be connect to the
word("first ten person" instead of "firs t ten person" )
For example :
String s = "I am enouuugGh of an artis t to draw freely upon my
imagination. ImaginatioOO n is more importan t than knowledge.
KKkKkKnowledge is limited. Imagination encircles the wwWorl d.";
Expected output :
I am enough of an artist to draw freely upon my imagination. Imagination
is more important than knowledge. Knowledge is limited. Imagination
encircles the world.
Please give suggestions and advice..

eclipse c++ project not showing even after downloading cdt

eclipse c++ project not showing even after downloading cdt

I have installed eclipse cdt and it intsalled properly and is even showing
in the installation details in help->about eclipse->installation details.
but I still cant see a c++ project option when i open a new project. It
was showing before but I changed the folder where eclipse was initially
in. Do i have to link to some path to fix it or what?

sizeof Module, Object, Attribute?

sizeof Module, Object, Attribute?

Is there a commonly used method of determining the size of a Module,
Object, or Attribute (of Module or Object)?
Something like the "sizeof" function, but taking as input a Module,
Object, or Attribute Reference (attrRef) and returning a number of bytes?
Cross Post:
https://www.ibm.com/developerworks/community/forums/html/topic?id=e594b6cf-b756-4838-b78f-38b96cf3c423&ps=25

Tuesday, 17 September 2013

Cannot access xml file in java including another xml file

Cannot access xml file in java including another xml file

I am running my class from script. This maain class accesses another
dependency class which is in dependency jar. Dependency class accesses xml
file which is in the same location as it is. This xml file includes
fragment files which are at the same location of xml file. But while
running script, ideally at runtime xml file should look fragments at its
own location but its lloking at the scripts dir.
Please help me how can i get xml file with included fragments.

shortest distance between two vertex

shortest distance between two vertex

Am new on using mxGraph on Java and i have created the next code :

public class Graphx extends JFrame {
public Graphx(){
super("JGrapghX");
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try
{
Object v1 = graph.insertVertex(parent, "1", "Reference", 20, 10, 80,30);
Object v2 = graph.insertVertex(parent, "2", "Book!", 340, 10,80, 30);
graph.insertEdge(parent, "1.2", "0.5", v1, v2);
Object v3 = graph.insertVertex(parent, "3", "Hello", 20, 100, 80,30);
Object v4 = graph.insertVertex(parent, "4", "World!", 360, 80,80, 30);
graph.insertEdge(parent, "3.4", "1.0", v3, v4);
Object v5 = graph.insertVertex(parent, "5", "Academic", 20, 140, 80,30);
Object v6 = graph.insertVertex(parent, "6", "Proceedings!", 340,
140,80, 30);
graph.insertEdge(parent, "5.6", "5.0", v5, v6);
Object v7 = graph.insertVertex(parent, "7", "communications", 20, 240,
80,30);
Object v8 = graph.insertVertex(parent, "8", "Conference!", 400,
230,80, 30);
graph.insertEdge(parent, "7.8", "2.0", v7, v8);
graph.insertEdge(parent, "1.4", "1.0", v1, v4);
graph.insertEdge(parent, "5.2", "3.0", v5, v2);
graph.insertEdge(parent, "4.7", "3.0", v4, v7);
graph.insertEdge(parent, "8.6", "3.0", v8, v6);
}
finally
{
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
getContentPane().add(graphComponent);
And i added the main class :

public static void main(String[] args) {
// TODO code application logic here
Graphx frame = new Graphx();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 600);
frame.setVisible(true);
}
Now, i want to create a method or to include the public Object[]
getShortestPath(mxGraph graph, Object from, Object to,mxICostFunction cf,
int steps, boolean directed)that gives me the shortest distance or path if
i give it two Vertex there is the DijkstraShortestPath . Any help please ?

Finding prime numbers 1-100 and write them to file.

Finding prime numbers 1-100 and write them to file.

Can someone help me figure out how to find all the prime numbers between
1-100 and write them to a file?
#include<iostream>
#include<fstream>
using namespace std;
bool isPrime(int);
int main()
{
int iNum;
cout << "This program will calculate and store all the prime numbers
between 1 and
100 "<<endl;
ofstream myfile( "writeto.txt" );
for(int i = 1; i <= 100; i++)
{
isPrime(i);
while(isPrime(i) == true)
{
myfile << i <<endl;
break;
}
myfile.close();
return 0;
}
}
bool isPrime(int iNum)
{
bool status;
if( iNum <= 1 )
return false;
for( int i = 2; i < iNum; i++ )
{
if( iNum % i == 0 )
return false;
}
return true;
}
How can I get this to work? I have been working on this for a while and
think it has to do something with my return. I am really lost and hope
someone can help me. I am not looking for answers I just want someone to
point me in the right direction.

Installing php-devel without using yum

Installing php-devel without using yum

On EC2 instance I have managed compile and install php from source by
custom configuration options. However, now I would like to install
php-devel. But when I do,
sudo yum install php-devel
yum wants to install the dependencies as well. Which is Amazon compiled
PHP source without my custom configuration options.
I have looked all over the internet to find a way to install php-devel
without using yum. But couldn't find it.
So is there any way I can install php-devel package without using yum?

ExtJS Charting: event on series mouseover

ExtJS Charting: event on series mouseover

Ideally, I want to highly a line chart series on mouseover.
The highlighting part is easy.
But currently, I only see events for mouseover, clicking ect on series
markers - not the lines themselves.
Anyone have a solution for this? I find markers very messy and cluttering
Thanks

.htaccess IF directory exists

.htaccess IF directory exists

I have a development server and a live server. Both use the same .htaccess
but I want the development server to be password protected. When I copy
the .htaccess file over to the live, I get a 500 error. Does .htaccess
offer some way to only password protect directories using conditionals
like IF?
what I'm using:
<Directory "/home/my/path/to/development/site/">
AuthName "Restricted Area 52"
AuthType Basic
AuthUserFile /home/my/path/to/development/site/.htpasswd
AuthGroupFile /dev/null
require valid-user
</Directory>
Could really use some help.

Sunday, 15 September 2013

Converting various different date formats in to one common date format Java or Perl

Converting various different date formats in to one common date format
Java or Perl

I have huge set of data stored on server and it's different rows contain
dates in as many as 20+ different formats. I want to convert them in to
one common format. How can I achieve that? Do I need to write separate
function for each format or is there some super function which can read
date of any format and convert it to a specific format.

Resetting Boostrap Affix with new offset in responsive website

Resetting Boostrap Affix with new offset in responsive website

I'm working on a website with the following page structure:

I'm using the Affix plugin so that when the user scrolls past the header,
the navigation becomes fixed at the top of the page, like so:

The website is responsive and when it's in the mobile viewport the header
is completely hidden with display: none. The problem is I can't seem to
get Affix to 'reset' with a new offset, which would now be 0 since the
navigation is always at the top of the page in the mobile viewport.
I tried the following:
$(window).resize(function () {
$("nav").affix({
offset: $("nav").position()
});
});
But that doesn't seem to do anything. When I resize down to the mobile
viewport, the navigation doesn't become fixed until I've scrolled down the
page by an amount equal to the size of the header (which is now completely
hidden with display: none).
I also tried disabling the Affix plugin before re-enabling it:
$(window).resize(function () {
$(window).off('.affix');
$("nav").affix({
offset: $("nav").position()
});
});
But when I resize, the Affix plugin is disabled but doesn't seem to get
re-initialised, so even when I resize only a small amount (not all the way
down to mobile viewport, so the header is still visible), the navigation
doesn't become fixed when I scroll past the header.
Any ideas?

Finding combinations and count in excel

Finding combinations and count in excel

I don't know much about excel and I'm trying to do the following. Any help
would be so appreciated.
So if a I had column A and column B:
A B
red green
red green
red green
blue pink
blue pink
blue pink
blue pink
black white
black white
Let's say I have hundreds of rows of combinations. What I need to do is on
a second sheet, show all the different combinations and the number of
times each occurs. So for the above, the result would be:
Combination: Number of times:
red green 3
blue pink 4
black white 2
So, I would need to give me the combination and the number of times it
occurs. Any idea how I could do this?

Giving permissions to apache user

Giving permissions to apache user

I've developed a web application that lets the users to upload images and
transform them to later download them again transformed. I obviously had
to give apache user permissions to the directory where users can upload:
$ chown root:www-data uploadFolder
$ chmod 1775 uploadFolder
This, gives apache group all permissions, except removing.
The application creates a directory for each user session inside the
uploadFolder directory with 0700 permissions, and saves the user's images
inside.
A crontab job is executing a script every 20 minutes, that checks which
sessions are active and removes all files and folders inside uploadFolder
that doesn't match any active session.
It's working fine since two months ago, but I'm not sure if it could be
dangerous for my application, database, or other sites in the same VPS.
Does anybody know the risk of being permissive in this situation?
Is there any alternative to avoid it?

Admin panel and backend for codeigniter

Admin panel and backend for codeigniter

Any admin panel and backend for Codeigniter you recommended (Both free
version and paid version)? Thank you.
Regards,
Tommy

vagrant ssh provisioning - mysql password

vagrant ssh provisioning - mysql password

I'm building a Vagrant box (CentOS 6.4) using SSH provisioning.
All's running fine, LAMP components installed and started but I've reached
the step where I should secure MySql (set mysql password, etc).
There's mysql_secure_installation that could be run, but it doesn't work
in a non-interactive mode.
I could run
/usr/bin/mysqladmin -u root password 'newpassword'
but if I provision the same box multiple times, Mysql will accept a new
password the first time, but then will complain.
Is there an elegant way of securing MySql, automatically, at provisioning
time? (I'm not using Chef/Puppet, just simple SSH provisioning)

angularjs - name array with ng-model

angularjs - name array with ng-model

I'm learning angularjs so please bare with me.
I have an add button that uses a directive to add-to a table's
(.estimates) tbody:
function EstimateCtrl( $scope, $compile ) {
$scope.add = function() {
angular.element('.estimates tbody').append( $compile('<tr
estimate></tr>')($scope) );
}
}
angular.module('dashboard', [])
.directive('estimate', function() {
return {
restrict: 'A',
template: '<td><input type="text"
placeholder="Suburb"/></td><td><select
ng-model="estimate.service" ng-options="service.value as
service.name for service in services"
class="form-control"></select></td><td>$0.00</td><td><button
type="button" class="remove">x</button></td>',
link: function( scope, element, attrs ) {
element.find('.remove').bind('click', function() {
element.closest('tr').remove();
});
}
}
});
How can I have an element array using ng-model in angularjs? For example:
<select name="foo[]"></select>
to
<select ng-model="foo[]"></select>
I've been digging around for a day and half but I can't seem to catch a
break. I was hoping that maybe someone can point me in the right
direction. Thank you very much for any help.

Saturday, 14 September 2013

Accessing folders on my android phone that are visible to the user vi USB

Accessing folders on my android phone that are visible to the user vi USB

When I connect my Nexus 4 to my PC via USB I get a nice set of folders
such as Alarms, Downloads, and DCIM. I would really like to access these
folders. However, when I use Environment.getExternalStorageDirectory() to
do so I get /storage/emulated/0 as the returned directory path. When I
create a directory or file there I am unable to see them when I browse
using my PC. My output popup claims that the folder/file exists but I'm
not able to see them. If I do the same thing in my emulator it always
defaults to the "SD card" I mounted and I can see the folders fine.
How would I go about accessing and writing to these folders without root
access. I've been searching all day, and even found a few new leads while
typing this, but no luck.
Thanks for any help you guys/gals can give.

Assigning to a new list just the last object of another list - Python

Assigning to a new list just the last object of another list - Python

OK, in Python I have list:
flowers = ["rose", "bougainvillea", "yucca", "marigold", "daylilly",
"lilley of the valley"]
Now, I want to assign just the last object of list flowers to a new list
called poisonous.
I tried:
poisonous=flowers[-1]
However this statement makes poisonous a string instead of a list.

ASP.NET 4.5 - JQUERY/AJAXCONTROL ToolKit and JQUERYMOBILE

ASP.NET 4.5 - JQUERY/AJAXCONTROL ToolKit and JQUERYMOBILE

Ok, so here is my issue.
I have been asked to revamp an old ASP.NET Forms 2.0 Web-site.
A-lot of the code and pages are good to go - And I would like to retain a
good chunk of it.
I have not been doing ASP.NET for at least 3 years - doing more MVC using
Jquery. But back in the day I used to use the AJAXControlLibrary quite a
bit for my 2.0 and 3.5 Ajax enabled ASP.NET forms.
The end users want a new set of screens in addition to old ones for a new
process workflow. From my perspective - I definitely want to use Ajax
calls (like the ones that used to be in the old Ajax Update panel or just
the Jquery Ajax calls I use a-lot in MVC.)
Now to make matters a bit more complex - this new workflow also has to
have a mobile experience. I have used JQUERYMOBILE in the past and was
planning on doing so for this product. (I can also use KendoUI of course).
So here are my choices (at least the ones I can see).
1.) Completely create and rewrite the new experience using MVC/JQUERY and
JQUERYMobile.
2.) Update the existing ASP.NET forms to 4.5 and use the native
functionality provided. (I notice that new ASP.NET forms projects 4.5
include jquery -but is using it like we do in MVC is trying to fit a
square peg in a round hole?)
3.) Like # 2 but add the new version of the AJAXCONTROL Library and use
its controls and methodology for Ajax. There are competing controls with
JQUERY in this library so I am really unclear what the best practice is
for this.
If I were to do this with option #1 - Its pretty clear how I would provide
the Mobile experience (i.e. have mobile views etc.) Again, not clear what
the analog would be in ASP.NET forms choices.
So any opinions are appreciated. Sorry if naïve questions. Just cracked
this all open today and realized there are a-lot of combinations to choose
from. And a wrong choice could kill my margins on the project!!
Thanks Mike

SQL To Select Records based on different values of a single column

SQL To Select Records based on different values of a single column

Table
Que_id | question | isPicture | cat_det_id
1 Where are U? 1 27
2 Hello 0 22
3 Hey 1 31
4 What is Dis? 1 27 .. . . ........ .. .... ... ........... . ... Given
the table in the picture as sample, I want select different number records
based on different values of cat_det_id.
For Instance to select 5 records that has cat_det_id of 27, 10 Records
that has cat_det_id of 31 and 7 records that has cat_det_id of 22
and these records will be presented as a records set ordered by this same
cat_det_id in ascending order.
Thank you.

is shell scripting more power full than other programming languages?

is shell scripting more power full than other programming languages?

I found that shell scripting( Bash shell, CShell) is more power full
language than other programming languages because it is running top of the
kernal.
here my question is, it is power full because of running top of the kernal
or any reasons ??
thanks in advance :)

PDO exception in JOIN query

PDO exception in JOIN query

I've been on this all morning and I can't figure out why it's not working.
$spn = '20275096';
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};
Dbq=".realpath('exported/test1.mdb')."; Uid=Admin");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare(" SELECT Cup_PartUpdateCommodityID FROM
Cup_PartUpdateCommodity INNER JOIN Cup_PartUpdateInfo ON
[Cup_PartUpdateCommodity].Cup_PartUpdateCommodityID =
[Cup_PartUpdateInfo].Cup_PartUpdateCommodityID INNER JOIN Cup_PartUpdate
ON [Cup_PartUpdateInfo].Cup_PartUpdateID =
[Cup_PartUpdate].Cup_PartUpdateID WHERE [Cup_PartUpdate].PartNum =
:partnum ");
$stmt->bindParam(':partnum', $spn);
$stmt->execute();
$row = $stmt->fetch();
echo $row['Cup_PartUpdateCommodityID'];
It throws the following error:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: -3100 [Microsoft][ODBC
Microsoft Access Driver] Syntax error (missing operator) in query
expression '[Cup_PartUpdateCommodity].Cup_PartUpdateCommodityID =
[Cup_PartUpdateInfo].Cup_PartUpdateCommodityID INNER JOIN Cup_PartUpdate
ON [Cup_PartUpdateInfo].Cup_PartUpdateID =
[Cup_PartUpdate].Cup_PartUpdateID'. (SQLExecute[-3100] at
ext\pdo_odbc\odbc_stmt.c:254)' in C:\sites\myproject\test.php:31 Stack
trace: #0 C:\sites\myproject\test.php(31): PDOStatement->execute() #1
{main} thrown in C:\sites\myproject\test.php on line 31
Note: The code above will be executed in a function that expects $spn as a
parameter. Just for now I'm setting a default value for $spn. Anyone?

fminunc alternate in numpy

fminunc alternate in numpy

Is their an alternate of fminunc function(in octave) in python. I have a
cost function for a binary classifier. Now I want to run gradient descent
to get minimum value of theta. The octave implementation will look like
this.
% Set options for fminunc
options = optimset('GradObj', 'on', 'MaxIter', 400);
% Run fminunc to obtain the optimal theta
% This function will return theta and the cost
[theta, cost] = ...
fminunc(@(t)(costFunction(t, X, y)), initial_theta, options);
I have converted my costFunction in python using numpy library, and
looking for the fminunc or any other gradient descent algorithm
implementation in numpy.

How to integrate RevMob with corona sdk

How to integrate RevMob with corona sdk

I want to integrate RevMob in corona but i can't get the exact way i can
use it. Following are the code which i am using to integrate RevMob in
Corona,because i m new to Corona and RevMob and i don't know how to work
with it. If any body knows please help to solve it. Thanks...
local RevMob = require("revmob")
display.setStatusBar( display.HiddenStatusBar )
local storyboard = require "storyboard"
local REVMOB_IDS = { ["Android"] = "", ["iPhone OS"] = "" }
RevMob.startSession(REVMOB_IDS)
RevMob.setTestingMode(RevMob.TEST_WITH_ADS)
local banner = RevMob.createBanner()
local banner = RevMob.createBanner({x = display.contentWidth / 2, y =
display.contentHeight - 20, width = 300, height =500 })
banner:hide()
banner:show()
banner:setPosition(banner.x + 1, banner.y + 1)
banner:setDimension(banner.width - 1, banner.height - 1)
banner:release()

Friday, 13 September 2013

Binding dynamically created table entries with KnockoutJS

Binding dynamically created table entries with KnockoutJS

My questions stem from having a dynamically generated table. How can I
bind the enabled status of a checkbox in each row of said table to an
expression that is evaluating whether or not there are a given number of
checked boxes in that column?
Here's an example of my table:
<table>
<tr>
<th>Happy</th>
<th>Name</th>
<th>Status</th>
<th>Label</th>
</tr>
<tr>
<td>
<input type="checkbox" data-bind="checked: HappyPeople, enabled :
HappyPeople.length < 5" />
</td>
<td>
<input type="text" />
</td>
<td>
<p></p>
</td>
</tr>
<tr>
<td>
<input type="checkbox" data-bind="checked: HappyPeople, enabled :
HappyPeople.length < 5" />
</td>
<td>
<input type="text" />
</td>
<td>
<p></p>
</td>
</tr>
<tr>
<td>
<input type="checkbox" data-bind="checked: HappyPeople, enabled :
HappyPeople.length < 5" />
</td>
<td>
<input type="text" />
</td>
<td>
<p></p>
</td>
</tr>
var viewModel = {
HappyPeople : ko.observableArray()
};
Or, here's a jsfiddle of the (non-working) example of what I'm trying to do
Looking at that fiddle / code, how can I limit the number of happy people
to say 5, and if 5 happy people are checked, the rest of the checkboxes
are disabled. My thinking was, bind the checked of each checkbox to an
array, then also bind that checkbox's enabled property to the length of
said array.
Keeping in mind that my table entries will all be laid out dynamically, I
think I may need to use a template --- that sounds like the right thing to
use, but I'm unsure. I don't fully understand templates. I'm already using
ASP.NET MVC4 to do a lof of the heavy lifting, looping through some data &
rendering out a for each necessary entry, so a template may be the wrong
thing to use.
I've got some of this working with javascript/jquery, but it's maddening
handling all of the states by hand. Knockout would make this a lot easier.

Why using const for arguments passed by value?

Why using const for arguments passed by value?

Say you have:
int f( const T a ) { ... }
int g( const T &a ) { ... }
I understand the use of const in g: we don't know how a is used outside
the function, so we want to protect it from being modified. However I
don't understand the use of const in f, where a is a local copy. Why do we
need do we need to protect it from being modified?

Why there is no pure java djvu encoders?

Why there is no pure java djvu encoders?

If there is no any java library that can encode djvu, what kind of
potential difficulties may appear while trying to implement it?

How to start Hadoop, Accumulo, and ZooKeeper from a java program?

How to start Hadoop, Accumulo, and ZooKeeper from a java program?

I am attempting to convert a bash script to a java program. Within this
script I run the start scripts for Hadoop, Zookeeper, and Accumulo:
/hadoop/bin/start_all.sh
/zookeeper/bin/zkServer.sh start
/accumulo/bin/start_all.sh
This is simple to do in a script. And if the programs are already running
I can call these startup scripts again no issue and the programs will
simply output that they are already running and their pids.
I'm trying to figure out if there is a way to do this within a java
program. Is there some hidden command in the Hadoop/ZooKeeper/Accumulo API
where I can run Class.run(configs) and it'll start or try to start
Hadoop/ZooKeeper/Accumulo?
My next step is that I can probably use jsch to run ssh commands, but that
seems like I'm not really leaving the bash script behind.

how to force content to stay in a div?

how to force content to stay in a div?

I have some products in a ul
when I hover a product the box become bigger
I want those products to stay in there position when a use the hover.
<div id="parent" style="position: fixed;">
<ul id="list">
<li id="product1">
<li id="product2">
...
<li id="product9">
</ul></div>
this happen for the first line. it throw the second far away.

Getting search term suggestions from the CQ5.5 index

Getting search term suggestions from the CQ5.5 index

I am implementing an auto-suggest facility for a search input box using
CQ5.5.
This article on Predictive Search mentions a search/suggestion component
in AEM (5.6), which seems to be present in CQ5.5, but missing the
com.day.cq.search.suggest.impl.SuggestionIndexManager service dependencies
it requires.
Is it possible to add this facility through some add-on package or
alternative CQ5.5 feature?
It seems that the underlying Lucene suggest API does not seem to be
exposed, but perhaps there some Jackrabbit API that I could use?

Thursday, 12 September 2013

Preventing auto rotation on every view controller of my application IOS 6

Preventing auto rotation on every view controller of my application IOS 6

How do I go about disabling auto rotation on every view controller of my
application? I want each view/screen to only be viewed in portrait mode, I
do not want my view controllers to transition to landscape mode if the
phone is rotated. How can I go about doing this? I have seen too many
confusing explanations/tutorials on the web. I have tried the following
code on a particular view controller and it did not help, the view still
rotated
- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL) shouldAutorotate {
return YES;
}

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated for Worklight HTTPS request

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated for
Worklight HTTPS request

I am trying to request google maps service through my worklight adapter. I
am using HTTPS for the first time. Here is my XML file
<wl:adapter name="GoogleMapApi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>GoogleMapApi</displayName>
<description>GoogleMapApi</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>https</protocol>
<domain>maps.googleapis.com</domain>
<port>80</port>
<!-- Following properties used by adapter's key manager for
choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getListOfBanks"/>
</wl:adapter>
And my implementation is
function getListOfBanks(latitude, longitude)
{
var input={
method:'get',
returnContentType:'JSON',
path:'/maps/api/place/nearbysearch/json?&sensor=false&location='+latitude+','+longitude+'&radius=50000&types=bank&name=bank&key=AIzaSyAvK-cXlRIptgo3e5SrAc62wDJfcOQD0so',
};
return WL.Server.invokeHttp(input);
}
What the service does is that if we feed the current latitude and
longitude, it gives us banks as JSON objects. Google has given me SSL key,
but I don't know if I am using it correct. By the way when I use the URL
on my browser it is listing me with the objects.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?&sensor=false&location=38.9714,-77.386&radius=50000&types=bank&name=bank&key=AIzaSyAvK-cXlRIptgo3e5SrAc62wDJfcOQD0so

saxon:indent-spaces attribute is being ignored

saxon:indent-spaces attribute is being ignored

In my question here I'm trying to pass in a param to my stylesheet so a
user can specify the level of indentation desired. Apparently Xalan cannot
read the value of a param into its indent-amount attribute, so I'm trying
with Saxon instead.
Saxon has the attribute indent-spaces which I am trying to use as follows:
<xsl:stylesheet
version="2.0"
xmlns:saxon="http://saxon.sf.net"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- <xsl:param name="indent-spaces" select="0"/> -->
<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"
saxon:indent-spaces="10"/><!-- Doesn't matter what I make the value of
indent-spaces, the output is always indented 3 spaces -->
Why is indent-spaces being ignored?

Rendering a div with ajax

Rendering a div with ajax

I have this div
<div id="name">
....
</div>
I also have a button that does this:
<h:commandLink id="bttn" action="#">
<f:ajax render="name"/>
</h:commandLink
The problem is that when executing, it says that there is no component
called "name". Is there a way I can render a div with an ajax without
enclosing it within a jsf component?
Thanks!

Hex not working

Hex not working

How is that this works (div cirlcedecider2 has is styled "green")
function badge1(){
if (document.getElementById("circledecider2").style.color == "green"){
document.getElementById("badge1").style.backgroundColor= "#ABCF37";
document.getElementById("badge1").style.width = "200px";
document.getElementById("badge1").style.height = "200px";
}}
But this does? (div cirlcedecider2 has is styled "#ABCF37")
function badge1(){
if (document.getElementById("circledecider2").style.color == "#ABCF37"){
document.getElementById("badge1").style.backgroundColor= "#ABCF37";
document.getElementById("badge1").style.width = "200px";
document.getElementById("badge1").style.height = "200px";
}}
The only difference is using a hexcode.

Default value if no value is in the scope?

Default value if no value is in the scope?

Retreiveing a value like {{cat}} from angular, is there a way to set a
value that will output if no value is in the $scope?

Not getting fb session in begning android

Not getting fb session in begning android

I am working on Facebook SDK. I have done many things such as download
photos, uploading photos, creating new albums and many more and all are
working fine.
But now I have a problem in getting FB session. Actually I have three
activities for ex. A, B & C.
In B activity user login successfully and in return he get an session. And
I can get this session in C activity and A activity also. But only in
following sequence. B to A, B to C, B to A to C, B to C to A. no matter I
close the application or not.
But when I close the application and open activity A I am not able to get
the active session. I also try this in facebook sample project
"SessionLoginSample". But similler things happens. I also try to save
accessToken and get this session but It doesn't work.
Actually I am try to create an library for future use.

Wednesday, 11 September 2013

How to add a library to Eclipse?

How to add a library to Eclipse?

I want to add this library to my project but I am not sure how to. I have
already searched for the answers online but most of them are for old
versions and do not work. Can someone give me step by step instructions
please?
Cheers

In WPF, a ViewModel have a reference to a Model

In WPF, a ViewModel have a reference to a Model

Assume that there're a PIModel (i.e. Personal Information Modle) and a
ViewModle(contains some infomation from PIModel and other).
// PIModel
public PIModel
{
private string firstName;
public string FirstName { get; set; }
private string lastName;
public string LastName { get; set; }
... // other
}
Then, the FirstName property and the LastName property need to be bound to
View, so I have two Question:
Whether the ViewModel have a property reference to a PIModel instance;
If so, whether the ViewModel have two propertise reference to
PIModel.FirstName and PIModel.LastName.
I learn about that implement the INotifyPropertyChanged in Model is not
recommended.

Unicode characters in Swing only display when using the default font-size

Unicode characters in Swing only display when using the default font-size

I'm trying to display a few Unicode characters inside of a jLabel. Take
for example, the "degrees Fahrenheit" character (¨H or "\u2109"). This
character is only being displayed when I use the default font-size, which
happens to be 11. When I change the font-size, the character is replaced
with an empty rectangle. I've tried several different sizes and several
different fonts that offer a wide range of unicode characters. Can anyone
tell me why Swing only displays this unicode character under a specific
font-size?

Reading data from a file in Python

Reading data from a file in Python

I have a data file that looks like this:
1,100
2,200
3,-400
4,500
As you can see, each data point has 2 components When I do
file.readlines() they all come up as strings such as '1,100\n' so I am
wondering how would I make them into integers?

Why can't I asynchronously load ReportDocuments in Crystal

Why can't I asynchronously load ReportDocuments in Crystal

Using the code below we run into an issue with Crystal.
It seems ok to create ReportDocuments but not to load these simultaneously
(DESPITE the fact they are loaded from different PHYSICAL places)
It works fine with the lock in place, but remove that lock and it freezes!!
Does anyone have any ideas?
public static object fLock = new object();
private void button1_Click(object sender, EventArgs e)
{
int[] i = { 1, 2, 3 };
Parallel.ForEach<int>(i, j => CreateReportOutput(j));
}
private void CreateReportOutput(int j)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new
CrystalDecisions.CrystalReports.Engine.ReportDocument();
**lock (fLock)**
rpt.Load(string.Format("C:\\_Temp\\temptabs\\reports{0:00}\\C_NOTES.RFM",
j));
rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
string.Format("C:\\_Temp\\temptabs\\output_{0}({1:00}).pdf",
DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff"), j));
}

How to get Postgres function name as well as function specific name from pg_catalog.pg_proc?

How to get Postgres function name as well as function specific name from
pg_catalog.pg_proc?

Since Postgres supports function overloading, getting function name as
well as function specific name(System generated without duplicates) is
more meaning full.
Assume i have 2 functions in the name as Func1 which are overloaded as
shown below,
CREATE FUNCTION "Schema"."Func1"(IN param1 INTEGER,
IN Param2 CHAR)
RETURNS INTEGER
AS $BODY$
begin
return param1+1;
end $BODY$
LANGUAGE PLPGSQL;@
CREATE FUNCTION "Schema"."Func1"(IN param1 INTEGER)
RETURNS INTEGER
AS $BODY$
begin
return param1+1;
end $BODY$
LANGUAGE PLPGSQL;@
How do i load the functions as well as input parameters correctly from
pg_catalog.pg_proc. With the help of information_schema.routines, there is
a way to load function 1)specific_name 2) routine_name
But many other attributes are missing in information_schema.routines like
1) isWindow function 2) isStrict function 3) isProRetSet function
So is there some other means to get the function specific_name from
pg_catalog.....

Border on print using window.print()

Border on print using window.print()

i have a issue about the border style on my window.print(). want is when i
print the border is showed. And the privious printing is hidden.
this is my sample code the print is working.
jsfiddle.net/v921/zHt8Y/12/

Tuesday, 10 September 2013

setting attributes or css of button in code behind in aspx

setting attributes or css of button in code behind in aspx

here is my aspx code for buttons
<div id="navigationButtons">
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
OnClick="btnSubmit_Click" CssClass="button submit"
Enabled="true" />
<asp:Button ID="btnNext" name="btnNext" Text="NEXT"
ToolTip="Next" runat="server" CssClass="button next"
TabIndex="0" OnClick="btnNext_Click" Enabled="false"/>
<asp:Button ID="btnPrev" Text="PREV" ToolTip="Previous"
runat="server" CssClass="button prev" TabIndex="2"
OnClick="btnPrev_Click" Enabled="true"/>
<asp:Button ID="btnExit" Text="EXIT" ToolTip="Exit"
runat="server" CssClass="button exit" TabIndex="3"
OnClick="btnExit_Click" />
</div>
I am unable to change the attributes from code behind so I browsed for the
solution and some blogs suggested using following code in the code behind.
((System.Web.UI.HtmlControls.HtmlElement)Page.Form.FindControl("btnNext")).Style.Add("visible",
"false");
but when I use it there is null exception error in the code. I don't know
how to fix this in the above code behind. Any solution is appreciated.
thanks.

clang++'s static analyzer and Makefiles

clang++'s static analyzer and Makefiles

I've recently discovered clang++'s static analyzer feature, and it's
fantastic for going over my code with a fine-toothed comb to find latent
bugs. I just uncomment this line in my Makefile:
CXXFLAGS += --analyze -Xanalyzer -analyzer-output=text
et voila, I'm in deep-bug-checking mode.
One minor problem with this, however, is that whenever the analyzer does
not find any problems in a particular .cpp file, doesn't produce any .o
file.
Normally that wouldn't be a big deal (I can always re-comment the above
line to build an actual executable), but usually when I see an
analyzer-warning, the first thing I want to do is try to fix the
underlying problem and then re-run make.
... which works, but since no .o files are being generated, make will
start re-analyzing all the .cpp files again from the beginning, rather
than just the .cpp files I actually modified since the previous run. This
means I end up spending rather a lot of time re-checking .cpp files that
haven't changed.
My question is, is there any way to get the static analyzer to output a .o
file (it doesn't have to be a valid object file, just any file with an
updated timestamp) so that Make will know that a "clean" .cpp file does
not need to be re-processed? (i.e. make Make work the same way it does
when doing a normal compile)

Trying to make my site responsive

Trying to make my site responsive

I am using the following css code. What I want to do is if the user is on
a iPad I want the background-image to be headerold.jpg or some way to make
the current headernew.jpg to display properly on the iPad. Currently part
of each end is cut off. I have tried @media query but I am not able to get
the code to work. Any help would be appreciated.
Thanks Roger
div.art-header-jpeg
{
position: absolute;
top: 0;
left:-50%;
width: 1344px;
height: 150px;
background-image: url('../img/headernew.jpg');
@media all and (max-width: 1000px) {background-image:
url('../img/headerold.jpg');}
background-repeat: no-repeat;
background-position: center center;
}

How the accessbility of a class or function in C++ is controlled

How the accessbility of a class or function in C++ is controlled

In language like C#. you can put public or internal in front of a class to
control the access level of a class. How this is done in an C++ DLL?

C++ send array of 2 integers as argument

C++ send array of 2 integers as argument

I am trying to make this C++ code more abstract, easier to see and
understand, and less space occupier. It is a function that takes a string
and two integers for a size and a position.
HWND CreateButon(string Title, const int[2] Size, const int[2] Position) {
// Create the control, assign title, size and position
// Return HWND
}
HWND MyButton = CreateButton("Button1", [100, 20], [10, 10]);
I know the last one is wrong. I just wrote it that way so you can see what
I mean. I would like to send the size and position values directly as an
argument. I could use structs but they must be declared before. The same
with some other kind of variables. I just want to send them in the
arguments as groups of two integers and I wonder if there's a workaround
for it. More than anything else it's just for the sake of having it
compact and simple.

While Using UJS in Rails 4, its throwing error undefined local variable or method `init_changed_attributes'

While Using UJS in Rails 4, its throwing error undefined local variable or
method `init_changed_attributes'

I am learning to implment UJS with Rails. And my rails Version is 4.0, I
guess thats troubling me now.
undefined local variable or method `init_changed_attributes' for
#<Post:0x3373488>
Extracted source (around line #6):
4 def load
5 @posts = Post.all
6 @post = Post.new
7 end
8 def new
9 end
While Running Migration for Post, Post got created, but encountered
Similar error in CMD prompt:
rake aborted!
undefined local variable or method `init_changed_attributes' for
#<ActiveRecord::SchemaMigratio
n version: nil>

Monday, 9 September 2013

Cascade changes in Mongodb in Django

Cascade changes in Mongodb in Django

Is there a way to change a element of collection in Mongoose and be
cascade changed in other collection that points this element, similar to
using MySQLs foreign keys?
For example, in MySQL I'd assign a foreign key and set it to cascade on
change or delete. Thus, if I were to delete or change name of a
activity_Type, all applications and associated activity_Types would be
removed or affected as well.
class ValuesHelper(object):
NAME = 'activityType'
def __init__(self, neo_on=False):
self.client =
MongoClient(settings.DATABASES['mongo']['HOST'],settings.DATABASES['mongo']['PORT'])
self.db = self.client[settings.DATABASES['mongo']['NAME']]

C# - connection leaking returning from class method

C# - connection leaking returning from class method

I has returning a connection from a class method in Connection class. In
my another class, I instantiate the connection class to open the
connection. I has close the connection as well but it seem like has
connection leak. Any idea how I can fix it. My code as below
public class Connection
{
private SqlConnection _oConn;
public SqlConnection GetConnection
{
get
{
if (_oConn == null)
{
string sConnString =
ConfigurationManager.ConnectionStrings["bplocator_database_connection"].ConnectionString;
_oConn = new SqlConnection(sConnString);
}
return _oConn;
}
}
}
In another class file, i call this connection class
private BPAdmin.data.Connection oConn
{
get
{
if (_oConn == null)
{
_oConn = new BPAdmin.data.Connection();
}
return _oConn;
}
}
public void getData
{
try
{
oConn.GetConnection.Open();
//Do something
}
catch
{
oConn.GetConnection.Close();
}
finally
{
oConn.GetConnection.Close();
}
}
I found that this cause a connection leaking and it cause application pool
reached max. Any idea whats wrong and how I can fix it. Please help!.

Volatilitux can't read physical memory at 753aec

Volatilitux can't read physical memory at 753aec

so i have a Samsung Galaxy Nexus phone in which i have dumped out it's RAM
using LiME. I tried to use Volatilitux to analyze this RAM file but i am
getting the following error when i run the program:
#python volatilitux.py -f /root/majorProject/ram.lime pslist
Error: RawDump: Unable to read physical memory at offset 753aec
Is it an issue with my RAM dump or issit volatilitux being uncompatible
with LiME extracts? Thanks.

Can I develop Android widgets using Sencha?

Can I develop Android widgets using Sencha?

I am very new to Sencha. Just wondering, if there is any possibility of
developing Android widgets using Sencha.

How to get the values in split python?

How to get the values in split python?

['column1:abc,def', 'column2:hij,klm', 'column3:xyz,pqr']
I want to get the values after the :. Currently if I split it takes into
account column1, column2, column3 as well, which I dont want. I want only
the values. This is similar to key-values pair in dictionary. The only
dis-similarity is that it is list of strings.
How will I split it?

MVC treeview click event

MVC treeview click event

I am really new to the MVC/jQuery world and having trouble getting the
full picture how to set up and handle a treeview click event to pass the
full path (Parent & Children) values to a MVC Controller in the treeview
below. Example: If I click on Houston. I would like to get the parent path
USA,Texas,Houston and then pass to a Controller. If just Texas, then I
want USA,Texas. I am using the jstree.com tree view. Thank you for the
help.
P.S. In the console log it's say: Uncaught TypeError: Cannot read property
'value' of undefined
<div id="divtree">
<ul id="tree" >
<li>
<a href="#">Locations</a>
<ul>
<li onclick="selectNode(event, this);" >
<a href="#">Texas</a>
<ul>
<li onclick="selectNode(event, this);" >
<a href="#">Houston</a>
<ul>
<li onclick="selectNode(event,
this);" >
<a href="#">Katy</a>
</li>
</ul>
<ul>
<li onclick="selectNode(event,
this);" >
<a href="#">Spring</a>
</li>
</ul>
<script type="text/javascript">
function selectNode(event,
nodeHtmlEl) {
console.log("selectNode Info:
" +
$(nodeHtmlEl).attr("li").value);
}
</script>
</li>
</ul>
<script type="text/javascript">
function selectNode(event, nodeHtmlEl) {
console.log("selectNode Info: " +
$(nodeHtmlEl).attr("li").value);
}
</script>
</li>
</ul>
<script type="text/javascript">
function selectNode(event, nodeHtmlEl) {
console.log("selectNode Info: " +
$(nodeHtmlEl).attr("li").value);
}
</script>
</li>
</ul>
</div>

display content in alphabetical order sections

display content in alphabetical order sections

I have a stored procedure that returns information and orders it by the
status and then the name of users. Currently when the results are
displayed they are ordered and displayed by the rank and then by name of
the user. I want to display the information as it is but within sections
so like:
A
list all users that start with letter A
B
list all users that start with letter B
How can i go about doing that in app. I am using MVC web app, c# and
knockout.js
Do i go about that in the View or View + knockout.js or controller?

HTML / JS "Lock / Hide" content until date set

HTML / JS "Lock / Hide" content until date set

I have a HTML5 / CSS page which I want to hide / disable / lock the
content on until a certaindate.
Does any one know of any HTML5 / JS ways of doing this and potentially
showing a message until viewing is available.
Please ask if you need any more clarification on the function.
Thanks in advance

Internal Server Error poblame

Internal Server Error poblame

The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at admin@localhost to inform them
of the time this error occurred, and the actions you performed just before
this error.
More information about this error may be available in the server error log.
for server. but main file view OK. plz solution me.

Sunday, 8 September 2013

Query stop working after change Where for Where in ()

Query stop working after change Where for Where in ()

Hi i used a COunt(*) to paginate in my php code,
The Variable $cat , look like this sometimes is
$cat = (1,2,3,4)
$cat = (1)
This time i need multiple cats, thats why thanks sorry for missing that ,
I always use something like
$query = "SELECT COUNT(*) as num FROM $tableName WHERE cat_id=$cat";
$total_pages = mysql_fetch_array(mysql_query($query)or
trigger_error('Query failed: ' . mysql_error(), E_USER_ERROR));
$total_pages = $total_pages['num'];
But now i nee to use WHERE id IN (1,2,3,4,5,etc) this is the actual query..
$query = "SELECT COUNT(*) as num FROM $tableName WHERE cat_id IN ($cat)";
$total_pages = mysql_fetch_array(mysql_query($query)or
trigger_error('Query failed: ' . mysql_error(), E_USER_ERROR));
$total_pages = $total_pages['num'];
But i get this error using WHERE IN
Warning: mysql_fetch_array() expects parameter 1 to be resource,
boolean given in /Applications/MAMP/htdocs/pcweb/admin/tiendas.php on
line 173
So how do you di this count then.. thanks i think there must be an easy
syntax error, but i cant find it cause i have never used Where IN, i look
into documentation here. http://www.w3schools.com/sql/sql_in.asp but i
think i do not know exactly what to google, so i ask..
Thanks

Unity3d Network, port is not opened

Unity3d Network, port is not opened

I try to create a simple network example over the internet. This is the code:
void OnGUI()
{
if (Network.isServer)
{
GUI.Label(new Rect(10, 10, 100, 30), "Server is started");
}
else
{
if (GUI.Button(new Rect(10, 10, 100, 30), "Create Server"))
{
Network.InitializeServer(10, 25000, true);
}
}
}
Then I turn off the firewall and antivirus programs. I forward the port
25000 into my local IP address.
Then I run the program and click on "Create Server" button to make it
running and go to http://www.yougetsignal.com/tools/open-ports/ to check
whether my port is opened. The result is always "closed". What did I do
wrong?
NOTE:
I tested the port with other application to make sure that it is not
blocked by ISP.
This is what I got by using netstat http://screencast.com/t/qzArfnxxH
Thanks

In TYPO3 6.x, how to disable entire tabs of content items

In TYPO3 6.x, how to disable entire tabs of content items

As configuring excludefields in that tiny box is painful and incomplete, I
use TCEFORM to simplify the TYPO3 backend for editors. I thought in TYPO3
6.x, this would be maybe a bit cleaner, but it's not. Everything's still
there, and with FAL, even more potentially user-confusing fields have been
introduced.
That's how I do it (in user group TSConfig):
page.TCEFORM.tt_content.longdescURL.disabled = 1
The syntax corresponds to table and column name, AFAIK.
I'll include my current setup (beware, Legacy from 4.5, there are probably
black holes in there) in an answer, as it's quite long.
If you disable all fields in a tab, the tab itself will disappear.
The question is:
Is there an easier way? Like, disabling an entire tab at once? Or
disabling everything and only including desired fields from the ground up?