Skip to content

Instantly share code, notes, and snippets.

View iamonuwa's full-sized avatar
💭
Learning 🦀

Onuwa Nnachi Isaac iamonuwa

💭
Learning 🦀
View GitHub Profile
@Nikolaj-K
Nikolaj-K / imusify_reward_model_v2.py
Created February 14, 2018 01:32
imusify reward model 2.0 dummy reference implementation
import math
ICO_SUPPLY = 10**9
DECIMALS = 8
FLOAT_FACTOR = 10**DECIMALS
IMUSIFY_OPERATION_STACK = (3-1) * ICO_SUPPLY * FLOAT_FACTOR
SOME_USER_ADDRESS = 'ASsudg...poor soul'
IMUSIFY_MAIN_IMU_ADDRESS = "AXjsdb...much IMU here"
IMUSIFY_OPERATION_IMU_ADDRESS = "AKjsdb...less IMU here"
@swapnilmishra
swapnilmishra / Carddetection.js
Last active January 15, 2020 18:28
Javascript function to detect type of debit/credit card
function getCardType(cardNum) {
if(!luhnCheck(cardNum)){
return "";
}
var payCardType = "";
var regexMap = [
{regEx: /^4[0-9]{5}/ig,cardType: "VISA"},
{regEx: /^5[1-5][0-9]{4}/ig,cardType: "MASTERCARD"},
{regEx: /^3[47][0-9]{3}/ig,cardType: "AMEX"},
@Zyzle
Zyzle / auth.guard.ts
Created July 21, 2016 10:32
Angular 2 Firebase auth guard
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { FirebaseAuth, FirebaseAuthState } from 'angularfire2';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private auth: FirebaseAuth, private router: Router) { }
@odigity
odigity / Firebase Database API Cheatsheet
Last active June 9, 2022 03:45
Firebase Database API Cheatsheet
There is no way to store an empty object/array/null value.
There are also no actual arrays. Array values get stored as objects with integer keys.
(If all keys are integers, it will be returned as an array.)
Basically, it's one giant tree of hashes with string keys.
Simply write a value to any location, and the intermediary locations will automatically come into existance.
── Classes ──
DataSnapshot : Container for a subtree of data at a particular location.
@sandeepsuvit
sandeepsuvit / interfaces.mongo-options.interface.ts
Created January 13, 2020 08:23 — forked from AliYusuf95/interfaces.mongo-options.interface.ts
MongoDB driver module for NestJS with dynamic mongo connection creation per request and handling open connections
import { ModuleMetadata, Type } from '@nestjs/common/interfaces'
/**
* Options that ultimately need to be provided to create a MongoDB connection
*/
export interface MongoModuleOptions {
connectionName?: string
uri: string
dbName: string
clientOptions?: any
@ckimrie
ckimrie / example.component.ts
Last active December 12, 2023 20:53
Example on how to achieve RxJS observable caching and storage in Angular 2+. Ideal for storing Http requests client side for offline usage.
import { Component, OnInit, OnDestroy } from '@angular/core';
import {Http} from "@angular/http";
import { LocalCacheService } from "./local-cache.service";
@Component({
selector: 'app-example',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class ExampleComponent implements OnInit, OnDestroy {
@nathanhleung
nathanhleung / FIX-MACOS-HANG.md
Last active February 24, 2024 08:25
Fix macOS Hanging Issue

Fix macOS Hanging Issue

Problem

Hey Apple users:

If you're now experiencing hangs launching apps on the Mac, I figured out the problem using Little Snitch.

It's trustd connecting to http://ocsp.apple.com >

@Luccasoli
Luccasoli / useReactNavigationQuery
Created May 14, 2021 23:44
useQuery layer implementing refetchOnWindowFocus in react-native project using react-navigation
import { useFocusEffect } from '@react-navigation/core';
import { useCallback } from 'react';
import {
QueryFunction,
QueryKey,
useQuery,
UseQueryOptions,
UseQueryResult,
} from 'react-query';
@AliYusuf95
AliYusuf95 / interfaces.mongo-options.interface.ts
Created September 8, 2019 14:02
MongoDB driver module for NestJS with dynamic mongo connection creation per request and handling open connections
import { ModuleMetadata, Type } from '@nestjs/common/interfaces'
/**
* Options that ultimately need to be provided to create a MongoDB connection
*/
export interface MongoModuleOptions {
connectionName?: string
uri: string
dbName: string
clientOptions?: any
@anchan828
anchan828 / README.md
Last active May 1, 2024 04:26
This is an improvement to allow @nestjs/typeorm@8.1.x to handle CustomRepository. I won't explain it specifically, but it will help in some way. https://github.com/nestjs/typeorm/pull/1233

You need to provide some classes and decorators yourself to maintain the same style as typeorm@2.x.

1. EntityRepository -> CustomRepository

@EntityRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {}