Skip to content

Instantly share code, notes, and snippets.

View akshatamohanty's full-sized avatar

Akshata Mohanty akshatamohanty

View GitHub Profile
@akshatamohanty
akshatamohanty / AnotherCmp.component.ts
Last active May 23, 2018 05:30
Optimized Change Detection in Angular Component
// https://pascalprecht.github.io/slides/angular-2-change-detection-explained/#/109
@Component()
class AnotherCmp {
notifier:Observable<any>;
constructor(private cd: ChangeDetectorRef) {}
ngOnInit() {
@akshatamohanty
akshatamohanty / getByteLen.js
Created May 30, 2018 09:24
bytes-in-string-function
/**
* Count bytes in a string's UTF-8 representation.
* Source: https://codereview.stackexchange.com/questions/37512/count-byte-length-of-string
*
* @param string
* @return int
*/
function getByteLen(normal_val) {
// Force string type
normal_val = String(normal_val);
@akshatamohanty
akshatamohanty / CountingInversions.ts
Created June 20, 2018 11:29
Stanford-Algorithms-Specialization-Coursera
//
// Divide and Conquer Algorithms, Assignment 2
//
abstract class MergeSort{
public static inversions: number = 0;
public static sort(arr: number[]) {
if (arr.length < 2) return arr;
@akshatamohanty
akshatamohanty / gitbook-publish.sh
Created July 25, 2018 05:47
Custom Script to publish a gitbook to gh-pages
#!/bin/bash
function exit_on_error(){
echo $1
git add .
git stash
git stash drop
echo 'moving to master'
git checkout master
exit 1
@akshatamohanty
akshatamohanty / simple-lottery.sol
Last active November 27, 2021 04:18
solidity-saturday-1-simple-lottery
/**
*Submitted for verification at Etherscan.io on 2021-11-26
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract Lottery {
uint MAX_PLAYERS = 3;
address manager;
@akshatamohanty
akshatamohanty / lottery-contract.sol
Last active December 9, 2022 19:21
[Practical Blockchain] Oracles 101: Lottery Contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/ConfirmedOwner.sol";
contract Lottery is VRFConsumerBaseV2, ConfirmedOwner {
event RequestSent(uint256 requestId, uint32 numWords);
event RequestFulfilled(uint256 requestId, uint256[] randomWords);
@akshatamohanty
akshatamohanty / lottery-contract-with-vrf.sol
Created December 9, 2022 19:19
[Practical Blockchain] Oracles 101: Lottery Contract with VRF
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/ConfirmedOwner.sol";
contract Lottery is VRFConsumerBaseV2, ConfirmedOwner {
event RequestSent(uint256 requestId, uint32 numWords);
event RequestFulfilled(uint256 requestId, uint256[] randomWords);
@akshatamohanty
akshatamohanty / lottery-contract.sol
Last active December 9, 2022 19:23
Practical Blockchain: Oracles 101 - Lottery Contract
/** Lottery Contract with VRF **/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/ConfirmedOwner.sol";
contract Lottery is VRFConsumerBaseV2, ConfirmedOwner {
event RequestSent(uint256 requestId, uint32 numWords);