Saturday, 31 August 2013

Firebase AngularFire nested collections

Firebase AngularFire nested collections

I have data of the form
{
"events" : {
"-J2MoqWZnkcRCSugBfj3" : {
"title" : "Some other event",
"ratings" : {
"-J2N4QYSk4y2BYznkGvk" : {
"value" : 0
},
"-J2N3rfUPlPNP45RUZYx" : {
"value" : 0
}
}
},
"-J2MpSSN8oldDqd-0jrr" : {
"title" : "New event"
}
}
}
The events collection has a nested collection called ratings. I wish to
manage both the collections through angularFireCollection, but I am not
sure how do I get around to do it.
My Angular controller and template are defined as:
APP.controller('EventsCtrl', function ($scope, angularFireCollection) {
$scope.events = angularFireCollection(<reference to events collection>);
});
<ul class="list-group">
<li class="list-group-item" ng-controller="IndividualEventCtrl"
ng-repeat="event in events">
<div><strong class="lead">{{event.title}}</strong></div>
<div ng-include="event.template"></div>
<rating value="rate" max="max" readonly="isReadonly"></rating>
</li>
</ul>
Controller for each event:
APP.controller('IndividualEventCtrl', function ($scope, FirebaseService,
angularFireCollection) {
$scope.max = 5;
$scope.rate = 0;
$scope.isReadonly = false;
var ratingsRef =
FirebaseService.events().child($scope.event.$id).child("ratings");
$scope.rating = ratingsRef.push({value:0});
});
The last two lines where I create the ratingsRef and add a new rating to
the collection cause my controller to go in some sort of an infinite loop.
I'd really like to know what is the best way to manage nested collections
so that I can add/update the elements in those collections.
Thanks.

c# Invalid Cast Exception when using an interface as generic type (Unity)

c# Invalid Cast Exception when using an interface as generic type (Unity)

So I am not sure if this is a C# generics issue I don't understand or
whether it has something to do with the Unity compiler not being able to
handle it. I come from C++ and am slightly experienced with c# but not
with generics.
So onto the issue: I have a generic class called TurnOrderQueue. in short
it is a custom Queue that orders things based on some values that are
passed in with it. (It is in a namespace called TurnOrderQueueNS)
I have an empty(for now) interface called IActor which is to represent
things that can take actions in a turn based game.
Finally I have a TurnOrderManager that handles everything with turn order
and owns a TurnOrderQueue.
When I attempt to instantiate the TurnOrderQueue using IActor as the type
I get an invalid cast exception public
TurnOrderQueueNS.TurnOrderQueue<IActor> TurnOrder = new
TurnOrderQueueNS.TurnOrderQueue<IActor>();
The Exception I get at runtime is: InvalidCastException: Cannot cast from
source type to destination type.
TurnOrderQueueNS.TurnOrderQueue`1[IActor]..ctor () TurnManager..ctor ()
Can you not use Interfaces as the type with generics in C# or am i missing
something?

imagestring align to the right

imagestring align to the right

I want to align the watermark of an image to the right side.
This is what i have so far but its aligned to the left...
// Add Watermark featuring Website Name
$home_url = home_url();
$search = array('http://','https://');
$site_name = str_ireplace($search, '', $home_url);
$watermark = imagecreatetruecolor($width, $height+15);
// Determine color of watermark's background
if (is_array($Meme_Generator_Data) &&
array_key_exists('watermark_background',$Meme_Generator_Data)
&& strlen($Meme_Generator_Data['watermark_background']) ==
7) {
$wm_bg =
$this->convert_color(substr($Meme_Generator_Data['watermark_background'],
1));
$bg_color = imagecolorallocate($watermark, $wm_bg[0],
$wm_bg[1], $wm_bg[2]);
imagefill($watermark, 0, 0, $bg_color);
}
// Determine color of watermark's text
if (is_array($Meme_Generator_Data) &&
array_key_exists('watermark_text',$Meme_Generator_Data) &&
strlen($Meme_Generator_Data['watermark_text']) == 7) {
$wm_text =
$this->convert_color(substr($Meme_Generator_Data['watermark_text'],
1));
$text_color = imagecolorallocate($watermark,
$wm_text[0], $wm_text[1], $wm_text[2]);
} else {
$text_color = imagecolorallocate($watermark, 255, 255,
255);
}
imagestring($watermark, 5, 5, $height, $site_name,
$text_color);
imagecopy($watermark, $img, 0, 0, 0, 0, $width, $height);
$img = $watermark;

Delete Function from List

Delete Function from List

I'm having trouble implementing the delete function, any help would be
appreciated. I have a list called memberlist that stores the persons name
and number. I have everything working except the delete function. Any help
would be appreciated.
public class Person
{
private string name;
private string phoneNumber;
public string Name
{
set { name = value; }
get { return name; }
}
public string PhoneNumber
{
set { phoneNumber = value; }
get { return phoneNumber; }
}
public void PrintInfo()
{
Console.WriteLine();
Console.WriteLine(" Name: {0}", name);
Console.WriteLine(" Phone Number: {0}", phoneNumber);
Console.WriteLine();
}
public void SaveASCII(ref StreamWriter output)
{
output.WriteLine(name);
output.WriteLine(phoneNumber);
}
public void LoadASCII(ref StreamReader input)
{
name = input.ReadLine();
phoneNumber = input.ReadLine();
}
}
public class membershipList
{
public Person[] ML = null;
public void AddMember(Person p)
{
if (ML == null)
{
ML = new Person[1];
ML[0] = p;
}
else
{
Person[] temp = ML;
ML = new Person[temp.Length + 1];
for (int i = 0; i < temp.Length; ++i)
{
ML[i] = new Person();
ML[i] = temp[i];
}
ML[temp.Length] = new Person();
ML[temp.Length] = p;
temp = null;
}
}
public void DeleteMember(string name)
{
if (ML == null)
{
Console.WriteLine(name + " had not been added before.");
}
else
{
int memberIndex = ML.MembershipList().FindIndex(p => p.Name ==
name);
if (memberIndex = -1)
{
Console.WriteLine(name + " had not been added before.");
return;
}
List<Person> tmp = new List<Person>(ML);
tmp.RemoveAt(memberIndex);
ML = tmp.ToArray();
}
}
public void PrintAll()
{
if (ML != null)
foreach (Person pers in ML)
pers.PrintInfo();
else Console.WriteLine("Then list is empty");
}
public void Search(string p)
{
if (ML != null)
{
foreach (Person pers in ML)
{
if (pers.Name.ToLower().CompareTo(p.ToLower()) == 0)
{
Console.WriteLine("1 Record Found:");
pers.PrintInfo();
break;
}
}
Console.WriteLine("Record not found.");
}
else Console.WriteLine("Then list is empty.");
}
public void ReadASCIIFile()
{
StreamReader input = new StreamReader("memberlist.dat"); ;
try
{
int num = Convert.ToInt32(input.ReadLine());
ML = new Person[num];
for (int i = 0; i < num; ++i)
{
ML[i] = new Person();
ML[i].LoadASCII(ref input);
}
input.Close();
}
catch (FormatException e)
{
Console.WriteLine(e.Message);
input.Close();
}
}
public void SaveASCIIFile()
{
StreamWriter output = new StreamWriter("memberlist.dat");
output.WriteLine(ML.Length);
foreach (Person pers in ML)
{
pers.SaveASCII(ref output);
}
output.Close();
}
}
class Program
{
static void Main(string[] args)
{
membershipList ML = new membershipList();
ML.ReadASCIIFile();
string option;
do
{
// Console.Clear();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("MemberShip List MENU");
Console.WriteLine();
Console.WriteLine(" a. Add");
Console.WriteLine(" b. Seach");
Console.WriteLine(" c. Delete");
Console.WriteLine(" d. Print All");
Console.WriteLine(" e. Exit");
Console.WriteLine();
Console.Write("option: ");
option = Console.ReadLine().ToLower();
switch (option)
{
case "a":
Person np = new Person();
Console.Write("Enter Name: ");
np.Name = Console.ReadLine();
Console.Write("Enter PhoneNumber: ");
np.PhoneNumber = Console.ReadLine();
ML.AddMember(np);
break;
case "b":
Console.Write("Enter Name: ");
string name = Console.ReadLine();
ML.Search(name);
break;
case "c":
Console.Write("Enter Name to be Deleted:");
ML.DeleteMember(name);
break;
case "d":
ML.PrintAll();
break;
case "e":
ML.SaveASCIIFile();
Console.WriteLine("BYE...... ");
break;
default:
Console.WriteLine("Invalid Option");
break;
}
} while (option.ToLower() != "d");
}
}

Project Euler #18 in Haskell

Project Euler #18 in Haskell

I am currently learning functional programming and Haskell coming from a
python background. To help me learn, I decided to do some project euler
problems (http://projecteuler.net/problem=18). Currently I am on #18.
Starting with this string,
"75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23"
I managed to convert it into a nested array using this function:
map (\x -> map (\y -> read y :: Int) (words x)) (lines a)
That function outputs this:
[[75],[95,64],[17,47,82],[18,35,87,10],[20,4,82,47,65],[19,1,23,75,3,34],[88,2,77,73,7,63,67],[99,65,4,28,6,16,70,92],[41,41,26,56,83,40,80,70,33],[41,48,72,33,47,32,37,16,94,29],[53,71,44,65,25,43,91,52,97,51,14],[70,11,33,28,77,73,17,78,39,68,17,57],[91,71,52,38,17,14,91,43,58,50,27,29,48],[63,66,4,68,89,53,67,30,73,16,69,87,40,31],[4,62,98,27,23,9,70,98,73,93,38,53,60,4,23]]
Is there a way to write that conversion function without the lambdas and
make it more readable?
How would I convert this nested array to a tree structure defined like so:
data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show, Read, Eq)
Or would it just be easier to leave it as an array and solve it from there?

How can one set elements on top of the Applicationbar (or have the layout be aware of it)?

How can one set elements on top of the Applicationbar (or have the layout
be aware of it)?

To clarify, I want to have my ApplicationBar resting on top of my
LayoutRoot grid. The desired effect would be like this:
<StackPanel>
<Grid x:Name="LayoutRoot" Background="Transparent">
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<StackPanel />
Of course, the above code doesn't work because the must be in the root tag
of the page, but I do wish it did.
Does anyone know a way that I can create this effect? It doesn't have to
be a perfect solution, just something that replicates it and will work on
any resolution.
Thank you for reading and for your help

Construct VB code based on a string containing the statements

Construct VB code based on a string containing the statements

What I'm trying to do this is writing a simple parser for the following
case in .NET that given a string like this :
If ([1] >=60 : 50; If ([1]>=50 : 40; If ([1]>=40 : 30; If([1]>=30 :
20;0))))
should return one like this :
If ([1] >=60) Then
Return 50
ElseIf ([1]>=50) Then
Return 40
ElseIf ([1]>=40 ) Then
Return 30
ElseIf([1]>=30 ) Then
Return 20
Else
Return 0
End If
Using split to divide the string into multiples strings first by ";" and
then by ":" and with the use of For Each, I have managed to do it(though
not in a very elegant way) That's why I wonder if there wouldn't be a more
elaborate way of doing this, using Regex perhaps
One last thing, do you think there is a quick way to get all the numbers
enclosed in square brackets(variable IDs) without duplicates .
For instance , given a string like :
If ([3] = 'M' AND [4] = 'S' AND [5]>=1000 : 20/100 * [5]; 500)
I get, let's say , an array of integers containing (3,4,5)
What's the best way to implement such things in .NET?? Any help would be
greatly appreciated
P.S. I couldn't find a good title for the question.

Factory Girl and nested attributes validation error

Factory Girl and nested attributes validation error

I have a model Company which accepts nested attributes for Recruiters
model. I need to have validation in my Company model that at least one
recruiter was created during Company creation.
class Company < ActiveRecord::Base
has_many :recruiters, dependent: :destroy, inverse_of: :company
accepts_nested_attributes_for :recruiters, reject_if: ->(attributes) {
attributes[:name].blank? || attributes[:email].blank? },
allow_destroy: true
validate { check_recruiters_number } # this validates recruiters number
private
def recruiters_count_valid?
recruiters.reject(&:marked_for_destruction?).count >=
RECRUITERS_COUNT_MIN
end
def check_recruiters_number
unless recruiters_count_valid?
errors.add(:base, :recruiters_too_short, count:
RECRUITERS_COUNT_MIN)
end
end
end
Validation works as expected but after adding this validation I have a
problem with FactoryGirl. My factory for company looks like this:
FactoryGirl.define do
factory :company do
association :industry
association :user
available_disclosures 15
city 'Berlin'
country 'Germany'
ignore do
recruiters_count 2
end
after(:build) do |company, evaluator|
FactoryGirl.create_list(:recruiter,
evaluator.recruiters_count, company: company)
end
before(:create) do |company, evaluator|
FactoryGirl.create_list(:recruiter,
evaluator.recruiters_count, company: company)
end
end
end
In tests, when I do
company = create(:company)
I get validation error:
ActiveRecord::RecordInvalid:
Validation failed: Company has to have at least one recruiter
When I first build company and then save it, the test passes:
company = build(:company)
company = save
Of course, I don't want to change all my tests this way to make them work.
How can I set up my factory to create associated model during creation
Company model?

Friday, 30 August 2013

Displaying point values on Matlab figure

Displaying point values on Matlab figure

I have a variable with 10 points in it. Say X. When I use plot(X,'.-r') it
plots the 10 points using '-' connection and the points are displayed
using '.'. I would like to see the values of the points on the figure.
When I use DataCursor I am able to just see the value of one point at a
time. I would like to have something which would allow me to see all the
values of the points in the figure. Can some one please help. I tried
using text annotation which gave me nothing. probably I didn't give proper
syntax Thanks

Thursday, 29 August 2013

Reading excel file using OLEDB Data Provider

Reading excel file using OLEDB Data Provider

I am using OLEDB Data Provider to read excel file, but the problem is that
in excel sheet some cloumn has an invalid value for example instead of
number string is there, When I read this invalid value I get an empty
string instead of actual value.

for above screenshot when read value john i get empty string.
So is there any way to read this invalid value?
Any help will be appreciated.

PHP list() assign - trim before assign or any other function?

PHP list() assign - trim before assign or any other function?

I am using a list() assign in PHP so I could assign array values to more
variables at once.
Thing is I need to trim() the array inputs before - of course you could do
a foreach on array before or after that - but is there a way to cast trim
as a some kind of assignment filter - or at least trim the array inline
(no external function or foreach)?
The question is more like general - can you add some filter function to a
list() assigment?

Wednesday, 28 August 2013

data.table doesn't modify by reference if the object is freshly loaded from file?

data.table doesn't modify by reference if the object is freshly loaded
from file?

It seems that if a data.table is freshly loaded, a function containing :=
wouldn't modify by reference.
Can anyone reproduce it? Is it a bug?
test<-function(data){data[,ppp:=1]}
a<-data.table(x=1:2)
save(a,file="ttt")
load("ttt")
test(a) # show ppp
a # doesn't have ppp
b<-data.table(x=1:2)
test(b) # show ppp
b # has ppp

Select statement where the text is equal to an underscore

Select statement where the text is equal to an underscore

In Oracle SQL is there any way to build a statement where the text is or
is not equal to an underscore?

Creating a circular mask for my graph

Creating a circular mask for my graph

I'm plotting a square image, but since my camera views out of a circular
construction, I want the image to look circular as well. So to do this, I
just wanted to create a mask for the image (basically create a matrix, and
multiply my data by the mask, so if I want to retain my image I am
multiplying by one, and if I want that part of the image to go to black, I
multiply by 0).
I'm not sure the best way to make a matrix that will represent a circular
opening though. I just want every element within the circle to be a "1"
and every element outside the circle to be a "0" so I can color my image
accordingly. I was thinking of doing a for loop, but I was hoping there
was a faster way to do it. So...all I need is:
A matrix that is 1280x720
I need a circle that has a diameter of 720, centered in the middle of the
1280x720 matrix (what I mean by this is all elements corresponding to
being within the circle have a "1" and all other elements have a "0"
My attempt
mask = zeros(1280,720)
for i = 1:1280
for j = 1:720
if i + j > 640 && i + j < 1360
mask(i,j) = 1;
end
end
end
Well the above obviously doesn't work, I need to look at it a little
better to form a better equation for determing when to add a 1 =P but
ideally I would like to not use a for loop
Thanks, let me know if anything is unclear!

How to bind an array to select by Angularjs?

How to bind an array to select by Angularjs?

I am trying to bind an object array to a select drop down, but I cannot
figure out how to make this work, can someone suggest how to make this
work?
HTML:
<div ng-app ng-controller="DisplayCtrl">
<select ng-model="eventName" ng-options="name.event for name in eventNames">
<option value="">Select Event</option>
</select>
<p>Currently selected: {{eventName.description}} </p></div>
AngularJS:
function DisplayCtrl($scope) {
$scope.eventNames = [{
event: "Function A",
description: "Gaming"
}, {
event: "Function B",
description: "Basketball"
}, {
event: "Function C",
description: "Football"
}, {
event: "Function D",
description: "Dancing"
}];
$scope.eventName = $scope.eventNames[1].event;}
http://jsfiddle.net/ztABS/

Tuesday, 27 August 2013

pagination doesn't work on title page wordpress

pagination doesn't work on title page wordpress

Help! My site is http://www.modernfuture.net I just started uploading it &
pagination doesn't work! Displays 404 message when you click next. I don't
know what to do! Any help would be great! Thanks!

GUI Cross-Platform in Windows, Linux, iOS, Android

GUI Cross-Platform in Windows, Linux, iOS, Android

I am developing a UI that should work in different operating systems. The
plan is to support Windows, Linux, iOS and Android.
Which GUI tool i can use to develop GUI's that supports all the 4 above
mentioned operating systems?
Thanks in advance.

Fadein not working on opera and firefox

Fadein not working on opera and firefox

Using jquery 1.9.1 for displaying tabs, the selected tab displays a div
(1, 2, 3 or 4) that displays the fadein effect. The effect appears to work
on the latest versions of ie, chrome and even safari, but not on firefox
and opera. I've checked examples of code containing @-moz-keyframes and
@-o-keyframes and it appears that the code is correct (I'm sure that
something is wrong somewhere though).
See #tab1, #tab2, #tab3, #tab4
Thanks
The live example can be seen and tested at:
http://jsfiddle.net/guisasso/6f6PY/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us">
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
// Wait until the DOM has loaded before querying the document
$(document).ready(function(){
$('ul.tabs').each(function(){
// For each set of tabs, we want to keep track of
// which tab is active and it's associated content
var $active, $content, $links = $(this).find('a');
// If the location.hash matches one of the links, use that
as the active tab.
// If no match is found, use the first link as the initial
active tab.
$active = $($links.filter('[href="'+location.hash+'"]')[0]
|| $links[0]);
$active.addClass('active');
$content = $($active.attr('href'));
// Hide the remaining content
$links.not($active).each(function () {
$($(this).attr('href')).hide();
});
// Bind the click event handler
$(this).on('click', 'a', function(e){
// Make the old tab inactive.
$active.removeClass('active');
$content.hide();
// Update the variables with the new link and content
$active = $(this);
$content = $($(this).attr('href'));
// Make the tab active.
$active.addClass('active');
$content.show();
// Prevent the anchor's default click action
e.preventDefault();
});
});
});
</script>
<style type="text/css">
.tabs {
border-bottom:3px #f2f2f2 solid;
padding-left:0px;
}
.tabs li {
list-style:none;
display:inline;
color:#08c;
}
.tabs a {
padding:5px 20px 5px 20px;
display:inline-block;
background:#ffffff;
text-decoration:none;
color:#08c;
top: 3px;
font-size: 22px;
line-height: 140%;
padding-top: 10px;
background: #ffffff;
box-sizing: border-box;
position: relative;
border-radius: 4px 4px 0 0;
margin-bottom:3px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.tabs a.active {
background: #ffffff;
border-bottom:3px orange solid;
color:#000000;
top:0px;
}
.tabs a:hover {
background: #f2f2f2;
top: 0px;
border-bottom:3px orange solid;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
-ms-transition: all .2s ease-in-out;
}
#tab1, #tab2, #tab3, #tab4 {
animation: fadein 1s;
-moz-animation: fadein 1s; /* Firefox */
-webkit-animation: fadein 1s; /* Safari and Chrome */
-o-animation: fadein 1s; /* Opera */
}
@keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
@-moz-keyframes fadein { /* Firefox */
from {
opacity:0;
}
to {
opacity:1;
}
}
@-webkit-keyframes fadein { /* Safari and Chrome */
from {
opacity:0;
}
to {
opacity:1;
}
}
@-o-keyframes fadein { /* Opera */
from {
opacity:0;
}
to {
opacity: 1;
}
}
</style>
</head>
<body>
<ul class="tabs">
<li><a href='#tab1'>Aluminum</a></li>
<li><a href='#tab2'>Copper</a></li>
<li><a href='#tab3'>Lead Coated Copper</a></li>
<li><a href='#tab4'>Ornamental</a></li>
</ul>
<div id="tab1">111111111111111 11111111111111111 1111111111111111111
1111111111111</div>
<div id="tab2">222222222222222 22222222222222222 2222222222222222222
2222222222222</div>
<div id="tab3">333333333333333 33333333333333333 3333333333333333333
3333333333333</div>
<div id="tab4">444444444444444 44444444444444444 4444444444444444444
4444444444444</div>
</body>
</html>

How can I check for first letter(s) in string in Ruby?

How can I check for first letter(s) in string in Ruby?

I'm writing test file, but I can't get it pass second test, here:
if word.start_with?('a','e','i','o','u')
word << "ay"
else
word << "bay"
end
Is start_with? the right method to do the job?
describe "#translate" do
it "translates a word beginning with a vowel" do
s = translate("apple")
s.should == "appleay"
end
it "translates a word beginning with a consonant" do
s = translate("banana")
s.should == "ananabay"
end
it "translates a word beginning with two consonants" do
s = translate("cherry")
s.should == "errychay"
end
end

Firefox javax.faces.ViewState issue

Firefox javax.faces.ViewState issue

i am using jsf 2.1 on tomcat 7
the page renders javax.faces.ViewState as expected, when hitting f5 the
server sends a new id for javax.faces.ViewState, which is correct. But
firefox keeps the old value in the hidden input:
<input type="hidden" value="2442695108697186454:-4079620282104128276"
id="javax.faces.ViewState" name="javax.faces.ViewState">
The result is that the old view-scoped bean is taken on ajax requests.
only when i hit strg+f5 firefox takes the new value from server. I think
i's a feature of firefox (i often see when reloading a page with a form
firefox keeps my inputs).
any ideas how to deal with that?

Monday, 26 August 2013

Android app oauth 2 authentication can application account login for non-twitter users

Android app oauth 2 authentication can application account login for
non-twitter users

I am implements oauth 2 authentication for twitter api 1.1 in my android
app so users can login with twitter and I can retrieve tweets with their
account. For folks who opt not to log in. Can I use my twitter application
account to login and retrieve tweets. I believe their is a daily limit to
this account, but I intend to catch this error and show to the user.

Query in source changes page

Query in source changes page

I would like how to use query criteria in source changes page. For
example, how to query changes done for a determined author, or done in a
period of time (e.g. 2013-01-01 until 2013-01-15). I am working in ScalaFX
Project, where source page is
https://code.google.com/p/scalafx/source/list. I tried to make a search
using a url such as
https://code.google.com/p/scalafx/source/list?author=rafael.afonso.
However, it did not work as imagined. Is there some documentation for
this?
Thanks,
Rafael Afonso

symfony2 : kernel.debug is always false

symfony2 : kernel.debug is always false

I use assetic to bundle css and js files together and I've noticed that
even in debug mode they are bundled. That should only happen when
kernel.debug is false.
So I've tried the following:
original :
assetic:
debug: %kernel.debug%
force to false:
assetic:
debug: false
force to true :
assetic:
debug: true
When I force to false, files are bundled. When I force true, files are not
bundled. When I live %kernel.debug%, files are bundled.
Why is %kernel.debug% equals to false even though in app_dev I've set it
to true:
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);

How to backup/restore standalone heroku postgres database?

How to backup/restore standalone heroku postgres database?

Is there a Heroku way to backup / restore a standalone postgres database
at https://postgres.heroku.com/ apart from using pg_dump / pg_restore ?
I can create a dump using
pg_dump --verbose -F c -b -h hostname -p port -U username -f "backup.dump"
-d database_name
and restore it using
pg_restore --verbose --clean --no-acl --no-owner -h hostname -p port -U
username -d database_name "backup.dump"

Having jquery script working in unusual way

Having jquery script working in unusual way

I was using the following script on my webpage , it is a script to change
the image to another image when mouse is on the image and change it back
to the previous one when mouse leaves the image
$('#awake_skull').mouseleave(function(){
$(this).children().remove();
$('<img src="images/u169.png" style="float:left;">').appendTo($(this));
});
$('#awake_skull').mouseenter(function(){
$(this).empty();
$('<img src="images/u169-r.png" style="float:left;">').appendTo($(this));
});
but instead of this , my script changes the image when mouse is on it ,
but not change back to original one when mouse leave the . I am having no
error messages in chrome console as well . please point out where i went
wrong Thanks in advance

\tkzDrawLine doesn't print node

\tkzDrawLine doesn't print node

I've made this drawing, but I can manage to place the node $m$ to the
line. Any suggestions? Thanks in advance

\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{center}
\begin{tikzpicture}
\coordinate (M) at (0,0) ;
\coordinate (A) at (canvas polar cs:angle=90,radius=3cm);
\coordinate (B) at (canvas polar cs:angle=20,radius=3cm) ;
\draw (M) circle (3cm);
\draw (A) -- (B) ;
\tkzDefMidPoint(A,B) \tkzGetPoint{P}
\draw (A) -- (P) node[midway,sloped] {$// $} ;
\draw (P) -- (B) node[midway,sloped] {$// $} ;
\tkzDrawLine[add = 0.5 and 1.6](P,M) node {m}; %PROBLEM%
\tkzDrawPoints(A,B,M);
\tkzLabelPoints(B,M);
\tkzLabelPoints[above](A);
\end{tikzpicture}
\end{center}
\end{document}

mouseOver in Highcharts

mouseOver in Highcharts

I have a chart. There is no mouseOver event in chart options, but I need
to get mouse coordinates when I move cursor. For example, I want to show
coordinates on xAxis and yAxis. Is it possible?

Sunday, 25 August 2013

Counting number of strings that contain substring matching Regular Expression

Counting number of strings that contain substring matching Regular Expression

I have regular expression R. And I want to find the F(n) is the number of
strings of length n that strings that contain substring matching Regular
Expression. Suppose the alphabet-size is M.
We can apply the generating function to compute the number of strings of
length n that matches R, but i can't find any answer for the above
question.
Do you have any idea on that?

Disabling laptop monitor on boot?

Disabling laptop monitor on boot?

I'm using a laptop with Ubuntu (no graphical desktop) to do all of my
work. The resolution is awful, at 1024x576 or something similar. So I just
close my laptop lid and plug it into an external monitor - but the
external one never seems to stretch out to its full size.
The reason for this is that the laptop monitor is always enabled - even
when the laptop lid is closed. As a result, the external monitor never
assumes the full size, and any time I set GRUB to use a resolution higher
than 1024x576, the external screen ignores it.
Is there any way to disable the laptop screen in GRUB, or to specify which
screen I want as the primary one? I've tried Google, and absolutely
nothing comes up.
(The computer is a Lenovo S10e, if it helps at all.)

Incompatible library version: libtk8.6.dylib requires ... when installing R package

Incompatible library version: libtk8.6.dylib requires ... when installing
R package

I'm trying to install the R package ggplot2, though the error that I am
getting seems unrelated to that specific package. I am running on Mac OSX
10.6.8. The error message is at the bottom of this message. What happened
was:
I opened up R and typed install.packages("ggplot2"). After typing this, an
X11 window opened saying that I should update to the latest version of
X11. I clicked through and updated X11. The install went through fine,
ending with a big green check mark.
Then, I thought, "let me check if R is up to date as well, as the ggplot
documentation suggests updating R before installing ggplot". So I opened
up R, and clicked "check for updates". Lo and behold! an update appeared.
I downloaded and installed the update. The install went through fine,
ending with a big green check mark.
When I opened R, I typed install.packages("ggplot2") and I got the message
below:



> install.packages("ggplot2");
--- Please select a CRAN mirror for use in this session ---
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so,
10):
Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/local/lib/libtk8.6.dylib
Reason: Incompatible library version: libtk8.6.dylib requires version
14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0



Your help is greatly appreciated. Thanks.

Android: ImageView getting negative width

Android: ImageView getting negative width

I'm not sure why, but when I set the width of an imageview (called c), it
returns a negative value. ivPiano is also an imageView.
ViewTreeObserver vto = llPiano.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
llPiano.getViewTreeObserver().removeGlobalOnLayoutListener(this);
c.setTop(ivPiano.getTop());
c.setLeft(ivPiano.getLeft());
ShowMessageLong(ivPiano.getWidth());
c.getLayoutParams().width = ivPiano.getWidth();
c.getLayoutParams().height= ivPiano.getHeight();
c.bringToFront();
ShowMessageLong(c.getWidth());
}
});
ShowMessageLong() just creates and shows a toast. The first time
(ivPiano's width) shows 1200, then second one (c's width) returns -22. Any
ideas why? Thanks in advance!!

PayPal OAuth: 400 Error even after specifying Host

PayPal OAuth: 400 Error even after specifying Host

I'm doing this one in golang, and I've been up just about the entire night
trying to get it to work. My latest frustration is that I'm getting a 400
error despite the numerous headers I've dropped into my request.
29 req.SetBasicAuth(app.id, app.secret)
30 req.Header.Set("Host", "www.sandbox.paypal.com")
31 req.Header.Set("Accept", "application/json")
32 req.Header.Set("Accept-Language", "en_US")
33 req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
34 req.Header.Set("Connection", "close")
I have auth set up, and every header I could think to add. I've pored over
the documentation and have tried the poke it to see if it works approach
as well. Heres the information I've been passing in the body
`{"grant_type": "client_credentials", "content-type":
"application/x-www-form-urlencoded"}`
If you need some more of the code just tell me. But I'm not super sure
it'll be a whole lot of good. I wanted to make the post as general as
possible as well.

Is there a simple way to delay a call for about 5 seconds?

Is there a simple way to delay a call for about 5 seconds?

I know I can use Thread.Sleep(5000), but it blocks the thread. I would
like to delay the call for 5 seconds, but not block the thread.

Saturday, 24 August 2013

could not hyperlink my video powerpoint 2007

could not hyperlink my video powerpoint 2007

I have a short movie in wmv format and tried to hyperlink in powerpoint
presentation but when I create a link there is no action at all.
what is wrong with it?
azam

Postfix/Dovecot Mail server with multiple domains and SSL

Postfix/Dovecot Mail server with multiple domains and SSL

On my mail setup I'm currently using self signed certificate generated for
server hostname.
And I'm curious is there some kind of SSL certificate that shared hosting
providers use for multiple domains mail and how are they setting them up?

Working with files in MonoGame and Android

Working with files in MonoGame and Android

So I made a game in XNA, and to get scores from a file I do something like
this...
private void GetScore()
{
if (File.Exists(scoreFilename))
{
using (StreamReader sr = new StreamReader(scoreFilename))
{
hiScore = Convert.ToInt16(sr.ReadLine());
}
}
else
{
FileStream fs = File.Create(scoreFilename);
fs.Close();
using (StreamWriter sw = new StreamWriter(scoreFilename))
{
sw.Write("0");
}
hiScore = 0;
}
}
This works on Windows, but how would I do this for Android?

how to split fields after reading the file in R

how to split fields after reading the file in R

I have a file with this format in each line:
f1,f2,f3,a1,a2,a3,...,an
Here, f1, f2, and f3 are the fixed fields separated by ,, but f4 is the
whole a1,a2,...,an where n can vary.
How can I read this into R and conveniently store those variable-length a1
to an?
Thank you.

Allowing custom CSS

Allowing custom CSS

I want to allow my users to insert their custom CSS into their websites.
The custom CSS file will be served to the customers website only. I will
host the CSS myself and I'm thinking of serving it through a PHP script
and doing the filtering there.
What should I pay attention to while doing this?
I should filter things, what exactly should not be included in the CSS file?
Thank you

use ffmpeg api to convert audio files. crash on avcodec_encode_audio2

use ffmpeg api to convert audio files. crash on avcodec_encode_audio2

From the examples I got the basic idea of this code. However I am not
sure, what I am missing, as muxing.c demuxing.c and decoding_encoding.c
all use different approaches.
The process of converting an audio file to another file should go roughly
like this: inputfile -demux-> audiostream -read-> inPackets
-decode2frames-> frames -encode2packets-> outPackets -write-> audiostream
-mux-> outputfile
However I found the following comment in demuxing.c: /* Write the raw
audio data samples of the first plane. This works
* fine for packed formats (e.g. AV_SAMPLE_FMT_S16). However,
* most audio decoders output planar audio, which uses a separate
* plane of audio samples for each channel (e.g. AV_SAMPLE_FMT_S16P).
* In other words, this code will write only the first audio channel
* in these cases.
* You should use libswresample or libavfilter to convert the frame
* to packed data. */
My questions about this are:
Can I expect a frame that was retrieved by calling one of the decoder
functions, f.e. avcodec_decode_audio4 to hold suitable values to directly
put it into an encoder or is the resampling step mentioned in the comment
mandatory?
Am I taking the right approach? ffmpeg is very asymmetric, i.e. if there
is a function open_file_for_input there might not be a function
open_file_for_output. Also there are different versions of many functions
(avcodec_decode_audio[1-4]) and different naming schemes, so it's very
hard to tell, if the general approach is right, or actually an ugly
mixture of techniques that where used at different version bumps of
ffmpeg.
ffmpeg uses a lot of specific terms, like 'planar sampling' or 'packed
format' and I am having a hard time, finding definitions for these terms.
Is it possible to write working code, without deep knowledge of audio?
Here is my code so far that right now crashes at avcodec_encode_audio2 and
I don't know why.
int Java_com_fscz_ffmpeg_Audio_convert(JNIEnv * env, jobject this, jstring
jformat, jstring jcodec, jstring jsource, jstring jdest) {
jboolean isCopy;
jclass configClass = (*env)->FindClass(env, "com.fscz.ffmpeg.Config");
jfieldID fid = (*env)->GetStaticFieldID(env, configClass,
"ffmpeg_logging", "I");
logging = (*env)->GetStaticIntField(env, configClass, fid);
/// open input
const char* sourceFile = (*env)->GetStringUTFChars(env, jsource, &isCopy);
AVFormatContext* pInputCtx;
AVStream* pInputStream;
open_input(sourceFile, &pInputCtx, &pInputStream);
// open output
const char* destFile = (*env)->GetStringUTFChars(env, jdest, &isCopy);
const char* cformat = (*env)->GetStringUTFChars(env, jformat, &isCopy);
const char* ccodec = (*env)->GetStringUTFChars(env, jcodec, &isCopy);
AVFormatContext* pOutputCtx;
AVOutputFormat* pOutputFmt;
AVStream* pOutputStream;
open_output(cformat, ccodec, destFile, &pOutputCtx, &pOutputFmt,
&pOutputStream);
/// decode/encode
error = avformat_write_header(pOutputCtx, NULL);
DIE_IF_LESS_ZERO(error, "error writing output stream header to file: %s,
error: %s"
, destFile, e2s(error));
AVFrame* frame = avcodec_alloc_frame();
DIE_IF_UNDEFINED(frame, "Could not allocate audio frame");
frame->pts = 0;
LOGI("allocate packet");
AVPacket pktIn;
AVPacket pktOut;
LOGI("done");
int got_frame, got_packet, len, frame_count = 0;
int64_t processed_time = 0, duration = pInputStream->duration;
while (av_read_frame(pInputCtx, &pktIn) >= 0) {
do {
len = avcodec_decode_audio4(pInputStream->codec, frame,
&got_frame, &pktIn);
DIE_IF_LESS_ZERO(len, "Error decoding frame: %s", e2s(len));
if (len < 0) break;
len = FFMIN(len, pktIn.size);
size_t unpadded_linesize = frame->nb_samples *
av_get_bytes_per_sample(frame->format);
LOGI("audio_frame n:%d nb_samples:%d pts:%s\n",
frame_count++, frame->nb_samples,
av_ts2timestr(frame->pts,
&(pInputStream->codec->time_base)));
if (got_frame) {
do {
av_init_packet(&pktOut);
pktOut.data = NULL;
pktOut.size = 0;
LOGI("encode frame");
DIE_IF_UNDEFINED(pOutputStream->codec, "no output
codec");
DIE_IF_UNDEFINED(frame->nb_samples, "no nb samples");
DIE_IF_UNDEFINED(pOutputStream->codec->internal, "no
internal");
LOGI("tests done");
len = avcodec_encode_audio2(pOutputStream->codec,
&pktOut, frame, &got_packet);
LOGI("encode done");
DIE_IF_LESS_ZERO(len, "Error (re)encoding frame: %s",
e2s(len));
} while (!got_packet);
// write packet;
LOGI("write packet");
/* Write the compressed frame to the media file. */
error = av_interleaved_write_frame(pOutputCtx, &pktOut);
DIE_IF_LESS_ZERO(error, "Error while writing audio frame:
%s", e2s(error));
av_free_packet(&pktOut);
}
pktIn.data += len;
pktIn.size -= len;
} while (pktIn.size > 0);
av_free_packet(&pktIn);
}
LOGI("write trailer");
av_write_trailer(pOutputCtx);
LOGI("end");
/// close resources
avcodec_free_frame(&frame);
avcodec_close(pInputStream->codec);
av_free(pInputStream->codec);
avcodec_close(pOutputStream->codec);
av_free(pOutputStream->codec);
avformat_close_input(&pInputCtx);
avformat_free_context(pOutputCtx);
return 0;
}

VMware for windows 2000

VMware for windows 2000

I'm planning to install windows 2000 server/advanced server with Sybaser
v11 on it onto a IBM x3650 M4. A total of 5 clients will be accessing
Sybase DB. Which VMware is recommended for this purpose ?
Please advise.
EDIT:
Just to add here I'm planning to have a minimum of 4 GB if for Windows
server 2000 and 8GB if for windows server 2000 advanced. I'm also willing
to do a Raid installation with 2tb of data.

Stop Sammy.js Loading On First Load

Stop Sammy.js Loading On First Load

I'm currently writing an SPA based on ASP.NET MVC4, knockout and Sammy.js.
I have setup the routes so that any standard HTTPRequest will return the
page and its content. but after first load the site loads all content
dynamically with the help of Sammy.js and its routing engine.
The problem i'm having is say i'm going to yourUrl.com/article/view/1.
this will display article 1 and then do any post load client side calls
necessary that don't affect SEO. Sammy.js will then do an async call to
get the content for /article/view/1. meaning that it pretty much loads the
content twice.
What i would like to achieve is to stop sammy.js from loading the url when
it is first created and run.
Thanks in advance!

Hosting multiple socks proxies on a single server

Hosting multiple socks proxies on a single server

I have multiple public IP addresses assigned to a single NIC in a Windows
Server 2012.
I want to be able to use each IP as a socks proxy server which has to be
accessible from other Internet users. How can I do this?
Can a single socks proxy server software be able to host multiple IPs? Do
I need to install a virtual server for each IP? What is the maximum IP
addresses I can use like this in a single server/NIC?
Say I have the following public IP addresses:
212.216.34.1
212.216.34.2
212.216.34.3
212.216.34.4
...
212.216.34.255
What I want is the internet user to be able to connect to internet over
any of the above IP addresses like:
212.216.34.1:1234
212.216.34.2:1234
212.216.34.3:1234
212.216.34.4:1234
etc.
Which socks proxy server do you suggest for this, WinGate?

Friday, 23 August 2013

website developed with codeigniter working well on localhost but internal server error 500 on live server

website developed with codeigniter working well on localhost but internal
server error 500 on live server

I am newbie to codeigniter i am developed a website from past few days.
The website working well on the localhost.but when i tested that that
website on live web server i gives out following error:
500 - Internal server error. There is a problem with the resource you are
looking for, and it cannot be displayed. i tried a lot of things like
.htaccess solutions available on different tutorials but not successful.
Then i tried my self debugging and found that when i comment out the model
loading line my index page get loaded without that data to have to get
from the db.But as soon as i remove comment from that line it again gives
me the same error. Then i checked my model i wont find any such
problem.Now i am not using any .htaccess. PHP version on server:5.2.17
codeigniter version:CodeIgniter_2.1.4
------------------------My code for controller
is---------------------------------
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php
class video extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->model('video_model');
$this->load->helper('html');
$this->load->library('session');
}
function index()
{
$this->session->unset_userdata('searchterm');
$data['latest_video']=$this->latest_video();
$data['uk_video']=$this->uk_video();
$data['hm_video']=$this->hm_video();
$this->load->view('index',$data);
}
function watch()
{
$v_type=$this->uri->segment(3);
$v_id=$this->uri->segment(4);
if($v_type && $v_id)
{
$data['multiple_videos']=$this->video_model->get_all_videos($v_type);
$data['single_video']=$this->video_model->get_single_video($v_id,$v_type);
$counter= $data['single_video'][0]['counter'];
$id= $data['single_video'][0]['v_id'];
$this->load->view('watch',$data);
$this->view_counter($id,$counter);
}
else
{
redirect('video','refresh');
}
}
function latest_video()
{
$data[]=$this->video_model->get_latest_video();
return $data;
}
function uk_video()
{
$data[]=$this->video_model->get_uttrakhand_video();
return $data;
}
function hm_video()
{
$data[]=$this->video_model->get_himachal_video();
return $data;
}
function result()
{
$this->load->view('search');
}
function view_counter($id,$counter)
{
$user_ip=$this->input->ip_address();
if(!$this->input->cookie($id))
{
$cookie=array('name'=>$id,'value'=>$user_ip,'expire'=>43200);
$this->input->set_cookie($cookie);
$counter++;
}
if($this->input->cookie($id))
{
if($this->input->cookie($id,TRUE)!=$user_ip)
{
$counter=+$counter;
}
}
$update=array('counter'=>$counter);
$this->db->where('v_id',$id);
$this->db->update('tblvideo',$update);
}
}
?>
------------------------My code for Model is---------------------------------
<?php class video_model extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
function get_latest_video()
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->order_by('v_time','DESC')->limit(3);
$query=$this->db->get();
return $latest_data=$query->result_array();
}
function get_uttrakhand_video()
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where('v_type','uk')->order_by('v_time','DESC')->limit(4,3);
$query=$this->db->get();
return $latest_data=$query->result_array();
}
function get_himachal_video()
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where('v_type','hm')->order_by('v_time','DESC')->limit(4,3);
$query=$this->db->get();
return $latest_data=$query->result_array();
}
function insert_data()
{
$data=array(
'v_title'=>$this->input->post('v_title'),
'v_name'=>$this->input->post('v_name'),
'v_description'=>$this->input->post('v_description'),
'v_tags'=>$this->input->post('v_tags'),
'v_duration'=>$this->input->post('v_duration'),
'v_type'=>$this->input->post('v_type')
);
return $this->db->insert('tblvideo',$data);
echo "data inserted";
}
function get_single_video($v_id,$v_type)
{
$cond=array('v_id'=>$v_id,'v_type'=>$v_type);
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where($cond);
$res=$this->db->get();
return $res->result_array();
}
function get_all_videos($v_type)
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where('v_type',$v_type)->order_by('v_time','DESC')->limit(30);
$query=$this->db->get();
return $query->result_array();
}
function get_video_list($limit,$offset)
{
$offset=intval($offset);
$this->db->select('v_id,v_name,v_title,v_description,v_tags,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->order_by('v_time','DESC')->limit($limit,$offset);
$query=$this->db->get();
return $query->result_array();
}
function get_total_number_videos()
{
$this->db->select('v_id,v_name,v_title,v_description,v_tags,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->order_by('v_time','DESC');
$query=$this->db->get();
return $query->num_rows();
}
function video_edit($v_id)
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_tags,v_type,v_duration,v_time')->from('tblvideo')->where('v_id',$v_id);
$query=$this->db->get();
return $query->result_array();
}
function video_update($id,$table,$form_data)
{
$this->db->where('v_id',$id);
return $response=$this->db->update($table,$form_data);
}
function delete($id,$table)
{
$this->db->delete($table, array('v_id' => $id));
}
function user_authentication($u_name,$pwd)
{
$array=array('username'=>$u_name,'password'=>$pwd,'type'=>'admin');
$this->db->select('username,password,id,type')->from('tblusers')->where($array);
$query=$this->db->get();
return $query->num_rows();
}
function user_data($u_name,$pwd)
{
$array=array('username'=>$u_name,'password'=>$pwd,'type'=>'admin');
$this->db->select('username,password,id,type')->from('tblusers')->where($array);
$query=$this->db->get();
return $query->result_array();
}
}?>
please take look at the problem thank you...

Types of polymorphism. More than one?

Types of polymorphism. More than one?

I am still in college and only remember about hearing about 1 type of
polymorphism when learning about Java; however, when I was in a C# class,
I just remember my professor talking about 4 types of polymorphism.
I am only aware of subclassing and defining specific behavior within more
specific classes, and being able to call those specific behaviors with a
single method in the base class because of an interface signature.
What are the other types, and are they of as big of an importance as the
only type we were taught above? Is that why there are not taught?

How to force styledText to break line in SWT

How to force styledText to break line in SWT

I'm trying to force the styledText breake the line but the effects are
hopeless. Instead, it extends size of my shell to width of biggest line.
I am trying to achieve that by creating class which extends shell
My constructor
super(SWT.ON_TOP | SWT.NO_TRIM | SWT.NO_FOCUS | SWT.NO_SCROLL);
FillLayout layout = new FillLayout();
layout.marginHeight = 1;
layout.marginWidth = 1;
setLayout(layout);
mForm = new ManagedForm(this);
FormToolkit toolkit = mForm.getToolkit();
body = mForm.getForm().getBody();
FillLayout layout2 = new FillLayout();
layout2.spacing = 2;
body.setLayout(layout2);
body = toolkit.createComposite(body, SWT.BORDER );
And when i want insert and show text. I am do this like that\ String text =
body = mForm.getToolkit().createComposite(parent, SWT.BORDER);
GridLayout l = new GridLayout();
l.marginHeight = 0;
l.marginWidth = 1;
body.setLayout(l);
StyledText bodyText = createDisabledText(body, text);
mForm.getForm().getContent().pack();
mForm.getForm().reflow(true);
pack();
setVisible(true);
and my create disabledText:
private StyledText createDisabledText(Composite parent, String value)
{
StyledText t = new StyledText(parent, SWT.SHADOW_NONE);
t.setText(value);
t.setEditable(false);
t.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
return t;
}
All is in class which extends shell. What i am doing wrong or is there
method like set maxSize?

Optimization of algebraic computation

Optimization of algebraic computation

Using mathematica, I can compute the mathematical representation of a
function that I then want to code in C++.
Say I get something like:
f=Log[2*x+3*y]+Sin[4*x+6*y]
It obviously makes sense in that case to do the computation:
temp=2*x+3*y
f=Log[temp]+Sin[2*temp]
Is there a way to get the expression that would reduce the execution time
/ number of operations / size of the expression or any good metric given a
more complex mathematical expression?

Phonegap parse xml response from API

Phonegap parse xml response from API

I looked many similar questions on this forum
Let me explain my requirement, My APIs returns xml response I need some
library/plugin that can accept my url and parse the response to json
format
Currently I have to write all different code for each api that I use, I
need some general functionality so that I can use same code for each
requirement

How can I counter rock armor?

How can I counter rock armor?

My brother and I sat down for some Magicka PVP 1v1, and was great and all
until he discovered rock armor, and that it can be combined with
resistances.
Seeing that I could no longer kill him, I cast my own rock armor with
resistances. We proceeded to pretty much have a stalemate for the rest of
the match.
Given that Magicka is a game that focuses on weaknesses and strengths,
what is the rock armor's weakness, and how can I counter it? Unfortunately
the self-cast armor wiki page does not have a lot of information on this
topic other than slows the caster down. However, the speed reduction is
marginal and not a huge contributing factor when it comes to combat.
For a specific example, say my rival uses this self-cast:

How could I take him out as quickly as possible?

Thursday, 22 August 2013

Compiling for STM32F4 Mac

Compiling for STM32F4 Mac

Good Day,
I just bought an STm32F4 and was able to load a sample .hex file located
inside: https://github.com/mechoid9/STM32F4
I had followed instructions from this site:
http://jeremyherbert.net/get/stm32f4_getting_started
And it explained how to code, but it failed to state how to actuaully
execute the makefile. I ran it and it gave me a chunk of errors:
SRCS: command not found
SRCS: command not found
CFLAGS: command not found
CFLAGS: command not found
The makefile looks like this:
# put your *.o targets here, make should handle the rest!
SRCS = main.c system_stm32f4xx.c
SRCS += lib/startup_stm32f4xx.s # add startup file to build
# all the files will be generated with this name (main.elf, main.bin,
main.hex, etc)
PROJ_NAME=main
more code goes..
I am not even sure how to even execute it to build my hex files etc.

Where is Phonegap folder location after installed?

Where is Phonegap folder location after installed?

Following the guide here, I have install NodeJS and from that, I installed
PhoneGap. But I don't know where PhoneGap folder resides on my harddisk.
Please help.

Python: Generic Loops that are similar to C#, and C++ and PHP in nature, natural nature.?

Python: Generic Loops that are similar to C#, and C++ and PHP in nature,
natural nature.?

You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..

will provide you with the top 1 million web sites in the world.
updated daily in a cvs file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.

always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.

google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest. ..........................................

Distribution of sample mean

Distribution of sample mean

Define a sequence of functions $f_i(x) = a^{x-t_i}$ for $t_{i+1} \geq x
\geq t_i$ and $0$ otherwise, where $0 \leq a\leq 1$. The values $t_i$ are
strictly increasing and $t_0 = 0$.
If you sample $k$ values $x_j$ uniformly at random from an interval
$[0,\dots,n]$, what is the distribution of $\sum_{j=1}^k f(x_j)/k$ as a
function of the values $t_i, k$ and $n$?

C++ - meaning of a statement combining typedef and typename

C++ - meaning of a statement combining typedef and typename

In a C++ header file, I am seeing this code-
typedef typename _Mybase::value_type value_type;
Now, as I understand, quoting from C++ the Complete Reference by Schildt-
Typename can be substituted by keyword class, the second use of typename
is to inform the compiler that a name used in a template declaration is a
type name rather than an object name.
Similarly, you can define new data type names by using the keyword
typedef. You are not actually creating a new data type, but rather
defining a new name for an existing type.
However, can you explain exactly what is the meaning of the above line of
code, where typedef and typename are combined together. And what does the
"::" in the statement imply?

Finding a digit in a sequence

Finding a digit in a sequence

How can i get the n-th digit from a sequence :
112123123412345123456123456712345678123456789123456789101234567891011...
So if I give input : 5 The output shoul be : 2
And the problem is the length of the sequence can reach up to 2147483650.
If using greedy algorithm it should takes lot of time. Anyone know how to
solve it with fast algorithm?

Wednesday, 21 August 2013

How does event based Nginx handle request single-threadly?

How does event based Nginx handle request single-threadly?

I have read several pose including this one: How does Nginx handle HTTP
requests? But there is one thing I still don't get it.
I understand how Nodejs handle request asyncly since node can be server
side script AND a web server. When you write code in node you know that
all functions will return quickly (asyncly), and for those not, you can do
whatever necessary (fork a process, use webworker, a thread, etc). But
Nginx is different. Nginx is just a HTTP server (Correct me if I'm wrong).
Assume we have some java code written with thread in mind, and now we try
to in Nginx. How does Nginx makes sure 1, all IOs are handled asyncly? 2,
if there is any computational intensive code block, how does it make sure
it doesn't block other requests?

Which One of These Logical Theses Does Not Hold for Relevant Logics?

Which One of These Logical Theses Does Not Hold for Relevant Logics?

I write in Polish notation and have included fully infixed notation here
also which indicates parsing order.
For every relevant logic simplification fails:
Simplifcation: CpCqp or [p$\rightarrow$(q$\rightarrow$p)]
I have a proof that from Syllogism, Commutation, Conjunction-Out Left, and
Conjunction-in I can deduce CpCqp, given detachment also.
Syllogism: CCpqCCqrCpr or
{(p$\rightarrow$q)$\rightarrow$[(q$\rightarrow$r)
$\rightarrow$(p$\rightarrow$r)]}
Commutation: CCpCqrCqCpr or
{[p$\rightarrow$(q$\rightarrow$r)]$\rightarrow$[q$\rightarrow$(p$\rightarrow$r)]}
Conjunction-Out Left: CKpqp or [(p$\land$q)$\rightarrow$p]
Conjunction-In: CpCqKpq or {p$\rightarrow$[q$\rightarrow$(p$\land$q)]}
I highly doubt relevant logics don't have CCpqCCqrCpr or CKpqp. Does
CpCqKpq not hold for some relevant logics, and CCpCqrCqCpr not hold for
others? Or do they both fail for all relevant logics? Or does only one of
them not hold? If so, which one?

How to make asynchronous calls from a WCF client to WCF Service in parallel

How to make asynchronous calls from a WCF client to WCF Service in parallel

I'm writing a service that has a call that is relatively long running. The
client needs to be able to make successive requests that run in parallel
to each other and for some reason my service will not execute them
concurrently unless the calls are executed from separate clients. I'm
trying to figure out what configuration setting(s) I'm missing.
I'm using the netTcpBinding. My throttling configuration is:
<serviceThrottling maxConcurrentInstances="10" maxConcurrentCalls="10"
maxConcurrentSessions="10"/>
The service contract:
[ServiceContract(CallbackContract=typeof(ICustomerServiceCallback))]
public interface ICustomerService
{
[OperationContract(IsOneWay = true)]
void PrintCustomerHistory(string[] accountNumbers,
string destinationPath);
}
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
public class CustomerService : ICustomerService
{
public void PrintCustomerHistory(string[] accountNumbers,
string destinationPath)
{
//Do Stuff..
}
}
In the client, I'm making two successive asynchronous calls:
openProxy();
//call 1)
proxy.PrintCustomerHistory(customerListOne,
@"c:\DestinationOne\");
//call 2)
proxy.PrintCustomerHistory(customerListTwo,
@"c:\DestinationTwo\");
On the service, the second operation begins only after the first one ends.
However, if I execute both calls from separate clients, they both execute
concurrently by the service.
What am I missing? I had assumed that by marking my service class as
"PerCall" that call 1 and call 2 each would receive their own
InstanceContext and therefore execute concurrently on separate threads.

App crashes after taking a pic

App crashes after taking a pic

Need Help with this. Looked at many post but can't figure it out. Could
someone please help me.
Error - [ResultInfo{who=null, request=2, result=-1, data=Intent {
act=inline-data dat=content://media/external/images/media/26698 (has
extras) }}]
public int GET_CAM_IMG=2;
public int GET_GAL_IMG=1;
img1.setOnClickListener(new OnClickListener() {
public void onClick(View v){
CharSequence[] names = { "From Gallery", "From Camera" };
new AlertDialog.Builder(context)
.setTitle("Select an option for updating your Profile Picture")
.setItems(names, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int pos) {
// TODO Auto-generated method stub
if (pos == 0) {
Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, GET_GAL_IMG);
} else {
Intent i = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
/**
i.putExtra("crop", "true");
i.putExtra("aspectX", 0);
i.putExtra("aspectY", 0);
i.putExtra("outputX", 200);
i.putExtra("outputY", 150);**/
startActivityForResult(i, GET_CAM_IMG);
}}}
)
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
}).create().show();
}
});}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent
intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case 2://Camera
Log.d("take","pic");
if (resultCode == -1) {
Uri selectimage=intent.getData();
Log.d("take","pic");
img1.setImageURI(selectimage);
}
break;
case 3://Selecting from Gallery
Log.d("view","pic");
if (resultCode == -1) {
Bitmap bmp_image = null;
Bundle extras = intent.getExtras();
bmp_image = (Bitmap) extras.get("data");
img1.setImageBitmap(bmp_image);
}
break;
}
}

UITableView data not appearing in main view using GCD(Grand Central Dispatch)

UITableView data not appearing in main view using GCD(Grand Central Dispatch)

i've done all the coding where i fetch data using XML and then show that
data on the UITableView, data is shown without using the GCD, but when i
add the UIActivityIndicator and used the gcd so the ActivityIndicator will
show until the all the data hasn't arrive.
here's my code:
[super viewDidLoad];
[self.activityIndicator startAnimating];
self.activityIndicator.hidesWhenStopped = YES;
dispatch_queue_t myQueue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(myQueue, ^ {
xmlParser = [[XMLParser
alloc]loadXMLByURL:@"http://www.irabwah.com/mobile/core.php?cat=0"];
[self.activityIndicator
performSelectorOnMainThread:@selector(stopAnimating)
withObject:nil waitUntilDone:YES];
});

How could I display website screenshots dynamically in my website?

How could I display website screenshots dynamically in my website?

I would like to create a website directory. But how could I display
preview (screenshots) from any website automatically?

Tuesday, 20 August 2013

Positioning .cls files in Linux Ubuntu

Positioning .cls files in Linux Ubuntu

I have a research paper accepted to a journal and the editor asked me to
use certain file with .cls and I am confused about where exactly I need to
dump this file .cls ? I tried to dump it to /usr/local/share/texmf/ but it
is not giving me the right pdf file. Can you help please ?

spring autowiring not working from a non-spring managed class

spring autowiring not working from a non-spring managed class

I have a class (Class ABC) that's instantiated by calling the constructor.
Class ABC in turn has a helper class (Class XYZ) injected using
auto-wired.
Ours is a Spring MVC based application and I don't see any exception while
server start-up.
But I still see Class XYZ coming as null. Is it because of the fact that
Class ABC is not instantiated by Spring Container?
In such scenarios, how do i make use of auto-wiring?
Thanks.

How/Why does the router throttle the internet speed by 10x? [on hold]

How/Why does the router throttle the internet speed by 10x? [on hold]

I recently set up an intranet, in our lab, on top of our university wide
network using a wireless router. This was needed as users wanted to be
able to share screens and access data easily across machines - disallowed
with the university wide network.
However, I've recently noticed (and users complained) that they were
getting a very slow connection when connected to the router. I ran
multiple tests using speedtest.net and it seems the router is throttling
the bandwidth by about 10x!
The tests show that the university network has upload and download
bandwidth to about 70-90 Mbps. Via the router, 7-10 Mbps download and ~20
Mbps upload. That's a huge difference IMHO.
Setup: The university issues public IPs from a pool of allocated IPs. The
router is set to clone the IP address of one of the main machines on the
network. (As per policy the same machine cannot have 2 IPs, hence the
cloning). The router gets a WAN IP from the university and the machines in
the lab connect to the router instead of the university network directly.
I've updated and set QoS profiles, updated firmware and also factory reset
the router to no avail.
Question: Why do routers throttle internet speed? How does this happen and
what are some ways to fix it? Can I ever get close to the speed of the
university network via the router/intranet?
(For what it's worth this is the Belkin Play N600 Router.)
UPDATE: Please note - I am NOT trying to circumvent any university policy
here. This is allowed by the university for individual labs and their
experiments. I only wish to know WHY/HOW the throttling happens and what
are some ways to deal with it.

Compare volume levels between to mp3 files

Compare volume levels between to mp3 files

I have two audio recordings that are going to be recorded and saved in mp3
format. The content of the mp3's will be short, only a couple seconds,
will be the same audio, but recorded at 2 different volume levels. I would
like to use java, or preferably jsp so I can run it on a server, to tell
me if there is a difference in volume between these two files. If anyone
has any suggestions, I would greatly appreciate it!
Thank you.

Google Chart Customization

Google Chart Customization

I want following Google Chart (Column Chart) to show its first label on
horizontal axis. Also I want each column to have same width; first and
last column need a change. How is it possible?

change magento price when changing custom options

change magento price when changing custom options

example http://s22.postimg.org/68tnc5b01/Untitled.jpg
I need to do that when the user selects the product size, the price is
changed automatically. How can this be done?

Jackson empty xml array deserialization

Jackson empty xml array deserialization

I have an incoming xml from Recurly service with list of transactions.
Sometimes it's empty and looks like this:
<transactions type="array">
</transactions>
I need to deserialize this using Jackson. I've tried next mapping
@XmlRootElement(name = "transactions")
public class TransactionObjectListResponse extends
ArrayList<TransactionObjectResponse> {
}
where TransactionObjectResponse class for each transaction. It works fine
for non-empty collections, but fails when no transactions came. Next
message appears:
java.lang.IllegalStateException: Missing name, in state: END_ARRAY
at
com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.getCurrentName(FromXmlParser.java:310)
at
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:289)
at
com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:157)
at
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:123)
at
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:230)
at
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:207)
at
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
at
com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
at
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
I used XmlMapper directly,
xmlMapper.readValue(responseXml, TransactionObjectListResponse.class);
Response entity structure isn't strict, any help would be appricated. Thanks.

Monday, 19 August 2013

onCheckedListener Contextaul actionbar

onCheckedListener Contextaul actionbar

vh.cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
if(isChecked){
startActionMode(mActionCallBack);
}
}
});
This is my current implementation for the checkbox onCheckedChangeListener
.. its a really simple implementation of the contextual actionbar. What I
need now is a solid implementation of the onCheckedChangeListener, which
is to cover the follows:
A check on the item should trigger the contextual action bar.
After one check, the contextual action bar should not be rebuilt(which is
happening now)
Full uncheck of the checkboxes should destroy the contextual action bar.
The tick in the contextual actionbar should cancel the checked state of
the checkboxes and also cancel the contextual actionbar itself.
Finally, since an api is calling on for data, the number of checkboxs in
the listView is not sure.(For now there are 3 checkBoxes). Help please.

Service Stack Client for 3rd party needs a parameter called Public

Service Stack Client for 3rd party needs a parameter called Public

I have a requirement to call a 3rd party rest api using service stack and
this is working fine.
But one of the rest api's requires a property called "public"
Is there an attribute I can specify to give it another name in the class
but use the public name when it calls the service?
so I have this definition in the class
public string public { get; set; }
The error I get is
Member modifier 'public' must precede the member type and name
Thanks

Unable to POST/Upload as TCP Retransmitssion

Unable to POST/Upload as TCP Retransmitssion

I am trying to post/upload data/file to a server (I have access to its
settings) but it doesn't progress and after awhile I recieve page loading
error
When I monitor the network through WireShark the lines below are shown
(checksum error and bad tcp)
1170 53.165583000 192.168.1.2 78.39.102.77 TCP 1506 [TCP
segment of a reassembled PDU]
1293 57.661244000 192.168.1.2 78.39.102.77 TCP 1506 [TCP
Retransmission] 60849 > http [ACK] Seq=1 Ack=1 Win=66792 Len=1452
.....
in the details of lines it says the error occurs on IP packets and mainly
because of incorrect checksum (its 0x0000) and suggest maybe caused by ip
checksum offload
What is the problem as these messages says? and how should I solve it?
disableing checksum? changing the NIC....

jQuery. Get CSS property value from URL (Same Origin)

jQuery. Get CSS property value from URL (Same Origin)

I would like to get the background color of an element that resides at an
external page, in the same domain. I have a working solution, but there
must be a better way and I hope that you might point me in the right
direction.
My Solution
I decided to first load the external page into an iframe:
var $page = $('<iframe/>').attr('src', 'http://mydomain.com/page');
Then append the iFrame to the body:
$('#iframe-placeholder').append($page);
And finally I access the CSS property:
$('iframe').load(function(){
var backgroundColor =
$(this).contents().find('#my-element').css('backgroundColor');
});
Downsides of this Approach
It's slow
It's asynchronous
Question
Is there a way to get the CSS property of that external page via Ajax?
I really need the call to be Synchronous and loading the whole page into
an iFrame is just an overkill.
Any suggestions would be very much appreciated...

Why [System.ComponentModel.ToolboxItem(false)] is coming in Asp.net Web service by default

Why [System.ComponentModel.ToolboxItem(false)] is coming in Asp.net Web
service by default

Any body please tell me why [System.ComponentModel.ToolboxItem(false)] is
used in Asp.net Web service

Sunday, 18 August 2013

Apache stanbol Jackrabbit Integration using cmsadapter authorization error

Apache stanbol Jackrabbit Integration using cmsadapter authorization error

I am trying to integrate Stanbol with jackrabbit using the stanbol
cmsadapter. I mostly followed steps suggested in this link.
While trying to access the session key using curl:
curl -X GET -H "Accept: text/plain" "http://:8080/cmsadapter/session?
repositoryURL=http://:10000/rmi&username=admin&password=admin&connectionType=JCR"
I get the following error:
unauthorized
Stanbol runs at localhost:8080 and jackrabbit at localhost:10000
What could be the reason? Also, has anyone successfully integrated them?
Thanks!

qsort C4090: 'function' : different 'const' qualifiers

qsort C4090: 'function' : different 'const' qualifiers

I try to compile the qsort function but received c4090 error. I don't know
why, as my "compare" function seems having the correct form.
#include <stdlib.h>
int Compare(const void *elemA, const void *elemB); // Prototype of Compare
void SortStudents(const char *studentList[], size_t studentCount)
{
qsort(studentList, studentCount, sizeof(studentList[0]), Compare);
}
#include <string.h>
int Compare(const void *elemA, const void *elemB)
{
return(strcmp(*(char **)elemA, *(char **)elemB));
}

Using my Rails app API for iPhone App

Using my Rails app API for iPhone App

I'm learning iOS Development with the Treehouse Library. Building an app
that gets information from a json API.
In the Treehouse API page all the posts are under a parent called "Posts"
(http://blog.teamtreehouse.com/api/get_recent_summary/)
posts: [
{
id: 22198,
url:
"http://blog.teamtreehouse.com/using-github-pages-to-host-your-website",
title: "Using GitHub Pages To Host Your Website",
date: "2013-08-16 09:30:20",
author: "Matt West",
thumbnail:
"http://blog.teamtreehouse.com/wp-content/uploads/2013/08/github-pages-feature-150x150.jpg"
},
{
id: 22196,
url:
"http://blog.teamtreehouse.com/running-tests-in-ruby-on-rails-treehouse-quick-tip",
title: "Running Tests in Ruby on Rails &#8211; Treehouse Quick Tip",
date: "2013-08-15 14:30:48",
author: "Jason Seifer",
thumbnail: null
},
The API from my Rails app doesnt have a Parent
(http://www.soleresource.com/releases.json)
[
{
shoe_name: "Air Jordan 4 "Green Glow"",
release_date: "2013-08-17T00:00:00.000Z",
shoe_colorway: "Dark-Grey/Green-Glow",
shoe_price: "160",
url: "http://www.soleresource.com/releases/8.json"
},
{
shoe_name: "Nike Barkley Posite",
release_date: "2013-08-17T00:00:00.000Z",
shoe_colorway: "Gamma-Green/Black",
shoe_price: "235",
url: "http://www.soleresource.com/releases/17.json"
},
In order to get the app to work I have to call the Parent (posts), like this:
self.upcomingReleases = [dataDictionary objectForKey:@"posts"];
How can I "wrap" my API under a Parent? (My model is called "Releases")

PHP form option fields will not display current value from file

PHP form option fields will not display current value from file

I've been working on a PHP form that changes values in a file on my
server. It almost works but in the form fields it does not display the
current data from the file correctly:
<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
$file = "/home/user/color.props";
$contents = file($file, FILE_SKIP_EMPTY_LINES);
foreach($contents as $line) {
list($option, $value) = explode('=', $line);
if ($option == 'color-name') {
$color_name = $value;
} elseif ($option == 'shape') {
$shape = $value;
}
}
if(isset($_REQUEST['color_choice'])){
exec('sed -i
'.escapeshellarg('s/color-name=.*/color-name='.$_REQUEST['color_choice'].'/g')."
/home/user/color.props");
echo 'Color setting has been updated';
}
?>
<?php echo "$color_name"; ?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="color_choice">;
<option value="0" <?php if($color_name[1] ==
'0'){?>selected="selected"<?php }?>>Red</option>;
<option value="1" <?php if($color_name[1] ==
'1'){?>selected="selected"<?php }?>>Blue</option>;
<option value="2" <?php if($color_name[1] ==
'2'){?>selected="selected"<?php }?>>Green</option>;
<option value="3" <?php if($color_name[1] ==
'3'){?>selected="selected"<?php }?>>Purple</option>;
</select>
<input type="submit" name="Submit" value="Submit" />
</form>
The form changes the values correctly but I need the $color_name[1] values
in the option field to display the updated value after the change has been
made. Currently it doesn't work and I don't understand why. I also see
this error "Notice: Undefined offset: 1.." I'm not sure if that matters or
not. Any help would be greatly appreciated!

HIve shell exception java type java.lang.Integer cant be mapped for this datastore

HIve shell exception java type java.lang.Integer cant be mapped for this
datastore

I have hadoop and hbase installed. When i run show tables comand in hive
shell the following error raised.
Hive version 0.10.0
Hbase version 0.90.6
Hadoop version 1.1.2
hive> show tables;
FAILED: Error in metadata: MetaException(message:Got exception:
org.apache.hadoop.hive.metastore.api.MetaException
javax.jdo.JDOFatalInternalException: JDBC type integer declared for field
"org.apache.hadoop.hive.metastore.model.MTable.createTime" of java type
java.lang.Integer cant be mapped for this datastore. NestedThrowables:
org.datanucleus.exceptions.NucleusException: JDBC type integer declared
for field "org.apache.hadoop.hive.metastore.model.MTable.createTime" of
java type java.lang.Integer cant be mapped for this datastore.) FAILED:
Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask