Thursday, 3 October 2013

Starting Glassfish without Sudo

Starting Glassfish without Sudo

I am currently having a problem starting Glassfish inside Eclipse on OS X.
It just hangs whilst trying to start the domain.
I think the problem may lie with the permissions of Glassfish - When I use
the 'start-domain domain1' command even in terminal, I must use 'sudo'
otherwise I get a 'permissions denied' error. If I use 'sudo', then the
server starts successfully from terminal.
I think this error may be carrying over into Eclipse - that is, the server
is trying to start but is timing out because Eclipse is not starting the
server with the correct permissions etc.
Is there any way to start the server via Eclipse by giving it root
permissions? Or another solution, is there any way to change the Glassfish
permissions so that it can be started without the 'sudo' command?
Thanks.

Wednesday, 2 October 2013

Navbar issue in Bootstrap 3.0

Navbar issue in Bootstrap 3.0

I want to create a collapsable, floating navbar to the right hand side of
the Jumbotron in my page. I am using Bootstrap 3.0.
My navbar collapses but the site name disappears when the navbar
collapses. Also the navbar is pinned to the top of my screen rather than
on the right hand side. What am I doing wrong? Thanks for the help.
<section>
<div class="navbar">
<nav class="navbar navbar-inverse" role="navigation">
<a class="navbar-brand" href="index.html">DD Portfolio</a>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</section>
<div class="jumbotron">
<div class="container">
<h1>Who Am I?</h1>
<p>I am a student and content writer</p>
<p><a href="#" class="btn btn-primary btn-large">Learn
More</a></p>
</div>
</div>
</div>

Change Base Url CodeIgniter and Ionauth

Change Base Url CodeIgniter and Ionauth

This is probably a really simple question but I am entirely new to
codeigniter. I am using ionauth for a secure account system but I would
like to change the url path, simply changing the class name is not
working, it simply gives me a 404 whenever I try access it. I am trying to
change the /auth/ location to /account/ but when I try it by just renaming
class Auth extends CI_Controller { to class Account extends CI_Controller
{ it does not work as expected.
Any suggestions are greatly appreciated, Again I am new to this so please
go easy it's probably a simple fix and me not know code igniter very well.
Thanks, Simon

return code of 256 from python

return code of 256 from python

This is a reposted question from raspberrypi.stackexchange.com. While I am
trying to get something to work on python on the raspberry pi, since it
doesn't involve any pi-specific things, it was suggested by someone I post
here instead. Original post is here.



I am trying to make a web ui to change the date in the rapsberry pi, but I
keep getting a return code of 256.
Currently what I have goes like this:
web page -> submits an ajax request to a python script python checks what
type of command (a time/date command in this case) and pieces together a
string looking like:
sudo date --set="20130901 20:10"
and stores it in a variable commandString. Then python goes:
os.system(commandString)
and the return value is passed all the way up to the web ui where it is
printed out.
I also currently return the commandString value to the web ui too to
verify it and it looks okay.
The problem is that every time I test, I keep getting back 256 as the
error return code. The date on the raspberry pi of course doesn't change
as I manually check it before and after.
However, if I manually go in to python on the raspberry pi and try:
commandString = 'sudo date --set="20130901 20:10"'
os.system(commandString)
It works with no issues. If I try it without sudo then I get a return
value of 256 as well, so I thought maybe it was a permissions issue with
my original script. I tried this link to check my script's permissions and
it seems to be okay? (os.geteuid() is 0)
If it matters, I am using lighttpd and fastcgi to run python from a web
ui. My lighttpd config is currently:
fastcgi.server = (
".py" => (
"python-fcgi" => (
"socket" => "/tmp/fastcgi.python.socket",
"bin-path" => "/var/www/command.py",
"check-local" => "disable",
"max-procs" => 1)
)
)
Any ideas on what I'm missing?



On the original post, it was also suggested I try something like:
echo <password> | sudo -S date --set="20130829 02:02
While it's probably not a good idea to put in my root password like that,
I tried it and got the same result: it works when doing in the
terminal/shell and within the python interpreter, but not via the web ui
to python.

Tuesday, 1 October 2013

How to pixelate an image with canvas and javascript

How to pixelate an image with canvas and javascript

I've been experimenting a bit with the canvas element and was curious how
to pull off an effect. I've somewhat got what I'm looking for from a
collection of tutorials and demos, but I need some assistance getting the
rest of the way there. What I'm looking for is to pixelate an image on
mouseover, then refocus/un-pixelate it on mouseout. You can see a good
example of the effect at http://www.cropp.com/ when mousing over the
blocks that are below the main carousel.
Here is a link to a fiddle I started. The fiddle won't work because you
can't use cross domain images (womp womp), but you can still see my code
thus far. When mousing over my canvas object I'm able to pixelate the
image, but it's kind of backwards to what I'm attempting to get. Any help
or advice would be greatly appreciated.
var pixelation = 40,
fps = 120,
timeInterval = 1000 / fps,
canvas = document.getElementById('photo'),
context = canvas.getContext('2d'),
imgObj = new Image();
imgObj.src = 'images/me.jpg';
imgObj.onload = function () {
context.drawImage(imgObj, 0, 0);
};
canvas.addEventListener('mouseover', function() {
var interval = setInterval(function () {
context.drawImage(imgObj, 0, 0);
if (pixelation < 1) {
clearInterval(interval);
pixelation = 40;
} else {
pixelate(context, canvas.width, canvas.height, 0, 0);
}
}, timeInterval);
});
function pixelate(context, srcWidth, srcHeight, xPos, yPos) {
var sourceX = xPos,
sourceY = yPos,
imageData = context.getImageData(sourceX, sourceY, srcWidth,
srcHeight),
data = imageData.data;
for (var y = 0; y < srcHeight; y += pixelation) {
for (var x = 0; x < srcWidth; x += pixelation) {
var red = data[((srcWidth * y) + x) * 4],
green = data[((srcWidth * y) + x) * 4 + 1],
blue = data[((srcWidth * y) + x) * 4 + 2];
for (var n = 0; n < pixelation; n++) {
for (var m = 0; m < pixelation; m++) {
if (x + m < srcWidth) {
data[((srcWidth * (y + n)) + (x + m)) * 4] = red;
data[((srcWidth * (y + n)) + (x + m)) * 4 + 1] =
green;
data[((srcWidth * (y + n)) + (x + m)) * 4 + 2] =
blue;
}
}
}
}
}
// overwrite original image
context.putImageData(imageData, xPos, yPos);
pixelation -= 1;
}

Creating a long precision number in C#

Creating a long precision number in C#

I have a bunch of code written by someone else for a statistics package,
like so:
float myValue = 0.0f;
That makes myValue a single point precision number. Is there a way to make
it go to five decimal places?
Is this the correct way:
float myValue = 0.00000f;

Mosaic and using VLC with axis cameras

Mosaic and using VLC with axis cameras

this is my code for the mosaic
new channel1 broadcast enabled
setup channel1 input
rtsp://root:pass@192.168.1.76/axis-media/media.amp?resolution=cif&codec=h264
setup channel1 option network-caching=600
setup channel1 output #mosaic-bridge{id=1,width=352,height=288}
new channel2 broadcast enabled
setup channel2 input
rtsp://root:pass@192.168.1.76/axis-media/media.amp?resolution=cif&codec=h264
setup channel2 option network-caching=600
setup channel2 output #mosaic-bridge{id=2,width=352,height=288}
new channel3 broadcast enabled
setup channel3 input
rtsp://root:pass@192.168.1.76/axis-media/media.amp?resolution=cif&codec=h264
setup channel3 option network-caching=600
setup channel3 output #mosaic-bridge{id=3,width=352,height=288}
new channel4 broadcast enabled
setup channel4 input
rtsp://root:pass@192.168.1.76/axis-media/media.amp?resolution=cif&codec=h264
setup channel4 option network-caching=600
setup channel4 output #mosaic-bridge{id=4,width=352,height=288}
new test broadcast enabled
setup test input "file://home/background.jpg"
setup test option image-duration=-1
setup test option image-fps=0
setup test output
#transcode{sfilter=mosaic,vcodec=mp4a,vb=8500,fps=25}:display
control channel1 play
control channel2 play
control channel3 play
control channel4 play
control test play
However when using the following vlc command in the terminal to run the
mosaic_config.conf
vlc --vlm-conf /etc/mosaic_config.conf
I get the following error
VLC media player 2.0.8 Twoflower (revision 2.0.8a-0-g68cf50b)
Fontconfig warning: FcPattern object size does not accept value "0"
[0x9c91188] main libvlc: Running vlc with the default interface. Use
'cvlc' to use vlc
without interface.
[0x9d244d8] [Media: test] main input error: open of
`file://home/background.jpg' failed
[0x9d244d8] [Media: test] main input error: Your input can't be opened
[0x9d244d8] [Media: test] main input error: VLC is unable to open the MRL
'file://home
/background.jpg'. Check the log for details.
"sni-qt/4246" WARN 21:35:23.637 void
StatusNotifierItemFactory::connectToSnw() Invalid
interface to SNW_SERVICE
[0xb5036a30] [Media: channel3] main decoder error: cannot create
packetizer output (mp4a)
[0xb4e02818] [Media: channel4] main decoder error: cannot create
packetizer output (mp4a)
[0x9cbb8b8] [Media: channel2] main decoder error: cannot create packetizer
output (mp4a)
[0xb500a6b8] [Media: channel1] main decoder error: cannot create
packetizer output (mp4a)
[0x9d1d228] [Media: channel3] main input error: ES_OUT_RESET_PCR called
[0x9d20bd8] [Media: channel4] main input error: ES_OUT_RESET_PCR called
[0x9d20bd8] [Media: channel4] main input error: ES_OUT_RESET_PCR called
[0x9d2a268] [Media: channel2] main input error: ES_OUT_RESET_PCR called
[0x9d1d228] [Media: channel3] main input error: ES_OUT_RESET_PCR called
[0x9d2a268] [Media: channel2] main input error: ES_OUT_RESET_PCR called
Anyone got anyway to resolve this or maybe i should be asking this in the
videolan forum

When is a convex polygon inscribable?

When is a convex polygon inscribable?

Defining the diameter of a convex polygon as the maximum possible distance
between all pairs of vertices, can we conclude that the convex polygon is
inscribable (i.e has all its sides as chords of a circle) if the diameter
isn't the diameter of the minimum bounding circle, in which case the
circumscribed circle is the minimum bounding circle?