Tag Archives: JavaScript

Setting button actions programatically in Java, Python, JavaScript, SWIFT and Kotlin

By | January 9, 2024

Button action calls for an action when user tap on a button. This may be for making a service call, for doing some calculation or simply just to dismiss a view. Here are the different ways of setting button action in different languages. Java Python (TKinter) JavaScript: Swift Kotlin These examples demonstrate how to set… Read More »

Three common errors in Python programming along with examples

By | January 5, 2024

1. Syntax ErrorExample: 2. IndentationErrorExample: Explanation: Python relies on indentation to define block structures. The print statement is not properly indented under the if statement, leading to an indentation error. 3.NameErrorExample: Explanation: The variable y is not defined before trying to print it, resulting in a NameError. It’s worth noting that the examples provided are… Read More »

Convert a date from Central Standard Time (CST) to Indian Standard Time (IST)

By | January 2, 2024

To convert a date from Central Standard Time (CST) to Indian Standard Time (IST), you need to consider the time zone difference between these two zones. Below are examples in Swift : Swift: Java: Python: JavaScript: These examples assume a specific date and time format. You should adjust the date format and time zone identifiers… Read More »

Converting date into string format in Python, Javascript, Java and Ruby

By | December 30, 2023

Pythonfrom datetime import datetimedate_object = datetime.now()date_string = date_object.strftime(“%Y-%m-%d %H:%M:%S”)print(date_string) JavaScriptconst currentDate = new Date();const dateString = currentDate.toISOString(); // Adjust the format as neededconsole.log(dateString); Javaimport java.text.SimpleDateFormat;import java.util.Date; public class DateToString {public static void main(String[] args) {Date currentDate = new Date();SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);String dateString = dateFormat.format(currentDate);System.out.println(dateString);}} Rubyrequire ‘date’current_date = DateTime.nowdate_string = current_date.strftime(‘%Y-%m-%d %H:%M:%S’)puts date_string… Read More »

Problem: There are N prisoners standing in a circle, waiting to be executed…

By | June 27, 2023

There are N prisoners standing in a circle, waiting to be executed. The executions are carried out starting with the kth person, and removing every successive kth person going clockwise until there is no one left. Given N and k, write an algorithm to determine where a prisoner should stand in order to be the… Read More »

Given a sorted array, find the smallest positive integer that is not the sum of a subset of the array.

By | June 27, 2023

Java public class SmallestPositiveInteger {    public static int findSmallestPositiveInteger(int[] nums) {        int smallest = 1;        for (int num : nums) {            if (num <= smallest) {                smallest += num;            } else… Read More »

Flutter vs. React Native: Unraveling the Performance Battle

By | June 25, 2023

Introduction: When it comes to developing cross-platform mobile applications, Flutter and React Native have emerged as the two dominant frameworks. As developers seek to create high-performing apps, it’s crucial to understand the performance capabilities of each framework. In this article, we will delve into the performance aspects of Flutter and React Native, examining their strengths… Read More »

Using Webview in Flutter – Part 1

By | March 24, 2019

We can use Webviews in Flutter with the help of webview plugins. I will be showing one of the plugins that is developed by the Flutter team. So Let’s start and we will add the dependency first Watch Video Tutorial     Add dependency   The plugin can be found in the below url https://pub.dartlang.org/packages/webview_flutter… Read More »

Is Javascript Multithreaded? How it handles asynchronous actions?

By | December 14, 2018

Javascript is a single threaded application. That means you cannot run more than one script at one time to modify DOM or something. But there are something called “Worker Threads” that spans separate threads outside your application that can do complex tasks which is linked by a Callback method. What is a Web Worker? When… Read More »

What are Angular JS modules? – A Simple Demo

By | July 15, 2017

Angular JS modules means : An AngularJS module defines an application. The module is a container for the different parts of an application like controller, services, filters, directives etc. The module is a container for the application controllers. Controllers always belong to a module. Example Here we have a module named “MyApp” and controller for… Read More »

How to call Android function from JavaScript?

By | January 10, 2017

Check the Video below to see what we are going to do… If the web page you plan to load in your WebView use JavaScript, you must enable JavaScript for your WebView. Once JavaScript is enabled, you can also create interfaces between your application code and your JavaScript code. Enabling JavaScript JavaScript is disabled in… Read More »

How to Refresh a HTML Page Using JavaScript ?

By | April 26, 2012

Hi, Most probably you may have encountered a situation where you have to refresh the web page in your code. Here is, how it could be done using JavaScript. Sample Refresh Here on button click it will call the function ‘refresh_yourPage()’, and it will refresh the page! 🙂

Showing Twitter updates on Blogger/Blogspot

By | April 24, 2011

Hi, If you want to show the latest twitter update of yours in your blogger/blogspot, then use the following steps. 1. Go to your blogger ‘Design’ 2. Click ‘Add A Gadget’ 3. Add ‘HTML/JavaScript’ 4. Paste the following JavaScript code into it and save 5. Done! Note : Replace ‘SampleURL’ with your twitter id &… Read More »

jQuery dollar sign alternative

By | April 8, 2011

Hi, Dollar ($) sign is a shortcut for jQuery. But sometimes it may have conflict with some other JavaScript library functions which also uses $ sign. What to do then? Its simple. Use jQuery noConflict() method for creating any custom names. See for yourselves. I am going to hide! Hide it! Here ‘jqNew’ is your… Read More »

Client Side Form Validation – using JavaScript

By | March 1, 2011

Hi, JavaScript is mainly used for client side scripting. In client side scripting one of the thing which we are usually in need is Validation of Forms. We want to know the user , who is interacting with the form have already given the necessary details before submitting or saving etc. Here is a simple… Read More »

Using Arrays in JavaScript – Basics

By | February 28, 2011

Hi… We all know, Arrays are nothing but variables which can hold all your variable values with a single name. Let’s see some basic operations of Arrays in JavaScript. To Create a New Array. Use the following code. var myArray = new Array(); This code of line created a new Array object called myArray. Adding… Read More »

Hide and Show a Text Using jQuery – Example

By | February 26, 2011

With jQuery manipulation of HTML & CSS can be done very easily. Here we are going to show how to Hide a line of text using jQuery & Show it back also. Let’s code speak first…. <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#hideButton").click(function(){ $("p").hide(); }); $("#showButton").click(function(){ $("p").show(); }); }); </script> </head> <body> <p>Hey!… Read More »

How do you call an actionscript function from a html page and viceversa. How to you access the actionscript variable function from an HTML page in actionscript.

By | December 26, 2010

The following code helps you to do this. Save the following  code as am .mxml file <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ private var calledFromJSHandlerFunction:Function = calledFromJSHandler; private function init():void{ html.addEventListener(Event.HTML_DOM_INITIALIZE, domInitialized); html.location = "start.html"; } private function domInitialized(event:Event):void{ html.htmlLoader.window.calledFromJSHandlerFunction = calledFromJSHandlerFunction; } private function calledFromJSHandler():void { mx.controls.Alert.show("ActionScript called from JavaScript", "Alert");… Read More »

what is E4X Simply?

By | October 5, 2010

E4X = JavaScript for XML E4X means “ECMAScript For XML”. It is a standard extension to ECMAScript. So in real life E4X means “JavaScript for XML”.