Monday, 30 September 2013

If $ a \mid bc $ then $\frac{a}{\gcd(a,b)} \mid c$?

If $ a \mid bc $ then $\frac{a}{\gcd(a,b)} \mid c$?

Prove or reject this statement:
If $ a \mid bc $ then $\displaystyle \frac{a}{\gcd(a,b)} \mid c$

Can a custom module have more than one namespace=?iso-8859-1?Q?=3F_=96_magento.stackexchange.com?=

Can a custom module have more than one namespace? – magento.stackexchange.com

Is it fine to have more than one namespaces for a custom module? I haven't
tried yet. But for some situations it's better if we can have this
feature. Any suggestion will be appreciated. Example: …

Oracle forms migrated from 10g to 11g

Oracle forms migrated from 10g to 11g

Once exported from oracle 10g to 11g, It is saying some java beans are
missing in the form. Is there something we need to change the FORM beans
path in new version.If not, Where are we mentioning the path for java
beans in reports.

Javascript: get *updated* value of textarea

Javascript: get *updated* value of textarea

I have atext area on my page.I am filling it up from some data at page
load.Then user changes the data in textarea and I alert the text of
textarea.but I am getting the same value in alert which was initially
loaded in text area.It's not updating at all.
html:
<textarea rows="8" style="width: 60%" id="cmds"></textarea>
<input type="button" class="btn" value="alert" onclick="alertCmds()" />
javascript"
$.post('/AutoRegress/AutoRegress?cmd=cmdlist'{url:$('#url').val(),revId:$('#revId').val()},
function(data) {
$("#cmds").val(data.replace(/,/g,"\n"));
});
fuction alertCmds(){
alert($('#cmds').text());
}

Sunday, 29 September 2013

Recurrence Relations and drawing Recursion trees

Recurrence Relations and drawing Recursion trees

Here is the algorithm
Algorithm Mystery(A: Array [i..j] of integer) i & j are array starting and
ending indexes
if i=j then return A[i]
else
k=i+floor((j-i)/2)
temp1= Mystery(A[i..k])
temp2= Mystery(A[(k+1)..j]
if temp1<temp2 then return temp1 else return temp2
I believe the complexity is: T(1) = c T(n) = 2T(n/2) + n
but from here I'm not sure where to go all the examples have the second
equation ending with cn so i have no idea how to draw the tree. Did i
solve the recursion wrong? I just need some help getting on the right
direction.

Django REST Framework: object is None only on one attribute, but not other

Django REST Framework: object is None only on one attribute, but not other

I have been having trouble understanding why the object (obj) passed into
field_to_native() changes from Nonetype to a correct object once I change
the attribute...
Here's the original issue: Splitting model instance for serializer into 3
different fields
mariodev from stackoverflow helped me on the original issue, but a strange
bug both of us cannot figure out:
Here's the code where it seems to have the problem:
COORD = dict(x=0, y=1, z=2)
class CoordField(serializers.Field):
def field_to_native(self, obj, field_name):
#retrieve and split coords
coor = obj.xyz.split('x')
return int(coor[COORD[field_name]])
class NoteSerializer(serializers.ModelSerializer):
owner = serializers.Field(source='owner.username')
firstname = serializers.Field(source='owner.first_name')
lastname = serializers.Field(source='owner.last_name')
x = CoordField()
y = CoordField()
z = CoordField()
class Meta:
model = Note
fields =
('id','owner','firstname','lastname','text','color','time','x', 'y',
'z')
xyz is a instance in the model Note. According to the traceback, when I do
obj.xyz, the obj = None.
Weirdly, if I do obj.color, the obj returns correctly (Note: someuser)
I don't understand how the obj can change just by changing the attribute.
What's beyond me is that the JSON data 'x' 'y' and 'z' ARE being passed to
the view, and my div boxes get the correct left, top, and z-index CSS
data. If this works, why am I getting an error?
If there's an error, why is the data still getting through?
style="left: 343px; top: 110px; z-index: 3;"
As you can see, the x,y,z DID pass through.
Any enlightenment would be wonderful! Thanks a bunch!
Here's the traceback in text view:
Traceback: File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response 140. response = response.render() File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/template/response.py"
in render 105. self.content = self.rendered_content File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/response.py"
in rendered_content 59. ret = renderer.render(self.data, media_type,
context) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in render 582. post_form = self.get_rendered_html_form(view, 'POST',
request) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in get_rendered_html_form 485. data = serializer.data File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in data 510. self._data = self.to_native(obj) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in to_native 309. value = field.field_to_native(obj, field_name) File
"/home1/thecupno/django/notes/desk/serializers.py" in field_to_native 10.
coor = obj.xyz#.split('x') <-- I commented out .split, and the problem
still persists.
Exception Type: AttributeError at /desk/restnote/ Exception Value:
'NoneType' object has no attribute 'xyz'

Rails controller action behavior without respond_to

Rails controller action behavior without respond_to

Rails Scaffold generator create some actions in a controller with
respond_to and some without it.
For example:
GET /replaces/new
GET /replaces/new.json
def new
@replace = Replace.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @replace }
end
end
GET /replaces/1/edit
def edit
@replace = Replace.find(params[:id])
end
I understand that Rails renders the view that has the same name as the
action. If I have multiple views with the same name (in different
formats), I have to specify which one you want in the request and use the
respond_to method to respond accordingly.
Questions:
Why the Scaffold generator create some actions without respond_to ?
What will be the behavior if there no respond_to and requests are coming
with different format? HTML? AJAX?

Java Server Faces error when trying to use an if method in my Bean class

Java Server Faces error when trying to use an if method in my Bean class

Hey im trying to set up a voting app that will display whether the user is
able to vote or not using an if statement in my bean class but this Unable
to find matching navigation case with from-view-id '/home.xhtml' for
action '#{user.checkAge(user.age)}' with outcome 'Invalid User, Please Try
Again!!!'. Im not very understanding of Java Server Faces yet and ive
tried messing around with the config files and googling the error but i
cant fix it. Can anyone help me please.
Here is my code:
**
Home.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
<title>Results Page</title>
</head>
<body>
<h:form>
Name: <h:outputText id="outTxt" value="#{user.name}"/><br></br>
Age: <h:outputText id="outTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check"
action="#{user.checkAge(user.age)}"/>
</h:form>
</body>
</html>
**
index.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Home Page</title>
</h:head>
<h:body>
<h:body>
<h:form>
Name: <h:inputText id="inTxt" value="#{user.name}"/><br></br>
Age: <h:inputText id="inTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check" action="home"/>
</h:form>
</h:body>
</h:body>
</html>
**
User.java
**
package MyPackage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class User
{
private String name;
private int age;
private String msg;
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String checkAge(int checkAgeVoter)
{
if(checkAgeVoter >= 18)
{
msg = "Valid User, Access Granted!!!";
}
else
{
msg = "Invalid User, Please Try Again!!!";
}
return msg;
}
}

Saturday, 28 September 2013

Only Print DataGridView in windows forms

Only Print DataGridView in windows forms

i want to ask, how do i print only DataGridView in windows forms and using
my own format. I also didn't know how to print a file in windows forms.
Could you guys help me? This will be my format when print:

And here is my DataGridView:

NOTE: This is just an example (only the DataGridView, but for the format i
want to when print be like that.

My background isn't spanning horizontally

My background isn't spanning horizontally

I have this code, the only code on the site that would be affecting the
background. I had Eric Meyer's CSS reset on, but commented it out to see.
It made no difference. The only code I have left is this.
* {
margin: 0;
padding: 0;
}
body {
background: url("../images/bg.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I tried many different things to get it to touch the side of the browsers,
but there remains an annoying margin or something on the sides. Any ideas
on how to get rid of this?
Here's what it looks like:

How to close previous popovers in fullCalendar?

How to close previous popovers in fullCalendar?

I am using fullCalendar in my website together with Bootstrap so that
everytime I click on a day in month view, there is a popover to add event,
just like that in Google Calendar. Here is my code
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
height: height,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
dayClick: function( date, allDay, jsEvent, view ){
$(this).children().popover({
title: 'haha',
placement: 'right',
content: 'haha',html : true, container: 'body'
});
$(this).children().popover('show');
}
})
The code should be right before $(this).children().popover({ so that it
closes all previously fired popover.
However, exactly, what code should I use to achieve this?
Thank you!

How to get rid of small gaps between horizontally aligned images?

How to get rid of small gaps between horizontally aligned images?

pPlease see a href=http://www.rcblue.com/test/Toby.html
rel=nofollowhttp://www.rcblue.com/test/Toby.html/a . There are very narrow
vertical gaps between the images. How to get rid of them?/p

Friday, 27 September 2013

Java RegEX To Split and Reverse String

Java RegEX To Split and Reverse String

I have a Java String "test/this/string" that I want to reverse to
"string/this/test" using a regular expression or the most efficient Java
algorithm. The way I know is to use the split method, loop over the array
and rebuild the string manually. The number of "/" can vary and doesn't
occur a fixed number of times. Any ideas?

.htaccess remove .html file/directory priority rewrite

.htaccess remove .html file/directory priority rewrite

I'm trying to rewrite so you can access files without .html and without
adding a trailing slash. here's the code being used:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*?)/?$
RewriteCond %{DOCUMENT_ROOT}/%1.html -f
RewriteRule ^(.*?)/?$ $1.html
But for my file structure on the server where I have this:
/public_html
..
/beginners
beginners.html
and inside /beginners folder there's other files, e.g.
/beginners/page1.html
I need rewrites to work like this:
if user inputs url: website.com/beginners - the server would return the
contents of file beginners.html currently it returns the contents of the
directory /beginners . so i need the server to first check if
beginners.html exists, if yes - then server serves beginners.html not the
directory /beginners
if the user accesses url website.com/beginners/page1 the server should
first check up if page1.html exists in the folder beginners and if it
finds the file page1.html then it serves the contents of the file
page1.html
can this be done?

java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_id]

java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [_id]

After another SO poster resolved my issue to insert a List[DBObject] ...
// Bulk insert all documents
collection.insert(MongoDBList(docs)) // docs is List[DBObject]
Now, I'm seeing this error when trying to insert.
java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [_id]
I've checked out the exactly named post, but I'm not sure how to apply the
answer to my problem.

Ruby - Scripting language or Object Oriented Language?

Ruby - Scripting language or Object Oriented Language?

Is Ruby a scripting language or an object oriented language that is
capable of producing complex programs?

UIGestureRecognizer with a touch moving off UIView

UIGestureRecognizer with a touch moving off UIView

I have a UILongPressGestureREcognizer with a minimum press length of 0
seconds. On UIGestureRecognizerStateStart I alter the UIView. On
UIGestureRecognizerStateEnded, I run the code for what ever the press is
suppose to do.
-(IBAction)longPressDetected:(UILongPressGestureRecognizer *)recognizer {
static NSTimer *timer = nil;
if (recognizer.state == UIGestureRecognizerStateBegan) {
// alter look of UIView
}
else if (recognizer.state == UIGestureRecognizerStateEnded) {
// do something
// change look back to original state
}
}
I am running into an issue where if the touch starts on the UIView and if
the touch is dragged outside of the UIView and is lifted, the
UIGestureRecognizerStateEnded still fires.
I need to be able to handle a touch inside the UIView, the user drag
outside of the UIView and to cancel it.
I know a UIButton can do it, but it does not fulfill all the needs I have.
How can I cancel a touch if the touch is dragged outside of the UIView?

InteliJ idea gui designer + maven

InteliJ idea gui designer + maven

I have a project created with help of GUI designer. Here is code of main
form.
public class MainForm {
MainForm() {
directLineOkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
}
}
});
crossLineOkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
}
public JPanel getMainPanel() {
return mainPanel;
}
private void createUIComponents() {
drawingPanel = new DrawingPanel();
}
private JPanel mainPanel;
private JComboBox directDirectionCombobox;
private JButton directLineOkButton;
private JButton crossLineOkButton;
private JComboBox crossLineComboBox;
private JTextField crossLineSizeValue;
private JButton clearButton;
private JLabel directLineLabel;
private JPanel directLinePanel;
private JLabel crossLineLabel;
private JPanel crossLinePanel;
private JPanel okClearButtonPanel;
private JTextField directLineSizeValue;
private JButton saveButton;
private JPanel drawingPanel;
private JButton cancelButton;
}
It works fine. Jar file generates fine, here code of pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DOC</groupId>
<artifactId>DOC</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
But when I try to run jar file there is a mistake.
Exception in thread "main" java.lang.NullPointerException
at MainForm.<init>(MainForm.java:14)
at Main.main(Main.java:13)
It show that mistake is at the line where directLineOkButton listener is
created. I create listener like said here:
http://www.jetbrains.com/idea/training/demos/GUI_Designer/GUI_Designer.html
in constructor using cmd+o. Here is code of xml of form:
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1"
bind-to-class="MainForm">
<grid id="27dc6" binding="mainPanel" layout-manager="FormLayout">
<rowspec value="center:23px:noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:47px:noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:7dlu:noGrow"/>
<rowspec value="center:25px:noGrow"/>
<rowspec value="top:174dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="fill:d:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:452px:noGrow"/>
<constraints>
<xy x="20" y="20" width="797" height="453"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3b663" class="javax.swing.JLabel"
binding="directLineLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Direct Line"/>
</properties>
</component>
<grid id="499e0" binding="directLinePanel" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:98px:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:80px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="1" column="0" row-span="2" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c383d" class="javax.swing.JComboBox"
binding="directDirectionCombobox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="2" anchor="8" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<enabled value="true"/>
<model>
<item value="Ââåðõ"/>
<item value="Âíèç"/>
<item value="Âïðàâî"/>
<item value="Âëåâî"/>
</model>
</properties>
</component>
<component id="17aa1" class="javax.swing.JTextField"
binding="directLineSizeValue">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="6" anchor="8" fill="1"
indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
</component>
<component id="44fc7" class="javax.swing.JButton"
binding="directLineOkButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<component id="5a571" class="javax.swing.JLabel"
binding="crossLineLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Cross Line"/>
</properties>
</component>
<grid id="77f1a" binding="crossLinePanel" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:98px:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:80px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="32368" class="javax.swing.JComboBox"
binding="crossLineComboBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="2" anchor="8" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<model>
<item value="Ââåðõ-âïðàâî"/>
<item value="Ââåðõ-âëåâî"/>
<item value="Âíèç-âïðàâî"/>
<item value="Âíèç-âëåâî"/>
</model>
</properties>
</component>
<component id="dbf23" class="javax.swing.JTextField"
binding="crossLineSizeValue">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="6" anchor="8" fill="1"
indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
</component>
<component id="c5c8a" class="javax.swing.JButton"
binding="crossLineOkButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<grid id="53bbc" binding="okClearButtonPanel"
layout-manager="FormLayout">
<rowspec value="center:d:noGrow"/>
<colspec value="fill:d:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="8" column="0" row-span="1" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
<border type="none"/>
<children>
<component id="41ba7" class="javax.swing.JButton"
binding="saveButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Ñîõðàíèòü"/>
</properties>
</component>
<component id="a6bf6" class="javax.swing.JButton"
binding="clearButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Î÷èñòèòü"/>
</properties>
</component>
<component id="40f1c" class="javax.swing.JButton"
binding="cancelButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Îòìåíèòü"/>
</properties>
</component>
</children>
</grid>
<grid id="2e94e" binding="drawingPanel" custom-create="true"
layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:d:grow"/>
<constraints>
<grid row="0" column="2" row-span="11" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<background color="-1"/>
</properties>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>

How to properly read SQL Server syntax?

How to properly read SQL Server syntax?

In the MSDN Library or the Technet website, Microsoft tend to use a pseudo
syntax in explaining how to use T-SQL statements with all available
options. Here is a sample taking from the Technet page on UPDATE
STATISTICS :
UPDATE STATISTICS table_or_indexed_view_name
[
{
{ index_or_statistics__name }
| ( { index_or_statistics_name } [ ,...n ] )
}
]
[ WITH
[
FULLSCAN
| SAMPLE number { PERCENT | ROWS }
| RESAMPLE
| <update_stats_stream_option> [ ,...n ]
]
[ [ , ] [ ALL | COLUMNS | INDEX ]
[ [ , ] NORECOMPUTE ]
] ;
<update_stats_stream_option> ::=
[ STATS_STREAM = stats_stream ]
[ ROWCOUNT = numeric_constant ]
[ PAGECOUNT = numeric_contant ]
How to properly read such description and quickly figure out what is
required and what is optional and a clean way to write your query?

Thursday, 26 September 2013

is it possible create a sql view from "horizontal" to "vertical"

is it possible create a sql view from "horizontal" to "vertical"

please see my attached below: my actual data will be store in table 1, can
I create a view that display data like table 2?

Wednesday, 25 September 2013

Controlling CSS using AngularJS

Controlling CSS using AngularJS

I am trying to control CSS through AngularJS. I am using ng-class and
ng-click for this purpose ..... I have made two function showError and
showWarning for this purpose. I am try to change CSS through setting their
properties true and false respectively
--------CSS---------
.error {
background-color: red;
}
.warning {
background-color: orange;
}
-------HTML---------
<div>
<h2> {{ message }} </h2>
<ul>
<li class="menu-disabled-{{ isDisabled }}" ng-click="stun()">
Stun</li>
</ul>
<div class='{ warning : {{ isWarning }}, error : {{ isError }} }'>
{{ messageText }}</div>
<button ng-click="showError()"> Simulate Error</button>
<button ng-click="showWarning()">Simulate Warning</button>
</div>
-------JS-----------
$scope.isError = false;
$scope.isWaring = false;
$scope.showError = function(){
console.log("error here");
$scope.messageText = "This is an error";
$scope.isError = true;
$scope.isWaring = false;
}//showError
$scope.showWarning = function() {
console.log("warning here");
$scope.messageText = "Just a Warning, Carry ON !!!";
$scope.isError = false;
$scope.isWaring = true;
}//showWarning
I am successful to access the function and printing the messageText using
ng-click but can't change the CSS properties////

Thursday, 19 September 2013

DLL issue. C# not recognizing DLL file, or its just me

DLL issue. C# not recognizing DLL file, or its just me

I'm assigned a task to use a DLL file in C#. I have created the DLL file
(Prog1210.dll) and have added it as a reference into the Solution explorer
in C#. The DLL file has a variable txtNumber1 which is trying to be
accessed in this main class.
Just wondering why it recognizes ValidateTextbox in the DLL in this class
form, but says it doesn't recognize Prog1210 in the using statement, and
doesn't recognize txtNumber1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Prog1210;
namespace StaticClass
{
class Class1
{
private void btnValidate_Click(object sender, EventArgs e)
{
// Use the ValidateTexbox class that has been added to this project
if (ValidateTextbox.IsPresent(txtNumber1) &&
ValidateTextbox.IsDouble(txtNumber1) &&
ValidateTextbox.IsWithinRange(txtNumber1, 1.0, 100.0))
{
MessageBox.Show("Textbox value is valid!", "Good Data");
}
else
{
// The ValidateTexbox methods assigns an error message to the Tag
// property of the textbox.
string display = (string)txtNumber1.Tag;
MessageBox.Show(display, "Bad Data");
txtNumber1.Focus();
}
}
}
}`

Are there any languages with "lateral" assignment operators?

Are there any languages with "lateral" assignment operators?

I don't know a really good name for what I'm talking about, but, most
programming languages use a syntax for assignment statements something
like this:
(variable) (assignment operator) (expression)
And some have some special assignment operators, such as var1 += var2
which is equivalent tovar1 = var1 + var2.
My question is basically, is there any language that would treat += like
above, but also have an =+ operator so that var1 =+ var2 would be
equivalent to var2 = var2 + var1?
Essentially, are there programming languages with "mirrorable" assignment
operators, so that the variable on the right is what gets assignment a new
variable (as opposed to the one on the left)?
Edit:
I suppose a much better example of what I'm referring to would be a
language in which you can have both (variable) (assignment operator)
(expression) and (expression) (assignment operator) (variable) as valid
statements.

How to put a variable in a Neo4j cypher query for a repository

How to put a variable in a Neo4j cypher query for a repository

I am using spring neo4j. I have a repository class that extends
GraphRepository<T>. I want to delete a specific object based on the uid in
the arguments to the method below.
public interface TypeRepository extends GraphRepository<Type> {
@Query("START n=node:node_auto_index(uid=uidValueYAA)" +
"MATCH n-[r]-()" +
"DELETE n, r")
public void deleteByUid(String uidValueYAA);
}
Note: my persisted class has an index annotation like the following:
@GraphId
private Long id;
@Indexed(unique=true) private String uid;
I get the following exception when I use the method like so:
typeRepository.deleteByUid(uid);
//The Exception
string literal or parameter expected|"START
n=node:node_auto_index(uid=uidValueYAA)MATCH n-[r]-()DELETE n, r"|
How can I use the method to delete a specific node based on the uid that I
pass to the method?

DICOM Render not showing all slices (with possible fix)

DICOM Render not showing all slices (with possible fix)

I had 88 DICOM image importing into a 2D Render, but only 8 where showing.
Using Chrome's developer tools I was able to see that all data (88 slices)
were loaded. However, the V.MRI.pixdim was incorrect (reporting a slice
thickness of 9+ where it was 1.5). Tracked the area to parserDC.js line
95. My locations were coming in as text, and when sorted as text were
sorting wrong. The below code seems to have solve my problem on a limited
test basis:
MRI.location.sort(function{a,b} {return a-b; })
Ben

How to see the updated output of index?

How to see the updated output of index?

On creating a index on table, in Sql server how can you see the output of
updated index ?
Query to create an index on the table called [dbo].[Sheet1$] in SQL Server.
create index ix_project_id_PK
on [dbo].[Sheet1$] ( [Project_Key] DESC)

May someone explain this html/css code to me?

May someone explain this html/css code to me?

How come when this code is run, it creates a drop-down list like it does?
HTML
<ul id="menu">
<li><a href="">Home</a></li>
<li><a href="">About Us</a>
<ul>
<li><a href="">The Team</a></li>
<li><a href="">History</a></li>
<li><a href="">Vision</a></li>
</ul>
</li>
<li><a href="">Products</a>
<ul>
<li><a href="">Cozy Couch</a></li>
<li><a href="">Great Table</a></li>
<li><a href="">Small Chair</a></li>
<li><a href="">Shiny Shelf</a></li>
<li><a href="">Invisible Nothing</a></li>
</ul>
</li>
<li><a href="">Contact</a>
<ul>
<li><a href="">Online</a></li>
<li><a href="">Right Here</a></li>
<li><a href="">Somewhere Else</a></li>
</ul>
</li>
</ul>
CSS
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover {
background: #617F8A;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a {
background: #617F8A;
}
li:hover li a:hover {
background: #95A9B1;
}
I know all the CSS properties and the HTML tags used in the above code,
but still, for somee reason, I've been trying for the past hour and still
not been able to completely comprehend it. Source: How to make a pure css
based dropdown menu?

Why the text fields are not getting disabled="disabled" in colorbox popup?

Why the text fields are not getting disabled="disabled" in colorbox popup?

I'm using PHP, Smarty , jQuery, Colorbox - a jQuery lightbox plugin, etc.
for my website. Now I'm displaying some output in a popup which is
generated by using " Colorbox - a jQuery lightbox plugin". Now I want to
disable all the text fields present in this popup when the form loads but
if I go to the HTML source of page the disabled="disabled" attribute from
the <input> tag gets removed and the text boxes are not getting disabled.
Can you tell me why this is happening? For your reference I'm putting
below the code which will display the data in a Colorbox pop up.
{if $subject_topic_questions}
{foreach from=$subject_topic_questions item=subject_topic_data}
<div class="hidden">
<div id="topics_{$subject_topic_data.subject_id}"
class="c-popup">
<h2 class="c-popup-header">Select Topics</h2>
<div class="c-content">
<input type="hidden"
name="subject_names[{$subject_topic_data.subject_id}]"
id="subject_names"
value="{$subject_topic_data.subject_name}">
<h2 class=""> {$subject_topic_data.subject_name}</h2>
<div class="c-tbl-wrap">
<table width="100%" cellspacing="0"
cellpadding="0" border="0" class="c-tbl">
<tbody>
<tr>
<td>
<p class="custom-form">
<input class="custom-check"
type="checkbox" name="" id="">
<label class="blue">Select All</label>
</p>
</td>
{foreach from=$difficulty_levels item=diff_levels
key=dkey}
<input type="hidden"
name="diff_levels[{$dkey}]"
value="{$diff_levels}">
<td width="22%"
align="center"><strong>{$diff_levels}</strong></td>
{/foreach}
</tr>
{foreach from=$subject_topic_data.topics
item=topic_diff_level_data}
<input type="hidden"
name="subject_{$subject_topic_data.subject_id}_topics[]"
value="{$topic_diff_level_data.topic_id}">
<tr>
<td valign="middle">
<p class="custom-form">
<input type="checkbox"
class="custom-check"
name="{$sheet_type}_topics_{$subject_topic_data.subject_id}[]"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}"
value="{$topic_diff_level_data.topic_id}"
onChange="enable_topic_ques('{$sheet_type}',
'{$subject_topic_data.subject_id}',
'{$topic_diff_level_data.topic_id}');
return false;">
<label>{$topic_diff_level_data.topic_name}</label>
<!-- <input type="hidden"
name="topic_names[{$topic_diff_level_data.topic_id}]"
value="{$topic_diff_level_data.topic_name}">
-->
</p>
</td>
{foreach
from=$topic_diff_level_data.difficulty_level
item=diff_level key=key_diff_lvl}
<td valign="middle">
{if $site_id=='ENTPRM'}<em>Total
{$diff_level.question_count}</em>{/if}
<input type="text"
name="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
maxlength="3" class="mini"
value="{$diff_level.added_no_questions}"
disabled="disabled">
<input type="hidden"
name="{$sheet_type}_available_questions_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
value="{$diff_level.question_count}">
</td>
{/foreach}
</tr>
{/foreach}
</tbody>
</table>
</div>
<p class="center"><a href="#" class="c-btn
fnClosePopup">Done</a> <a href="#"class="c-btn
c-gray-btn fnClosePopup">Cancel</a></p>
</div>
</div>
</div>
{/foreach}
{/if}
The main code you need to consider is as below from the above code:
<input type="text"
name="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
maxlength="3" class="mini" value="{$diff_level.added_no_questions}"
disabled="disabled">
Can you tell me how the disabled="disabled" attribute gets vanishes after
page load and if there is any way to apply to it, please tell me. Thanks
in advance.

Wednesday, 18 September 2013

Display Image In dynamically ImageViews From Gallery

Display Image In dynamically ImageViews From Gallery

Once See My Problem,Actually I want Show ImageView as below atteched image
like that ,after by clicking button to add imagview dynamically,clicking
image display image from gallary,
![enter image description here][1] Thanks,
Sorry For My poor English...

allocating an object of abstract class type

allocating an object of abstract class type

im trying to incorporate a CCTable view in my cocos2d-x app. i have
followed the source code from the testcpp and i am still getting this
error and in not 100% sure why
"allocating an object of abstract class type 'GameList'"
here is my source code
GameList.h
#ifndef __Squares__GameList__
#define __Squares__GameList__
#include "cocos2d.h"
#include "cocos-ext.h"
#include "GameListScene.h"
#include "GameManager.h"
using namespace cocos2d;
class GameList : public CCLayer, public extension::CCTableViewDataSource,
public extension::CCTableViewDelegate
{
public:
virtual bool init();
CREATE_FUNC(GameList);
~GameList(void);
CCLabelTTF* titleLabel;
CCLabelTTF* loginLabel;
CCLabelTTF* passwordLabel;
virtual void tableCellTouched(extension::CCTableView* table,
extension::CCTableViewCell* cell);
virtual CCSize tableCellSizeForIndex(extension::CCTableView *table,
unsigned int idx);
virtual unsigned int numberOfCellsInTableView(extension::CCTableView
*table);
};

Fortran: Integer too big for its kind

Fortran: Integer too big for its kind

I am setting an integer to a value less than its maximum, but receiving an
error that it is too big for it's kind. Why is this? Here is a sample
program.
program max_int
integer, parameter :: i32 = selected_int_kind(32)
integer(kind = i32) :: my_int
!The largest integer of this kind
print*, huge(my_int)
!This works
my_int = 100000
!This doesn't, and gives an error.
!my_int = 1000000000000
print*, my_int
end program

What is a more general way of creating an arraylist in C# like the one in the example?

What is a more general way of creating an arraylist in C# like the one in
the example?

Objective: Achieve a more general way of creating an arraylist.
Issue: I have to create multiple arraylists, each matched to a unique
structure for the purpose of comparing and updating a table in Sql
database. In the spirit of DRY I am trying to find a better way of
creating each array. The code I am using is as follows
Sample Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
public static void Users()
{
String sql = "";
try
{
conn.Open();
sql = "SELECT" +
"database.dbo.table1.username," +
"database.dbo.table1.status" +
"FROM" +
"database.dbo.table1";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
//structure below
User structure_A = new User();
structure_A.username = dr.GetValue(0).ToString();
structure_A.status = dr.GetValue(1).ToString();
//added to arraylist
arraylist_A.Add(structure_A);
}
dr.Close();
conn.Close();
}
Note: More information can be provided as requested. Thank you in advance
for any insight

Trying to iterate in a item cause: "Uncaught TypeError: Cannot read property 'length' of undefined"

Trying to iterate in a item cause: "Uncaught TypeError: Cannot read
property 'length' of undefined"

I'm trying to iterate through a element using this code:
$.each(element, function(index, item) {
...
});
I check element type by executing this command $.type(element) in Chrome
console and I got "object" as output. I check also what has element inside
using this command element and got this as output:
[<input type=&#8203;"text" name=&#8203;"input_color_5[]&#8203;"
class=&#8203;"field_color" data-selector=&#8203;"color"
data-id=&#8203;"color_5" placeholder=&#8203;"Color">&#8203;]
Also I tried all this command from console:
element.val() -> return ""
element.attr('data-selector') -> return "color"
element.attr('data-id') -> return "color_5"
If I use instead this other code:
element.each(function(index, item) {
...
});
Then the error turn on:
Uncaught TypeError: Cannot call method 'each' of undefined
This is how I construct element object:
function getDivId() {
var inputValues = [];
inputValues.push($('#choices_picker input[type="text"]'));
return inputValues;
}
And I call later in this way:
$('#choices_picker').on("click", "#create-variation", function(e) {
var parent_id = $(this).closest("section").attr("id");
var element = getDivId(parent_id);
$('#variations_holder').show();
$('#variations_holder').html("");
html = "";
iterateChoices("", element[0], element.slice(1), 0);
$('#variations_holder').append(html);
});
And finally this is the function iterateChoices():
function iterateChoices(row, element, choices, counter) {
if ($.isArray(choices)) {
$.each(element, function(index, item) {
if (counter === 0) {
row = '<label>UPC:</label> <input style="display:
inline-block" type="text" value="" name="pupc[]" />';
row += '<label>Precio:</label> <input style="display:
inline-block" type="text" value="" name="pprice[]" />';
row += '<label>Cantidad:</label><input type="text"
style="display: inline-block" value="" name="pqty[]" />';
}
if (choices.length > 0) {
iterateChoices(row + '<input disabled="disabled" value="'
+ item.value + '"></div>', choices[0], choices.slice(1),
counter + 1);
}
});
} else {
html_temp = "";
element.each(function(index, item) {
html_temp += row + '<input value="' + item.value + '"
disabled="disabled"><br>';
});
html += html_temp;
}
}
Then I ask myself, isn't element a object since I got the error? What is
wrong or what I'm doing wrong?

How can I skip path resolution when creating a new VS project?

How can I skip path resolution when creating a new VS project?

I've created a custom MVC VS project template for my company. Within the
csproj file, I reference the "_references.js" file of a different project
a couple of levels higher than my current project. The way I have added
this file in the template is as follows:
<ItemGroup>
<Content Include="..\..\MyCompany\Scripts\_references.js">
<Link>Scripts\_references.js</Link>
</Content>
...
</ItemGroup>
However, this ends up rendering like this when the project is created:
<ItemGroup>
<Content
Include="..\..\..\..\..\..\..\Users\MyUser\AppData\Local\Temp\MyCompany\Scripts\_references.js">
<Link>Scripts\_references.js</Link>
</Content>
...
</ItemGroup>
It looks like the process of creating the project is resolving the path in
relation to the location of where the template is being used to build the
project.
Is there someway to force my path? I'd like this path to remain constant
when the project is rendered.
Thanks!

Chef: why can't I subscribe to a directory :create action?

Chef: why can't I subscribe to a directory :create action?

I have created the following recipe block which should run at the point
that the /etc/httpd/ssl directory is created:
ruby_block "Copy SSL certificates" do
block do
certificate_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_filename']}"
key_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_key_filename']}"
chain_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_chain_filename']}"
if File.exists?(certificate_file) && File.exists?(key_file)
FileUtils.cp(certificate_file, "#{node['apache']['dir']}/ssl")
FileUtils.cp(key_file, "#{node['apache']['dir']}/ssl")
end
if File.exists?(chain_file)
FileUtils.cp(chain_file, "#{node['apache']['dir']}/ssl")
end
end
action :nothing
subscribes :create, resources(:directory => "/etc/httpd/ssl")
end
(This is directly modelled off an opscode example - under "Stash a file in
a data bag")
In the Chef output, I can see my recipe file being loaded:
[2013-09-18T13:19:45+00:00] DEBUG: Loading Recipe
chef-magento::copy_ssl_certificates via include_recipe
and, lower down, I can see the directory being created:
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/ssl]
action create (apache2::default line 138)
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] created
directory /etc/httpd/ssl
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] owner changed
to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] group changed
to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] mode changed
to 755
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/conf.d]
action create (apache2::default line 145)
but at no point does it run my code.
What am I doing wrong?

Revision Control - Ruby on Rails

Revision Control - Ruby on Rails

I have this application i'm working on and it works just fine. I am using
paperclip for image upload. User's can upload logos after which an admin
can accept them or ask them for changes after which they will upload an
updated version after they make ammends.
Right now, when you edit with paperclip (upload a new image) it deletes
the old one. I want like to keep a revision of how the logos have changed
over time. The old images should be accessible in some kind of history.
Are there any tutorials on how to do this, or how can I go about
implementing this functionality?
Any help will be very much appreciated. Thanks!!!!!

Tuesday, 17 September 2013

How to Java Regex to match everything but specified pattern

How to Java Regex to match everything but specified pattern

I am trying to match everything but garbage values in the entire
string.The pattern I am trying to use is:
^.*(?!\w|\s|-|\.|[@:,]).*$
I have been testing the pattern on regexPlanet and this seems to be
matching the entire string.The input string I was using was:
Vamsi///#k03@g!!!l.com 123**5
How can I get it to only match everything but the pattern,I would like to
replace any string that matches with an empty space or a special charecter
of my choice.

Saving images from website to folder using curl php

Saving images from website to folder using curl php

I am able to save images from a website using curl like so:
//$fullpath = "/images/".basename($img);
$fullpath = basename($img);
$ch = curl_init($img);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$rawData = curl_exec($ch);
curl_close($ch);
if(file_exists($fullpath)) {
unlink($fullpath);
}
$fp = fopen($fullpath, 'w+');
fwrite($fp, $rawData);
fclose($fp);
However, this will only save the image on the same folder in which I have
the php file that executes the save function is in. I'd like to save the
images to a specific folder. I've tried using $fullpath =
"/images/".basename($img); (the commented out first line of my function)
but this results to an error:
failed to open stream: No such file or directory
So my question is, how can I save the file on a specific folder in my
project? Another question I have is, how can I change the filename of the
image I save on the my folder? For example, I'd like to add the prefix
siteimg_ to the image's filename. How do I implement this?

How can I disable input field spaces with MooTools?

How can I disable input field spaces with MooTools?

I can't find this anywhere, we need to disable the space bar (spaces) in a
input field of our form using MooTools 1.2
I have a solution for jQuery which doesn't work, however we have our site
based completely on our framework of choice.
Thank you for your help!!
<form action="signup.php" method="POST">
<input id='username' name='signup_username' type='text'
class='home_signin_field' maxlength='50' size='22'
onclick="this.value='';" onfocus="this.value='';"
onblur="this.value=!this.value?'Your Name':this.value;" value="Your Name">
</form>

Detect mouseover on element bottom margin

Detect mouseover on element bottom margin

Is it possible with plain JavaScript or jQuery to detect a mouseover on an
element bottom margin, ie when the mouse is over the element margin but
not on the element contain itself?
It seems it's possible because the Medium editor can display a link (a
"plus" sign) when the mouse is over the bottom margin of paragraph
elements, but not when the mouse is over the paragraph text. I have no
idea how they achieve that. Here is how it works in Medium:
http://d.pr/i/njS+

Google Map Heading Marker or Indicator

Google Map Heading Marker or Indicator

The "Google Maps" app in Jellybean has an indicator which adjusts based on
the way you're facing. I am interested in implementing a similar indicator
but for multiple indicators.
Does anyone have an idea on how they implemented their heading indicator
(note it maintains its heading even when the map is rotated). I attempted
my own approach using markers, then I realized that markers will not
rotate with the map (kind of an oh duh moment after a few hours of
labor...)
So as of right now I see two solutions:
Capture map rotation and transfer it to the marker
Draw over the map using OpenGL
Could anyone offer any advice before I start down another rabbit hole?
Thanks!

Sunday, 15 September 2013

How do I install gimp on Android

How do I install gimp on Android

I am trying to install GIMP on android.
because I am trying to do some good art on my android tablet. I have
autodesk Sketch Book and I am Really good doing art on that. I was also
trying gfxtablet and gimp on linux.
Much THANKS.

jsfiddle same codes display different results on html

jsfiddle same codes display different results on html

I put http://jsfiddle.net/48Hpa/19/ same codes to HTML, but I get
different results
....................................................................................................................................................................
why is that?

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<link type="text/css" rel="stylesheet" href="style.css" />
<link type="text/css" rel="stylesheet"
href="http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css"
/>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$(function () {
$("#slider1").slider({
range: "min",
value: 36,
min: 12,
max: 36,
slide: function (event, ui) {
$(".amount1").val(ui.value);
writesum();
}
});
$(".amount1").val($("#slider1").slider("value"));
});
$(function () {
$("#slider2").slider({
range: "min",
value: 50000,
min: 1,
max: 50000,
slide: function (event, ui) {
$(".amount2").val(ui.value);
writesum();
}
});
$(".amount2").val($("#slider2").slider("value"));
});
function writesum() {
var months = $('.amount1').val();
var credits = $('.amount2').val();
var payment = parseFloat(Number(credits) / Number(months))
var rounded = payment.toFixed(2);
$('.amount3').val(rounded);
}
});
</script>
</head>
<body>
<input type="text" class="amount1" />
<div class="container">
<div id="slider1"></div>
</div>
<input type="text" class="amount2" />
<div class="container">
<div id="slider2"></div>
</div>
<div class="sonuccontainer">
<div class="bilgilendirme">aylýk ödeme miktarýnýz</div>
<input type="text" class="amount3" />
</div>
</body>
</html>

How to generate a labelled dendogram using agnes?

How to generate a labelled dendogram using agnes?

Using the code from :
http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Hierarchical_Clustering
Here is how to generate a dendogram :
# import data
x <- read.table("data.txt")
# run AGNES
ag <- agnes (x, false, metric="euclidean", false, method ="single")
# print components of ag
print(ag)
# plot clusters
plot(ag, ask = FALSE, which.plots = NULL)
I'm receiving an error on
ag <- agnes (x, false, metric="euclidean", false, method ="single")
The error is :
Error in agnes(x, false, metric = "euclidean", false, method = "single") :
object 'false' not found
This implementation of agnes works but its generating numbered labels for
the dendogram :
ag <- agnes (data, metric="euclidean")
# plot clusters
plot(ag, ask = FALSE, which.plots = NULL)
The dendogram :

The dendogram generated from
http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Hierarchical_Clustering
includes labels :
Here is the data file :
,ba,fi,mi,vo,rm,to
ba,0,662,877,255,412,996
fi,662,0,295,468,268,400
mi,877,295,0,754,564,138
vo,255,468,754,0,219,869
rm,412,268,564,219,0,669
to,996,400,138,869,669,0
How can generate a labelled hierarchical cluster based on above data which
is same as labelled dendogram above ?

Parse error: syntax error, unexpected T_VARIABLE in bindValue

Parse error: syntax error, unexpected T_VARIABLE in bindValue

if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = $_POST['content'];
if (empty($title) or empty($content)) {
$error = 'All fields are required!';
} else {
$query = $pdo->prepare("INSERT INTO articles (atricle_title,
atricle_text, atricle_timestamp) VALUES (?, ?, ?)")
$query->bindValue(1, $title); //error is here
$query->bindValue(2, $content);
$query->bindValue(3, time());
$query->execute();
header(Location: index.php);
}
Someone knows what's the problem here?. The code itself is more then that,
but this is to only relevent part.
Thanks.

Struggling with simple node.js code

Struggling with simple node.js code

I really can't figure out what I've done wrong. I've spent about half an
hour looking at this code and re-reading code that essentially does the
same thing and works. The 'data' event and corresponding callback is never
triggered.
var http = require("http");
http.createServer(function(request, response){
response.writeHead(200);
console.log('Executing');
request.on('data', function(chunk){
console.log('data being read');
console.log(chunk.toString());
});
request.on('end', function(){
console.log('done');
response.end();
});
}).listen(8080);
Please help

Parents Selector in CSS?

Parents Selector in CSS?

For example HTML :
<div id="css">
<a href="/forum"></a>
</div>
How can I choose the parent selector of a href ? I have tried :
#css! > a[href*="/forum"]
But not successful . Thanks for your helping

PHP: Sessions never expire

PHP: Sessions never expire

Last night I logged in and the following morning I was still logged in,
even if I quit my browser. I want the session to expire after a few hours
and I thought that it would work with "session.gc_maxlifetime" set to
"1440" and "session.cache_expire" set to "180"
Here is what I could find from PHP.ini
Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx
session.auto_start Off
session.bug_compat_42 Off
session.bug_compat_warn Off
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_httponly Off
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_divisor 1000
session.gc_maxlifetime 1440
session.gc_probability 0
session.hash_bits_per_character 5
session.hash_function 0
session.name PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path /var/lib/php5
session.serialize_handler php
session.use_cookies On
session.use_only_cookies On
session.use_trans_sid 0
On our old server we used the same settings and the sessions worked. The
only difference from the old one is the "session.save_handler" that is set
to "memcache" on the old server. Also "session.save_path" is different.

Saturday, 14 September 2013

Disable direct access to certain files (include)

Disable direct access to certain files (include)

I'm triyng to blobk access to certain files. I have on my server many
files like this
filename_sql.php
Basically i need to disallow user to access directly to sql.php files:
http://url.com/filename_sql.php <<<
I have created an htaccess with this code, but i can access files direcly
calling url. What do I wrong?
<Files ~ "\.sql(.php)?$">
Order allow,deny
Deny from all
</Files>
Thanks all.

Django Template - iterating through nested dictionary - too many examples

Django Template - iterating through nested dictionary - too many examples

I have a call to an external data source that successfully returns a
dictionary in this format. There can be any number of entries:
{
'0090000': {'status': 'some status', 'modified_date':
'2013-08-09T14:23:32Z', 'modified_by': 'John Doe', 'severity': '3
(Normal)', 'created_by': 'Dan Smith', 'summary': "some status",
'created_date': '2013-07-18T21:10:36Z'},
'0060000': {'status': 'some status', 'modified_date':
'2013-06-24T03:19:01Z', 'modified_by': 'Jay Johnson', 'severity': '4
(Low)', 'created_by': 'Tony Thompson', 'summary': "some other status",
'created_date': '2012-05-03T17:45:19Z'}...
}
I'm pulling this data end using some information gathered in a form. I've
read a ton of docs and examples of how to iterate through this and present
the data in a template but I can't quite make it work.
My view is as follows:
def agenda_detail(request, agenda_id):
#get the meeting data
a_data = get_object_or_404(meetingEvent, pk=agenda_id)
#get the DEE data for the VAT fieldset
account_id = a_data.account_number.pk
#get the stored session user/pass
username = request.session['username']
password = request.session['password']
dee_data = onsiteEngineer.objects.filter(account=account_id)
#now we get the case data from the Portal API
portal_raw = CustomerInformation()
customer_data = portal_raw.getOpenCaseInfo(account_id,username,password)
return render_to_response('agendas/detail.html',{'a_data':a_data,
'dee_data': dee_data, 'customer_data': customer_data.iteritems()},
context_instance=RequestContext(request))
My template code dealing with this is (I don't care about the html
formatting right now, i just want to see the data on the screen:
{% for key, value in customer_data.items %}
<p>{{ key }}</p>
{% for info in value %}
{{ value }}
{% endfor %}
{% endfor %}
It's showing no data. I've tried multiple combinations (using .items,
using iteritems, etc.) but I can't quite get it to work.
All advice appreciated.

Android kill service from a service and prevent it to reopen

Android kill service from a service and prevent it to reopen

Im developing an application and I need to block some apps from one service.
¿How can I kill those applications services and prevent them to restart
when my service is running?
Thank you very much :)

selectbox display the same div

selectbox display the same div

I want selecbox to show div.
no matter what I choose in the selectbox I want to display the same div
I took this code:
$('#Field16').bind('change',function(){
$('.box').hide();
$('#'+$(this).val()).show();
});
What do I need to change?
Thanks

javascript to achive the same result as css ellipsis

javascript to achive the same result as css ellipsis

due to some reason I cant use the css method
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
width: 100px;
the above make my user define text in a li if reached 100px, it will add
'...', can it be achieve using jquery?

GIT internal server error

GIT internal server error

I keep getting this error from the git server of my project at
http://code.google.com/p/mdpm
remote: Error: internal server error
error: RPC failed; result=18, HTTP code = 200
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
What is it? I can't push anything

How to set charset of gradle

How to set charset of gradle

I use gradle for my android application.But when I build it,I got some
error like"error:need';'".And I aslo get some strange words where I use
unEnglish words.So I guess the reason of it maybe the charset.So how could
I set charset=utf-8 of gradle?

Friday, 13 September 2013

How to elegantly return an object that is default-initialized?

How to elegantly return an object that is default-initialized?

I have a class like below:
class VeryVeryVeryLongTypeName
{
bool is_ok;
VeryVeryVeryLongTypeName() : is_ok(false) {}
};
VeryVeryVeryLongTypeName f()
{
VeryVeryVeryLongTypeName v;
... // Doing something
if (condition_1 is true)
{
return v;
}
else
{
return VeryVeryVeryLongTypeName();
}
... // Doing something
if (condition_2 is true)
{
return v;
}
else
{
return VeryVeryVeryLongTypeName();
}
}
I think the statement return VeryVeryVeryLongTypeName(); is very tedious
and ugly, so, my question is:
How to elegantly return an object that is default-initialized?
or in other words:
Is it a good idea to add a feature into the C++ standard to make the
following statement is legal?
return default; // instead of return VeryVeryVeryLongTypeName();

Raname an item on listview

Raname an item on listview

I have a listview and a rename button, if I want to rename an item on the
listview I just click the rename button and it would look like this
I would be able to type the new name. I know that I can just double click
the item and then rename it, but I want to use a button.
How can I also create an event after it renamed the item? if it renamed
the file successfully, e.g.
if (*renamed was successful*) then ShowMessage('You successfully renamed
this item !');

Landscape mode UI in storyboard

Landscape mode UI in storyboard

For my iPad application, I am using storyboard and want my UI to adjust
both in portrait and landscape modes properly. My UI go for a toss in
landscape mode. Is there any way we can fix this from storyboard?
I want to keep both Portrait and Landscape modes.

If statement seems to be skipping to else

If statement seems to be skipping to else

I'm trying to write a program that decides whether a circle is
inside/touching a rectangle. The user puts in the center point for the
circle and the radius, and two diagonal points for the rectangle.
I'm not sure how to include all points of the circumference of the circle,
to tell that there is at least one point in/touching the rectangle. Anyone
sure how to do this?
When I run my current program, I'll purposely enter points of a circle
being inside of a rectangle, and should work with the if statements I put,
but it prints out the wrong answer.
import java.util.Scanner;
public class lab4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double cx, cy, x, y, r, p1x, p1y, p2x, p2y, max;//input
String a;
System.out.print("Enter cx: ");
cx = in.nextDouble();
System.out.print("Enter cy: ");
cy = in.nextDouble();
System.out.print("Enter r: ");
r = in.nextDouble();
System.out.println("Enter x value of point 1:");
p1x = in.nextDouble();
System.out.println("Enter y value of point 1:");
p1y = in.nextDouble();
System.out.println("Enter x value of point 2:");
p2x = in.nextDouble();
System.out.println("Enter y value of point 2:");
p2y = in.nextDouble();
max = p2x;
if (p1x > max)
max = p1x;
max = p2y;
if (p1y > max)
max = p1y;
if (cx >= p1x && cx <= p2x)
a = "Circle is inside of Rectangle";
if (cx >= p1x && cx <= p2x)
a = "Circle is inside of Rectangle";
if (cx+r >= p1x && cx+r <= p2x)
a = "Circle is inside of Rectangle";
if (cx-r >= p1x && cx-r <= p2x)
a = "Circle is inside of Rectangle";
if (cy >= p1y && cy <= p2y)
a = "Circle is inside of Rectangle";
if (cy >= p1y && cy <= p2y)
a = "Circle is inside of Rectangle";
if (cy+r >= p1y && cy+r <= p2y)
a = "Circle is inside of Rectangle";
if (cy-r >= p1y && cy-r <= p2y)
a = "Circle is inside of Rectangle";
else
a = "Circle is outside of Rectangle";
System.out.println(a);

Display UTC time incorrect after 12am

Display UTC time incorrect after 12am

I'm using a simple javascript to display the local time in my country on a
website, but it seems to be broken. After 12 midnight, by right the clock
should reset to AM instead, but it keeps showing the time in PM (eg. 1 PM
instead of 1 AM)
JS:
function updateClock (){
var currentTime = new Date();
var currentHours = currentTime.getUTCHours() + 8;
var currentMinutes = currentTime.getUTCMinutes();
var currentSeconds = currentTime.getUTCSeconds();
// var bucurestiOffset = 3*60000;
// var userOffset = currentTime.getTimezoneOffset()*60000;
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
var currentTimeString = currentHours + ":" + currentMinutes + ":" +
currentSeconds + " " + timeOfDay;
document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
Don't know how to go about fixing this.

Getting Partial response from server using php

Getting Partial response from server using php

I am running a page with an Oracle query that will take more than one
minute to execute.I am opening this page with the java script function
window.open.During the query execution time the page is showing blank
white page. Is there any method to show some status message instead of
blank page.I used ob_flush and some other buffering function, but it is
not working..

Thursday, 12 September 2013

How to run jsp pages in eclipse using tomcat server?

How to run jsp pages in eclipse using tomcat server?

![I want to run java program in a web browser. I installed tomcat and
eclipse. but i am getting an error "Starting tomcatv7.0 server at local
host". How to solve this error? Please help me. I have attached the error
page1

How to solve optimistic concurrency update case in JPA

How to solve optimistic concurrency update case in JPA

Is there any way to know when optimistic concurrency problem occurs in JPA
and how to solve it?
Problem description: In my project, when I want to update data in DB but
other user was using it. At that kind of situation, I want to get
DB_STATUS or exception which means "Other user was using..". So that I
want to skip updating DB.

C++ Build an array of data by repeating a vector many times

C++ Build an array of data by repeating a vector many times

I have a sequence of numbers that I need to repeat many times and get the
repeated data as a pointer to the data along the size (actually element
count). I need that data to pass it on to an API.
What would be the most efficient way to allocate the memory, pass on the
repeated data and then free it again. I currently have the sequence that
needs to be repeated stored in a std::vector
A couple of thoughts I had were along the lines of:
// Setup code
unsigned int repeat = 30000;
std::vector<int> datavector(5, 0); // assume this would contain arbitrary
numbers that needed to be repeated
// Idea 1:
{
unsigned int byte_size_step = datavector.size() * sizeof(int);
unsigned int byte_full_size = byte_size_step * repeat;
int *ptr = malloc(byte_full_size);
for(unsigned int i=0; i<repeat; i++)
{
memcpy(ptr+(i*byte_size_step), datavector.data(), byte_size_step);
}
apiFunc(ptr); // apiFunc copies the data
free(ptr)
}
// Idea 2:
{
std::vector datarepeated(datavector.size()*repeat);
for(unsigned int i=0; i<repeat; i++)
{
datarepeated.insert(datarepeated.begin()+(i*size_step),
datavector.begin(), datavector.end());
}
apiFunc(datarepeated.data());
}
Though I felt that there would be a function or easy-to-go method laying
around to quickly repeat the sequence in memory. I'm probably missing
something. I personally don't know if something like this could benefit
from a multithreaded solution.
Any tips to do this (most) efficiently are welcome.

JQuery click only registers first click and not subsequent clicks

JQuery click only registers first click and not subsequent clicks

I have a button group of three buttons. The relevant haml code is:
.btn-group#refresh-buttons
%button.btn.btn-default#refresh-5-sec 5 sec
%button.btn.btn-default#refresh-30-sec 30 sec
%button.btn.btn-default#refresh-60-sec 60 sec
I'm trying to build an adjustable refresh-rate feature. The first click
registers and sets the refresh rate correctly (I inspected the event
object) but subsequent clicks on any button thereafter do not register,
they do not create an event object. My JS code is below:
$(document).ready(function() {
var intervalId = window.setInterval(function(){
$('.container').load('/dashboard/index .container');
}, 60000);
console.log(intervalId);
$("#refresh-buttons").on("click", "button", function(event) {
if(event.target.id === "refresh-5-sec") {
clearInterval(intervalId);
setInterval(function(){
$('.container').load('/dashboard/index .container');
}, 5000);
}
else if(event.target.id === "refresh-30-sec") {
clearInterval(intervalId);
setInterval(function(){
$('.container').load('/dashboard/index .container');
}, 10000);
}
else if(event.target.id === "refresh-60-sec") {
clearInterval(intervalId);
setInterval(function(){
$('.container').load('/dashboard/index .container');
}, 15000);
}
});
});
Thanks.

Inspect cookies using PERL

Inspect cookies using PERL

I've written a short PERL script that lists the current cookies for the
website, but somehow it reports the cookie's domain and expires empty.
What am I doing wrong or am I misunderstanding the mechanics behind
cookies?
The script is live here, but it may help if you visit my blog first so
there are actually some cookies set. Here is my source code:
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Cookie;
my $table;
my %cookies = CGI::Cookie->fetch;
if ( keys %cookies ) {
$table .= "<table border=\"3\" cellpadding=\"5\">";
$table .= "<caption>COOKIES</caption>";
$table .=
"<tr><th>Name</th><th>Domain</th><th>Path</th><th>Expires</th><th
align=\"left\">Value</th></tr
foreach my $cookie ( keys %cookies ) {
$table .= "<tr>";
$table .= "<td>$cookie</td>";
$table .= "<td>" . $cookies{ $cookie }->domain() . "</td>";
$table .= "<td>" . $cookies{ $cookie }->path . "</td>";
$table .= "<td>" . $cookies{ $cookie }->expires . "</td>";
$table .= "<td>" . $cookies{ $cookie }->value . "</td>";
$table .= "</tr>";
}
$table .= "</table>";
}
print "Content-Type: text/html\n\n";
print "<html>\n";
print "<head></head>\n";
print "<body>\n";
print "$table";
print "</body>\n";
print "</html>\n";
Regardless the various cookies on various websites where I install the
script, the output looks like this and Domain and Expires is always empty:
+-----------------------------------------------------------------------------------------+
| Name | Domain | Path | Expires | Value
|
|---------------+--------+------+---------+-----------------------------------------------|
| bb2_screener_ | | / | | 1379007156
2001:980:1b7f:1:a00:27ff:fea6:a2e7 |
+-----------------------------------------------------------------------------------------+

Wednesday, 11 September 2013

twitter bootstrap 3 tab view

twitter bootstrap 3 tab view

I want to have tab view using twitter bootstrap 3:
http://jsfiddle.net/K9LpL/2/
<ul class="nav nav-tabs">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#profile">Profile</a></li>
<li><a href="#messages">Messages</a></li>
</ul>
<div id='content' class="tab-content">
<div class="tab-pane active" id="home">
<ul>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
</ul>
</div>
<div class="tab-pane" id="profile">
<ul>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
</ul>
</div>
<div class="tab-pane" id="messages">
</div>
<div class="tab-pane" id="settings"></div>
</div>
This code does not work to me. Most of examples on net are not with 3rd
version. It would be great if anybody tell me what my problem is or even
if giving me a standard working example(with bootstrap 3).

How do I best duck-type this Go DisjointSets data structure?

How do I best duck-type this Go DisjointSets data structure?

I have a DisjointSets data structure (pulled from Cormen), implemented in
Go to work with int64.
type DisjointSets struct {
ranks map[int64]int64
p map[int64]int64
}
// New returns a new DisjointSets
func NewDisjointSets() *DisjointSets {
d := DisjointSets{map[int64]int64{}, map[int64]int64{}}
return &d
}
// MakeSet adds element x to the disjoint sets in its own set
func (d *DisjointSets) MakeSet(x int64) {
d.p[x] = x
d.ranks[x] = 0
}
// Link assigns x to y or vice versa, depending on the rank of each
func (d *DisjointSets) Link(x, y int64) {
if d.ranks[x] > d.ranks[y] {
d.p[y] = x
} else {
d.p[x] = y
if d.ranks[x] == d.ranks[y] {
d.ranks[y] += 1
}
}
}
// FindSet returns the set in which an element x sits
func (d *DisjointSets) FindSet(x int64) int64 {
if x != d.p[x] {
d.p[x] = d.FindSet(d.p[x])
}
return d.p[x]
}
// Union combines two elements x and y into one set.
func (d *DisjointSets) Union(x, y int64) {
d.Link(d.FindSet(x), d.FindSet(y))
}
I'd like to write as little incremental code as possible to use this
structure for float64, string, etc. How do I do this?
What I've tried so far
I've read everything I can about Interfaces, but I just don't seem to
understand how to apply it without having to write a complete
implementation for each type.