Thursday, 3 October 2013

How to replace a old text with the new text in powerpoint presentation using openxml

How to replace a old text with the new text in powerpoint presentation
using openxml

i am new to Openxml. i have a requirement that i need to replace occurence
of texts in powerpoint presentation with new text. am opening the already
created ppt file. For Example i have 30 slides and in some of the slides i
have <> text, i need to replace <> with orginal customer name which am
getting from web page. it should replace all the occurence of the <> with
the new text. How do i replace it ?
My code :
sPptPath = Server.MapPath("~/Source/PPT/") +
DdSubSolutions.SelectedItem.Text.Trim().ToString() + ".pptx";
var pkg = Package.Open(sPptPath, FileMode.Open, FileAccess.ReadWrite);
// Specify the URI of the part to be read
var uri = new Uri("/ppt/presentation.xml",
UriKind.Relative);
PackagePart part = pkg.GetPart(uri);
var xmlMainXmlDoc = new XmlDocument();
xmlMainXmlDoc.Load(part.GetStream(FileMode.Open,
FileAccess.Read));
xmlMainXmlDoc.InnerXml =
xmlMainXmlDoc.InnerXml.Replace("cust", "banu");
// Open the stream to write document
var partWrt = new
StreamWriter(part.GetStream(FileMode.Open,
FileAccess.Write));
xmlMainXmlDoc.Save(partWrt);
partWrt.Flush();
partWrt.Close();
pkg.Close();
am getting invalid operation exception in the below line var uri = new
Uri("/ppt/presentation.xml", UriKind.Relative);
Thanks, Banu

Wednesday, 2 October 2013

How to install Web Platform Installer on remote Windows Server 2012 R2 in Core mode?

How to install Web Platform Installer on remote Windows Server 2012 R2 in
Core mode?

Because of a Core installation mode I can't login remotely and setup it
from installer.
Is there any other way?
Then I could connect to this web server using remote management and
install software from it:

Remove Text from a String in an SSIS Package

Remove Text from a String in an SSIS Package

I am currently updating an already existing SSIS package. The current
Package pulls data from an Excel Spread Sheet that is provided by our IT
Department. It lists Machine Names of Computers and counts it for a
License Report.
I currently have the Job (derived column) strip off the M (Mobile) or D
(Desktop) from the first part of the machine name so that it returns just
the user name, which is what I need for the report.
MBRUBAKERBR => BRUBAKERBR
However, our IT Department just implemented Windows 7 and with it a new
Naming convention. Now there is a 76A, B, C or D that is added to the end
of all of the updated machines. If the machine has not been updated then
it stays with the older Naming Convention (seen Above).
There are also machines that have to stay on XP, their names have been
update to have X3A, B, C or D at the end of theirs.
MBRUBAKERBR76A or DBRUBAKERX3C
What I need is to remove the last part of the name so that I just get the
user name out of it for reporting.
The issues is I can't use a LEFT, RIGHT, LTRIM or RTRIM expression as some
of the computer names will only have the M or D in front (as they have not
yet been upgraded).
What can I do to remove these characters without rebuilding this package?

How nodejs based on videochat works

How nodejs based on videochat works

I'm trying to develop a webcam video chat using nodejs, so I have got one
computer capturing the webcam on a video tag, mounting every frame on a
canvas, catching the image from the canvas and sending this image via
socket, another person connected to the socket recieves the image and
mounts it on a img tag.
I don't know how node js works, so I would like to know if the server of
node js is transporting all the traffic or it is sended directly to the
client?
thanks

Tuesday, 1 October 2013

Perform Method on Main Thread Issue

Perform Method on Main Thread Issue

Hi I am trying to call a method from another subclass and it is working
but not being displayed on the main screen. The log shows that the method
is working but more than likely on a new instance of my controller.
Here is the method in my ViewController Class
//.h
{
- (void)updateCells;
}
//.m
- (void)updateCells
{
//Code in here
}
And in the method from another subclass that calls the method:
ViewController *viewController = [[ViewController alloc] init];
dispatch_async(dispatch_get_main_queue(), ^{
[viewController updateCells];
});
I tried the dispatch_async to have it perform the updateCells on the
screen but the method is called and nothing inside it is displayed. Should
I not create a new viewController instance and if so what should I do
instead? Thanks I am new to how calling methods from different classes
works.

Unable to get connection, DataSource invalid - Netbeans, MySQL

Unable to get connection, DataSource invalid - Netbeans, MySQL

I'm following the tutorial of Netbeans site:
https://netbeans.org/kb/docs/web/mysql-webapp.html
everything was working fine until this step: Implementing JSTL code STEP 4
where the list should be displayed I get the following error:
javax.servlet.ServletException: javax.servlet.jsp.JspException:
Unable to get connection, DataSource invalid: "java.sql.SQLException:
Error in allocating a connection. Cause: Connection could not be allocated
because: java.net.ConnectException : Error connecting to server localhost
on port 1527 with message Connection refused."
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource
invalid: "java.sql.SQLException: Error in allocating a connection. Cause:
Connection could not be allocated because: java.net.ConnectException :
Error connecting to server localhost on port 1527 with message
Connection refused."
note The full stack traces of the exception and its root causes are
available in the GlassFish Server Open Source Edition 4.0 logs.
I suppose netbeans still tries to connect to the Derby DB. How can i
change it to MySQL DB? I am using Java EE7, MySQL, Netbeans, Glassfish 7

Partition resize after ubuntu on windows8

Partition resize after ubuntu on windows8

pI have got a weird problem and I ended up getting 3 partitions after
installing ubuntu on windows 8./p pIn sequence: 1. windows 8 - main
partition 2. Grub - 1 MB 3. ubuntu - 38 GB + Swap (5 GB) 4. 20 GB
partition which I had partitioned before installing ubuntu thinking that I
will install ubuntu on this partition/p p(The ubuntu 13.04 got installed
on original C:\ drive itself and took out 38.12 GB.)/p pHere is my prob: I
want to move 20 GB partition to C drive and make total size of ubuntu as
20 GB instead of current 38 GB. /p

Root Owns Home Directory, chown does not work

Root Owns Home Directory, chown does not work

I am running Ubuntu 12.04 and having various problems. I have traced it
back to the fact that my user's home directory (/home/user) is owned by
root.
The /home directory is actually mounted on another drive, but I can see
that in fstab I am mounting only /home and not /home/user.
The chown command below does not seem to work:
sudo chown -R user /home/user
This will run without errors, however it does not actually change
ownership of the direcory. Here is the output of ls -ld after running the
command:
drwxrwxrwx 1 root root 20480 Sep 25 00:07 /home/user
This is the same as it was previously.

Monday, 30 September 2013

Bash=?iso-8859-1?Q?=2C_name_of_the_stdin_file=3F_=96_unix.stackexchange.com?=

Bash, name of the stdin file? – unix.stackexchange.com

I have to write a bash script which will count symbols like "<" and ">"
from stdin. For example: $ ./myscript.sh <example.html > - 20 < - 21 Found
mismatching brackets! I did this: …

Cardinality of lower triangular Matrix contains rational number

Cardinality of lower triangular Matrix contains rational number

Can anybody explain what is the cardinality of lower triangular Matrix
contains rational number and size of matrix is lower than 7?
I don't have any idea where to start and what to do?

Sub-bullets using Verdana are not the right size in IE

Sub-bullets using Verdana are not the right size in IE

This might be really picky, but a person in QA pointed out to me that
sub-bullets are tiny when using Verdana in IE: http://jsbin.com/IQEmEq/2
The first list is using the default browser style, the second list is
using Verdana. Notice the sub-bullet in the first list has a normal size,
i.e. it is the same size as the other bullets in the list. But in the
second list the sub-bullet is smaller than the other bullets.
Chrome and Firefox seem to render all the bullets the same size regardless
of font, but IE for some reason doesn't.
How can I "fix" this?

jquery get next input element value in

jquery get next input element value in

I have some piece of an html table which reads like
<table>
<tr>
<td><input type="text" class="myclass" name="first_ele[]" value="100" /></td>
<td><input type="text" class="anotherclass" name="secon_ele[]" value=""
/></td>
</tr>
</table>
I have a piece of jquery that will get the value of the element that
contains class "myclass" on keyup and I am getting the proper value. I
need to get the value of the next input element. FYI , The table gets rows
added dynamically. My issue is I don't know how to point to the next
available input element.
my jquery to get the element which has the class "myclass" is as follows.
$('.tInputd').keyup(function(){
var disc = $(this).val();
});
your help is greatly appreciated.

Sunday, 29 September 2013

How to use "applyforce" to blow the objects into direction?

How to use "applyforce" to blow the objects into direction?

i'm learning box2dweb with html5, and i'm trying to use applyforce to
objects when the circle and square almost near the ground, how to do that?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
<script type="text/javascript" src="box2d/Box2dWeb-2.1.a.3.min.js"></script>
<script type="text/javascript">
var world;
function init() {
var b2Vec2 = Box2D.Common.Math.b2Vec2
, b2BodyDef = Box2D.Dynamics.b2BodyDef
, b2Body = Box2D.Dynamics.b2Body
, b2FixtureDef = Box2D.Dynamics.b2FixtureDef
, b2Fixture = Box2D.Dynamics.b2Fixture
, b2World = Box2D.Dynamics.b2World
, b2MassData = Box2D.Collision.Shapes.b2MassData
, b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape
, b2CircleShape = Box2D.Collision.Shapes.b2CircleShape
, b2DebugDraw = Box2D.Dynamics.b2DebugDraw
;
world = new b2World(
new b2Vec2(0, 10) //gravity
, true //allow sleep
);
var fixDef = new b2FixtureDef;
fixDef.density = 1.0;
fixDef.friction = 0.5;
fixDef.restitution = 0.2;
var bodyDef = new b2BodyDef;
//create ground
bodyDef.type = b2Body.b2_staticBody;
bodyDef.position.x = 9;
bodyDef.position.y = 13;
fixDef.shape = new b2PolygonShape;
fixDef.shape.SetAsBox(10, 0.5);
world.CreateBody(bodyDef).CreateFixture(fixDef);
//create some objects
bodyDef.type = b2Body.b2_dynamicBody;
for(var i = 0; i < 10; ++i) {
if(Math.random() > 0.5) {
fixDef.shape = new b2PolygonShape;
fixDef.shape.SetAsBox(
Math.random() + 0.1 //half width
, Math.random() + 0.1 //half height
);
} else {
fixDef.shape = new b2CircleShape(
Math.random() + 0.1 //radius
);
}
bodyDef.position.x = Math.random() * 10;
bodyDef.position.y = Math.random() * 30;
var direction = new b2Vec2(-5,0);
world.ApplyForce( direction , world.GetPosition() );
world.CreateBody(bodyDef).CreateFixture(fixDef);
}
//setup debug draw
var debugDraw = new b2DebugDraw();
debugDraw.SetSprite(document.getElementById("canvas").getContext("2d"));
debugDraw.SetDrawScale(30.0);
debugDraw.SetFillAlpha(0.3);
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit |
b2DebugDraw.e_jointBit);
world.SetDebugDraw(debugDraw);
window.setInterval(update, 1000 / 60);
};
function update() {
world.Step(
1 / 60 //frame-rate
, 10 //velocity iterations
, 10 //position iterations
);
world.DrawDebugData();
world.ClearForces();
};
</script>
</head>
<body onLoad="init();">
<canvas id="canvas" width="600" height="400"></canvas>
</body>
</html>
the above code is the example from official web, i've added
var direction = new b2Vec2(-5,0);
world.ApplyForce( direction , world.GetPosition() );
there is an error
Uncaught TypeError: Object # has no method 'GetPosition'

Beginner to haskell

Beginner to haskell

`ver :: (Float,Float)->(Float,Float)->(Float,Float)->(Float,Float,Float)
ver g=sqrt((((fst x -fst y)^2)+((snd x -snd y)^2)))
ver g1=sqrt((((fst x -fst z)^2)+((snd x -snd z)^2)))
ver g2=sqrt((((fst y -fst z)^2)+((snd y -snd z)^2)))
():g++g1++g2`
I write this and I keep getting the error: naked expression at top level
What I want to do is to take the distance between 3 buildings and present
them as a tuple for exemple: (dAB,dBC,dAC)

python counter, python random list

python counter, python random list

In python, how would I get a list to randomly shuffle 1000 times and then
return the times it was picked out of the list. For example a dice has 6
sides and I want it rolled 1000 times every time how could I get a return
list that shows how many times they were picked?

How to distinguish between fired events for a UIButton callback action

How to distinguish between fired events for a UIButton callback action

When defining a callback for a UIButton I listed several events for the
same action
In the target I would like to be able to distinguish what event triggered
the callback
[button addTarget:self action:@selector(callback:)
forControlEvents:UIControlEventTouchDown | UIControlEventTouchCancel];
-(void)callback:(UIButton *)button
{
// need to be able to distinguish between the events
if (event == canceled)
{
}
if (event == touchDown)
{
}
... etc
}

Saturday, 28 September 2013

Multiples ip address on interface. The wrong one is used for output. What is wrong?

Multiples ip address on interface. The wrong one is used for output. What
is wrong?

I ran curl on curlmyip.com, and I got the wrong output ip address. My
systemd service file is:
[Unit]
Description=Wired Networking
Wants=network.target dibbler-client.service
Before=network.target dibbler-client.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/24 dev ${interface}
ExecStart=/sbin/ip addr add ${failover}/32 dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway} src ${failover}
ExecStart=/sbin/ip -6 addr add ${addressv6}/64 dev ${interface}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip -6 addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down
[Install]
WantedBy=multi-user.target
And variables are:
interface=eno1
address=88.190.15.135
address6=2001:bc8:300a:dead::b12d
failover=212.83.129.104
broadcast=88.190.15.255
gateway=88.190.15.1
Now, ip addr give me:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc mq state
UP qlen 1000
link/ether b8:ac:6f:94:e2:4e brd ff:ff:ff:ff:ff:ff
inet 88.190.15.135/24 scope global eno1
valid_lft forever preferred_lft forever
inet 212.83.129.104/32 scope global eno1
valid_lft forever preferred_lft forever
inet6 2001:bc8:300a:dead::b12d/64 scope global
valid_lft forever preferred_lft forever
inet6 2a01:e0b:1000:15:baac:6fff:fe94:e24e/64 scope global dynamic
valid_lft 2591996sec preferred_lft 604796sec
inet6 fe80::baac:6fff:fe94:e24e/64 scope link
valid_lft forever preferred_lft forever
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether b8:ac:6f:94:e2:4f brd ff:ff:ff:ff:ff:ff
8: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
and ip route:
default via 88.190.15.1 dev eno1 src 212.83.129.104
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.1
88.190.15.0/24 dev eno1 proto kernel scope link src 88.190.15.135
How can curlmyip.com tell me that I reach it with 88.190.15.135?
Thanks!

Flexslider lazyloading - to only load an image when it's truly needed

Flexslider lazyloading - to only load an image when it's truly needed

This is really only following on from an answer to Flexslider lazyloading
here I am using that code which I Have copied below. I would like to alter
it so that images only loaded when truly needed.
I tried the other Flexslider properties, before: and after: but they
created a delay on the first slide? Please can I get some help with this.
$('#slider').flexslider({
start: function (slider) {
// lazy load
$(slider).find("img.lazy").each(function () {
var src = $(this).attr("data-src");
$(this).attr("src", src).removeAttr("data-src");
});
}
});
When viewing the slider source live in Firebug, and running the script
above I expected to see empty src attributes for all slides that had not
initiated, but all src attributes were full from the start, I thought lazy
loading meant on demand? How do I test if lazy loading is working?
Thanks

Compile Android with JDK 1.7 - Android Development Tool

Compile Android with JDK 1.7 - Android Development Tool

I have a source code which currently I use Java Compiler 1.6 to compile
it, I want to use 1.7 version instead, I go to project properties and in
Java Compiler section I change "Compiler Compliance" to 1.7, but when I
build the project I get an error:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7'
instead. Please use >Android Tools > Fix Project Properties.
When I do its recommendation, It change the compiler to 1.6 again. I'm
using Android Development Tool.
Thx

How to convert this Scala code to Scheme?

How to convert this Scala code to Scheme?

In Scala, I have this type Set = Int => Boolean how do I/can I mimic that
in Scheme?
For instance, in Scala, I have
def singletonSet(elem: Int): Set = (x: Int) => (x == elem)
def union(x: Set, y: Set): Set = (z: Int) => (x(z) || y(z))
def forall(s: Set, p: Int => Boolean): Boolean = {
def iter(a: Int): Boolean = {
if (a > bound) true
else if (s(a) && !p(a)) false
else iter(a + 1)
}
iter(-bound)
}
In scheme, this is what I have so far:
(define (singletonSet elem) (lambda (x) (= x elem)))
(define (union x y) (lambda (z) (or x(z) y(z))))
(define bound 1000)
(define -bound 1000)
(define (forall s p)
(local ((define (iter a)
(cond
[(> a bound) true]
[(and s(a) (not (p(a)))) false] -- get error of result not
true or false
[else (iter (+ a 1))])))
(iter -bound)))
My second question is how do I get rid of that error?

Friday, 27 September 2013

Kendo Dataviz Chart Stack Causes Axis to be High

Kendo Dataviz Chart Stack Causes Axis to be High

I have a Kendo Dataviz column stacked graph and the axis value is
extremely higher than the values in the chart. For example, I have two
groups, one has a value of 1 stacked on a value of 1 and the axis goes to
30. When I turn stacking off, it goes to 2.5. I'm not sure what is causing
this. Has anyone ever encountered that issue? I can't set a max because
the values will always be different. Is there a way to dynamically set the
max?
function createChart() {
$("#chart").kendoChart({
dataSource: {
transport: {
read:
"http://localhost:8888/available_sold_graph.php",
dataType: "json"
},
schema: {
data: "data"
},
sort: {
field: "DateHeader",
dir: "asc"
}
},
title: {
text: "Available / Sold"
},
legend: {
position: "bottom"
},
seriesDefaults: {
type: "column",
stack: true
},
series:
[{
field: "Available",
name: "Available",
color: "#3c9ad1"
}, {
field: "Sold",
name: "Sold",
color: "#9dcb4a"
}],
categoryAxis: {
field: "DateHeader",
labels: {
rotation: -0
}
},
tooltip: {
visible: true,
format: "N0"
}
});
}
$(document).ready(createChart);
$(document).bind("kendo:skinChange", createChart);
</script>

How many seconds does a "sample" represent in the profiler?

How many seconds does a "sample" represent in the profiler?

In the Visual Studio Profiler, there is an option to use a "sampling"
method of profiling which can be used on my ASP.NET MVC app:
The sampling profiling method of the Visual Studio Profiling Tools
interrupts the computer processor at set intervals and collects the
function call stack. A call stack is a dynamic structure that stores
information about the functions that are executing on the processor.
This allows me to get a rough indication of what code is taking the
longest to execute. However, I am not sure how much time each sample value
represents. Is 3,441 34.41 seconds? Maybe there is no pure conversion to a
time measurement. If so, can someone explain why? The documentation claims
that there are set intervals, but does not elaborate on how long each
interval lasts.

Search in Google Map

Search in Google Map

I try search in google maps directions . for example , i have two
points(C,E) and draw a direction from C to E, and have in data base routes
(for example A-E,A-K) ,how can i find all routees which contain C-E route
? Thanks.

View selected values of a form

View selected values of a form

I'm trying to view the value selected in a radio button. The form is:
<form onsubmit="return false;">
<fieldset>
<h3>Textos</h3>
<label>Nombre:</label>
<input type="text" name="nombre"/>
<label>Apellido:</label>
<input type="text" name="apellido" />
<label>Contraseña:</label>
<input type="password" name="contrasena" />
<div class="limpia"></div>
</fieldset>
<fieldset>
<h3>Gustos musicales:</h3>
<label>POP <input type="checkbox" name="pop" value="POP"
class="gmusicales"
/></label>
<label>ROCK <input type="checkbox" name="rock" value="ROCK"
class="gmusicales"
/></label>
<label>HIP-HOP <input type="checkbox" name="hiphop" value="HIP-HOP"
class="gmusicales"
/></label>
<label>METAL <input type="checkbox" name="metal" value="METAL"
class="gmusicales"
/></label>
<div class="limpia"></div>
</fieldset>
<fieldset>
<h3>Sistema operativo</h3>
<label>Windows <input type="radio" name="SO" value="Windows"
class="soperativo"/>
</label>
<label>Linux <input type="radio" name="SO" value="Linux"
class="soperativo"/>
</label>
<label>Mac <input type="radio" name="SO" value="Mac"
class="soperativo"/></label>
<div class="limpia"></div>
</fieldset>
<fieldset>
<input type="reset" value="Borrar"/>
<input type="submit" onclick=muestra() value="Probar" />
<div class="limpia"></div>
</fieldset>
</form>
The problem is in my javascript code:
var nom;
var ape;
var con;
var gustos = document.getElementsByClassName("gmusicales");
var sistema = document.getElementById("soperativo");
var resultado;
var i;
var h2 = document.createElement("h2");
function muestra()
{
nom = document.forms[0].elements.nombre.value;
ape = document.forms[0].apellido.value;
con = document.forms[0].contrasena.value;
resultado = nom + " " + ape + " " + con;
for(i=0; i<=gustos.length; i++)
{
if (gustos[i].checked)
{
resultado = resultado + " " + gustos[i].value;
alert(resultado);
}
}
for(i=0; i<=sistema.length; i++)
{
if (sistema[i].checked)
{
resultado = resultado + " " + sistema[i].value;
alert(resultado);
}
}
document.body.appendChild(h2);
document.h2.appenChild(resultado);
}
What I want is to view the values of sistema operativo fieldset. You can
choose only one. When I select it, I don't view anything. When I select
the other one, that is a checkbox, I can view the values. I want to create
an h2 html tag and to print the values.
How can I do it?
Thanks.

Just a universally quantified hypotesis in coq proof

Just a universally quantified hypotesis in coq proof

Another hard goal (for me, of course) is the following:
Goal ~(forall P Q: nat -> Prop,
(exists x, P x) /\ (exists x, Q x) ->
(exists x, P x /\ Q x)).
Proof.
I absolutely have no idea of what could I do. If I introduce something, I
get a universal quantifier in the hypotesis, and then I can't do anything
with it.
I suppose that it exists a standard way for managing such kind of
situations, but I was not able to find it out.

Error in loading file with same name in Alfresco

Error in loading file with same name in Alfresco

I am using below script for uploading a file in alfresco but it refuses to
create stating conflict.
"\n" + "http://www.w3.org/2005/Atom'
xmlns:app=\"http://www.w3.org/2007/app\"
xmlns:cmisra=\"http://docs.oasis-open.org/ns/cmis/restatom/200908/\"
xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\"
xmlns:alf=\"http://www.alfresco.org\">\n" + "" + fileName + "\n" + "" +
fileDescrption + "\n" + "" + author + "\n" + "" + encoder.encode(bytes) +
"\n" + "\n"+ "\n" + "\n"+ "D:hs:doc\n"+ "\n" +
"<cmis:propertyId
propertyDefinitionId=\"cmis:versionable\">\n"+
"<cmis:value>TRUE</cmis:value>\n"+
"</cmis:propertyId>\n" +
"</cmis:properties>\n" +
"</cmisra:object>\n" +
"</entry>\n";
Please let me know, how can i enable versioning using cmis rest .
Regards Garvit

Working Directory in VS and remote machine

Working Directory in VS and remote machine

I'm using a 3rd party SDK in my C# project. In References I've added that
class library. I had also to set Working Directory to the location of that
class library, because of other dependencies, there are some other DLL
files which are needed for that class library.
My application works fine when running from Visual Studio. Now, I don't
know how to deploy my application to get it work on other machines.
I have redistrubate package for the 3rd party SDK and it will install the
class library I'm using and all it's dependencies. By the way I can't
choose destination where to install the SDK.
My application is installed on other location and I can't get it work. The
class library is also included in the installation of my application, but
it's not working. It works when I copy all files in the folder there I've
installed the SDK in to the folder of my application.
Does anyone know how to deploy this kind of applications? Is there a way
to specify "Working Directory" outside the Visual Studio? Could I use
DllImport instead in my application?
Regards

Thursday, 26 September 2013

Difference between MEF and Simple Use

Difference between MEF and Simple Use

what is the difference between using MEF to reusing components and Simply
Adding Reference to the DLL of another project in current project? I mean
that we also add reference to the project we import in our current
project. Then how it is different from conventional form of component use?

Wednesday, 25 September 2013

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING,
expecting ',' or ';'

After adding this code:
<?php
foreach($emp as $empdata){
echo "<tr><td>".$empdata[emp_id]."</td><td>"."<a
href="?>edit.php?emp_id=<?php echo $empdata[emp_id]
">".$empdata[emp_name]."</a></td></tr>";
} ?>
I get this:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING,
expecting ',' or ';' in
/home/kumar/public_html/amsConcrete/single_pages/employee/show_employee.php
on line 23
Any suggestions? Please

Thursday, 19 September 2013

Beginner Java trouble with Parameters

Beginner Java trouble with Parameters

I am currently learning Java and have been having problems with parameters
I'm trying to create a program that takes input.. age and classifies the
person based on said age.
< 2 a baby, < 4 a toddler, < 13 a child, < 20 a teenager, < 35 a young
adult, < 65 middle aged, < 100 geriatric, greater than or = 100 antique
It needs to return a string classifying the person, I wrote this
String getMaturityLevel(int age) {
if(age < 2)
maturity = ("a baby");
if(age < 4)
return("a toddler");
if(age < 13)
return("a child");
if(age < 20)
return("a teenager");
if(age < 35)
return("a young adult");
if(age < 65)
return("middle aged");
if(age < 100)
return("geriatric");
if(age >= 100)
return("antique");
}
Which doesn't compile as it needs a return statement, so my problem is,
how do I effectively write the code? I don't know how to store the results
I tried something different with age < 2
Any help would be appreciated.

Objective-c iPhone : Region allocation error NSString memory limit?

Objective-c iPhone : Region allocation error NSString memory limit?

When using this code in xcode for iphone I get an allocation
region error. (Using simulater)
NSString* str =@"Sommetext";
for (int i =1; i < 50 ; i++) {
str = [[[str stringByAppendingString:@"\n"]
stringByAppendingString:str] stringByAppendingString:@""];
NSLog([NSString stringWithFormat:@"%d",i]);
}
Monitoring the log shows an increase from 1 till 26 and then
crashes with the following error.
Appname(239,0xac5c9a28) malloc: * mmap(size=805306368) failed (error
code=12) * error: can't allocate region
However running the same code (in java) on my android (Samsung
Galaxy S2) has no problems even when I loop it 1000 times.

SSIS Derived Column

SSIS Derived Column

I want to use where clause in derived column ie
I have Table 1, Table 2 I have to compare these both and change the Name
column in table 1.
Two conditions are to be satisfied
1) If I have name as UNK or UNKNOWN or NULL and HI_UN as 1 then it needs
to be changed to UNKNOWN
2) If I have name as UNK or UNKOWN or NULL and P_M has A or R then it
needs to be changed to UNoccupy
Table 1
NUM VEH NAME P_M HI_UN
017 1 UNK A 1
037 2 DESORMEAUX, JR. MICHELLE B 2
043 3 UNK R 3
073 4 UNKNOWN A 4
Table 2
VEH HI_UN
1 1
2 2
3 3
4 4
END RESULT:
NUM VEH NAME P_M
HI_UN
017 1 UNKNOWN A 1
037 2 DESORMEAUX, JR. MICHELLE B 2
043 3 UNoccupy R 3
073 4 UNKNOWN A 4

Quotes, inside quotes, inside quotes in javascript

Quotes, inside quotes, inside quotes in javascript

I try to put \ before quotes, change double for single quotes... but
nothing. Everyone have a solution or tip? Thanks!
This is the code:
html.append('<li lat="'+dataRaw[key].optionsDir['gpsLatitude']+'"
lon="test">'+thumbnailHtml+descriptionHtml+'</li>');

Underlined text in forms

Underlined text in forms

I have noticed that if the user do not write correct English in a form,
words get underlined in red. The problem comes when people writes correct
French or any other language that is not English, it gets underlined too.
How to control this? I mean, how to control the input language or at least
that never underline.
For instance in this form: http://jsfiddle.net/wxrJP/
if you write maison a red line appears.
HTML:
<form>
<input type="text" name="name">
<textarea id="normal" name="text"></textarea>
</form>

Convert YouTube API Call into AJAX

Convert YouTube API Call into AJAX

I am tryning to covert a YouTube API Library Call into ajax to add a video
to a playlist, it works with the JS Library like this:
part: 'snippet',
resource: {
snippet: {
playlistId: playlistId,
resourceId: details
}
}
Now i want to convert this PART / Snippet into something i can send with
JQuery/AJAX as data Parameter
Can someone plz help me covering this into a working AJAX Call ?
Whatever i tried triggers a "404 Bad Request" Error from the API…
thx in advance

Setting random relations in Laravel 4 setting NULL in field

Setting random relations in Laravel 4 setting NULL in field

Problem
We have domain, for example, example.ua. It has second-level domain:
second.example.ua. They both registered on virtual hosting TimeWeb.ru. And
our e-mail domain @example.ua is there too. We want to get to VDS-server
from the same TimeWeb.ru.So we registered new VDS-server and installed
Ubuntu.
First, we move files for exapmle.ua from virtual host to VDS and changed
address record in virtual host command panel to IP of virtual server.
Everything was just fine, but we didn't test sending e-mail.
After that, we move files, db and second-level domain second.example.ua
exactly the same way (we changed address record for second.example.ua). We
forgot to install some mail-server on VDS, so we roll everything back and
then installed Postfix. After than we move another domain example2.ua to
VDS by changing a-record and copied files from second.example.ua.
Everething was set, so we start testing. Everething is fine, but we can't
receive mails to @example.ua. Thats a BIG problem for us. Postfix sending
all mails to another domains (gmail.com, mail.ru, me.com), but not to
example.ua.
There's Postfix configuration just right now:
readme_directory = /usr/share/doc/postfix
#Òóò ÿ ïîìåíÿë mail.example.ua íà mail.example2.ua
myhostname = mail.example2.ua
#Òóò ÿ ïîìåíÿë example.ua íà example2.ua
mydomain = example2.ua
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost
unknown_local_recipient_reject_code = 550
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = localhost
inet_protocols = all
sendmail_path = /usr/sbin/sendmail.postfix
mailq_path = /usr/bin/mailq.postfix
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix
Proposal
We think, that Postfix trying to send to @example.us by local, without
sending it to the space. But we can't move absolutely to VDS, so we can't
change this.
Seems to be...
It seems for me, that postfix have to be forced to send mails via
internet, not by local. Can anybody help?

Wednesday, 18 September 2013

Bootstrap images in carousel not sliding

Bootstrap images in carousel not sliding

I am using twitters bootstrap carousel, sometimes images slide , sometimes
they dont.. and when they do not
TypeError: $next[0] is undefined
$next[0].offsetWidth // force reflow
$next[0].offsetWidth // force reflow bootstrap.js (line 351)
this error comes. I have no know what does that mean.

How do i assign an to ls in linux Bash?

How do i assign an to ls in linux Bash?

array=${ls -d */}
echo ${array[@]}
I have three directories: ww ee qq. i want them in an array and then print
the array.

What about cached (temporary) files on DNS change?

What about cached (temporary) files on DNS change?

I have a short question about caching. At this moment we are working on a
new website which will go live soon, on a different server with a
different IP-adress.
What about people who's browser has cached the old website? Will the
browser detect the DNS change and empty the cache/load the new website or
is there a chance people will see the old website, despite of the
DNS/WebServer change? And if so, how can I avoid that people see the old
website?
Thanks in advance! BlueCola

Increment or create a numeric value in an array

Increment or create a numeric value in an array

I want to create or increment a value for a key in an array. So for
example if I have a key 'money' I can increment it in the array by a set
value, or create it if it doesn't exist yet. Currently I'm doing this
which seems a long way of going about it.
if(array_key_exists("money", $account_array)) {
$account_array["money"] = $account_array["money"] + $increase;
}
else {
$account_array["money"] = $increase;
}

What is a reference in Java EXACTLY?

What is a reference in Java EXACTLY?

I have read a bunch of questions on stackoverflow, Can I pass parameters
by reference in Java?, Passing a String by Reference in Java?.
Let's say, I pass a reference of a string, x, to a method. The method
takes a copy of this reference, x', which still points to the original
object.
My question is: what is the difference between the two references now.
They point to the same object now.

TFS (web) gives error when building Typescript. TypeScript.targets not found

TFS (web) gives error when building Typescript. TypeScript.targets not found

We just converted our javascript files to typescript. Everything builds
locally just fine but our build in TFS (cloud version i.e.
tfs.visualstudio.com) gave us the error:
The imported project "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v11.0\TypeScript\Microsoft.TypeScript.targets"
was not found. Confirm that the path in the declaration is correct, and
that the file exists on disk.
Locally we are using typescript version 0.9.1.1 and VS2012
And advise?

convert Datetime to simple Date

convert Datetime to simple Date

I am having trouble converting a variable that's in String format (from a
DateTime selector control on a form) to simple Date.
I am trying the conversion because I am getting the below error message:
INVALID_FIELD: \nAND c.Status__c = 'Closed' AND c.Close_Date__c >
2013-07-01T00:00:00Z\n ^\nERROR at Row:1:Column:326\nvalue of filter
criterion for field 'Close_Date__c' must be of type date and should not be
enclosed in quotes
I tried:
sQry += " AND c.Close_Date__c > " + DateTime.ParseExact(filterFromDate,
"d", CultureInfo.InvariantCulture) + " AND c.Close_Date__c < " +
DateTime.ParseExact(filterFromDate, "d", CultureInfo.InvariantCulture);
but it's not accepting it (compiler doesn't recognise CultureInfo.
where am I going wrong please?

Why can reinterpret_cast not convert an int to int?

Why can reinterpret_cast not convert an int to int?

My compiler is the latest VC++ 2013 RC.
void f()
{
int n1 = 0;
int n2 = reinterpret_cast<int>(n1); // error C2440
}
error C2440: 'reinterpret_cast' : cannot convert from 'int' to 'int'
Why can reinterpret_cast not be used in such an obvious case?

Tuesday, 17 September 2013

Android:How to use/install KitKat(4.4) in eclipse

Android:How to use/install KitKat(4.4) in eclipse

Still I am not aware about the latest android news. But as my current
awareness android already released its latest version KitKat(4.4), but
still it is not available in eclipse(after upgradation of SDK Manager).
So is there any way to use/install android KitKat(4.4) version in eclipse ?
OR I has problem in my eclipse which is unable to get latest versions..
All help or suggestions are appreciable.
Thank you

Writing empty columns in python

Writing empty columns in python

I have the following two types of txt files:
File1
Sample1012, Male, 36, Stinky, Bad Hair
Sample1043, Female, 28, Hot, Short Hair, Hot Body, Hates Me
Sample23905, Female, 42, Cougar, Long Hair, Chub
Sample123, Male, 32, Party Guy
File2
DEAD, Sample123, Car Accident, Drunk, Dumb
ALIVE, Sample1012, Alone
ALIVE, Sample23905, STD
DEAD, Sample1043, Too Hot, Exploded
I just want to write a simply Python script to join these files based on
the sample field but keep running into a problem with the random number of
data columns. For instance, I end up with:
Sample1012, Male, 36, Stinky, Bad Hair, ALIVE, Sample1012, Alone
Sample1043, Female, 28, Hot, Short Hair, Hot Body, Hates Me, DEAD,
Sample1043, Too Hot, Exploded
Sample23905, Female, 42, Cougar, Long Hair, Chub, ALIVE, Sample23905, STD
Sample123, Male, 32, Party Guy, DEAD, Sample123, Car Accident, Drunk, Dumb
When what I want is:
Sample1012, Male, 36, Stinky, Bad Hair, EMPTY COLUMN, EMPTY COLUMN, ALIVE,
Sample1012, Alone
Sample1043, Female, 28, Hot, Short Hair, Hot Body, Hates Me, DEAD,
Sample1043, Too Hot, Exploded
Sample23905, Female, 42, Cougar, Long Hair, Chub, EMPTY COLUMN, ALIVE,
Sample23905, STD
Sample123, Male, 32, Party Guy, EMPTY COLUMN, EMPTY COLUMN, EMPTY COLUMN,
DEAD, Sample123, Car Accident, Drunk, Dumb
I'm basically just reading in both files with .readlines() and then
comparing the relevant column with the sample ID with a simple "==" and if
true then it prints out the line from the first file and the the second.
Not sure how to use len() to determine the max number of columns in file1
so that I can account for that at the end of each line if it is not the
max number of columns before appending the line from the other file
(provided the "==" is true).
Any help greatly appreciated.

What is wrong with my array insertion algorithm? (Java)

What is wrong with my array insertion algorithm? (Java)

NOTE you will need to know all the stuff I say up here before you
understand what I need help with
First, trust me I know there are better ways of doing this...including
methods that are already made for arrays. However my assignment requires
me to do it from scratch. Right now I am supposed to make a class that has
a final SIZE=100; and a next = 0; when the instance is created.
Since the array has 100 elements, and we don't want to print out the
entire thing, code as been written so that it only prints up to element
'next', an integer that tells us how many elements have been entered. So
at the beginning: next = 0 and whenever we insert an element, we are
supposed to increase next so that the correct number of elements are
printed in a client. All you need to know is that next must increase +1 by
the end of the method.
One last thing...you cannot use a separate array, and whenever an element
is added, it should be added such that all the elements from A[0] to
A[next] are in order (no sorting is allowed).
Here is what I have (it is inconsistent and doesn't work for some tests I
do):
public void insert(int n){
int left = 0;
int right = next;
while (left < right) {//Binary Search. Looks for where n should be
placed.
int middle = (left + right) / 2;
if(n < A[middle])
right = middle - 1;
else
left = middle + 1;
}
//Once the loop ends, left and right are equal, and the spot where
//n should go is found. We will name this index loc.
int loc = left; //or right, it doesn't matter since they are equal.
for(int i = next ; i-1 >= loc; i--) //Everything is copied one over
(right).
A[i] = A[i-1];
A[loc] = n; //The number is placed in the space that follows the
order.
next++; //Let the instance know that the size went up.
}

Dynamically Drawing Multiple Child Views to a Subclass of ViewGroup

Dynamically Drawing Multiple Child Views to a Subclass of ViewGroup

OK, this one has really got me stumped. I have scoured every source I
could uncover (including every Stack Overflow question I could find) for
the last five hours, but I am still WAT.
I have a class that extends ViewGroup. I am attempting to place
YouTubeThumbnails onto this ViewGroup in an interesting grid pattern
(that's what the logic in the onThumbnailLoaded method does). However,
only the first thumbnail is drawn to the screen.
A FunkThumbnail is just a wrapper for a YouTubeThumbnailView with some
video metadata thrown in. The log calls at the end of onLayout do prove
that data for multiple thumbnails is being passed to view.layout. I tried
to use the invalidate method and also tried to extend onMeasure according
to some examples but to no avail. I have, however, been able to use this
same code to draw the grid of thumbnails by extending RelativeLayout (and
not overriding onLayout), but the relativeLayout cannot extend past the
edge of the screen...
The reason I am attempting to extend ViewGroup with a custom layout is
because I want my layout to be drawn past the edge of the screen so when
users pan the layout around with swipe movements what's coming onto the
screen is already drawn. I have looked into combining a vertical and
horizontal ScrollLayout, but I think it might end up being more difficult
to implement some custom swipe animations with that method.
Thanks for any help!!! Code follows:
` package com.cagrabowski.nfg;
import java.util.HashSet; import java.util.Iterator;
import android.content.Context; import android.util.AttributeSet; import
android.util.DisplayMetrics; import android.view.View; import
android.view.ViewGroup;
import com.cagrabowski.L; import
com.cagrabowski.nfg.FunkThumbnailFactory.FunkThumbnail; import
com.cagrabowski.nfg.FunkThumbnailFactory.LargeFunkThumbnail; import
com.cagrabowski.nfg.FunkThumbnailFactory.MediumFunkThumbnail; import
com.cagrabowski.nfg.FunkThumbnailFactory.SmallFunkThumbnail;
public class NeurofunkGrid extends ViewGroup implements
FunkThumbnailFactoryClient {
public static final int MAX_DESIRED_ROWS_ON_SCREEN = 4;
public static final int NUM_ROWS_OFF_SCREEN = 6;
public static final int NUM_COLUMNS_OFF_SCREEN = 6;
// PlayerView cannot be less than 100px.
public static final int PLAYER_VIEW_MIN_HEIGHT = 110;
// YouTube thumbnails have 16/9 aspect ratio.
public static final double THUMB_ASPECT_RATIO = 16 / 9d;
private HashSet<FunkThumbnail> nails = new HashSet<FunkThumbnail>();
private boolean[][] grid;
private byte numRows, numColumns;
private short heightUnit, widthUnit;
private LayoutParams smallLP, mediumLP, largeLP, fillLP;
public NeurofunkGrid(Context context) {
super(context);
}
public NeurofunkGrid(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NeurofunkGrid(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
void initialize(FunkActivity funkActivity) {
DisplayMetrics displayMetrics = funkActivity.getResources()
.getDisplayMetrics();
numRows = MAX_DESIRED_ROWS_ON_SCREEN + 1;
while (PLAYER_VIEW_MIN_HEIGHT * --numRows + 1 >
displayMetrics.heightPixels)
;
numColumns = 0;
while (PLAYER_VIEW_MIN_HEIGHT * THUMB_ASPECT_RATIO * ++numColumns <
displayMetrics.widthPixels)
;
heightUnit = (short) (displayMetrics.heightPixels / numRows);
widthUnit = (short) (heightUnit * THUMB_ASPECT_RATIO);
L.e("height unit: " + heightUnit + ", width unit: " + widthUnit);
smallLP = new LayoutParams(widthUnit, heightUnit);
mediumLP = new LayoutParams(widthUnit * 2, heightUnit * 2);
largeLP = new LayoutParams(widthUnit * 3, heightUnit * 3);
fillLP = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
numRows += NUM_ROWS_OFF_SCREEN;
numColumns += NUM_COLUMNS_OFF_SCREEN;
grid = new boolean[numRows][numColumns];
FunkThumbnailFactory.registerFunkThumbnailFactoryClient(this,
funkActivity, funkActivity.getVideoData());
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
Iterator<FunkThumbnail> iterator = nails.iterator();
while (iterator.hasNext()) {
FunkThumbnail nail = iterator.next();
int width = 0, height = 0;
switch (nail.getSize()) {
case SMALL:
width = widthUnit;
height = heightUnit;
break;
case MEDIUM:
width = widthUnit * 2;
height = heightUnit * 2;
break;
case LARGE:
width = widthUnit * 3;
height = heightUnit * 3;
break;
}
View view = nail.getView();
float left = view.getX(),
//
top = view.getY(),
//
right = view.getX() + width,
//
bottom = view.getY() + height;
L.e("fleft: " + view.getX() + ", top: " + view.getY() + ", right: "
+ (view.getX() + width) + ", bottom: "
+ (view.getY() + height));
L.e("left: " + (int) left + ", top: " + (int) top + ", right: "
+ (int) right + ", bottom: " + (int) bottom);
view.layout((int) left, (int) top, (int) right, (int) bottom);
}
L.e("onLayout");
/*
* final int count = getChildCount();
*
* for (int i = 0; i < count; i++) { final View child = getChildAt(i);
*
* int left = (int) child.getX(), // top = (int) child.getY(), // right
* = (int) child.getX() + child.getMeasuredWidth(), // bottom = (int)
* child.getY() + child.getMeasuredHeight();
*
* L.e("left: " + left + ", top: " + top + ", right: " + right +
* ", bottom: " + bottom); child.layout(left, top, right, bottom); }
*/
}
@Override
public void onThumbnailLoaded(FunkThumbnail thumbnail) {
/*
* String out = ""; for (int i = 0; i < grid.length; i++) { for (int ii
* = 0; ii < grid[i].length; ii++) { out = out.concat(i + ", " + ii +
* ": " + grid[i][ii] + ", "); } }
*
* L.e(out);
*/
// small thumbnail placement logic
if (thumbnail instanceof SmallFunkThumbnail) {
small: for (int i = 0; i < grid.length; i++) {
int ii = 0;
do {
if (grid[i][ii] == false) {
thumbnail.getView().setX(widthUnit * i);
thumbnail.getView().setY(heightUnit * ii);
nails.add(thumbnail);
addView(thumbnail.getView(), fillLP);
grid[i][ii] = true;
break small;
} else if (ii == grid[i].length - 1) {
break;
}
} while (grid[i][ii++] == true);
if (i == grid.length - 1) {
break small;
}
}
// medium thumbnail placement logic
} else if (thumbnail instanceof MediumFunkThumbnail) {
medium: for (int i = 0; i < grid.length; i++) {
int ii = 0;
do {
if (i + 1 < grid.length && ii + 1 < grid[i].length
&& grid[i][ii] == false && grid[i + 1][ii] == false
&& grid[i][ii + 1] == false
&& grid[i + 1][i + 1] == false) {
thumbnail.getView().setX(widthUnit * i);
thumbnail.getView().setY(heightUnit * ii);
nails.add(thumbnail);
addView(thumbnail.getView(), fillLP);
grid[i][ii] = true;
grid[i + 1][ii] = true;
grid[i][ii + 1] = true;
grid[i + 1][ii + 1] = true;
break medium;
} else if (ii == grid[i].length - 1) {
break;
}
} while (grid[i][ii++] == true);
if (i == grid.length - 1) {
break medium;
}
}
// large thumbnail placement logic
} else if (thumbnail instanceof LargeFunkThumbnail) {
large: for (int i = 0; i < grid.length; i++) {
int ii = 0;
do {
if (i + 2 < grid.length && ii + 2 < grid[i].length
&& grid[i][ii] == false) {
thumbnail.getView().setX(widthUnit * i);
thumbnail.getView().setY(heightUnit * ii);
nails.add(thumbnail);
addView(thumbnail.getView(), fillLP);
grid[i][ii] = true;
grid[i + 1][ii] = true;
grid[i + 2][ii] = true;
grid[i][ii + 1] = true;
grid[i + 1][ii + 1] = true;
grid[i + 2][ii + 1] = true;
grid[i][ii + 2] = true;
grid[i + 1][ii + 2] = true;
grid[i + 2][ii + 2] = true;
break large;
} else if (ii == grid[i].length - 1) {
break;
}
} while (grid[i][ii++] == true);
if (i == grid.length - 1) {
break large;
}
}
} else {
throw new IllegalArgumentException(
"FunkThumbnail must be one of SmallFunkThumbnail,
MediumFunkThumbnail, or LargeFunkThumbnail");
}
L.e("size: " + thumbnail.getSize().toString());
L.e("onThumbnailLoaded");
}
@Override
public byte getNumRows() {
return numRows;
}
@Override
public byte getNumColumns() {
return numColumns;
}
public short getHeightUnit() {
return heightUnit;
}
public short getWidthUnit() {
return widthUnit;
}
} `

Remove escape sequences from parsed HTML

Remove escape sequences from parsed HTML

I'm using the Python mechanize module to submit a simple query to a
website, then break down the returned elements to get the data I need. But
I can't seem to correctly handle the escape sequences that get passed
back. here's my code:
def stripEscape(string): #credit goes to sarnold
delete = ""
i=1
while (i<0x20):
delete += chr(i)
i += 1
t = string.translate(None, delete)
return t
def getHTML(metID):
br = mechanize.Browser()
response = br.open("http://urlgoeshere.com")
br.form = list(br.forms())[0]
br["PROMPT12"] = metID
response = br.submit()
htmlText = response.read()
parseHTML(htmlText)
def parseHTML(htmlText):
htmlText.index('table')
arr = re.split(r'(</?\w{2}>)',htmlText) # everything after
background tag
logFile = open('Log.txt','wb')
for ele in arr:
ele = stripEscape(ele)
if ele == '':
arr.remove(ele)
for ele in arr:
logFile.write("ele: "+ele+'\n')
if re.match('/table', ele):
logFile.write("END OF TABLE FOUND")
logFile.write("\nele: "+ele+'\n')
break
# other element filters
The stripEscape function works just fine when I pass it arguments via
interactive shell, but one of the array elements from the website is
\r\n</table>\r\n, and this "escapes" my filters. It gets written to my log
file like so:
ele: normal
ele: stuff
ele:
</table>
ele: more
ele: normal
The closing table tag bypassing the filter causes all my other filters to
go haywire. Is there a better way of handling escape sequences?

How to center TextBox element inside Grid

How to center TextBox element inside Grid

I'm developing WP8 app for my own needs and want it to have small live
tile with text. Since small tile cannot display text, I'm generating
appropriate image with needed text. Here is the code:
WriteableBitmap bmpSmall = new WriteableBitmap(159, 159);
var grid = new Grid();
grid.Width = bmpSmall.PixelWidth;
grid.Height = bmpSmall.PixelHeight;
var background = new Canvas();
background.Width = bmpSmall.PixelWidth;
background.Height = bmpSmall.PixelHeight;
SolidColorBrush backColor = new
SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
background.Background = backColor;
var textBlock = new TextBlock();
textBlock.Text = "qwerty";
textBlock.FontWeight = FontWeights.Bold;
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Center;
textBlock.FontSize = 28;
textBlock.Foreground = new SolidColorBrush(Colors.White);
grid.Children.Add(textBlock);
bmpSmall.Render(background, null);
bmpSmall.Render(grid, null);
bmpSmall.Invalidate();
using (IsolatedStorageFile isf =
IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream imageStream = new
IsolatedStorageFileStream("/Shared/ShellContent/smallTile.jpg",
System.IO.FileMode.Create, isf))
{
bmpSmall.SaveJpeg(imageStream, 159, 159, 0, 100);
}
}
ShellTile tile = ShellTile.ActiveTiles.First();
FlipTileData tileData = new FlipTileData();
tileData.SmallBackgroundImage = new
Uri(@"isostore:/Shared/ShellContent/smallTile.jpg", UriKind.Absolute);
tile.Update(tileData);
And result looks like:
http://s22.postimg.org/wori0zcg1/wp_ss_20130917_0001.png
As you see, text is aligned to top left corner. The question is "Why"?
Since I'd set textBlock.HorizontalAlignment and
textBlock.VerticalAlignment - I expect it in the center of the image. For
example the following XAML looks like you can expect and like I need:
<Grid Width="159" Height="159">
<Grid.Background>
<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
</Grid.Background>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
FontWeight="Bold" FontSize="28" Foreground="White">qwerty</TextBlock>
</Grid>
What did I miss? How can I center text?

Sunday, 15 September 2013

how to save application data when app goes to suspended mode

how to save application data when app goes to suspended mode

Is there a method to save the last application state in winrt and metro
apps. Onsuspending event helps to capture the app suspension. But how to
save its last state.

How to delete some rows in a file by using bash file?

How to delete some rows in a file by using bash file?

I want to delete some specific rows in a file. For example I have a file
containing these rows :
+1 1:-51.000000
+1 1:-47.000000
+1 1:-53.000000
+1 1:-48.000000
+1 1:-49.000000
+1 1:-42.000000
I want to delete the last 3 rows. How to do that in bash file? So far I
just know about 'sed' deleting lines, not rows.
Thank you for the answer

how to execute F9 for excel spreadseet in python

how to execute F9 for excel spreadseet in python

I'm using python to execute some external command on excel.
x1 = win32com.client.DispatchEx("Excel.Application")
wb = x1.workbooks.open(filePath+fileName);
x1.run("fileName!someMacro")
results+=[(wb.ActiveSheet.Cells(4,8).Value,
wb.ActiveSheet.Cells(4,16).Value)];
And it is working, runs the macro and I can collect the results. I have
another sheet - there in Formulas bar I have a button "Calculate Now" / F9
I would like to run F9 and collect results from that sheet. But the
following code doesn't seems to executes F9 - thus I'm getting all the
results with same values.
results = []
sheet2=wb.Sheets(5).Select
for i in range(n):
wb.Sheets(5).Calculate
results+=[(wb.Sheets(5).Cells(12,11).Value,
wb.Sheets(5).Cells(12,10).Value];
How can I execute the F9 for excel from python?

jQuery - Parallax Scrolling

jQuery - Parallax Scrolling

I want a parallax scrolling effect on my site but I can't get it to work..
Like: http://abduzeedo.com/
This is what I've got and I've already searched the web and found
tutorials but without any success: http://jsfiddle.net/4WsCZ/
$("#container").scroll(function () {
var s = $("#container").scrollTop();
$("#container #page-head").css("-webkit-transform","translateY(" +
(s/2) + "px)");
}
Thanks!

Sort column by occurrence in shell

Sort column by occurrence in shell

I'm new to unix. I'm trying to sort a file by the occurence of values in a
certain column in it:
IP - - Website
1.1.1 - - stackoverflow.com
0.0.5 - - a.com
1.1.1 - - google.com
expected result:
IP - - Website
1.1.1 - - stackoverflow.com
0.0.5 - - a.com
I tried different methods: - sort -k1 | uniq -c (didn't work because uniq
checks the whole line, including websites) - using sort -u -t- -k1
Can anyone help me, or at least tell me what I'm doing wrong please?

Changing object dimensions for different resolutions

Changing object dimensions for different resolutions

I am a complete newbie at objective-C and have somehow managed to hack my
way through making my first app. Well almost.
I built my app 4inch/retina and am now making it backward compatible to
3.5. I spent a couple hours messing with constraints and couldn't seem to
get it working. My question - is it possible to change an object
parameters according to phone resolution with code? Something like...
if(3.5 inch screen){
object.height= 250px;
object.x= 250px;
object.y= 250px;
}else{
object.height= 350px;
object.x= 250px;
object.y= 250px;
}
Thanks for any help.

unfortunately app has stopped working, first android app, using google maps api

unfortunately app has stopped working, first android app, using google
maps api

Making my first android app, just followed the instructions on the google
maps api version 2 official site step by step. Did everything as it said.
Including getting the api key, making emulators, installing all the SDK,
google services etc.. Not sure why I get an error message as soon as I
attempt to start the application: "Unfortunately googleMaps has stopped
working".
Can't say the error output is very helpful to me as this is my first
android app. I could use some guidance.
Here is LogCat output:
09-15 11:26:39.755: I/Process(959): Sending signal. PID: 959 SIG: 9
09-15 11:26:42.685: D/AndroidRuntime(972): Shutting down VM
09-15 11:26:42.685: W/dalvikvm(972): threadid=1: thread exiting with
uncaught exception (group=0x409961f8)
09-15 11:26:42.715: E/AndroidRuntime(972): FATAL EXCEPTION: main
09-15 11:26:42.715: E/AndroidRuntime(972): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.example.googlemaps/com.example.googlemaps.MapActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating
class fragment
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.ActivityThread.access$600(ActivityThread.java:122)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.os.Looper.loop(Looper.java:137)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.ActivityThread.main(ActivityThread.java:4340)
09-15 11:26:42.715: E/AndroidRuntime(972): at
java.lang.reflect.Method.invokeNative(Native Method)
09-15 11:26:42.715: E/AndroidRuntime(972): at
java.lang.reflect.Method.invoke(Method.java:511)
09-15 11:26:42.715: E/AndroidRuntime(972): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-15 11:26:42.715: E/AndroidRuntime(972): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-15 11:26:42.715: E/AndroidRuntime(972): at
dalvik.system.NativeStart.main(Native Method)
09-15 11:26:42.715: E/AndroidRuntime(972): Caused by:
android.view.InflateException: Binary XML file line #2: Error inflating
class fragment
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-15 11:26:42.715: E/AndroidRuntime(972): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Activity.setContentView(Activity.java:1835)
09-15 11:26:42.715: E/AndroidRuntime(972): at
com.example.googlemaps.MapActivity.onCreate(MapActivity.java:12)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Activity.performCreate(Activity.java:4465)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-15 11:26:42.715: E/AndroidRuntime(972): ... 11 more
09-15 11:26:42.715: E/AndroidRuntime(972): Caused by:
android.app.Fragment$InstantiationException: Unable to instantiate
fragment com.google.android.gms.maps.MapFragment: make sure class name
exists, is public, and has an empty constructor that is public
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Fragment.instantiate(Fragment.java:572)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Fragment.instantiate(Fragment.java:540)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Activity.onCreateView(Activity.java:4235)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
09-15 11:26:42.715: E/AndroidRuntime(972): ... 20 more
09-15 11:26:42.715: E/AndroidRuntime(972): Caused by:
java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
09-15 11:26:42.715: E/AndroidRuntime(972): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-15 11:26:42.715: E/AndroidRuntime(972): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-15 11:26:42.715: E/AndroidRuntime(972): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-15 11:26:42.715: E/AndroidRuntime(972): at
android.app.Fragment.instantiate(Fragment.java:562)
09-15 11:26:42.715: E/AndroidRuntime(972): ... 23 more
09-15 11:31:42.784: I/Process(972): Sending signal. PID: 972 SIG: 9
Didn't really add much to the application except for changing the manifest
file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<!-- google api so we can use google maps -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key"/>
<!-- Internet access to download maps -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- Network state access to check if we can access internet -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- save catched maps to external storage -->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- google services -->
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<!-- location based on WIFI/GSM -->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<!-- location based on GPS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.googlemaps.MapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Saturday, 14 September 2013

Passing value in IEnumerable method

Passing value in IEnumerable method

net mvc c#.I have created model for view.I can receive all rows from the
table but when I try to pass value in method which is return list is not
working Here is my code
Controller class
public ActionResult Index()
{
TechnicianDBO db = new TechnicianDBO();
List<Technician> technicians = db.technicians.ToList();
return View(technicians);
}
[HttpPost]
public ActionResult Index(int Postcode)
{
TechnicianDBO db = new TechnicianDBO();
List<Technician> technicians =
db.Jobtechnicians(Postcode).ToList();
return View(technicians);
}
Db class
public IEnumerable<Technician> Jobtechnicians(int postcode)
{
string connectionString =
ConfigurationManager.ConnectionStrings["testConnect"].ConnectionString;
List<Technician> Jobtechnicians = new List<Technician>();
using (SqlConnection con = new
SqlConnection(connectionString))
{
SqlCommand cmd = new
SqlCommand("spGetTechnicianByPostcode", con);
con.Open();
SqlParameter paramId = new SqlParameter();
paramId.ParameterName = "@postcode";
paramId.Value =postcode;
cmd.Parameters.Add(paramId);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Technician technician = new Technician();
technician.Id = Convert.ToInt32(dr["techId"]);
// technician.Username =
dr["techUsername"].ToString();
technician.Firstname =
dr["techFirstname"].ToString();
technician.Lastname = dr["techLastname"].ToString();
technician.LandlineNo = dr["landlineNo"].ToString();
technician.MobileNo = dr["mobileNo"].ToString();
technician.Address1 = dr["address1"].ToString();
technician.Address2 = dr["address2"].ToString();
technician.Postcode =
Convert.ToInt32(dr["postcode"]);
technician.Email = dr["email"].ToString();
technician.Fax = dr["fax"].ToString();
technician.Profession =
Convert.ToInt32(dr["ProfessionId"]);
Jobtechnicians.Add(technician);
}
return Jobtechnicians;
}

storing stuff into a variable size structure

storing stuff into a variable size structure

I have a follow up question to something I asked a couple of days ago. I
have a variable length structure,
typedef struct
{
int *positions1, *positions2;
char *symbols, *args;
char (*names)[100];
} agentInfo;
int initStruct(agentInfo *ai, int x)
{
ai-> positions1 = malloc(x * sizeof(int));
ai-> positions2 = malloc(x * sizeof(int));
ai-> symbols = malloc(x);
ai-> args = malloc(x);
ai-> names = malloc(100 * x);
return 0;
}
Which I call and create an instance of (mystruct). And I want to read
stuff into it each array so that I can access it using an index. I was
thinking something like,
int a, b;
char c, d;
char e[100];
char buffer[100];
while(fgets(buffer, 100, fp) != NULL){
if(sscanf(buffer, "%d %d %c %s %c", &a, &b, &c, e, &d))
mystruct -> positions1[i] = a;
mystruct -> positons2[i] = b;
mystruct -> symbols[i] = c;
strcpy((mystruct -> names[i]), e);
mystruct -> args[i] = d;
i++;
}
}
When I print a, b, c, d, e on each iteration, they appear correct. If I do,
printf("%d %d %c %s %c\n", (mystruct-> positions1[i]), (mystruct ->
positions2[i]),
(mystruct->symbols[i]), (mystruct -> names[i]), (mystruct -> args[i])
It doesn't seem to have read the values into my structure. What am I doing
wrong with my indexing?

Facebook API - Get list of unpublished and published posts of a page

Facebook API - Get list of unpublished and published posts of a page

I'm having a little bit of trouble getting a lists of posts of a page on
facebook...
I'm using this url to get the posts of the page
string.Format("{0}/posts, pageid)
But I cant take the unpublished posts.. It only gets the published
posts... Is there any permission I have to use... or some other parameter?
I also tried like this
string.Format("{0}/posts?is_published=false", pageid)
... But no luck
Any help would be appreciated!

Multiplication on 32 bits using only 8 bit numbers

Multiplication on 32 bits using only 8 bit numbers

I saw this interview question online and can't find a good method other
than the usual subtractive methods. Any suggestions if this can be done
quicker using some bitshift of recursion or something similar ?

C implentation of Simon Plouffe's 1996 algorithm for computing pi fails

C implentation of Simon Plouffe's 1996 algorithm for computing pi fails

You can see the pi formula in the "approximations of pi" Wikipedia
article. I was attracted to the formula because it is compact and promises
efficient computation, plus it is specialized for base 10. The formula is
pi = -3 + SUM(n=0,oo): n*(2^n)*(n!)^2/(2*n)!
My C code is below. It seems very straight forward. It computes all of the
intermediate steps, but it completely fails to converge. What is the bug?
James Beauchamp jwbeauch@illinois.edu
#include <stdio.h>
#include <math.h>
#define sq(x) ((x)*(x))
int nfac(int);
int main()
{
double term, denom, sum;
double w, x, y, z, pi;
int n;
/* Plouffe's 1996 algorithm
(see http://en.wikipedia.org/wiki/Approximations_of_ð: */
sum = -3.;
for(n=1; n <= 11; n++)
{
printf("n= %d\n", n);
printf("n! = %.0f\n", w = nfac(n));
printf("(n!)^2 = %.0f\n", x = sq(w));
printf("2^n = %.0f\n", y = pow(2,n));
printf("(2*n)! = %.0f\n", z = nfac(2*n));
printf("n*2^n)*((n!)^2)/(2*n)! = %f\n", term = n*y*x/z);
printf("sum = %f\n\n", sum += term);
}
printf("pi = %.10f\n\n", pi = sum);
}
int nfac(int n)
{
int i, nn;
if(n==0) return 1;
nn = 1;
for(i=1; i<=n; i++)
nn= i*nn;
return nn;
}

Add jar to classpath using Maven without installing to repository

Add jar to classpath using Maven without installing to repository

I have a jar that has a specific naming and must not be altered because
native libraries are referring to it (part of a JNI). I can not install it
to a maven repository because of mavens naming convention. How can I add
this file to the classpath using maven configuration? It works by adding
the jar to the ".classpath" file of eclipse, but I want a maven solution
to this problem.
Thanks in advance!

Download a file using JQuery, ajax and c#

Download a file using JQuery, ajax and c#

I have tried many articles on net for downloading a text file using
JQuery, Ajax and C#. Most of them says you cannot download file using
ajax.
Here is my JQuery-Ajax code
$(document).on("click", "#imgDownload", function (event) {
$.ajax({
url: "/members/DownloadSelectedFile?SelectedUserName=" +
$("#AllowedFriends").find(":selected").text() +
"&SelectedFileName=" + $(this).siblings("span").eq(0).text(),
success: function () {
alert("Khushi");
}
});
});
Here is my C# code
public void DownloadSelectedFile(string SelectedUserName, string
SelectedFileName)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "Filename=" +
SelectedFileName + ".txt");
Response.TransmitFile(Server.MapPath("~/Users/" +
SelectedUserName + "/" + (string)Session["LoggedInUserName"] +
"/" + SelectedFileName + ".txt"));
Response.End();
}
So, what are the changes that I need to make to be able to download a text
file.

php find more similar description from my database not eact match

php find more similar description from my database not eact match

i have mysql classified database
i need to find more similar like more than 60% similar classified ads from
mysql database.
not exact match.
while( $type = mysql_fetch_assoc($result) ){
$node = new sqlNode();
$node->table = "tt_".$type['ID'];
$node->select = "ID, Title, Description, MemberID, PostDate ";
$node->where = " where online = '1'";
if(($categoryR = $mysql->select($node)) === false )
die($mysql->debugPrint());
// this part need to find more similar function
}
please help me

Friday, 13 September 2013

How to remove the space between paragraphs (p)

How to remove the space between paragraphs (p)

How can i remove spaces between paragraphs in html.
<p class="first">This is a smalple demo</p>
<p class="second">This is second demo</p>
Please suggest. Thanks in advance.

Responsive background image resolution

Responsive background image resolution

I'm having issues with background image scales and responsive design.
I have a simple header image background along with a content image
background. The header image is supposed to merge seamlessly into the
content. Both images have fine grain textures, so they need to be the same
scale at all times.
The header background is in an <img> tag, while the content is a
background-image, as it needs to utilise the repeat-y functionality for an
unknown amount of content...
But you can see the grain difference between the scaled inline image, and
the background:

I'm aware of the background-size attribute, but this is not backwards
compatible, and I'm unsure if it caters responsively.
My CSS:
#header{
max-width:700px;
width:100%;
margin:0 auto;
}
#header img{
max-width:700px;
width:100%;
}
#content{
max-width:700px;
width:100%;
height:600px; // <-- for testing with no content
margin:0 auto;
background-image:url('../imgs/bg-main.jpg');
background-repeat:repeat-y;
}
The Relevant HTML:
<section id="header">
<img src="lib/imgs/bg-top.jpg"/>
</section>
<section id="content">
<!-- content goes here !-->
</section>
Any help on a fix or some options would be great.

I am new to php. I need to set up a php environment in Windows 7 and execute a .php file. Could you provide me detailed steps to do this?

I am new to php. I need to set up a php environment in Windows 7 and
execute a .php file. Could you provide me detailed steps to do this?

I am new to php. I need to set up a php environment in Windows 7 (32bit
machine) and execute a .php file. Could you provide me detailed steps to
do this?

Matlab - Help using text scan, how to ignore comments and header columns?

Matlab - Help using text scan, how to ignore comments and header columns?

I need help using text scan. I am trying to read data that has the
following format:
# ---------------------------------- WARNING
----------------------------------------
# The data you have obtained from this automated U.S. Geological Survey
database
# have not received Director's approval and as such are provisional and
subject to
# revision. The data are released on the condition that neither the USGS
nor the
# United States Government may be held liable for any damages resulting
from its use.
# Additional info: http://nwis.waterdata.usgs.gov/nwis/help/?provisional
#
# File-format description:
http://nwis.waterdata.usgs.gov/nwis/?tab_delimited_format_info
# Automated-retrieval info:
http://nwis.waterdata.usgs.gov/nwis/?automated_retrieval_info
#
# Contact: gs-w_support_nwisweb@usgs.gov
# retrieved: 2013-09-13 13:10:29 EDT (nadww01)
#
# Data for the following 1 site(s) are contained in this file
# USGS 08067074 CWA Canal at Thompson Rd nr Baytown, TX
#
-----------------------------------------------------------------------------------
#
# Data provided for site 08067074
# DD parameter Description
# 01 00010 Temperature, water, degrees Celsius
# 02 00095 Specific conductance, water, unfiltered, microsiemens
per centimeter at 25 degrees Celsius
#
# Data-value qualification codes included in this output:
# A Approved for publication -- Processing and review completed.
# P Provisional data subject to revision.
#
agency_cd site_no datetime tz_cd 01_00010 01_00010_cd 02_00095
02_00095_cd
5s 15s 20d 6s 14n 10s 14n 10s
USGS 08067074 2013-01-05 00:00 CST 10.3 A 391 A
USGS 08067074 2013-01-05 00:15 CST 10.3 A 391 A
USGS 08067074 2013-01-05 00:30 CST 10.3 A 391 A
USGS 08067074 2013-01-05 00:45 CST 10.3 A 391 A
USGS 08067074 2013-01-05 01:00 CST 10.3 A 391 A
USGS 08067074 2013-01-05 01:15 CST 10.3 A 391 A
USGS 08067074 2013-01-05 01:30 CST 10.3 A 391 A
USGS 08067074 2013-01-05 01:45 CST 10.3 A 391 A
USGS 08067074 2013-01-05 02:00 CST 10.3 A 391 A
USGS 08067074 2013-01-05 02:15 CST 10.3 A 391 A
USGS 08067074 2013-01-05 02:30 CST 10.3 A 391 A
USGS 08067074 2013-01-05 02:45 CST 10.2 A 391 A
USGS 08067074 2013-01-05 03:00 CST 10.2 A 391 A
USGS 08067074 2013-01-05 03:15 CST 10.2 A 391 A
USGS 08067074 2013-01-05 03:30 CST 10.2 A 391 A
USGS 08067074 2013-01-05 03:45 CST 10.2 A 391 A
USGS 08067074 2013-01-05 04:00 CST 10.2 A 391 A
USGS 08067074 2013-01-05 04:15 CST 10.2 A 392 A
USGS 08067074 2013-01-05 04:30 CST 10.2 A 391 A
USGS 08067074 2013-01-05 04:45 CST 10.2 A 391 A
USGS 08067074 2013-01-05 05:00 CST 10.2 A 391 A
USGS 08067074 2013-01-05 05:15 CST 10.2 A 391 A
USGS 08067074 2013-01-05 05:30 CST 10.2 A 391 A
USGS 08067074 2013-01-05 05:45 CST 10.2 A 391 A
USGS 08067074 2013-01-05 06:00 CST 10.2 A 391 A
USGS 08067074 2013-01-05 06:15 CST 10.1 A 391 A
USGS 08067074 2013-01-05 06:30 CST 10.1 A 391 A
USGS 08067074 2013-01-05 06:45 CST 10.1 A 391 A
USGS 08067074 2013-01-05 07:00 CST 10.1 A 391 A
USGS 08067074 2013-01-05 07:15 CST 10.1 A 391 A
USGS 08067074 2013-01-05 07:30 CST 10.1 A 390 A
USGS 08067074 2013-01-05 07:45 CST 10.0 A 391 A
USGS 08067074 2013-01-05 08:00 CST 10.0 A 390 A
USGS 08067074 2013-01-05 08:15 CST 10.0 A 391 A
USGS 08067074 2013-01-05 08:30 CST 10.0 A 391 A
USGS 08067074 2013-01-05 08:45 CST 10.0 A 390 A
USGS 08067074 2013-01-05 09:00 CST 10.0 A 390 A
USGS 08067074 2013-01-05 09:15 CST 10 A 390 A
USGS 08067074 2013-01-05 09:30 CST 10 A 390 A
USGS 08067074 2013-01-05 09:45 CST 10 A 390 A
USGS 08067074 2013-01-05 10:00 CST 10 A 390 A
USGS 08067074 2013-01-05 10:15 CST 10 A 390 A
USGS 08067074 2013-01-05 10:30 CST 10 A 390 A
USGS 08067074 2013-01-05 10:45 CST 10 A 390 A
USGS 08067074 2013-01-05 11:00 CST 10 A 390 A
USGS 08067074 2013-01-05 11:15 CST 10 A 390 A
USGS 08067074 2013-01-05 11:30 CST 10 A 390 A
USGS 08067074 2013-01-05 11:45 CST 10 A 389 A
USGS 08067074 2013-01-05 12:00 CST 10 A 389 A
USGS 08067074 2013-01-05 12:15 CST 10 A 389 A
USGS 08067074 2013-01-05 12:30 CST 10 A 389 A
USGS 08067074 2013-01-05 12:45 CST 10 A 389 A
USGS 08067074 2013-01-05 13:00 CST 10 A 389 A
USGS 08067074 2013-01-05 13:15 CST 10 A 389 A
USGS 08067074 2013-01-05 13:30 CST 10 A 389 A
The only two data entries I am concerned with are "Specific conductance",
and "date". (columns 3 and 7 respectively)
I was able to do this on a consistant basis using the following code:
%%
% Collect conductance data
filename = 'conductivityData_Temp_File';
%%
% Determine length of data file
fid = fopen('conductivityData_Temp_File','r');
fseek(fid, 0, 'eof');
chunksize = ftell(fid);
fseek(fid, 0, 'bof');
ch = fread(fid, chunksize, '*uchar');
N = sum(ch == sprintf('\n')); % number of lines
fclose(fid)
%%
% Read conductivity data
fileconductID = fopen(filename);
waterConductivityData = textscan(fileconductID, '%s %d %s %s %f %s %f %s',
N, 'delimiter', '\t', 'EmptyValue', 0, 'headerlines', 27);
fclose(fileconductID);
However, I found out that you can simply use 'commentstyle' to ignore the
comments. This is important because I am reading multiple files and
occasionally I will encounter a file that does not have exactly 27 comment
rows. That will make my program throw an error.
Can someone tell me how I can adjust my textscan code to ignore the
comment rows and skip the two header rows?
(if you want to downlad an example tab deliminated file to work with use
this link: here
Thank you!

how to display adds on specicfic pages using addmob phonegap plugin

how to display adds on specicfic pages using addmob phonegap plugin

I'm developing an application in phonegap ,I want to display adds on
specific pages,but using
https://github.com/sainttex/PhoneGap-Android-Native-AdMob plugin adds are
displayed in every page

Thursday, 12 September 2013

is adcolony 2.0.1.33 compatible with ios7?

is adcolony 2.0.1.33 compatible with ios7?

I know that AdColony has a new sdk2.2 which was tested on ios7. However,
our app is currently using 2.0.1.33 which is the sdk that doesn't use the
udid. Basically, it's the sdk prior to 2.2 What will happen if i don't
upgrade my sdk2.2? Will it still be compatible with ios7? Will my app
experience problems? I'm not really sure about the consequences of not
updating. But right now when i'm testing on an ios7 device and i'm still
able to get ads from AdColony.

Javascript pull data from string?

Javascript pull data from string?

I have a long URL that contains some data that I need to pull. I am able
to get the end of the URL by doing this:
var data = window.location.hash;
When I do alert(data); I receive a long string like this:
#access_token=0u2389ruq892hqjru3h289r3u892ru3892r32235423&token_type=Bearer&expires_in=3600
note in the example the access token is not valid, just random numbers I
input for example purpose
Now that I have that long string stored in a variable, how can I parse out
just the access token value, so everything in between the first '=' and
'&. So this is what I need out of the string:
0u2389ruq892hqjru3h289r3u892ru3892r32235423
I was reading up on php explode, and others java script specific stuff
like strip but couldn't get them to function as needed. Thanks guys.

Passing the result of a function to a directive

Passing the result of a function to a directive

I have a list in controllerA - controllerA also has a function that
determines if an item in that list has been imported. I'd like to pass
this boolean into each of the listed objects' directives (so controllerB -
the controller for each of the objects - can see if its object has been
imported), but it's not working as I'd hoped.
I have the following (simplified) in my HTML:
<tbody>
<tr objectpane object="object"
objectIsImported="objectIsImported(object)"></tr>
</tbody>
This view is paired to an ng-controller (controllerA) that has the
following function defined:
$scope.objectIsImported = function(object) {
alert("never gets hit");
};
objectpane directive has this:
aoo.directive('objectpane', ['$log', function ($log) {
return {
restrict: 'A',
templateUrl: '/App/objectmanager/objectpane.html',
scope: {
object: "=",
objectIsImported: "="
},
controller: 'ObjectPaneController'
};
}]);
Within ObjectPaneController (ControllerB) I have this:
$scope.alreadyImported = $scope.objectIsImported; // from scope in directive
The problem is that the $scope.objectIsImported from controllerA is not
getting hit, ever. What am I doing wrong?