Saturday, 31 August 2013

Pyramid PostgreSQL basic example

Pyramid PostgreSQL basic example

I can't find any examples of PostgreSQL being used with Pyramid, I'd like
to see an example showing how to get a simple CRUD application running.

How to fix scrolling issues with liquid layout image 100% width and height?

How to fix scrolling issues with liquid layout image 100% width and height?

I am using a liquid layout on my site. The background is a an image (
slideshow ) and it works how I want. The photo stretches and resizes with
the size of the browser.
However, I just noticed that when I move my browser window as thin or
narrow as it goes, the image is still there but when I scroll to the right
the image cuts off into the background. But full size works fine.
basically I want it to be 100% width and height at all times and never
scroll horizontally or ever exposing the body.
Please let me know what else you need to know to help. Here is the html
and css. thanks
#revolver {
background-color:#ccc;
width:100%;
min-height:100%;
z-index:10001;
}
.revolver-slide {
width:100%;
min-height:100%;
background-position:center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.revolver-slide img {
width:100%;
min-height:100%;
}
.page-section {
width:100%;
height:100%;
margin:0px auto 0px auto;
}
html,body {
height:100%;
}
<div class="page-section clear">
<!-- 100% width -->
<div id="revolver">
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-6.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-2.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-8.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-11.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-7.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-4.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-9.jpg');"></div>
</div>
</div>

Dispatching GestureEvent (TouchEvent) to View in Viewpager

Dispatching GestureEvent (TouchEvent) to View in Viewpager

I have a ViewPager with a SectionPagerAdapter handling Fragments.
The Fragment has the following Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tvemptyview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/card_bg"
android:text="@string/no_trans"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="@+id/transactionlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:divider="@null"
android:dividerHeight="0dp" >
</ListView>
<RelativeLayout
android:id="@+id/rLayout1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@drawable/footer_shadow"
android:orientation="horizontal" >
<TextView
android:id="@+id/tvMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/btn_dateback"
android:text="test"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
I'm trying to catch a swipe gesture (left or right) on the TextView
tvMonth but I have absolutely no idea how to dispatch the Event from the
ViewPager down to the TextView itself. The Fragments just keep on
scrolling and thats it.
I can attach an OnTouchListener to the TextView and the recognition works
pretty fine but the tabs are changing anyway.
How can i solve this problem?

How do I write Ruby's each_cons in Clojure?

How do I write Ruby's each_cons in Clojure?

How can I rewrite this Ruby code in Clojure?
seq = [1, 2, 3, 4, 5].each_cons(2)
#=> lazy Enumerable of pairs
seq.to_a
=> [[1, 2], [2, 3], [3, 4], [4, 5]]
Clojure:
(??? 2 [1 2 3 4 5])
;=> lazy seq of [1 2] [2 3] [3 4] [4 5]

MySQL Precison Issues in DECIMAL NUMERIC data type

MySQL Precison Issues in DECIMAL NUMERIC data type

In writing a function for scientific application, I ran into issues. I
traced it back to MySQL's lack of precison.
Here is the page from the official documentation which claims that The
maximum number of digits for DECIMAL is 65 -
http://dev.mysql.com/doc/refman/5.6/en/fixed-point-types.html . It also
describes how the value will be rounded if it exceeds the specified
precison.
Here is reproducible code (a mysql stored function) to test it -
DELIMITER $$
DROP FUNCTION IF EXISTS test$$
CREATE FUNCTION test
(xx DECIMAL(30,25)
)
RETURNS DECIMAL(30,25)
DETERMINISTIC
BEGIN
DECLARE result DECIMAL(30,25);
SET result = 0.339946499848118887e-4;
RETURN(result);
END$$
DELIMITER ;
If you save the code above in a file called test.sql, you can run it by
executing the following in mysql prompt -
source test.sql;
select test(0);
It produces the output -
+-----------------------------+
| test(0) |
+-----------------------------+
| 0.0000339946499848118900000 |
+-----------------------------+
1 row in set (0.00 sec)
As you can see, the number is getting rounded at the 20th digit, and then
five zeroes are being added to it to get to the required/specified
precison. That is cheating.
Am I mistaken, or is the documentation wrong?

Timer not starting in vb.net

Timer not starting in vb.net

net program that uses excel as a datasource. I then fill a datagridview
with this datasource and make changes to the dataset via the datagridview.
I'm trying to find a way to refresh this dataset via a button that will
update the values after a change. My only problem is that I'm trying to
set up a timer in my refresh method but it never initializes/starts. I
can't figure out why, from what I've found online the way to start a timer
in vb.net is to set the timer variable to enabled = true. I've stepped
into my debugger and found that the timer never starts. Here is my code
below, if there is anyone who can figure out why this timer isn't starting
I would greatly appreciate your help!
Dim mytimer As New System.Timers.Timer
Sub refresh()
write2Size()
mytimer.timer = New System.Timers.Timer(20000)
'Starting Timer
mytimer.Enabled = True
Cursor.Current = Cursors.WaitCursor
AddHandler mytimer.Elapsed, AddressOf OnTimedEvent
'Setting the cursor back to normal here
Cursor.Current = Cursors.Default
mytimer.Enabled = False
objworkbook.Save()
objExcel.ActiveWorkbook.Save()
myDS.Clear()
retrieveUpdate()
End Sub
Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
Console.WriteLine(&quot;The Elapsed event was raised at {0}, e.SignalTime)
End Sub

Issue with creating XMLQuery for given XPATH

Issue with creating XMLQuery for given XPATH

I have a table having one columns as XMLTYPE being stored with
Object-Relational storage. Below is table ddl.
CREATE TABLE Orders ( Order_id number not null,
Order_status Varchar2(100),
Order_desc XMLType not null)
XMLTYPE Order_desc STORE AS OBJECT RELATIONAL
XMLSCHEMA "http://localhost/public/xsd/Orderstore.xsd"
ELEMENT "OrderVal"
);
I have successfully registered the schema to load XSD with XML DB. Below
is the XML being loaded into the XMLTYPE column.
<?xml version="1.0" encoding="utf-8"?>
<draftorders>
<OrderSumm>
<Ordercod>OrderBookings</Ordercod>
</OrderSumm>
<Orderattrs>
<Orderattr Ordername="Order Name">
<OrderVal>
<listvalue>Node1_Child1_OrderValue_1</value>
<Orderattrs>
<Orderattr Ordername="Node2_Child1">
<OrderVals>
<OrderVal>
<listvalue>Node2_Child1_OrderValue_1</value>
</OrderVal>
</OrderVals>
</Orderattr>
<Orderattr Ordername="Node2_Child2">
<OrderVals>
<OrderVal>
<listvalue>Node2_Child2_OrderValue_1</value>
</OrderVal>
</OrderVals>
</Orderattr>
</Orderattrs>
</OrderVal>
</OrderVals>
</Orderattrs>
</OrderVal>
</OrderVals>
</draftorders>
I have the query using "extract" to print the below output:
SELECT
extract(o.Order_desc,'/OrderVal[1]/Orderattrs/Orderattr[1]/OrderVals/OrderVal[1]/Orderattrs/Orderattr[0]/@Ordername').getStringVal()
"Node1",
extract(o.Order_desc,'/OrderVal[1]/Orderattrs/Orderattr[1]/OrderVals/OrderVal[1]/Orderattrs/Orderattr[0]/OrderVals/OrderVal[1]/listvalue/text()').getStringVal()
"Node1Child",
extract(o.Order_desc,'/OrderVal[1]/Orderattrs/Orderattr[1]/OrderVals/OrderVal[1]/Orderattrs/Orderattr[1]/@Ordername').getStringVal()
"Node2",
extract(c.Order_desc,'/OrderVal[1]/Orderattrs/Orderattr[1]/OrderVals/OrderVal[1]/Orderattrs/Orderattr[1]/OrderVals/OrderVal[1]/listvalue/text()').getStringVal()
"Node2Child"
FROM Orders o;
OUTPUT:-
Node2_Child1
Node2_Child1_OrderValue_1
Node2_Child2
Node2_Child2_OrderValue_1
I want to achieve the same output using XMLQuery, but I am unable to build
query to print the child node. Till now, I can only print the node value
using XMLQuery as given below:-
SELECT XMLQuery(
'/OrderVal[1]/Orderattrs/Orderattr[1]/OrderVals/OrderVal[1]/Orderattrs/Orderattr[0]/@Ordername'
PASSING o.Order_desc RETURNING CONTENT
)
FROM Orders o;
How can I achieve the same output from using "extract", with "XMLQuery" ?
Thanks.

Friday, 30 August 2013

How to solve these two Queries help please

How to solve these two Queries help please

I am new to SQL and I have a homework assignment. I did all questions
right but still unable to figure out this two queries so please help if
you can. I appreciate you in advance.
I have FOUR tables:
EMPLOYEE which conatin the attributes (Fname, Minit, Lname, Ssn, Bdate,
Address, Sex, Salary, Super_ssn, Dno)
Table DEPARTMENT have the columns ( Dname, Dnumber, Mgr_ssn, Mgr_start_date)
Table PROJECT have the columns ( Pname, Pnumber, Plocation, Dnum)
Table DEPENDENT (Essn, Dependent_name, Sex, Bdate, Relationship)
Q1. For the department that controls the most number of projects, list its
name? I came up with this query but still it just gives me each Department
how many Projects it control but can not get it to work as giving me just
the one that has the most :(
SELECT Dname, COUNT(distinct Pnumber) as NumberOfProjects
FROM Department, Project
WHERE Dnum = Dnumber
GROUP BY Dname;
Q2. Retrieve the names and Ssn of employee who have more dependents than
any other employees?
I came up with this but idk why it does not work. I keep on getting an error
SELECT Fname, Lname, Ssn
FROM Employee
WHERE max((SELECT COUNT(*)
FROM Dependent
WHERE Ssn = Essn));
BTW I am using MySql WorkBench 5.2 and The language is just SQL allowed to
be used

Thursday, 29 August 2013

How to get absolute coords for remote computer[teamviewer like program]

How to get absolute coords for remote computer[teamviewer like program]

http://i.imgur.com/XsXh4Cz.png I am creating a teamviewer like
application, everything except for the remote mouse position is complete.
I have done a bit of googling and did not turn up anything that would help
me to complete this so i've decided to ask here, how the heck would you do
this?

Best practice for appending all Backbone Collection elements to a view?

Best practice for appending all Backbone Collection elements to a view?

For example I have a gallery model that renders a view. That model also
creates a collection of slides. Each slide has it's own view and I would
like to append all these collection views ( the slides ) to the main
gallery view. I can think of a few ways to do this but I'm not sure which
is best. I'm new to backbone so any suggestions are much appreciated.
Thanks in advance!

how to read .IGES file in php

how to read .IGES file in php

I want to read .STL, .IGES files in php, these are basically 3D design
files. I want to get image & dimension from file when user uploads the
file.

How to retrieve column items from listview in code

How to retrieve column items from listview in code

I am new to wpf and am going for an MCTS exam. I have searched for 2 days
now on how to retrieve row column items in code. I have been able to
insert data into the listview by creating a structure and adding row items
via code.
Public Structure SimpleData
Public Property Txt1 As String
Get
Return mTxt1
End Get
Set(value As String)
mTxt1 = value
End Set
End Property
Private mTxt1 As String
Public Property Txt2 As String
Get
Return mTxt2
End Get
Set(value As String)
mTxt2 = value
End Set
End Property
Private mTxt2 As String
Public Property Txt3 As String
Get
Return mTxt3
End Get
Set(value As String)
mTxt3 = value
End Set
End Property
Private mTxt3 As String
End Structure
Public Structure MyData
Public Property Desc() As String
Get
Return m_Desc
End Get
Set(value As String)
m_Desc = Value
End Set
End Property
Private m_Desc As String
Public Property Progress() As Integer
Get
Return m_Progress
End Get
Set(value As Integer)
m_Progress = Value
End Set
End Property
Private m_Progress As Integer
Public Property ProgressText() As String
Get
Return m_ProgressText
End Get
Set(value As String)
m_ProgressText = Value
End Set
End Property
Private m_ProgressText As String
Public Property Pic() As String
Get
Return m_Pic
End Get
Set(value As String)
m_Pic = Value
End Set
End Property
Private m_Pic As String
End Structure
Private Sub Button2_Click(sender As System.Object, e As
System.Windows.RoutedEventArgs) Handles Button2.Click
Dim sd As New SimpleData
sd.Txt1 = "Today is"
sd.Txt2 = "a good day"
sd.Txt3 = "O YES!"
listView1.Items.Add(sd)
End Sub
I want to be able to retrieve row(0).Item(0).ToString, which is how to
retrieve it in win forms. Expecting a response. Thanks in advance

Wednesday, 28 August 2013

How do I give all list items a max-width without having all of them fill that width

How do I give all list items a max-width without having all of them fill
that width

http://cdpn.io/gsDHK
Link to Codepen ^
I have a problem with this list. I need to break the words at a certain
point on all of these, but I am unable to change the HTML within the list
items.
I set a max-width of 72px on each list item. But Now they are all 72px
wide. They should be auto width with a max width of 72px. The white space
on either side of each list item has to be even. As you can see on the
Learning Center link, there is more white space than on the others.

if elseif statement not working php

if elseif statement not working php

so i have these two stored procedures. the first one works properly, but
the second wont. it still executes the first one. i tried commenting out
the others except the second stored proc and it works fine. what am i
doing wrong here?
if($view='group'){
$sql = "CALL
sp_edit_biochem_group('$item_group_ID','$item_group_code','$item_group_desc','$item_group_qty','$uom','$location','$inv_by','$as_of_date')";
}
elseif ($view='breakdown'){
$sql = "CALL
sp_edit_biochem_breakdown('$status','$as_of_date','$serial_no','$item_breakdown_ID')";
}

CSS display-table + SPAN error

CSS display-table + SPAN error

I have this example: Fiddle link
A table using display: table, display: table-cell, display: table-row
I need add before <p> a <span> tag, but my table structure breaks.
Any idea? Thanks
Example:
<fieldset>
<span>
<p>
<label>First Name: </label>
<input type="text" />
</p>
</span>
<span>
<p>
<label>Second Name: </label>
<input type="text" />
</p>
</span>
<span>
<p>
<label>Country: </label>
<select>
<option>Choose</option>
</select>
</p>
</span>
<span>
<p>
<label>Age: </label>
<select>
<option>Choose</option>
</select>
</p>
</span>
</fieldset>

Tuesday, 27 August 2013

Ruby Page object Gem - Unable to pick a platform for the provided browser (RuntimeError)

Ruby Page object Gem - Unable to pick a platform for the provided browser
(RuntimeError)

I get this error on running my feature file.
Unable to pick a platform for the provided browser (RuntimeError)
Help required, please.
Here is the code;
class GooglePage include PageObject
def self.visitor visit("http://www.google.com") end
end
env.rb
require 'selenium-webdriver' require 'page-object' require 'rubygems'
require 'page-object/page_factory'
World (PageObject::PageFactory) @browser = Selenium::WebDriver.for :firefox
Step-Definitions
require_relative 'GooglePage'
Given(/^I am on the Google home page$/) do
visit(GooglePage) # visit('http://www.google.com')
on(GooglePage).visitor end

ios - View is pixelated when scaled down

ios - View is pixelated when scaled down

I have a UIView that is composed of two UIImageViews. They are concentric
circle shapes. When I scale this view down like this:
CABasicAnimation *resizeAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.scale"];
resizeAnimation.fromValue = [NSNumber numberWithDouble:1.0];
resizeAnimation.toValue = [NSNumber numberWithDouble:0.25];
resizeAnimation.fillMode = kCAFillModeForwards;
resizeAnimation.removedOnCompletion = NO;
The edges of the images get rough and pixelated when scaled down. Is there
anything I can do to prevent this or at least minimize it?

Create HTML elements with php

Create HTML elements with php

I have a image heavy wordpress site.
To help with loading I'm using lazy loading.
The lazyload plugin requires the img url in a 'data-original' attribute.
I'm changing the img element using the function to add the image url to
'data-original' and the placeholder to the 'src'
function add_lazyload($content) {
$dom = new DOMDocument();
@$dom->loadHTML($content);
foreach ($dom->getElementsByTagName('img') as $node) {
$oldsrc = $node->getAttribute('src');
$node->setAttribute("data-original", $oldsrc );
$newsrc =
''.get_template_directory_uri().'/library/images/nothing.gif';
$node->setAttribute("src", $newsrc);
//create img tag
$element = $dom->createElement("img");
$dom->appendChild($element);
}
$newHtml = $dom->saveHtml();
return $newHtml;
}
add_filter('the_content', 'add_lazyload');
The lazyloading is working but I wanted to add a non javascript fall back
Is it possible with the above function to create a new 'img' element using
the 'src' from the original 'img'
so the new 'img' element would look like this
<noscript><img src="img/example.jpg" width="640" heigh="480"></noscript>

Joomla 3.1.4 please help me

Joomla 3.1.4 please help me

I am experimenting with Joomla 3.1.4. Whenever I add a new module the
template does not show at all in the front-end. The site is blank. On
disabling the new module it starts showing properly again. Even a basic
hello world type of module does not seem to work and nor does a third
party extension I have tried. I can see them in the extension manager and
in the module manager and they have installed successfully. Frustrated
with all this I decided to install a new 3.1 template which too installed
successfully. However this template does not show anything in the
front-end either with my module enabled. It almost seems that there is
some sort of security restriction which is disabling the template from
rendering whenever any change is made to the basic installation. Can
someone please give pointers to resolving this odd behaviour.

xml to JTree with Xstream, Nodenames lost, Java

xml to JTree with Xstream, Nodenames lost, Java

I serialize a JTree with Xstream but all Nodenames in the xml-file are
lost. The Nodes are custom objects with a toString methode. In my programm
the Tree works fine. I tested the serialization and serialisation with
nodes of the type string, no problems.
How can i serialize a JTree object with custom object nodes to xml?
This is how my tree is build:
JTree tree = new JTree();
tree.setRootVisible(false);
tree.setExpandsSelectedPaths(true);
DefaultMutableTreeNode project = new DefaultMutableTreeNode(this);
DefaultTreeModel treeModel = new DefaultTreeModel(project, true);
DefaultMutableTreeNode task = new DefaultMutableTreeNode(new
C_Task("Task"));
DefaultMutableTreeNode entry = new DefaultMutableTreeNode(new
entry("entry1"));
project.add(task);
task.add(entry);
tree.setModel(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

Monday, 26 August 2013

iOS,getting magnetic field values in milli gauss

iOS,getting magnetic field values in milli gauss

I am using tesla meter sample code by apple to detect magnetic field in my
app,it is giving readings in micro tesla,its values are normally between
25-60 micro tesla,but i want readings in milli gauss,i want to convert
these values in milli gauss using expression 1 microtesla = 10 milli
gauss.but the problem is my values gets very high like 400-800 milli gauss
normally,But the other EMF DETECTORs(K-2 EMF DETECTOR)shows value vary low
in milli gauss i.e 1.5-10 milli gauss.Am i doing anything wrong.any help
would be appreciable.

Contstruct url to router another controller in module

Contstruct url to router another controller in module

I am new to ZF2. I have question for url('route-name', $urlParams,
$urlOptions); ?>
What should I construct $urlParams and $urlOptions when multiple
controller in module?
I rename Album module as Shop and it has two controllers: indexController
and VendorController. In the View>Shop>Vendor>index.phtml, I add:
<p><a href="<?php echo $this->url('shop', array('action'=>'add')); ?>">
Add new vendor</a></p>
aiming this link would links to localhost/shop/vendor/add. But the page
shows the link is: localhost/shop
while what i want is localhost/shop/vendor/add
My understanding is that I should set $urlOPtions field, could anyone give
me example? Thanks all Below is module.config.php:
'router' => array(
'routes' => array(
'shop' => array(
'type' => 'Literal',
'options' => array(
'route' => '/shop',
'defaults' => array(
'__NAMESPACE__' => 'Shop\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Shop\Controller\Index' => 'Shop\Controller\IndexController',
'Shop\Controller\Vendor'=> 'Shop\Controller\VendorController'
),
),

GNU Make removes downloaded zip files for no apparent reason

GNU Make removes downloaded zip files for no apparent reason

I have this makefile tha sthould download and build openssh (along with
other things):
ROOT_DIR=$(PWD)
DATA_DIR=$(ROOT_DIR)/data
SOURCES_DIR=$(ROOT_DIR)/sources
RESOURCES_DIR=$(ROOT_DIR)/resources
DRAFTS_DIR=$(ROOT_DIR)/drafts
$(SOURCES_DIR):
mkdir $(SOURCES_DIR)
$(RESOURCES_DIR):
mkdir $(RESOURCES_DIR)
$(DRAFTS_DIR):
mkdir $(DRAFTS_DIR)
openssh-tar-url="ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/OpenSSH/portable/openssh-6.2p2.tar.gz"
TAR_PROJECTS += openssh
openssh:
echo "Building $@"
openssh-clean: openssh-archive-clean
.SECONDEXPANSION :
$(TAR_PROJECTS) : $(SOURCES_DIR) $(SOURCES_DIR)/$$@-archive
$(DRAFTS_DIR)/%.tar.gz: $(DRAFTS_DIR)
echo "Pulling $*."
wget $($*-tar-url) -O $(DRAFTS_DIR)/$*.tar.gz
.SECONDEXPANSION :
$(SOURCES_DIR)/%-archive : | $(DRAFTS_DIR)/$$*.tar.gz
mkdir $@
cd $@ && tar xvzf $(DRAFTS_DIR)/$*.tar.gz
%-archive-clean:
rm -rf $(SOURCES_DIR)/$*-archive $(DRAFTS_DIR)/$*.tar.gz
When i run make openssh it runs correctly but at the end it removes the
archive it downloaded. This is very strange to me:
$ make openssh --just-print
echo "Pulling openssh."
wget
"ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/OpenSSH/portable/openssh-6.2p2.tar.gz"
-O
/home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
mkdir
/home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/sources/openssh-archive
cd
/home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/sources/openssh-archive
&& tar xvzf
/home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
echo "Building openssh"
rm
/home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz

How can I make this query better?

How can I make this query better?

I'm learning SQL through GALAXQL http://sol.gfxile.net/galaxql.html
Im on lesson 17 - GROUP BY/HAVING
Here is the scenario:
Let's look at couple of SELECT operations we haven't covered yet, namely
GROUP BY and HAVING.
The syntax for these operations looks like this:
SELECT columns FROM table GROUP BY column HAVING expression
The GROUP BY command in a SELECT causes several output rows to be combined
into a single row. This can be very useful if, for example, we wish to
generate new statistical data as a table.
For example, to find out the highest intensities from stars for each
class, we would do:
Select Class, Max(Intensity) As Brightness From Stars Group By Class Order
By Brightness Desc
The HAVING operator works pretty much the same way as WHERE, except that
it is applied after the grouping has been done. Thus, we could calculate
the sum of brightnesses per class, and crop out the classes where the sum
is higher than, say, 150.
SELECT class, SUM(intensity) AS brightness FROM stars GROUP BY class
HAVING brightness < 150 ORDER BY brightness DESC
We could refer to columns that are not selected in the HAVING clause, but
the results might be difficult to understand. You should be able to use
the aggregate functions in the HAVING clause (for example, brightness <
MAX(brightness)*0.5, but this seems to crash the current version of
SQLite.
When combined with joins, GROUP BY becomes rather handy. To find out the
number of planets per star, we can do:
SELECT stars.starid AS starid, COUNT(planets.planetid) AS planet_count
FROM planets, stars WHERE stars.starid=planets.starid GROUP BY
stars.starid
Hilight the star with most orbitals (combined planets and moons). (Note
that the validation query is somewhat heavy, so be patient after pressing
"Ok, I'm done..").



Here was my answer
SELECT stars.starid AS HighStar,
(COUNT(planets.planetid) + COUNT(moons.moonid)) AS OrbitalsTotal
FROM stars
LEFT OUTER JOIN planets
ON stars.starid = planets.starid
LEFT OUTER JOIN moons
ON planets.planetid = moons.planetid
GROUP BY stars.starid
ORDER BY OrbitalsTotal DESC;
This query showed me that the star with the most oribtals has 170 orbitals
So then:
INSERT INTO hilight SELECT result.HighStar
FROM result
INNER JOIN stars
ON result.HighStar = stars.starid
WHERE result.OrbitalsTotal = 170
My question to you is how can I make this query better? I don't want to
have to hard code the 170 orbitals and I dont want to have to create a
second query to insert the data.

SQL Server: Convert varchar to decimal (with considering exponential notation as well)

SQL Server: Convert varchar to decimal (with considering exponential
notation as well)

I need to convert data of a table and do some manipulation. one of the
columns datatype is Varchar, but it stores decimal numbers. I am
struggling in converting the varchar into decimal.
I have tried following CAST( @TempPercent1 AS DECIMAL(28, 16))
Problem is that data also has some values in exponential notation,
example: 1.61022e-016. The sql query is throwing error on encountering
such value. The error is Error converting data type varchar to numeric.
I need to know how to handle exponential notation values during varchar to
decimal conversion?

Update MKMapView when app is in background

Update MKMapView when app is in background

I have code in my iOS app that uses MKMapView to run certain code when the
user moves:
- (void)mapView:(MKMapView *)mapView
didUpdateUserLocation:
(MKUserLocation *)userLocation
{
// The code I want to run
}
I was wondering if it was possible to keep updating even if the app was in
the background, or if not, how to replicate this code in
CLLocationManager.

Better way to re-order Django form errors?

Better way to re-order Django form errors?

Is there a better, more "Django-istic", way to put Django form error
messages in a particular order than the technique shown below? I have a
form with ten fields in it. If the user doesn't fill out a required field
or if they enter invalid data, I iterate through the form's error fields
which I've put in a custom error list by displaying a red "x" and the
error message(s) at the top and a red "x" next to the invalid field(s)
below:
{# template.html #}
<form method="post" action=".">
{% csrf_token %}
{# Non-field errors removed for clarity #}
{# Iterate through error messages in custom ordered error list #}
{% for error_message in ordered_error_list %}
<img src='/static/img/red_x.png' alt='Error'></img>
&nbsp;{{ error_message }}<br>
{% endfor %}
<br>
{% for field in form.visible_fields %}
<div>
{{ field.label_tag }}<br />
{{ field }}
{% if field.errors %}
<img src='/static/img/red_x.png' alt='Error'></img>
{% endif %}
</div>
{% endfor %}
{# Hidden fields removed for clarity #}
<p><input type="submit" value="Continue" /></p>
</form>
Here's my view and helper function:
# views.py
def create_member_profile(request):
if request.method == "POST":
form = CreateMemberProfileForm(request.POST)
if form.is_valid():
# Process form data and redirect to next page...
return HttpResponseRedirect(reverse('review-member-profile'))
# Before I re-POST the form and display the errors, I'll put the
errors in order
else:
ordered_error_list = put_member_profile_errors_in_order(form)
else:
form = CreateMemberProfileForm()
return render_to_response(template, locals(),
context_instance=RequestContext(request))
def put_member_profile_errors_in_order(form):
errors_in_order = [] # List
for error in form['field_1'].errors:
errors_in_order.append(error)
for error in form['field_2'].errors:
errors_in_order.append(error)
for error in form['field_3'].errors:
errors_in_order.append(error)
# ...
for error in form['field_10'].errors:
errors_in_order.append(error)
return errors_in_order
The reason this all seems necessary is that form.errors is a dictionary
and Python dictionaries, by definition, are unordered. However, as I said,
I want any error messages at the top to be displayed in the same order as
the form fields they refer to. I couldn't find any form.errors attributes
that would allow me to re-order the form errors. I don't like the "for
error in form[]" blocks but they seem to be required if I want to strip
the HTML tag from the beginning of each error. Also note that I'm not
checking for errors by putting each "for" loop inside an "if
form['field'].errors" block because omitting this doesn't make a
difference and I want this code to run as fast as possible.
Is there a better way to do this? Thanks!

Choosing authentication method to work with ISA proxy

Choosing authentication method to work with ISA proxy

Given: 1. Client application supports only Basic authentication 2. When
client application runs from machine in the same domain with the ISA -
it's Ok. 3. When client application runs from machine that not belongs to
the ISA server's domain - client cant access to internet.
I know that ISA server can be configured to authenticate only with
integrated authentication method(I cant change this) But why it's work in
case 2 ?
Which method to choose to solve the problem with ISA proxy: 1) add NTLM
method to client or 2) add Kerberos method to client? I hope it will work
with ISA. It is portable. What are cons?

Touch events using jmonkey in windows 8

Touch events using jmonkey in windows 8

I tried using the jmonkey touch api's but the onTouch/onTouchEvent method
is not getting triggered in windows-8.
Please let me know whether it supports windows-8 or not?

RTMFP and peer-to-peer ports/firewalls

RTMFP and peer-to-peer ports/firewalls

Trying to implement RTMFP for video/audio conferencing app.
The developers have cited this issue:
RTMFP and firewall/NAT traversal options
We have openRTMFP (cumulus) server up and running. We could have this sat
inside or outside the company network (outside for the "cloud" service,
inside for the "local instance" service). But this firewall/NAT issue
looks a show stopper.
Has anybody over come this ?

Sunday, 25 August 2013

Changing default line discipline at kernel level/ any way other than( user space) IOCTL TCIOCSETD

Changing default line discipline at kernel level/ any way other than( user
space) IOCTL TCIOCSETD

I am implementing a custom line discipline in order to communicate with
the peripheral connected to the serial port. So during kernel boot itself
i want to assign the custom line discipline to serial port which is
connected to the peripheral. When i walk through the kernel source, i come
to know that by default all the serial port will be assigned n_tty line
discipline with this function tty_ldisc_init(struct tty_struct *tty). Now
how can i identify the particular serial port and assign custom line
discipline? I searched a lot , i am getting all the refernce from user
spcae. I have a dependency, because two component will be using this line
discipline. i component can access from user space while the other is in
kernel space. So if user space component is not up, kernel space module
cannot communicate

std::istringstream iss(std::move(string)); crosses the initialization though it's out side loop

std::istringstream iss(std::move(string)); crosses the initialization
though it's out side loop

Initially I wrote std::istringstream iss(std::move(string)); inside while
loop so gave error crosses initialization inside loop. Now it's not inside
any loop but even it gives error crosses the initialization.
code:
std::istringstream iss(std::move(reslut_string));
while (iss >> result_string)
{
tmp = ++s1[result_string];
if (tmp == max_count)
{
most.push_back(result_string);
}
else if (tmp > max_count)
{
max_count = tmp;
most.clear();
most.push_back(result_string);
}
}
std::cout << std::endl << "Maximum Occurrences" << std::endl;
for (std::vector<std::string>::const_iterator it = most.cbegin(); it !=
most.cend(); ++it)
std::cout << *it << std::endl; //
If I declare std::istringstream iss; in function declaration part and
directly write
while (iss >> result_string)
{
tmp = ++s1[result_string]; .....
}
Then it does not give error but std::cout << *it << std::endl; does not
write anything!
Here entire function code:
void *SocketHandler(void *lp)
{
typedef std::unordered_map<std::string,int> occurrences;
occurrences s1;
std::string ss;
std::ostringstream bfr;
std::string result_string;
std::vector<std::string> most;
int max_count = 0;
int tmp=0;
while ((NULL != word) && (50 > i)) {
ch[i] = strdup(word);
excluded_string[j]=strdup(word);
word = strtok(NULL, " ");
skp = BoyerMoore_skip(ch[i], strlen(ch[i]) );
bfr << excluded_string[j] << " ";
result_string = bfr.str();
j++;
// std::cout << "string is :" << r1;
i++;
if(str==NULL && str==NULL and skp !=NULL)
{
pcount=0;
ncount=0;
}
}
std::cout << "string is :" << result_string << "\n";
std::istringstream iss(std::move(reslut_string));
while (iss >> result_string)
{
tmp = ++s1[result_string];
if (tmp == max_count)
{
most.push_back(result_string);
}
else if (tmp > max_count)
{
max_count = tmp;
most.clear();
most.push_back(result_string);
}
}
std::cout << std::endl << "Maximum Occurrences" << std::endl;
for (std::vector<std::string>::const_iterator it = most.cbegin(); it
!= most.cend(); ++it)
std::cout << *it << std::endl;
return 0;
}

[ Fashion & Accessories ] Open Question : What size timberlands should I get?

[ Fashion & Accessories ] Open Question : What size timberlands should I get?

I'm 17, I usually wear a 8.0, 8.5-9 in women shoes,so should I get a 8
wide, since there shoes a big I don't wab

[ Air Travel ] Open Question : Give some example were metal will come in contact with metal and there is wear and tear?

[ Air Travel ] Open Question : Give some example were metal will come in
contact with metal and there is wear and tear?

Web service registration patterns (proxy with multiple client services)

Web service registration patterns (proxy with multiple client services)

I'm in a bit of an architectural bind. I need to build a high speed cross
web service communication architecture that collocates registrations for
the same user type on a single servicing web service, but at the same time
can scale in the future to handle multiple user types.
Here are the main points:
Just a few users of a single user type
Right now just a few user types … but in the future I expect the number of
user types to grow significantly
All users of the same user type must to be registered on the same web
service (they are going to information share within that single service –
ie use that single service as a hub to share data). Due to the nature of
the data they cannot route it through the proxy after the initial
registration.
As users register they will need to initially connect to a single well
known external point (proxy) which will then farm them out to the correct
service for the day. (ie users won't have any pre-knowledge of what single
service will be servicing them that day … they will have to register with
a proxy first and that proxy will direct them to the correct service for
them)
The 2 possible architectures that I'm debating over:
When the user first contacts the "well known external point" it could
simply respond with "your service is XXX … go contact him directly." Then
the user would be responsible for registering with the service that was
supplied.
When the user first contacts the "well known external point" it could
forward the registration information onto the service and that service
could essentially "reverse register" with the client.
In general architecture 2 feels more complicated, but might have some
merit because we're not depending on the user to "do the right thing".
Thoughts on which approach is better? Alternate thoughts?
See the image for a graphical depiction of the two architectures.
I'd post an image but !stack! wont let me reference it because I don't
have a 10+ reputation!
Ha found a way to cheat ... stack uploaded the image ... but wont let me
embed it directly ... here is the link: http://i.stack.imgur.com/c0NC6.jpg

Saturday, 24 August 2013

VB.NET JSON data from website

VB.NET JSON data from website

I'm currently using VB .NET 2010. I'm trying to read data from a JSON
request from the website
https://tradingpost-live.ncplatform.net/ws/search.json (Guild Wars 2
site).
The website requires you to be logged in via the forums. Even having this
in my vb app via a webbrowser object, I am still receiving a 401
Unauthorized error. I assume some sort of cookie is needed???
The biggest issue I have is trying to run the larger search @
https://tradingpost-live.ncplatform.net/ws/search.json?text=&levelmin=0&levelmax=80&count=0
This gives me the error "Unable to download search.json from
tradingpost-live.ncplatform.net. Unable to open this Internet site. The
requested site is either unavailable or cannot be found. Please try again
later.
By using Firefox, I can login and view each of these 2 sites without any
issues. Any chance I can get a pointer in the right direction? So far I've
installed JSON.NET but have no clue how to use it or if I should be doing
something else...... almost midnight and my brain is fried!

unable to start activity componentinfo java.lang.nullpointerexception arrays preferences

unable to start activity componentinfo java.lang.nullpointerexception
arrays preferences

i m' having the next problem:
unable to start activity componentinfo java.lang.nullpointerexception
i' doing a program with preferences, this is the code:
package com.toogle.button;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class MainActivity extends Activity implements
OnCheckedChangeListener {
EditText editable;
TextView texto;
ToggleButton toggle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
SharedPreferences sp =
PreferenceManager.getDefaultSharedPreferences(getBaseContext());
boolean fondo = sp.getBoolean("checkbox", true);
if (fondo == true){
ll.setBackgroundColor(Color.BLUE);
}
String plist = sp.getString("lista", null); **//HERE IS THE PROBLEM**
if (plist.equals("1")){
ll.setBackgroundColor(Color.GREEN);
}
String toast = sp.getString("nombre", null);
if(toast.equals("emi")){
Toast t = Toast.makeText(this, "bien", Toast.LENGTH_SHORT);
t.show();
}
editable = (EditText) findViewById(R.id.etEditable);
texto = (TextView) findViewById(R.id.tvTexto);
toggle = (ToggleButton) findViewById(R.id.tgToggle);
toggle.setOnCheckedChangeListener(this);
}
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
if (toggle.isChecked()){
editable.setTextColor(Color.RED);
editable.setTextSize(30);
texto.setText("Activado");
}else{
editable.setTextColor(Color.BLACK);
editable.setTextSize(20);
texto.setText("Desactivado");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()){
case R.id.iConoce:
Intent c = new Intent("com.toogle.button.CONOCE");
startActivity (c);
break;
case R.id.iPrefs:
Intent p = new Intent("com.toogle.button.PREFS");
startActivity (p);
break;
case R.id.iSalir:
finish();
break;
}
return false;
}
}
The aray XML File:
<?xml version="1.0" encoding="utf-8"?>
<string-array name="lista">
<item>Uno</item>
<item>Dos</item>
<item>Tres</item>
<item>Cuatro</item>
</string-array>
<!-- Values -->
<string-array name="lValores">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
and here is the logcat:
08-24 20:28:49.689: E/AndroidRuntime(31419): FATAL EXCEPTION: main
08-24 20:28:49.689: E/AndroidRuntime(31419): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.toogle.button/com.toogle.button.MainActivity}:
java.lang.NullPointerException
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.os.Looper.loop(Looper.java:123)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.ActivityThread.main(ActivityThread.java:4627)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
java.lang.reflect.Method.invokeNative(Native Method)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
java.lang.reflect.Method.invoke(Method.java:521)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
dalvik.system.NativeStart.main(Native Method)
08-24 20:28:49.689: E/AndroidRuntime(31419): Caused by:
java.lang.NullPointerException
08-24 20:28:49.689: E/AndroidRuntime(31419): at
com.toogle.button.MainActivity.onCreate(MainActivity.java:43)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-24 20:28:49.689: E/AndroidRuntime(31419): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-24 20:28:49.689: E/AndroidRuntime(31419): ... 11 more
Thanks.

can't run google play services based application

can't run google play services based application

I'm trying to create an application with Google Play Services. I've
referenced the Google Play Services library project, and targeted the API
to Google API-17 (I've also tried API 18). I did everything as explained
on Google website. However, when I run the application, it's trying to
update Google Play Services unsuccessfully, and displaying the following
output:
[2013-08-25 00:48:29 - google-play-services_lib] Uploading
google-play-services_lib.apk onto device 'emulator-5554' [2013-08-25
00:48:30 - google-play-services_lib] Installing
google-play-services_lib.apk... [2013-08-25 00:48:45 -
google-play-services_lib] Re-installation failed due to different
application signatures. [2013-08-25 00:48:45 - google-play-services_lib]
You must perform a full uninstall of the application. WARNING: This will
remove the application data! [2013-08-25 00:48:45 -
google-play-services_lib] Please execute 'adb uninstall
com.google.android.gms' in a shell. [2013-08-25 00:48:45 - Weeel] Launch
canceled!
Any help would be greatly appreciated. Thank you

LINQ to Entities : "select new" expression tree throws System.NotSupportedException

LINQ to Entities : "select new" expression tree throws
System.NotSupportedException

I'm trying to build an Expression Tree that reflects a "select new" query.
I'm using Ethan's answer to this question. It works great for common lists
but with LINQ to Entities I get this exception:
System.NotSupportedException: Unable to create a constant value of type X.
Only primitive types or enumeration types are supported in this context.
Where X is the Entity I'm querying.
Using the debugger this is the IQueryable with the expression tree:
SELECT [Extent1].[Id] AS [Id], [Extent1].[Nombre] AS [Nombre],
[Extent1].[Apellido] AS [Apellido]FROM [dbo].[Empleadoes] AS
[Extent1].Select(t => new Nombre;String;() {Nombre = t.Nombre})
And this is the IQueryable using normal linq notation (not actually the
same query but to get the point - they are different)
SELECT [Extent1].[Dni] AS [Dni], [Extent1].[Nombre] + N' ' +
[Extent1].[Apellido] AS [C1]FROM [dbo].[Empleadoes] AS [Extent1]
Any help appreciated. Thanks.

Issue with images on qml WebView app

Issue with images on qml WebView app

http://i.stack.imgur.com/sF6Ux.png http://i.stack.imgur.com/frsyI.png
Images doesn't appear on any qml webview app. I'm using Belle Refresh and
I already reinstalled QtWebkit component.

fRee Here!!! Fulham v Arsenal Live Stream August 24,2013 TV ON PC EPL

fRee Here!!! Fulham v Arsenal Live Stream August 24,2013 TV ON PC EPL

Watch Fulham vs Arsenal Live Stream Online Free English Premier League
08/24/2013 How Giroud's debut campaign with Arsenal is viewed depends
completely on expectations. Those who hoped he would completely revitalize
the Gunners' attack were left disappointed, but the French international
put together a solid term.
======>>> http://bit.ly/Ztttjg
======>>> http://bit.ly/Ztttjg
He finished the season with 17 goals across all competitions and also had
double-digit assists. When you consider it was the striker's first foray
into the Premier League, there's no reason to believe he can't take
another step forward in his second season with the club.
Giroud is off to a great start. He scored inside the first 10 minutes of
the opener before Aston Villa turned the match around, and also netted a
penalty against Fenerbahce. The Gunners hope he can maintain that early
momentum against Fulham.

How to split text in Java

How to split text in Java

I want to split the String text so that only first letter comes as output.
But its not happening. Can anyone help me please??
Class
public class textSplit {
public static void main(String[] args) {
// TODO Auto-generated method stub
String text = "abcd";
String [] letters = text.split(null);
System.out.println(letters[0]);
}
}

How to use the grep result in command line?

How to use the grep result in command line?

When I use grep to find some texts which I need, it will display lines
containing a match to the given pattern.
For example,
# grep -r ".*Linux" *
path0/output.txt:I hope you enjoyed working on Linux.
path1/output1.txt:Welcome to Linux.
path2/output2.txt:I hope you will have fun with Linux.
then, I want to edit the path2/output2.txt, hence, I type vim
path2/output2.txt.
But, I think it doesn't a effective way.
How can I copy the path after grep?

Friday, 23 August 2013

How to search data in database and add it to textboxes in C#.NET?

How to search data in database and add it to textboxes in C#.NET?

I have multiple data in database so i need to add them in different
textBoxes. here is my code
private void Search_button1_Click(object sender, EventArgs e)
{
string query = string.Empty;
if (ID_textBox1.Text.Trim().Length > 0)
{
try
{
query = "SELECT
ProductName,ProductDescription,SellPrice FROM Table2
WHERE ProductID='" + ID_textBox1.Text+ "'";
SqlConnection Conn =
CreateConnection.create_connection();
SqlCommand cd = new SqlCommand(query, Conn);
SqlDataReader reader = cd.ExecuteReader();
while (reader.Read())
{
Name_textBox2.Text =
reader["ProductName"].ToString();
Description_textBox3.Text
=reader["ProductDescription"].ToString();
Unit_Price_textBox5.Text =
reader["SellPrice"].ToString();
}
reader.Close();
Name_textBox2.Text = Name_textBox2.Text;
Description_textBox3.Text = Description_textBox3.Text;
QTY_textBox4.Text = 1.ToString();
Unit_Price_textBox5.Text = Unit_Price_textBox5.Text;
Price_textBox6.Text =
(decimal.Parse(QTY_textBox4.Text) *
decimal.Parse(Unit_Price_textBox5.Text)).ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

Sizes of arrays declared with pointers

Sizes of arrays declared with pointers

char c[] = "Hello";
char *p = "Hello";
printf("%i", sizeof(c)); \\Prints 6
printf("%i", sizeof(p)); \\Prints 4
My question is, why do these print different results? Doesn't c[] also
declare a pointer that points to the first character of the array (and
therefore should have size 4, since it's a pointer)?

Explaination of Appfog's 10mb of RAM MongoDB and Redis instances?

Explaination of Appfog's 10mb of RAM MongoDB and Redis instances?

On their pricing page, under full details, every plan has MongoDB and
Redis listed as having 10mb RAM. Does this mean I cannot exceed 10mb worth
of data in MongoDB and Redis databases? Or do they share the total 2GB RAM
that's available in my plan?
Source: https://www.appfog.com/pricing/

Creating variable pagebreaks

Creating variable pagebreaks

Is it possible to procedurally generate page breaks by measuring text/page
space? I am having a problem which you can see here:

There are two problems in this picture. First, the heading should overflow
to the next page because it doesn't fit...but more importantly, and more
annoyingly, the heading should be forced to the next page because its
content does not fit on the same page.
I am procedurally generating my latex from javascript, so it is sort of
hard to post code snippets, but I can show you the function/environment I
am using...it is the second code block in the accepted answer here
Any ideas or tips for measuring the text?

Issue with is_copy_constructible

Issue with is_copy_constructible

Should the type trait be able to handle cases such as std::vector <
std::unique_ptr <int> > and detect that it's not copy constructible?
Here's an example at https://ideone.com/gbcRUa (running g++ 4.8.1)
#include <type_traits>
#include <vector>
#include <iostream>
#include <memory>
int main()
{
// This prints 1, implying that it's copy constructible.
std::cout << std::is_copy_constructible<
std::vector<std::unique_ptr<int> > >::value << std::endl;
return 0;
}
If this is the correct behavior for is_copy_constructible, is there a way
to detect that the copy construction is ill formed? Well, beyond just
having it fail to compile.

How to Check table Exist or Not and then Create a table if not Exist?

How to Check table Exist or Not and then Create a table if not Exist?

I want to write code to check table already exist or not in SQL Server
2008 and If Not Exists then create it and then insert records into it.
Please tell me how to do it? Is it necessary to create Stored Procedure
for it?

Thursday, 22 August 2013

Creating a responsive menu in Bootstrap

Creating a responsive menu in Bootstrap

I am trying to create a dropdown menu using Bootstrap, but I am not able
to make it responsive. This is my menu :

But when I resize the window, it is not resizing & width stays constant.

Here is my code :
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap test</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet"
href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet"
href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script
src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<style type="text/css">
p{
text-align: center;
}
img {
max-width:100%;
}
.dropdown-menu{
width: 50em;
}
</style>
</head>
<body>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle"
data-toggle="dropdown">
Action <span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<div class="panel panel-default">
<div class="panel-heading">My Menu</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
</div>
<div class="row">
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
<div class="col-xs-2"><img
src="http://placeimg.com/128/128/tech"><p>Stuff</p></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

How to parse color (saved data) from one controller class to another controller class?

How to parse color (saved data) from one controller class to another
controller class?

I'm practically new in IOS dev.
I would like to ask, let's say if i have a controllerA.m and I have a
@property (nonatomic, weak) UIColor *savedColor;
How can I parse the savedColor from controllerA.m to controllerB.m whereby
i wish to set the background color of an UIImageView *mainImage same as
the savedColor?

After trying to install ubuntu no OS is working

After trying to install ubuntu no OS is working

I am very new to Ubuntu, i tried to install it from a usb stick but it got
stuck on the swap partition so i tried quit and now i can not even boot on
windows 8.
I tried also the boot repair and I get this report.
Any suggestions,i can not even enter into BIOS mode
Thank you in advance
Zampeta

Why is the destructor called?

Why is the destructor called?

I wrote a simple vector class which overloads assignment and addition
operators. The code adds two vectors and prints vectors before and after
the addition. Surprisingly destructor ~MyVector() is being called after
the line c=a+b. I do not see the reason why is it so, as neither of
objects a,b and c gets out of scope. Do you understand the reason for
invocation of the destructor?
#include<iostream>
#include<cstdlib>
using namespace std;
template<typename T>
class MyVector
{
public:
MyVector(int s)
{
size=s;
a=new T[s];
}
~MyVector()
{
delete[] a;
size=0;
};
void freeVec()
{
cout<<"Calling destructor. a[0]= "<<a[0]<<endl;
if(a!=NULL)
{
free(a);
a=NULL;
}
}
int getSize(void)
{
return size;
}
void setSize(int ss)
{
size=ss;
}
T &operator[](int i)
{
return a[i];
}
MyVector &operator=(MyVector mv)
{
if(this==&mv)
return *this;
for(int i=0;i<mv.getSize();i++)
this->a[i]=mv[i];
this->size=mv.getSize();
return *this;
}
MyVector operator+(MyVector &mv)
{
for(int i=0;i<size;i++)
{
this->a[i]+=mv[i];
}
cout<<endl;
return *this;
}
private:
int size;
T *a;
};
int main(void)
{
MyVector<int> a(3),b(3),c(3);
a[0]=1;a[1]=2;a[2]=3;
b[0]=4;b[1]=5;b[2]=6;
cout<<"initial vector"<<endl;
for(int i=0;i<3;i++)
cout<<a[i]<<" ";
cout<<endl;
for(int i=0;i<3;i++)
cout<<b[i]<<" ";
cout<<endl;
c=a+b;
cout<<"final vectors"<<endl;
for(int i=0;i<3;i++)
cout<<a[i]<<" ";
cout<<endl;
for(int i=0;i<3;i++)
cout<<b[i]<<" ";
cout<<endl;
for(int i=0;i<3;i++)
cout<<c[i]<<" ";
cout<<endl;
cout<<endl;
return 0;
}

Most Algortihms used in Named Entity Recognition [on hold]

Most Algortihms used in Named Entity Recognition [on hold]

What are the the most used algorithms for NER? I know the answer sequence
labelling algorithms like HMM, MEMM, CRF, are mostly used but I want
justification why is that???
Why other classification algorithms (SVM , naive bayes etc..) are now
working well and not frequently used in NER task?
Thanks in advance!

intellij plugin com.intellij failed to initialized

intellij plugin com.intellij failed to initialized

everyone, here I encounter a problem after the installation of Intellij
IDEA 12.1.3 on my WINDOWS XP sp2 System.
Here, I just describe it as follows: After the second time installation,
the startup of Intellij encounts that "plugin com.intellij failed to
initialized and will be disabled: Unknown macro:$ROOT_CONFIG$ in storage
spec : $ROOT_CONFIG$/keymaps please restart Intellij IDEA"
PS: this problem only happened for the second and so on installation of
the Intellij IDEA on my system.

Is there a way to change FlowDirection only for a specific Grid RowDefinition in WPF?

Is there a way to change FlowDirection only for a specific Grid
RowDefinition in WPF?

I have an existing UI design and i would like to add RTL support with
minimal changes in existing XAMLs. Currently, most screens are 3x3 Grids
of the following form:
row 0: [ Title - 2 columns ] [ Quit - 1 column ]
row 1: [ Content - 3 column ]
row 2: [ Back - 1 column ] [ empty ] [ Next - 1 ]
I would like to add RTL support only for Row 0 and Row 2. Is that
possible? I couldn't find FlowDirection property for it. I dont mind
overriding the Grid control and implementing this myself i just couldn't
find how... Any ideas?

Wednesday, 21 August 2013

Ubuntu Freezing

Ubuntu Freezing

I've been using ubuntu 12.04 lts in my dell inspiron 3521, it's been two
weeks and it has frozen so many times, the mouse, keyboard everything
freezes, i've tried reisub but since the keyboard was frozen as well it
didn't work, what shall I do it's really annoying.

Storage for Disaster Recovery

Storage for Disaster Recovery

We have a few PostgreSQL servers which add up to 1 TB. We want to do a
PostgreSQL Point-In-Time-Recovery which needs in turn for us to store the
base of each database in a secure location should any disaster hit. I'm
looking at the storage options. I looked at AWS Glacier but the pricing
needs a Math PhD or something. AWS S3 is another option. So I was
wondering if you have used something that can make it even easier. Here
are the requirements I have in mind: 1 - Not so pricey. At 1 TB, AWS S3
will cost less than $100. I guess we could drag the budget to maximum $150
if there's a justification. 2 - We use Linux so something with a Linux
client (lovely if it's available on Debian repos) would be really nice. 3
- We don't really care about deduplication since every time we have a new
version we will basically wipe out the old one. Any hint is appreciated.

Restrict Google Search Custom Autocomplete

Restrict Google Search Custom Autocomplete

Is it possible to use an XML file to force google custom search to suggest
only the terms in the XML?
Thanks.

How do you stop/break a simple if statement?

How do you stop/break a simple if statement?

I want to stop or break my if statement. I know I can make another
statement that would cause it to stop. Is there a keyword I can't find?
if @filter
if @filter == "templates"
base_dir = "public/files/marketing"
@files = Dir.glob("#{base_dir}/voip/#{@filter}/*")
@view = "files"
This is where I want to break the if statement.
end
arrays_of_strings_to_check_against = ['logos', 'datasheets',
'buyers_guides', 'videos', 'web_banners', 'presentations', 'documents',
'press_releases', '3cx' ]
if @type ...

How does energy loss work in Redstone Energy Conduits

How does energy loss work in Redstone Energy Conduits


In this situation you see I have my conduits linearly running along the
line of engines. It says on the wiki that the conduits have a 5% energy
loss, implemented at points where energy enters the line. Does this mean
that with 5 entry points linearly spread (like I have here) that by the
time the energy reaches me I've lost 25% of my energy, or still just 5%?

Add .pm file to CakePHP

Add .pm file to CakePHP

I have a .pm file with a 30+ subs. The functionality in those subs needs
to be called from my CakePHP pages. What is the Cake way to include the
.pm file in a CakePHP project so I can call the subs from a View or
Controller?
Where should I put the .pm file? How should I include the file into the
CakePHP project? How do I call the subs in the .pm file?
I can't find anything in the CakePHP documentation. The place that it
seems it should be is in the App, but I can't find anything to do what I
want to do.

Timing - chart is shown too late

Timing - chart is shown too late

My chart is ready now and you can see here an example:
http://www.ariva.de/gold-kurs/push-chart?boerse_id=36
There is one problem left: As we have a lot of advertising on our page,
the chart renders only after all is ready, so sometimes the user has to
wait some seconds. I think, Highcharts waits for document.ready?
Is there a possibility to control the order of the Javascript functions
and show the chart earlier?

Tuesday, 20 August 2013

python:cherrypy how to implement facebook authentication

python:cherrypy how to implement facebook authentication

my ios application require to login from facebook. how would i
authenticate facebook user id from server side coding.
i read this link Design for Facebook authentication in an iOS app that
also accesses a secured web service but they did not provide code
description.
can u plz provide me server side code(python+cherrypy) and its description
how to authenticate facebook.

How to increase opacity of an image when scrolling?

How to increase opacity of an image when scrolling?

I have a fixed top bar / nav bar on my website and in the center I have a
logo. I want this logo to start off as hidden when a user comes to the
page. As the user scrolls down (around 200 pixels), I want this logo to
fade in. When they scroll back up to the top, I want the logo to fade back
out.
Here is the script I'm using right now:
<script>
$(document).ready(function(){
$(window).scroll(function(){
if($(this).scrollTop() > 100){
$('#logo').fadeIn(1000);
}
});
});
</script>
There are two problems:
1) The nav-bar to the right of the logo is also starting off as invisible
and fading in, though I don't want it to (it doesn't have id=logo). I'm
not sure why this is happening.
2) The logo is not fading out when I scroll back up. I know I need to use
the fadeOut function but when I tried basically reversing the fadeIn
function, I got some funky results.
Here is my site url: http://bestdressedghetto.com/displayPosts.php
And here is a snippet of the relevant topBar code (it is a php file that
is included in all the pages that should have a top-bar....the javascript
code above is in displayPosts.php):
<header>
<center><a href="displayPosts.php" id="logo">
<img class="img-responsive" src="images/bdg-logo-floral.png" />
</a></center>
<nav style="display:block">
<a style="font-size:30px; position: relative; top: -5px;" href="#"
id="menu-icon"></a>
<ul>
<li><a class="nav-link" href="#">About</a></li>
<li><a class="nav-link" href="displayTapes.php">Tapes</a></li>
<li><a class="nav-link" href="#">Subscribe</a></li>
<li><a class="nav-link" href="#">Contact</a></li>
</ul>
</nav>
</header>
Any and all help is very-well appreciated!

Google Glass Quickstart Java HTTP ERROR 503 Error Service_Unavailable

Google Glass Quickstart Java HTTP ERROR 503 Error Service_Unavailable

Whenever I try to run the java mirror quick start master on localhost:8080
and I am getting.
HTTP ERROR: 503
Problem accessing /. Reason:
SERVICE_UNAVAILABLE
Powered by Jetty://
I am using the mav jetty:run in the command line. I do not know where I am
going wrong. I am afraid the solution is hitting me in the face, and i
can't see it.
Any Help would be appreciated thank you in advance.
Scanning for projects...
----------------------------------------------------------------------
Building glass-java-starter 0.1-SNAPSHOT
----------------------------------------------------------------------
>>> maven-jetty-plugin:6.1.26:run (default-cli) @ glass-java-starter >
--- maven-resources-plugin:2.6:resources (default-resources) @ glass-j
er ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
--- maven-compiler-plugin:3.1:compile (default-compile) @ glass-java-s
-
Nothing to compile - all classes are up to date
--- maven-resources-plugin:2.6:testResources (default-testResources) @
va-starter ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\mirror-quickstart-java-master\s
esources
--- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ glas
arter ---
No sources to compile
<<< maven-jetty-plugin:6.1.26:run (default-cli) @ glass-java-starter <
--- maven-jetty-plugin:6.1.26:run (default-cli) @ glass-java-starter -
Configuring Jetty for project: glass-java-starter
Webapp source directory = C:\mirror-quickstart-java-master\src\main\we
Reload Mechanic: automatic
Classes = C:\mirror-quickstart-java-master\target\classes
Logging to org.slf4j.impl.SimpleLogger(org.mortbay.log) via org.mortba
4jLog
Context path = /
Tmp directory = determined at runtime
Web defaults = org/mortbay/jetty/webapp/webdefault.xml
Web overrides = none
web.xml file = C:\mirror-quickstart-java-master\src\main\webapp\WEB-IN
Webapp directory = C:\mirror-quickstart-java-master\src\main\webapp
Starting jetty 6.1.26 ...
jetty-6.1.26
NG] Failed startup of context org.mortbay.jetty.plugin.Jetty6PluginWebA
@6d9ef759{/,C:\mirror-quickstart-java-master\src\main\webapp}
ang.ClassNotFoundException: com.google.glassware.SignOutServlet
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadCla
rstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRe
244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRe
230)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLo
:401)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLo
:363)
at org.mortbay.jetty.handler.ContextHandler.loadClass(ContextHandler.
)
at org.mortbay.jetty.plugin.Jetty6MavenConfiguration.parseAnnotations
venConfiguration.java:141)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configure(Abst
guration.java:119)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXm
ation.java:180)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configureWebAp
tConfiguration.java:96)
at org.mortbay.jetty.plus.webapp.Configuration.configureWebApp(Config
ava:149)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.
)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.ja
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6P
ppContext.java:115)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.ja
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollect
152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(Context
llection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.ja
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollect
152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.ja
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.ja
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.ja
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServ
32)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJett
a:454)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMo
96)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJett
java:210)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Defa
luginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecu
208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecu
153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecu
145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildPr
ecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildPr
ecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreade
fecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifec
er.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
7)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
l.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(L
ava:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
.java:414)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.ja
Started SelectChannelConnector@0.0.0.0:8080
Started Jetty Server

ActionMailer body string interpolation not printing value of variables, is printing exact string

ActionMailer body string interpolation not printing value of variables, is
printing exact string

I have a mailer that looks like (@user and @foo are passed to the
containing method):
mail(to: @user.email, subject: 'Foo is expired',
body: 'Your Foo reservation for #{@foo.bar.name} in position
#{@foo.position}
has expired. Please recreate the reservation if necessary')
I'm testing it with some puts, puts mail.body looks like:
'Your Foo reservation for #{@foo.bar.name} in position #{@foo.position}
has expired. Please recreate the reservation if necessary'
Am I just mistaken on how I'm doing interpolation? Has it something to do
with ActionMailer, or outputting text to console?
Thanks.

Fatal error: Call to a member function saveAs() on a non-object

Fatal error: Call to a member function saveAs() on a non-object

I am following this tutorial:
http://www.yiiframework.com/wiki/349/how-to-upload-image-photo-and-path-entry-in-database-with-update-functionality/#hh0
but my problem is when i try to upload the image it gets all the time
saying this: Fatal error: Call to a member function saveAs() on a
non-object
*/
public function actionCreate()
{
$model=new Imagem;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Imagem']))
{
$rnd = rand(0,9999);
$model->attributes=$_POST['Imagem'];
$uploadedFile=CUploadedFile::getInstance($model,'image');
$fileName = "{$rnd}-{$uploadedFile}";
if($model->save()){
**$uploadedFile->saveAs(Yii::app()->basePath.'/../imagem/'.$fileName);**
$this->redirect(array('admin'));
}
}
$this->render('create',array(
'model'=>$model,
));
}
On bold is the piece of the code that is generating so much problems, i
searched in the internet but all the solutions provided don't solve
anything.

phonegap Inappbrowser not displaying toolbar (ios)

phonegap Inappbrowser not displaying toolbar (ios)

I have tried everything possible to my understand and also calling the
inappbrowser as esplained on the phonegap website, its working but i can't
seem to get status bar displayed and it doesn't launch in fullscreen.
I have user the code below in my webpage tag.
<script type="text/javascript">
function onDeviceReady() {
var ref = window.open('http://www.bbc.co.uk', '_blank',
'location=yes');
// close InAppBrowser after 5 seconds
setTimeout(function() {
ref.close();
}, 5000);
}
</script>
Used the
onClick="onDeviceReady();
which is perfectly launching the inappbrowser. I have have done everything
possible with my config.xml and please find code below
<preference name="phonegap-version" value="2.9.0" />
<preference name="permissions" value="none" />
<preference name="orientation" value="landscape" />
<preference name="target-device" value="tablet" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="false" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="load-url-timeout" value="15000" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value=".25" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="ShowSplashScreenSpinner" value="true" />
but nothing seem to bring up the browser toolbar. Been on this for 2days
now and i have tested it on both the simulator and live device. the
inappbrowser shows up but not in fullscreen and without the toolbar.
Any help will do and thanks in advance.

only get the src value

only get the src value

I have in the database a field that will always have an tag. and also lots
of text.. (for example:
Hey there.. whats up? .. and this is my photo!..
)
I need to get ONLY what between the
src
I tried :
public string LinkPicCorrect(string path)
{
//string input = "[img]http://imagesource.com[/img]";
string pattern = @"\<img>([^\]]+)\\/>";
string result = Regex.Replace(path, pattern, m =>
{
var url = m.Groups[1].Value;
// do something with url here
// return the replace value
return @"<img src=""" + url + @""" border=""0"" />";
},
RegexOptions.IgnoreCase);
result = "<img src='" + result + "'/>";
return result;
}
But I've got a parsing error :
Exception Details: System.ArgumentException: parsing "\([^]]+)\/>" -
Reference to undefined group name img.
dunno though if my code is the right path...

Monday, 19 August 2013

SFML Side Collisions

SFML Side Collisions

I have been playing around with gravity stuff in SFML and I am beginning
to implement collisions to stop upward movement. However I need to be able
to see what side of an object I am hitting so that I can know if it just
restricts left or right movement, upward movement, or downward movement. I
would imagine that there is already a class in SFML that allows you to do
that, but it's not in the SFML 2.1 resource tutorials. Thanks!

How do I make this JavaScript work on my local machine?

How do I make this JavaScript work on my local machine?

The code I have below works if it's on my server but when viewed on my
local machine it gives me the following errors:
ReferenceError: jQuery is not defined
$(document).ready(function() {
default.html (line 24)
ReferenceError: $ is not defined
$(document).ready(function() {
default.html (line 12)
ReferenceError: $ is not defined
$(document).ready(function() {
CODE:
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="slider/site/style.css">
<script type="text/javascript" src="slider/src/unslider.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var unslider = $('.container').unslider();
$('.arrow').click(function() {
var fn = this.className.split(' ')[1];
// Either do unslider.data('unslider').next() or .prev()
depending on the className
unslider.data('unslider')[fn]();
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$('.line1').fadeIn(7000);
$('#slide2').delay(1000).fadeIn(3200);
$('#slide3').delay(1800).fadeIn(3200);
$('.line4').delay(4000).fadeIn(3500);
});
</script>

Inject Object on deployed REST service

Inject Object on deployed REST service

I'm developing a REST API in an Osgi bundle. I'm using Jersey to deploy
the services into a jetty container with a javax servlet for each class
with REST services.
Each class has an attribute like this
Private DBInterface dbInterface;
With setters and getters, and I need to inject the object from another
bundle once the service is deploy (in runtime). So anyone know a way to do
it?
Thanks in advance.
PD: I'd like to do it without declaring the service as singleton so every
REST request is answered from another instance of the service (actual
stateless REST)

Whats wrong with my Strongly typed DataSet

Whats wrong with my Strongly typed DataSet

I created a dataSet in a solution then added 4 table adapter's to it, all
worked fine. Now after few days I am trying to add another table adapter
and it's not showing it in intellisense. This is how it looks like,

I looked at other xsd in solution and they either don't have "...cs" file
and only have designer.cs file.
for privacy reson cant show code sorry.

Sunday, 18 August 2013

the value to "out" parameter must be assigned in the method body, otherwise the method will not be compiled

the value to "out" parameter must be assigned in the method body,
otherwise the method will not be compiled

I have the following code in c#
class Sample{
public void sum(out int num1,int num2)
{
}
public void print()
{ int i=12;
sum(out i,10);
Console.WriteLine(i);
}
}
why the following code give error saying "the out parameter 'num1' must be
assigned before control leaves the current method",even i am not writing
any statement there or not using num1 and i already assign it the value in
callee method?

Assigning variables from inputs in FOR loop in python

Assigning variables from inputs in FOR loop in python

For my university python course I have an assignment which asks:
Create a change-counting game that gets the user to enter the number of
coins necessary to make exactly two dollars. Design an algorithm, express
it in pseudocode, and then use it to implement a Python program that
prompts the user to enter a number of 5c coins, 10c coins, 20c coins, 50c
coins, $1 coins and $2 coins. If the total value of those coins entered is
equal to two dollars, then the program should congratulate the user for
winning the game. Otherwise the program should display a message advising
that the total was NOT exactly two dollars, and showing how much the value
was above or below two dollars.
I understand how to implement the program but im having trouble trying to
apply a variable to the user inputs without repetition.
I would like to use a FOR loop like so:
def main():
for coin in ['5c','10c','20c','50c','$1','$2']:
int(input("Enter the number of " + coin + " coins you wish use: "))
#Call the main funtion
main()
But how do I assign a new variable to each user input every time it loops?

Stored UIImage pixel data into c array, unable to determine array's element count

Stored UIImage pixel data into c array, unable to determine array's
element count

I initialized the array like so
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, bounds);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSUInteger width = CGImageGetWidth(imageRef);
NSUInteger height = CGImageGetHeight(imageRef);
unsigned char *rawData = malloc(height * width * 4);
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * width;
NSUInteger bitsPerComponent = 8;
CGContextRef context = CGBitmapContextCreate(rawData, width, height,
bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast
| kCGBitmapByteOrder32Big);
However, when I tried checking the count through an NSLog, I always get 4
(4/1, specifically).
int count = sizeof(rawData)/sizeof(rawData[0]);
NSLog(@"%d", count);
Yet when I NSLog the value of individual elements, it returns non zero
values.
ex.
CGFloat f1 = rawData[15];
CGFloat f2 = rawData[n], where n is image width*height*4;
//I wasn't expecting this to work since the last element should be n-1
Finally, I tried
int n = lipBorder.size.width *lipBorder.size.height*4*2; //lipBorder holds
the image's dimensions, I tried multiplying by 2 because there are 2
pixels for every CGPoint in retina
CGFloat f = rawData[n];
This would return different values each time for the same image, (ex.
0.000, 115.000, 38.000).
How do I determine the count / how are the values being stored into the
array?