Skip to content

Instantly share code, notes, and snippets.

View rammyblog's full-sized avatar

Babatunde Onasanya rammyblog

View GitHub Profile
@rammyblog
rammyblog / Valid Palindrome.js
Created October 9, 2025 23:28
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.
/**
* @param {string} s
* https://leetcode.com/problems/valid-palindrome/
* @return {boolean}
*/
var isPalindrome = function(s) {
const words = s.toLowerCase().replace(/[^a-zA-Z0-9]/g, '')
let valid = false
let leftPointer = 0
let rightPointer = words.length - 1
@rammyblog
rammyblog / isAnagram.js
Created October 8, 2025 09:04
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
/**
* https://leetcode.com/problems/valid-anagram/
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isAnagram = function(s, t) {
if(s.length !== t.length){
return false
}
@rammyblog
rammyblog / groupAnagrams.js
Created October 7, 2025 23:34
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
/**
* https://leetcode.com/problems/group-anagrams/
* @param {string[]} strs
* @return {string[][]}
*/
var groupAnagrams = function(strs) {
const ma = new Map()
const final = []
for(const word of strs){
let current = word
@rammyblog
rammyblog / containsDuplicate.js
Created October 7, 2025 22:07
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
/**
* @param {number[]} nums
* @return {boolean}
* https://leetcode.com/problems/contains-duplicate/description/
*/
var containsDuplicate = function(nums) {
const hash = {}
for(let i = 0; i<=nums.length; i++){
let current = nums[i]
if(current in hash){
@rammyblog
rammyblog / TwoSum.js
Last active October 7, 2025 21:56
Two Sum Solution
/**
* https://leetcode.com/problems/two-sum/
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var twoSum = function(nums, target) {
const hash = {}
for(let i = 0; i<=nums.length; i++){
let current = nums[i] // 7
@rammyblog
rammyblog / Local PR test and merge.md
Created August 10, 2021 09:20 — forked from adam-p/Local PR test and merge.md
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
import { createContext } from "react"
import priceTrackerApi from "../../api/apiUtils"
const initalTrackerState = {
loading: false,
data: null,
error: false,
errResponse: null,
}
@rammyblog
rammyblog / py_gravatar.py
Last active May 15, 2020 21:51
Gravatar Python3 Image Requests (Get Gravatar Image URL using user email)
import hashlib
import requests
def get_gravatar_image_url(email):
# Set your variables here
default = "https://res.cloudinary.com/rammy/image/upload/ar_4:3,c_fill/c_scale,w_auto,dpr_auto/v1589578218/default_avatar.png"
size = 200
base_url = "https://www.gravatar.com/avatar/"
import React, { Component } from 'react';
import axios from 'axios';
const GlobalContext = React.createContext();
GlobalContext.displayName = "Context Setup";
class GlobalProvider extends Component {
state = {
data: []
body{
background: #E5E5E5;
}
.wrapper{
min-height: 100%;
display: flex;
align-items: center;
justify-content: center;
}