Skip to content

Instantly share code, notes, and snippets.

View himelnagrana's full-sized avatar

Himel Nag Rana himelnagrana

View GitHub Profile
@himelnagrana
himelnagrana / applaud.html
Last active September 2, 2021 11:42
Applaud Sound Play
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var audioElement = document.createElement("audio");
audioElement.setAttribute("src", "https://www.soundjay.com/human/sounds/applause-01.mp3");
audioElement.addEventListener("ended", function () { audioElement.currentTime = 0; }, false);
@himelnagrana
himelnagrana / basic-utils.ts
Last active September 3, 2021 11:45
a typescript utility class with some basic checks
export class Utils {
static maxItemOfArray = (arr: any) => [...arr].sort((a, b) => b - a).slice(0, 1)[0];
static areAllEqual = (array: any) => array.every((item: any) => item === array[0]);
static averageOf = (...numbers: any) => numbers.reduce((a: any, b: any) => a + b, 0) / numbers.length;
static intersection = (arr1: number[], arr2: number[]) => arr1.filter(num => arr2.includes(num));
// following will be applicable only if the arrays are sorted
  • npm install
  • node index.js ba 1000000

Result will be 13

@himelnagrana
himelnagrana / Cefalo School - React Native Class 11.md
Created January 3, 2018 09:12
Cefalo School - React Native Class 11

Cefalo School - React Native Class 11


Running on Devices

ANDROID

  • Enable debugging over usb -- Settings > About Phone -- Tap Build Number row seven times -- Go back one step and Developer Options will be open [Based on Android variants, it might be on top menu or under additional settings] -- Then from Developer Options enable the two items:
@himelnagrana
himelnagrana / ExportingImage.m
Created January 3, 2018 08:32
Passing Properties from Native to RN
NSArray *imageList = @[@"http://www.thinkgeek.com/images/products/frontsquare/jvkn_sw_beak_back_buddy.jpg",
@"https://images-na.ssl-images-amazon.com/images/I/41yAU9p60jL._SY300_.jpg"];
NSDictionary *props = @{@"images" : imageList};
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"ImageBrowserTest"
initialProperties:props];
@himelnagrana
himelnagrana / CalendarManager.h
Created January 3, 2018 05:19
iOS Native Modules
#import <React/RCTBridgeModule.h>
@interface CalendarManager : NSObject <RCTBridgeModule>
@end
@himelnagrana
himelnagrana / EmpManToast.js
Last active January 3, 2018 10:05
Android Native Module Example
/**
* This exposes the native EmpManToast module as a JS module. This has a
* function 'show' which takes the following parameters:
*
* 1. String message: A string with the text to toast
* 2. int duration: The duration of the toast. May be ToastExample.SHORT or
* ToastExample.LONG
*/
import {NativeModules} from 'react-native';
@himelnagrana
himelnagrana / Cefalo School - React Native Class 07.md
Created December 6, 2017 11:26
Cefalo School - React Native Class 07

Cefalo School - React Native Class 07


REACT NATIVE APIs

  • React Native provides a number of built-in components.There are a number of APIs for both the platforms (common and individuals).

Components and APIs

@himelnagrana
himelnagrana / Cefalo School - React Native Class 06.md
Last active November 29, 2017 09:58
Cefalo School - React Native Class 06

Cefalo School - React Native Class 06


BASICS

  • Build native mobile apps using JavaScript and React

Sample Code 1

  • With React Native, you don't build a mobile web app, an HTML5 app, or a hybrid app. You build a real mobile app that's indistinguishable from an app built using Objective-C or Java.
import React, { Component } from 'react';
import { Image, ScrollView, Text } from 'react-native';
class AwkwardScrollingImageWithText extends Component {
render() {
return (
<ScrollView>
<Image
source={{uri: 'https://i.chzbgr.com/full/7345954048/h7E2C65F9/'}}
style={{width: 320, height:180}}