Monday, August 26, 2019

How to Open a Python App via Desktop Icon on Raspberry Pi 3

Open a python application via desktop icon on raspberry pi 3
OS: Linux Raspian
Language: Python 2.7

There are two aspects to opening a python app via a desktop icon on raspberry pi 3, the first aspect is to make the python file executable and second is to create the.desktop file that contains the link to the executable python file location.

Executable Python File

Let’s discuss the first aspect. In order to make the python file executable follow the steps given below:-
  1. At the top of the python file include #!/usr/bin/env python this should be the first line of code. The version of python that is being used should also be mentioned as given in the image below
  2. Give admin permission to run the python file using the below code, the code must be executed on the raspberry pi terminal  window
Sudo chmod +x/file_location/name_of_file.py
3. Once the the two steps are completed reboot the system to save the changes


Create .desktop file

Second aspect of creating a .desktop file is as follows:-

  1. Navigate to the “Desktop” folder in the raspberry pi usually, this is the subfolder of the”pi” folder under the “home” folder.
  2. Create a new file
  3. In this, the newly created file include the below
  • Name – This is the name of the Desktop icon, this name will be displayed under the icon image on the desktop.
  • Comment – This is a non-mandatory tag that gives the description of the application
  • Exec –  This tag is the main execution script, write it in the way you would call the script from the python terminal. “Python” pretext is important here because without this execution of the script will fail. The location of the file can be anywhere that is accessible within the raspberry pi, not on a pen drive or external memory storage.
  • Icon – This tag gives the details for the icon image, this can be any image format png, jpeg etc. The location of the image file should be correct here as well.
  • Terminal – This tag if true will open the terminal window when the application is open else if false the terminal window will not. This is a good option if you want to debug the code.
  • Type – This is the type of script.
4. Save the file as a .desktop file.
5. Reboot the raspberry pi again.
6. Double click on the desktop icon to open the python application

Monday, September 26, 2016

How to Handle Multiple Submit Buttons in Single MVC Form?

MVC View Form – [.cshtml]

Following is the MVC form which contains two submit buttons:
 
  1. @using (Html.BeginForm("Index""Home", FormMethod.Post, new { id = "form1" }))  
  2. {  
  3. @Html.TextBoxFor(m => m.Name, new { maxlength = 50 })  
  4. <input type="submit" id="btnSubmit" name="command" value="Submit" />  
  5. <input type="submit" id="btnReset" name="command" value="Reset" />  
  6. }  
I have used name=”command” as button property which will later needed to identify the command either Submit or Reset in action method below.
 
Below method in your .cs page to determine the command name and then perform task according to the button’s command name. 
 
  1. [HttpPost]  
  2. public ActionResult Index(StudentModel model, string command)  
  3. {  
  4.        if (command == "Submit")  
  5.        {  
  6.                //your "Submit" button code here..                                  
  7.        }  
  8.        else if (command == "Reset")  
  9.        {  
  10.                //your "Reset" button code here..  
  11.        }  
  12.        return View(model);  
  13. }  
We need to add command parameter in ActionResult Index(StudentModel model, string command)action method which is the key to determine the call and depending on that we can perform specific tasks for that command type. 

Friday, August 5, 2016

Freedom 251 Maker Starts Delivery of 65,000 Units to Customers

  • The Freedom 251 smartphone is priced at Rs 251
  • Second dispatch includes 65,000 customers
  • Over 7 crore customers registered for the Freedom 251

After the initial dispatch of 5,000 units, Indian company Ringing Bells on Monday announced it has started deliveries of 65,000 more Freedom 251 smartphone units across many states in India. These include West Bengal, Haryana, Himachal, Bihar, Uttarakhand, New Delhi, Punjab, Jammu & Kashmir, Maharashtra, Madhya Pradesh, Jharkhand, Rajasthan, and Uttar Pradesh.
For those unaware, Ringing Bells announced the Freedom 251 smartphone in February this year, with a shocking price tag of Rs. 251. With that unbelievable price tag, the smartphone received as many as 7 crore registrations.
After much delay, the company managed to dispatch the first batch of 5,000 units last month. The only mode of payment is cash on delivery, and therefore it collects Rs.251 (plus delivery charges of Rs. 40) only once the smartphone is delivered. With the latest batch of 65,000 units, makes the total shipment figures go up to 70,000.
“We started the process of lottery few days back, and now we are dispatching the units to the people. We are elated with the response that we have got for the delivered units. It gives us immense pleasure when we see the satisfied reactions of people who got more than they wished for in terms of quality of our low-cost product,” the company spokesperson said.
The Freedom 251 budget Android smartphone touts a quad-core processor, a 4-inch display, apart from front and back cameras. The company looks to ship the Freedom 251 smartphone to 200,000 registered users at least, and then chalk out the roadmap for further production.
At an event last month, Ringing Bells announced two new budget Android smartphones – Ringing Bells Elegance and Ringing Bells Elegant – as well as four new feature phones, three power banks, and a 31.5-inch HD LED TV.

Source: http://thinkur.com/freedom-251-maker-starts-delivery-of-65000-units-to-customers/

Tuesday, July 12, 2016

Freedom 251 Delivery Started, Claims Ringing Bells

  • Ringing Bells says deliveries began on Friday in 5 states
  • First batch includes only 5,000 customers
  • Over 7 crore customers registered for the Freedom 251
Ringing Bells, the Noida-based company that courted controversy after announcing a phone at an astonishingly low price of Rs. 251 five months back, on Friday claimed it has begun delivery of the world’s cheapest smartphone in five states including Haryana, West Bengal, and Bihar.
“Of the 5,000 units of Freedom 251 phones that we committed to deliver in the first phase, we have started the delivery of 2,240 phones today through distributors and couriers,” Ringing Bells Director Mohit Goel told PTI.
This includes 390 phones in Haryana, 540 phones in West Bengal, 605 phones in Himachal Pradesh, 484 in Bihar and 221 phones in Uttarakhand.
Goel further said the company will initiate tomorrow the delivery of 2,000 more smartphones. Of this lot, 223 phones will go to consumers in Delhi, 364 phones in Punjab, 108 in J&K, 521 in Maharashtra, 194 in Madhya Pradesh, 225 in Jharkhand and 365 in Rajasthan.
“The balance 760 phones are going to be delivered in UP on Monday (July 11) across five areas including Noida, Ghaziabad, Meerut, among others,” Goel said.
For the Freedom 251 smartphone, buyers will have to shell out Rs. 291, including Rs. 40 as the delivery charge.
Once the delivery in UP kicks off on July 11, Goel claimed that the company would start working on plans for delivery of the next lot of 2,00,000 smartphones.
“The parts have already arrived at the factory,” he pointed out.
In February, the company announced the Freedom 251 phone which saw a mad rush of over 7 crore people jostling to register, but when the prototype was presented to media it turned out to be produced by another manufacturer with its logo covered.
This led to protests from buyers and consequent inquiries by police and tax officials, forcing the company to stop sale of the product and offer refunds to those who had booked the phone.
The Freedom 251 prototype touts a quad-core processor, a 4-inch screen and front and back cameras, priced at an astonishingly low price of Rs. 251.
On Thursday, the company unveiled new more-expensive smartphone models as well as an LED TV priced at Rs. 9,990.

Friday, May 20, 2016

How to Remove Duplicate Character from String in SQL

Code Snippet 
  1. CREATE FUNCTION[dbo].[FUN_Remove_Duplicate_Char](@Input[varchar](max))  
  2. RETURNS[varchar](max)  
  3. AS  
  4. BEGIN  
  5. DECLARE @Count int;  
  6. DECLARE @Return_String[varchar](max);  
  7. DECLARE @Char_Index int;  
  8. DECLARE @Temp_Str[varchar](max);  
  9. SET @Count = 0;  
  10. SET @Return_String = @Input;  
  11. WHILE @Count <= 255  
  12. BEGIN  
  13. SET @Char_Index = CHARINDEX(CHAR(@Count), @Return_String, 0);  
  14. IF(@Char_Index > 0)  
  15. BEGIN  
  16. SET @Temp_Str = SUBSTRING(@Return_String, @Char_Index + 1, LEN(@Return_String));  
  17. SET @Temp_Str = REPLACE(@Temp_Str, CHAR(@Count), '');  
  18. SET @Return_String = SUBSTRING(@Return_String, 1, @Char_Index) + @Temp_Str;  
  19. END  
  20. SET @Count = @Count + 1;  
  21. END  
  22. RETURN @Return_String;  
  23. END  
Example 
  1. SELECT dbo.FUN_Remove_Duplicate_Char('Hello How Are You'AS String_;   
Output:
 
Helo wArYu

Wednesday, April 27, 2016

How to use innerhtml in JavaScript?

var maincontent = document.getElementById("content").innerHTML;
maincontent = "<p>" + first;
On the second line you're overwriting the variable, not setting the .innerHTML. This is what you want:
var maincontent = document.getElementById("content");
maincontent.innerHTML = "<p>" + first;

Tuesday, February 23, 2016

How to do partial page postbacks WITHOUT AJAX UPDATE PANEL in ASP.NET?

With out using Update Panel its not possible in asp.net web form  besiccelly ASP.NET AJAX uses 'normal' AJAX to 'ajax-ify' it's pages and achieve partial-updates...and in doing so, it trades & manages view-state MULTIPLE times throughout a single call. This is WHY it is called a 'partial-postback'. Subsequently, this is also why they originally described the UpdatePanel as a means to make your pages 'ajaxy' (because it is not the same thing as using AJAX).but if you want to do that so try to use webmethods with json or jquery

For more refer:- http://www.aspsnippets.com/Articles/Insert-Update-Data-to-Database-with-jQuery-AJAX-and-WebMethod-in-ASPNet.aspx