Skip to main content

Posts

Showing posts from 2018

how to solve Fibonacci, prime and composite number and factorial using a single static class in typescirpt.

working link ------------- https://stackblitz.com/edit/typescript-be1art these are some frequently asked question such as prime numbers, factorial and Fibonacci series for an interview purpose. I am trying to solve these question using a single static class in typescript. here the whole code of my static class where I am using a single class to solve these problem's class MathProblem { //Fibonacci series-------------------- static Fibonacci ( max ) { let a : number = 0 ; let b : number = 1 ; let f : number = 1 ; let series =[]; for ( let i = 0 ; i <= max ; i ++) { if ( i === 0 ) { f = 0 ; } else if ( i === 1 ) { f = 1 ; } else { f = a + b ; a = b ; b = f ; } series . push ( f ); } return series ; } //factorial----------------...

generate unique random number between a range using static class in typescript

I am creating a simple class which includes all four methods for different type of random occurrence and based on random range its generate a unique set of the random numbers between ranges. working link=> https://stackblitz.com/edit/typescript-qrmqc4 code=> enum randomType { includeMinMax = 0 , exculdeMin = 1 , exculdeMax = 2 , exculdeMinMax = 3 } //get random number between two range class seedRandom { static maxOccur = 100 ; //min and max include public static getRandomNumber ( min : number , max : number ) { return Math . round ( Math . random ()*( max - min )+ min ); } //if you don't wanna include max value or max exclude public static getRandomNumberNotMax ( min : number , max : number ) { return Math . round ( Math . random ()*( max -( min + 1 ))+ min ); } //if you don't wanna include min value or min exclude public static getRandomNumberNotMin ( min : number , max : number ) { return...

create a custom alert box with multiple layout options in objective c

// //   EGviewAlert.h-------------------------- #import <UIKit/UIKit.h> @interface EGviewAlert : UIView //alert view with heading message and ok button typedef void (^closeAction)( id ); typedef void (^cancelAction)( id ); -( void )Alert:( NSString *)heading withMsg:( NSString *)message withOkBtn:( NSString *)okBtnMsg closeAction:( void (^)( id ))completeBlock; //alert view with heading message and ok button and cancel button -( void )Alert:( NSString *)heading withMsg:( NSString *)message withOkBtn:( NSString *)okBtnMsg withCancelBtn:( NSString *)cancelBtnMsg closeAction:( void (^)( id ))completeBlock cancelAction:( void (^)( id ))cancelAction; //for custom layout -( void )customAlert:( NSDictionary *)messages   closeAction:( void (^)( id ))completeBlock cancelAction:( void (^)( id ))cancelAction; //heading view @property ( nonatomic , strong ) UIView *HeadingView; //heading text @property ( nonatomic , ...

starting with pixijs ,typescript and gsap( https://greensock.com/?product-plugin=js-pixiplugin )

Here is a little example of how we can combine the power of WebGL using pixijs , typescript gsap for tween. i am using https://stackblitz.com which is vscode type online editor add necessary dependencies w orking example below => https://stackblitz.com/edit/typescript-h7u5zm NPM Install for pixijs npm install pixi.js Typescript Definitions for Pixi.js v4 https://github.com/pixijs/pixi-typescript npm install gsap https://greensock.com/?product-plugin=js-pixiplugin for pixijs

creating a tabbar in reactjs using reusable button class where user can pass any html content using jsx.

full working example in below link:- sample contain three type of component's 1. Button 2. Slider 3. TabBar https://stackblitz.com/edit/react-qjonsv?file=Hello.js tab bar class code:- export class TabBar extends Component { constructor ( props ) { this . state = { content : undefined }; super ( props ); this . tabDataDiv = React . createRef (); } componentDidMount () { this . state = { content : this . props . data [ 0 ]. tabData }; this . setState ( this . state ); } updateTabData ( data ) { this . state = { content : data }; this . setState ( this . state ); } getTabs () { let tabArray =[]; for ( let key in this . props . data ) { tabArray . push (< GTbutton color = "pink" label ={ this . props . data [ key ]. name } buttonClick ={ ()=> ...

creating slider and button as a reusable component in reactjs

wokring link=> https://stackblitz.com/edit/react-qjonsv?file=index.js main class import React , { Component } from 'react' ; import { render } from 'react-dom' ; import { Hello , RoundSlider } from './Hello' ; import './style.css' ; //a button class class GTbutton extends Component { constructor ( props ) { super ( props ); } PointerDown () { this . props . buttonClick (); } render () { return ( < div > < button class = "button" onClick ={ this . click =()=> { this . PointerDown (); }} style ={{ background : this . props . color }}>{ this . props . label }</ button > </ div > ); } } class App extends Component { constructor () { super (); this . state = { name : 'React' }; } handleClick () {...