Skip to content

Instantly share code, notes, and snippets.

View sohel-rana's full-sized avatar

Md Sohel Rana sohel-rana

View GitHub Profile
@sohel-rana
sohel-rana / Promise.js
Last active May 5, 2018 08:17
A promise sample
function find (x) {
if (x === 10) {
return Promise.resolve(10);
} else {
return new Promise(function (resolve, reject) {
try {
if (x === 0) {
throw ('0 not allowed');
}
let t = parseInt(x);
@sohel-rana
sohel-rana / assignment.js
Last active September 27, 2017 18:08
JavaScript ES5 version of the assignment
/**
* finds the highest product of the three items passed in
* @param arrayOfInts<type array>
*/
function highestProductOf3(arrayOfInts) {
if (arrayOfInts.length < 3) {
throw new Error('Less than 3 items!');
}
// we're going to start at the 3rd item (at index 2)
@sohel-rana
sohel-rana / freeMemoryInMac.js
Created June 3, 2016 06:51
A NodeJS script to find out free memory in Mac OSX. You can also find other data like total used memory, wired memory etc.
/**
* User: Sohel
* Date: 6/3/16
* Time: 11:49 AM
*/
var sys = require('sys');
var exec = require('child_process').exec;
var child;
@sohel-rana
sohel-rana / NamingConvention.md
Last active March 14, 2024 08:24
Naming Convention for JavaScript

#Coding Conventions

Variables

Use camelCase for variable naming. Also use full word where possible

Good variable names: user, userAddress, stockInfo, tempUserLocalAddress etc.

Bad variable names: user\_data, new_user etc.

$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_APP_SECRET,
));
// Get User ID
$result = '';
$user_id = $facebook->getUser();
if ($user_id) {
$access_token = $facebook->getAccessToken();
<!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" >
<head>
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
var NumOfRow = 1;
function Button1_onclick(){
string[] paramsStr=new string[4];
paramsStr[0]=ctrl1.ClientID;
paramsStr[1]=ctrl2.ClientID;
paramsStr[2]=ctrl3.ClientID;
paramsStr[3]=ctrl4.ClientID;
string script=string.Format(@"function IDIssue() {
var ctrl1=document.getElementById('{0}');
var ctrl2=document.getElementById('{1}');
var ctrl3=document.getElementById('{2}');
string script=string.Format(@"function IDIssue() {
var ctrl1=document.getElementById('{0}');
var ctrl2=document.getElementById('{1}');
var ctrl3=document.getElementById('{2}');
// add necessary implemenation here
}",
ctrl1.ClientID, ctrl2.ClientID, ctrl3.ClientID
);
ContentPlaceHolder cp = (ContentPlaceHolder)Page.Master.FindControl("CPH");
TextBox tbName = (TextBox)cp.FindControl("txtName");
TextBox tbAge = (TextBox)cp.FindControl("txtAge");
string script=string.Format(@"function IDIssue() {{ var txtName=document.getElementById('{0}'); var txtAge=document.getElementById('{1}'); alert('your name is '+ txtName.value+' and age is '+txtAge.value); }}",tbName.ClientID, tbAge.ClientID);
ClientScript.RegisterClientScriptBlock(this.GetType(), "IDIssue", script, true);
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CPH" Runat="Server">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
<asp:Button ID="btnShow" runat="server" Text="Show " OnClientClick="IDIssue();"/>
</asp:Content>