Skip to content

Instantly share code, notes, and snippets.

View ashish173's full-sized avatar
🏠
Working from home

Ashish Singh ashish173

🏠
Working from home
View GitHub Profile
@ashish173
ashish173 / .deps...remix-tests...remix_accounts.sol
Created April 17, 2022 07:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
address[15] memory accounts;
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;

Keybase proof

I hereby claim:

  • I am ashish173 on github.
  • I am ashishait (https://keybase.io/ashishait) on keybase.
  • I have a public key ASBd6vMalHeeL01NO8cp45RIAF8VewFO3Gw99G-i5PuA4Ao

To claim this, I am signing this object:

@ashish173
ashish173 / happy-point.markdown
Created September 19, 2017 14:40
happy point
@ashish173
ashish173 / flatten.js
Created September 13, 2017 13:25
Flatten an arran in JS
function flatten(arr) {
var i = 0;
while (i < arr.length) {
arr = arr.reduce(function (prev, curr) {
return prev.concat(curr);
}, []);
i++;
}
return arr;
}
@ashish173
ashish173 / ngif_local_ref.ts
Last active July 7, 2017 16:24
NgIf Else local data reference
<div *ngIf="$userObservable | async; else loading; let user">
Hello {{user.last}}, {{user.first}}!
</div>
<ng-template #loading>Fetching data...</ng-template>
@ashish173
ashish173 / update_view_method.ts
Created December 19, 2016 02:09
Update view for NgIf Else Directive
private _updateView() {
if (this._context.$implicit) {
if (!this._thenViewRef) {
this._viewContainer.clear();
this._elseViewRef = null;
if (this._thenTemplateRef) {
this._thenViewRef =
this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
}
}
@ashish173
ashish173 / flatmap.ts
Created December 8, 2016 21:38
FlatMap
var source = Rx.Observable
.range(1, 2)
.flatMap(function (x) {
return Rx.Observable.range(x, 2);
});
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });
@ashish173
ashish173 / switchMap.ts
Created December 8, 2016 21:29
SwitchMap operator
//emit immediately, then every 5s
const source = Rx.Observable.timer(0, 5000);
//switch to new inner observable when source emits, emit items that are emitted
const example = source.switchMap(() => Rx.Observable.interval(500));
//output: 0,1,2,3,4,5,6,7,8,9...0,1,2,3,4,5,6,7,8
const subscribe = example.subscribe(val => console.log(val));
//emit every click
const sourceTwo = Rx.Observable.fromEvent(document, 'click');
//if another click comes within 3s, message will not be emitted
@ashish173
ashish173 / map.ts
Created December 8, 2016 21:26
Map operator
//emit (1,2,3,4,5)
const source = Rx.Observable.from([1,2,3,4,5]);
//add 10 to each value
const example = source.map(val => val + 10);
//output: 11,12,13,14,15
const subscribe = example.subscribe(val => console.log(val));
//emit ({name: 'Joe', age: 30}, {name: 'Frank', age: 20},{name: 'Ryan', age: 50})
const sourceTwo = Rx.Observable.from([{name: 'Joe', age: 30}, {name: 'Frank', age: 20},{name: 'Ryan', age: 50}]);
//grab each persons name