Skip to content

Instantly share code, notes, and snippets.

View muhammadawaisshaikh's full-sized avatar
💻
#codedWorld #dev

Muhammad Awais muhammadawaisshaikh

💻
#codedWorld #dev
View GitHub Profile
@muhammadawaisshaikh
muhammadawaisshaikh / dependency-injection.component.ts
Created October 19, 2019 18:25
Deep Dive into Dependency Injection
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dependency-injection',
templateUrl: './dependency-injection.component.html',
styleUrls: ['./dependency-injection.component.scss']
})
export class DependencyInjectionComponent implements OnInit {
// Car
@muhammadawaisshaikh
muhammadawaisshaikh / data.service.ts
Created October 24, 2019 10:39
Unrelated Components: Sharing Data with a Service - Angular
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable()
export class DataService {
private messageSource = new BehaviorSubject('default message');
currentMessage = this.messageSource.asObservable();
constructor() { }
@muhammadawaisshaikh
muhammadawaisshaikh / template-literals-hackerrank.js
Created November 18, 2019 12:04
Day 5: Template Literals hacker rank
let expressions = [10, 14];
console.log(expressions);
let p1 = expressions[1];
let a1 = expressions[0];
let s1 = (p1 + (Math.sqrt(Math.pow(p1, 2) - 16 * a1 )))/4;
let s2 = (p1 - (Math.sqrt(Math.pow(p1, 2) - 16 * a1 )))/4;
let arr = [];
// find repetitive charachters from string using javascript
var str = 'abcaefbhij';
var count = 1;
var num = 0;
var temp = str.charAt(num);
// console.log(temp);
for (let i = 1; i <= str.length; i++) {
if (str.charAt(i)==temp) {
@muhammadawaisshaikh
muhammadawaisshaikh / getVendorsRails.txt
Created December 8, 2019 18:15
getting vendors in different controller select html using rails
def get_vendors
@vendors = Vendor.all.order(id: :asc)
@vendors_array = []
@vendors.each do |vendor|
@vendors_array << vendor.name
end
end
def new
// 1. Set up the reCAPTCHA verifier
// firebase.auth().languageCode = 'it';
// To apply the default browser preference instead of explicitly setting it.
firebase.auth().useDeviceLanguage();
// Use invisible reCAPTCHA
function captchaVerifier() {
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
'size': 'invisible',
@muhammadawaisshaikh
muhammadawaisshaikh / auth_controller.rb
Created January 2, 2020 07:37
firebase and google cloud platform send code and verification code using ruby
require 'open-uri'
module Api
module V1
class AuthController < ApplicationController
# send code
def send_code
phone_number = params[:phone_number]
recaptcha_token = params[:recaptcha_token]
@muhammadawaisshaikh
muhammadawaisshaikh / higher-order-component.js
Created January 22, 2020 13:28
React superpowers with the HOC Pattern
import React from "react";
class Welcome extends React.Component {
render() {
return (
<div>
Welcome {this.props.user}
</div>
);
}
@muhammadawaisshaikh
muhammadawaisshaikh / HOC.js
Created January 23, 2020 05:03
ReactJS Higher Order Components Tutorial
import React, {Component} from 'react';
export default function Hoc(HocComponent, data){
return class extends Component{
constructor(props) {
super(props);
this.state = {
data: data
};
}
@muhammadawaisshaikh
muhammadawaisshaikh / index.html
Created February 3, 2020 07:05
getting event value on message click using vanilla javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>