Skip to content

Instantly share code, notes, and snippets.

View tolumide-ng's full-sized avatar

Tolumide Shopein tolumide-ng

  • Ex-Andela
  • Berlin, Germany
  • 05:40 (UTC -12:00)
View GitHub Profile
mod Graph {
use std::collections::HashMap;
pub struct DAG {
graph: Option<HashMap<u8, Vec<u8>>,
}
impl DAG {
pub fn new(graph_info: Vec<(u8, u8)>) -> Vec<u8> {...}
pub fn execute() {
use Graphs;
// Graphs::DAG::new(vec![(4, 3), (1, 2), (4, 1), (3, 1)]);
// Graphs::DAG::new(vec![(1, 2), (1, 4), (2, 3), (2, 4), (4, 3), (4, 5)]);
Graphs::DAG::new(vec![(0, 2), (1, 2), (2, 3), (3, 4)]);
}
mod Graphs {
use std::collections::HashMap;
pub fn execute() {
use Graphs;
// Graphs::DAG::new(vec![(4, 3), (1, 2), (4, 1), (3, 1)]);
// Graphs::DAG::new(vec![(1, 2), (1, 4), (2, 3), (2, 4), (4, 3), (4, 5)]);
let result = Graphs::DAG::new(vec![(0, 2), (1, 2), (2, 3), (3, 4)]);
println!("THE RESULT >>> {:?}", result);
}
import * as React from "react";
interface entryDef {
isIntersecting: Boolean;
intersectionRatio: number;
}
interface IntersectionObserverDef {
ancestorElem?: Element,
}
import * as React from "react";
interface entryDef {
isIntersecting: Boolean;
intersectionRatio: number;
}
interface IntersectionObserverDef {
ancestorElem?: Element,
}
import * as React from "react";
interface entryDef {
isIntersecting: Boolean;
intersectionRatio: number;
}
interface IntersectionObserverDef {
ancestorElem?: Element,
}
import * as React from "react";
export const DisplayProductsComponent = () =>< {
const {createScrollObserver, converge, setConverge} = useIntersectionObserver();
const [product, setProduct] = React.useState<ProductDef>(undefined);
const loadMoreRef = React.useRef<HTMLDivElement>(null);
let scrollObserver = createScrollObserver();
React.useEffect(() => {
// other conditions/cases
@tolumide-ng
tolumide-ng / isObjectDifferent.js
Created March 19, 2021 10:57
Get the difference between two deeply nested Objects in javascript
// this comparison would not work for function and symbol comparisons
// this would only work best for compared objects that do not belong to same address in memory
// Returns true if there is no difference, and false otherwise
export const isObjNotSame = (obj1, obj2) => {
if (typeof obj1 !== "object" && obj1 !== obj2) {
return false;
}
if (typeof obj1 !== "object" && typeof obj2 !== "object" && obj1 === obj2) {
return true;
@tolumide-ng
tolumide-ng / 77. Combinations (#1 Backtracking +DFS).java
Created May 15, 2021 20:27 — forked from yitonghe00/77. Combinations (#1 Backtracking +DFS).java
77. Combinations (https://leetcode.com/problems/combinations/description/): Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
// Backtracking + DFS solution
// Time: O(2 ^ n), 29ms
// Space: O(n) for there will be only n recursion calls (excluding result), 41.6mb
class Solution {
List<List<Integer>> ans;
public List<List<Integer>> combine(int n, int k) {
ans = new ArrayList<>();
combineR(n, k, 1, new ArrayList<>());
return ans;
}
@tolumide-ng
tolumide-ng / delete-likes-from-twitter.md
Created August 30, 2021 21:16 — forked from aymericbeaumet/delete-likes-from-twitter.md
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }