Wednesday, May 16, 2012

Convert http live streaming to rtsp live streaming

How to covert http live streaming in to rtsp live streaming in online? I mean to convert without any software.





Detect Arabic language using Javascript?

How to detect Arabic language when typed in a Textbox using a Javascript??
Is there any way to do this.



I want to do a system where the system automatically detects the Arabic Language written in the textbox of the Webpage.





Monitoring scripts and sending email when it crashes

I have some perl scripts which are scheduled using task scheduler in windows 2003 R2 and 2008. These scripts are called directly using perl.exe or via a batch file.



Sometimes these scripts fails to execute (crashes maybe) and we are not aware of these crashes.



Are there any ways a mail can be sent when these script crashes? more or less like monitoring of these scripts



Thanks in advance



Karthik





How to get effected rows after update statement in mysql?

How to get effected rows after update statement in mysql.





APNS Openssl Connection from PHP for Apple Push Notification?

Finally i have sent a notification from my local server to my device. I followed this tutorial http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2 and many of the peoples from stack overflow helped me to reach this. I Thank you all my friends.



I have one doubt on the server setup. For my local use i have used MAMP for Apache and MySQL servers. Finally i open the ssl from Terminal used certificate.pem and key.pem. Is there any way to open ssl from php script. But, i don't know any single script of php because i am ios developer. Sorry for this.



Yesterday i have used below commands in my Terminal to open ssl and connect to APNS,



unknownc42c032e8297:~ gopi$ /Applications/MAMP/bin/php/php5.3.6/bin/php /Users/gopi/Desktop/PushChatServer/push/push.php development
unknownc42c032e8297:~ gopi$ cd /Users/creagx/Desktop/PushChatServer/push
unknownc42c032e8297:push gopi$ telnet gateway.sandbox.push.apple.com 2195
Trying 17.149.34.66...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
Connection closed by foreign host.
unknownc42c032e8297:push **gopi$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert gopiAPNCert.pem -key gopiAPNKey.pem**
Enter pass phrase for gopiAPNKey.pem:
CONNECTED(00000003)
.
.
.
.
Verify return code: 0 (ok)
---
creagx
closed

unknownc42c032e8297:push gopi$ /Applications/MAMP/bin/php/php5.3.6/bin/php /Users/gopi/Desktop/PushChatServer/push/push.php development
^C


Is there any way to openssl from our php file? It is possible or Terminal usage is better and is the only way for this? Can anyone please help me on this? Thanks in advance.





database of the Department of salaries

I have a database of the Department of salaries and have a history of each salary schedule, but there are more more data one month example :



date name description amount
2012-5-1 ali saler 2000$
2012-5-4 ali mobile bill 140$
2012-5-4 ali Rent housing 120$
2012-4-4 ali Rent housing 120$
2012-4-4 ali Rent housing 120$



2012-4-4 ali Rent housing 120$



Needed for each month that the total salary ..
AND each month print line in the end



thank you





Button and size of text

I have a problem with size of text in button. I have layout where I use weightSum and my button width is match parent and hight is 30%. Everything works fine but when I change size of screen on emulator my text is still small. How I can change size text depend on size of screen?
This is xml:



<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100" >

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_weight="30" />

</LinearLayout>




Tidy code for a sequence of jQuery animations on different elements?

I'm currently using this code, and it does what I want it to



$('#about-link').click(function() {
$('#login').fadeOut(function(){
$('#about').fadeIn(function() {
$('#about').one('click', function() {
$('#about').fadeOut(function(){
$('#login').fadeIn();
});
});
});
});
return false;
})


However, the amount of nesting there is insane. Is there are way to write this in a less nested way?





Function object approach safe for function pointers?

I'm coding on a project which makes heavy use of curried objects and templates. The new decltype feature of c++11 means that I could start accepting function objects that do not explicitly define a return type as the curry for my function objects. Instead, the return type could be extracted with a meta function such as:



template<typename func_T, typename arg1_T>
struct unary_result {
typedef typename std::remove_reference<std::remove_cv<decltype(func_T()(arg1_T()))>::type>::type type;
};


Given a function object:



struct foo {
int operator()(double) const;
};


(which does not inherit from std::unary_function<double, int> or define its result_type), I could just get it as unary_result<foo, double>::type, which works out well in my current code (for one thing, it allows the same function object to have different behavior for different parameters).



My question is: how would this interact with function pointers?



I am aware that STL is able to use function objects and function pointers interchangeably, but have never actually worked with function pointers, so my intuitions are not very well developed in this area. I am also aware that this might be something that is buried somewhere in Boost already (I'm sure someone will point that out very soon if this is the case).





Visual Studio: differentiate app.config for debug and release mode

Is there a way to automatically use a separate app.config when building in release mode?



In other words, I want to test with one app.config, and release with another.



Currently, I keep a separate copy called app.config.production, and manually overwrite bin\Release\Application.exe.config after building for release.





Reflection for plugins

In C I could write a plugin by having a shared library implement the following interface:



extern "C" int initialize(SomeArgument * state);
extern "C" int shutdown(SomeArgument * state);


Obviously this is a very high level interface, but I think it gets the point across. I've heard that a good use of reflection is to write plugins, but why would that be superior to what I have here? Using an interface like this gives the following advantages:




  • faster (reflection isn't fast, both looking up methods and calling indirectly)

  • memory (reflection has memory overhead)

  • straight-forward (entry/exit points for the plugin are intuitively obvious)



Am I just missing something?





fetching data from three tables

I am having three tables




  1. user(id,fname,lname)

  2. picture(picid,pic_path,userid)

  3. friends(friend_of,friends_id,status)



    want to fetch id,fname,lname,pic_path for all friends_id of friends_of=1




picture path may be null





SimpleView Based app with id initWithFrame Not working

I have app to create a graph i have created a view based app and then add the code for creating graph in it but it does not disply the graph. If use same code to create a separate UIView then it works other wise not



   #import <UIKit/UIKit.h>
#import "ECGraph.h"
#import "ECGraphItem.h"
@class GraphsViewController;
@interface Display : UIView {

NSArray *percentages;

int myY;
ECGraph *graph;
ECGraphItem *item1;
ECGraphItem *item2;


}
@property(nonatomic,retain)NSArray*percentages;

-(void) setPercentageArray:(NSArray*) array;

@end


#import "Display.h"
#import "ECGraph.h"
@implementation Display
@synthesize percentages;

- (id)initWithFrame:(CGRect)frame {

self = [super initWithFrame:frame];
if (self) {
// Initialization code.
}
return self;
}


- (void)drawRect:(CGRect)rect {


CGContextRef _context = UIGraphicsGetCurrentContext();



graph = [[ECGraph alloc] initWithFrame:CGRectMake(500,-320,320, 200) withContext:_context isPortrait:NO];


item1 = [[ECGraphItem alloc] init];

item2 = [[ECGraphItem alloc] init];
/*
ECGraphItem *item1 = [[ECGraphItem alloc] init];

ECGraphItem *item2 = [[ECGraphItem alloc] init];*/

item1.isPercentage = YES;



item1.yValue=myY;




item1.width = 35;
item1.name = @"item1";

item2.isPercentage = YES;
item2.yValue =17;

item2.width = 35;
item2.name = @"item2";



[graph setXaxisTitle:@"name"];
[graph setYaxisTitle:@"Percentage"];
[graph setGraphicTitle:@"Histogram"];
[graph setDelegate:self];
[graph setBackgroundColor:[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1]];



NSArray *items = [[NSArray alloc] initWithObjects:item1,item2,nil];


[graph drawHistogramWithItems:items lineWidth:2 color:[UIColor blackColor]];




}


I am adding this view in GraphsViewController but its not showing anything



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.



 - (void)viewDidLoad {
[super viewDidLoad];

[self createGraph];



percentages = [NSArray arrayWithObjects:@"80",@"17", nil];

display = [[Display alloc] init];

[self.view addSubview:display];

[display setPercentageArray:percentages];

}




RMI rebind JRMP error

Since a few days i get the following error when I try to run my java server application:



SEVERE: Stratego server exception: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
java.net.SocketTimeoutException: Read timed out


My main method looks like:



Stratego stratego = new Stratego();
try
{
if (System.getProperty("java.security.policy") == null)
{
System.setProperty("java.security.policy", "src/Server/Policy/server.policy");
}
if (System.getProperty("java.rmi.server.codebase") == null)
{
System.setProperty("java.rmi.server.codebase", "file:/D:/.../build/classes");
}
if (System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
LocateRegistry.createRegistry(9292);
Naming.rebind("rmi://localhost:9292/StrategoServer", stratego);

Logger.getLogger(Stratego.class.getName()).info("Stratego server ready");
}
catch (Exception e)
{
Logger.getLogger(Stratego.class.getName()).log(Level.SEVERE, "Stratego server exception: {0}", e.toString());
}


The policy, codebase and SecurityManager are new but when i comment them out, I still get this error. It all worked well before.
Can anyone tell me why?



Oh btw, I use Windows 7 x64 and JDK 7





parsing string and create Dictionary

I have the following string pattern: 1:2,2:3.



This is like array in one string:

The first element is: 1:2

The second element is: 2:3



I want to parse it and create a dictionary:

1,2 // 0 element in Dictionary

2,3 // 1 element in Dictionary



This is my code:



Dictionary<int,int> placesTypes = new Dictionary<int, int>();

foreach (var place in places.Split(','))
{
var keyValuePair = place.Split(':');
placesTypes.Add(int.Parse(keyValuePair[0]), int.Parse(keyValuePair[1]));
}


Is there the best way to do this?



Thanks.





BizTalk Scripting - Receive Location Schedule

I'm tasked with 2 things that I'm not seeing support for.




  1. Writing a script to enable a receive location with a schedule (No
    schedule currently set)

  2. Writing a script to remove a schedule from a receive location.



I see how to enable/disable a receive location, but I don't see how to manipulate the schedule via script.





network restricted website

How can I restrict my network connections to a only my web-server?



EG, a user would connect to my network (WIFI/LAN) when they open a web browser and enter 127.0.0.1 it will load my app. But if they enter any other web address it would redirect back to 127.0.0.1?



Thanks everyone!





Concerns about ASP.NET SPA(Single Page Application)

Here is my knowing about ASP.NET SPA:




  1. have to use Upshot to talk to the server;

  2. have to use DbDataController to provide Web APIs;

  3. have to use Entity Framework Code first...



so, many concerns come out:




  1. have to provide metadata for the upshot to work, this will obviously expose the structure of your database;

  2. can i use Entity Framework Database First instead of Code First? You may ask why. Because Code First don't provide you the ability to customize your database(index customization, stored procedure...etc.);

  3. A problem i met: when i add a "TestUpshot.edmx" file(generated from database 'northwind') to the MySpaApp.Models folder(trying to test whether i can use the edmx classes in the MyDbDataController class, and generate proper metadata in the client side), and run the application, there is an exception:"System.ArgumentException: Could not find the conceptual model type for MySpaApp.Models.Categories."...



Need help here, thanks in advance.



Dean





Standard button size in new iPhone(640*960)

what is the standard size of buttons in iPhone(640*960) as specified by Apple Inc.





XmlSerializer to serialize a class, i want child tag names as given in a public property

I am using XmlSerializer to serialize a class, which has a list of objects
as part of it.Now what is happening is, the child tag names are taking the name from the class name but what i want is it'd take the name from a public field inside child class.Please help, which xml attribute should i use to make it work.



I have this code:



SessionAnalyser sa = new SessionAnalyser();
Circle c = new Circle();
c.Name = "AP";// I want this property as the TAG Name


XML O/P i am getting:



<SessionAnalyser>
<Circle>
<Name>AP</Name>
...
</Circle>
</SessionAnalyser>


Required XML O/P:



<SessionAnalyser>
<AP>
...
</AP>
</SessionAnalyser>




Using Action Filters on MVC C# using query String

Im using class name RightCheckerAttribute to check user permission in MVC3 application...
So the RightCheckerAttribute class is like this...



    public bool isAdmin { get; set; }

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpContextBase context = filterContext.HttpContext;

bool result = Convert.ToBoolean(context.Request.QueryString["isAdmin"].ToString());

if (isAdmin != result)
{
RouteValueDictionary redirecttargetDictionary = new RouteValueDictionary();
redirecttargetDictionary.Add("action", "NoPermission");
redirecttargetDictionary.Add("controller","Singer");
filterContext.Result = new RedirectToRouteResult(redirecttargetDictionary);

}

//base.OnActionExecuting(filterContext);
}


So in Method i applying this have head as..



[RightChecker (isAdmin=true)]



Im Executing this method as this..



http://localhost:5576/Singer/DeleteSinger?isAdmin=true



The problem is whether I'm passing true or false... I got result variable as false... And I'm getting:




Exception[Null Object references]...






Replacing Java 7 with Java 6

Currently I am running java 7 on Windows 7



C:\>java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)


How can i replace it with Java 6 ?? What is the best way ??





Is it better to pass reference to an object or pass individual attributes in an object in Java?

I'm dealing with legacy code and I constantly see method calls with multiple attributes from the same object being passed into a method:



update(user.getID(), user.getLanguage() etc...)


Is there a distinct advantage or disadvantage to doing it this way or would I just be as well to pass in the user object (in this case) and deal with attributes within the method called?



Cheers,



Alexei Blue.





how to restart a subsystem in alfresco 4 community?

i'm working in installing and configuring Alfresco community edition 4 (alfresco-community-4.0.d-installer-linux-x64.bin) on a 64bit ubuntu server (10.04.4 LTS). I'm trying to authenticate and syncronize users and group with out OpenLDAP server but as long as we make changes to
$TOMCAT_HOME/shared/classes/alfresco/extension/subsystems/Authentication/ldap/ldap1/ldap-authentication.properties
i have to restart tomcat or the whole server.



Is there a way to restart only a single subsytem in alfresco community edition?
Thanks





DialogFragment orientation change

I have an activty and two fragments. One of the fragments extends DialogFragment and shows some text.
In my activity i have overriden onCreate method:



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layoutId);
if (savedInstanceState == null)
initFragment();
}


initFragment() adds a fragment to a FrameLayout in my layoutId. If no DialogFragment is shown everything works fine, but in case DialogFragment instance is shown - orientation change throws IllegalStateException that fragment did not return View on the line "setContentView".



BTW I'm using ActionBarSherlock





Can I use Nhibernate QueryOver to group and count by a collection's count of an entity?

There are two classes in my project like below:



public class Teacher
{
public virtual long Id {get;set;}
public virtual IList<Student> Students {get;set;}
}


public class Student
{
public virtual long Id {get;set;}
public virtual string Name {get;set;}
}


I need a query which get Students' count of each Teacher and group by with the count result. Also with the frequency of each count(eh... count of count number). I don't know how to do this using queryover. It's like if given data like this:



teacher1.Students = [student1,student2,student3] //teacher1's student count is 3
teacher2.Students = [student4]
teacher3.Students = [student5,student6,student7]
teacher4.Students = [student8]
teacher5.Students = [] //empty


I need query result like this:



[
[0,1], //1 teacher has 0 students
[1,2],
[3,2] //2 teachers have 3 students
]


Updated: the sql is like this:



select tc.tCount, count(tc.TRID)
from (select tr.Id as TRID, count(std.Id) as tCount
from Teacher tr
JOIN Student std on std.TeacherId = tr.Id
GROUP BY tr.Id ) as tc GROUP BY tc.tCount




jQuery select span class not working

Im trying to select the span by using the (.class) selector but for one or another reason this is not working.



<div class="text-wrap">
<div class="text-list">
<div class="text-suggestion">
<span class="text-label">Lorem</span>
</div>
</div>
</div>

jQuery(document).ready(function() {

jQuery('.text-label').click(function(e){
alert('lol');
});
});


I can only select .text-wrapper the others are not working.. is this a jQuery program fault? I also have to say that im using the jQuery textext plugin.



UPDATE:



I forgot the quotes in my first post but this is not the problem. The code is also in a script tag otherwise it would not be possible to select the text-wrap div.



I still have the problem that everthing that is in the text suggestion div can't be triggered.



I am using the textext plugin from Textext





Extjs: Nested Apps

I'm trying to move a rather complex app to Extjs. In our current application we used a very modular approach where we structured the app into multiple sub-apps, which were loaded by a main app. I'd like to reuse this approach with Extjs using a fresh "MVC base" per sub-app.



At the moment I've got a simple main app and simple customer-sub-app. Both work nicely independently. But once I try to add the customer to main app, I just see a blank area.



Is there maybe a more recommended way of doing this?



My main app:



Ext.application({
name: 'ISA',
appFolder: 'app',
launch: function() {
Ext.create('Ext.container.Viewport', {
layout:'border',
defaults: {
collapsible: true,
split: false,
bodyStyle: 'padding:15px'
},
items: [{
title: 'ProcessBar',
region: 'north',
height: 150,
cmargins: '5 0 0 0'
},{
title: 'Main Area',
id:'desktop',
xtype:"panel",
collapsible:false,
region:'center',
margins: '5 0 0 0',
cmargins: '0 0 0 0',
height:300,
items:[{
type:"ISA.extensions.customer",
height:300
}]

}]
});
}
});


My Customer App:



Ext.define('ISA.extensions.customer',{
extend:'Ext.app.Application',
alias:'customer',
name: 'ISA.extensions.customer',
appFolder: 'app',
controllers: [
'Users'
],
launch: function() {
Ext.create('Ext.panel.Panel', {
layout:'border',
height: 400,
renderTo: "desktop",
defaults: {
collapsible: false,
split: false,
bodyStyle: 'padding:0px'

},
items: [{
title: 'Customer App',
region:'center',
margins: '0 0 0 0',
cmargins: '0 0 0 0',
width: 175,
minSize: 100,
maxSize: 250,
items: {
xtype: 'userlist'
}
}]
});
}
});


Ext.define('ISA.extensions.customer.view.user.List' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.userlist',

title : 'All Users',

initComponent: function() {
this.store = {
fields: ['name', 'email'],
data : [
{name: 'Ed', email: 'ed@sencha.com'},
{name: 'Tommy', email: 'tommy@sencha.com'}
]
};

this.columns = [
{header: 'Name', dataIndex: 'name', flex: 1},
{header: 'Email', dataIndex: 'email', flex: 1}
];

this.callParent(arguments);
}
});

Ext.define('ISA.extensions.customer.controller.Users', {
extend: 'Ext.app.Controller',
views: [
'user.List'
],
init: function() {
this.control({
'viewport > panel': {
render: this.onPanelRendered
}
});
},

onPanelRendered: function() {
console.log('The customer list was rendered');
}
});




Select First Element by jQuery

This is My HTML Dom



<dd>
<div class="Addable Files">
<div style="margin:5px;">
<select name="Kind" id="kind">
<option value="1" >K1</option>
<option value="2" >K2</option>
<option value="3" >K3</option>
</select>

<div class="customfile">
<span aria-hidden="true" class="customfile-button button">Browse</span>
<input type="file" name="Files" class="fileupload customfile-input">
</div>
<select name="yap">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
</div>
<input type="button" value="new" style="margin-top:5px;" class="AddNewE button red" id="AddFiles">
</dd>


And my Script:



//Add new Addable div
$('.AddNewE').click(function () {


var Target = $('.Addable.Files:first');
var CloneTarget = $(Target).clone();
CloneTarget.insertAfter('.Addable.Files:last');

$('select').css('color', 'gray');
$(Target).find('select').each(function () {
$(this).css('color', 'red');

});
});


So I expect when I click add button just first two select (two select of first div) be Red and all other selects be gray, but I see weird behavior, In first Add everything is OK, but then in each Add all selects be red except second one, I think Target is first div and also I select Target's Select elements so why all selects be Red? where is my problem?





Elements are not in DOM after Backbone.layoutManager view rendered

I have some editor application with few switchable pages, each of this pages hase it's own action in router. Views are designed using Backbone.LayoutManager. After rendering one of them (editor_publish) i need to draw google map.



When i render this page first time (withing one session), $('.map') selector returns non-empty result and then i can draw map in it. But when I'm trying to render it in second time (i.e. go to another page and then back again to this one), same selector in same code return - 'undefined'. For me this mean that template elements are not in the DOM at the moment i'm trying g to select map container. But why this happens? I can't see difference between first and second pages visit.



I remember something like that was taking place when I re-rendered same Layout manager. But in this code, new LM will be created for each router's action. How this can be solved?



The router:



Editor = Backbone.Router.extend({
immo: {},
lm: {},
nav: [],
pages: [],
routes: {
'editor/basic': 'basic',
'editor/basic/:id': 'basic',
'editor/details': 'details',
'editor/details/:id': 'details',
'editor/photos': 'photos',
'editor/photos/:id': 'photos',
'editor/publish': 'publish',
'editor/publish/:id': 'publish',},
initialize: function(){
var self = this;
if (!_length(self.immo)){
self.immo = new Immo_Object();
}
},

basic: function(id){
var self = this;
self.init(new View_EditorBasic({model: self.immo}));
self.nav.push({caption: '&gt; Next Step', link: 'details'});
self.run(id);
},

details: function(id){
var self = this;
self.init(new View_EditorDetails({model: self.immo}));
self.nav.push({caption: '&lt; Prev Step', link: 'basic'});
self.nav.push({caption: '&gt; Next Step', link: 'photos'});
self.run(id);
},

photos: function(id){
var self = this;
self.init(new View_EditorPhotos({model: self.immo}));
self.nav.push({caption: '&lt; Prev Step', link: 'details'});
self.nav.push({caption: '&gt; Next Step', link: 'publish'});
self.run(id);
},

publish: function(id){
var self = this;
self.init(new View_EditorPublish({model: self.immo}));
self.nav.push({caption: '&lt; Prev Step', link: 'photos'});
self.run(id);
},

init: function(page){
var self = this;
self.nav = [];
self.pages = [
{name: 'basic', caption: 'Basic Infos'},
{name: 'details', caption: 'Details'},
{name: 'photos', caption: 'Photos'},
{name: 'publish', caption: 'Publish'},
];

self.lm = new Backbone.LayoutManager({
template: 'editor',
views:{
'.editor': new View_Editor({
collection: self.pages,
views: {
'.editor_form': page,
'.editor_top_nav, .editor_bottom_nav': new View_EditorNavigation({collection : self.nav})
}})
}
});
},

done: function(self){
if (!self) self=this;
self.compose_navigation();

self.lm.render(function(el){
$('#content').html(el);
$(el).find(".facts dl").columnize();
});
},

run: function(id){
var self = this;
if (id && !self.immo.get('id')){
self.immo.set({id: id});
self.immo.fetch({success: function(){
return self.done(self);
}});
}else{
self.store();
self.done();
}
},

compose_navigation: function(){
var self = this;
_.each(self.nav, function(item){
item.link = 'editor/' + item.link;
if (self.immo.get('id')) item.link += '/' + self.immo.get('id');
});
},

store: function(){
var self = this;
var form = $('.editor_form form').serializeObject();
self.immo.set(form);
return true;
},
});


The view where problem is:



View_EditorPublish = Backbone.View.extend({
template: 'details',

serialize: function(){
return {immo: this.model, details: Immo.details(this.model)};
},

render: function(layout){
return layout(this).render().then(function(el) {
$(el).find(".facts dl").columnize();
console.log($('.map'));
});
},
});