Skip to content

Instantly share code, notes, and snippets.

View oyekanmiayo's full-sized avatar
🎯
Focusing

Ayomide Oyekanmi oyekanmiayo

🎯
Focusing
View GitHub Profile
@oyekanmiayo
oyekanmiayo / c.c
Last active December 13, 2022 20:59
How to read from and write to standard input and ouput.
#include <stdlib.h>
int main(){
// Read integer from line
int t;
scanf("%d",&t);
// Read integer from line times
for(int a0 = 0; a0 < t; a0++){
@oyekanmiayo
oyekanmiayo / slack.js
Created September 11, 2022 22:49
How to call slack API
// See https://developers.google.com/apps-script/guides/services/external
// and https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
function fetchListOfChannels() {
var options = {
'method' : 'get',
'contentType': 'application/json',
'headers': {
'Authorization': 'Bearer <access_token>',
}
};
@oyekanmiayo
oyekanmiayo / appscript.js
Last active September 12, 2022 06:57
Cool things to do on Appscript
// Enter value in a cell
var valueRange = Sheets.newValueRange();
valueRange.values = [["text"]];
const result = Sheets.Spreadsheets.Values.update(valueRange,
SHEET_ID, A1_NOTATION, {valueInputOption: "RAW"});
// Fetches values as a multidimensional array
Sheets.Spreadsheets.Values.get(SHEET_ID, RANGE)
@oyekanmiayo
oyekanmiayo / rm_mysql.md
Created December 12, 2021 23:06 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    
@oyekanmiayo
oyekanmiayo / del-req.go
Last active December 7, 2020 14:05
Get Request in Go
// reference: https://stackoverflow.com/questions/46310113/consume-a-delete-endpoint-from-golang
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func sendRequest() {
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class AESCBCDecryption {
static final String cipher_type = "AES/CBC/PKCS5Padding";
public static void main(String[] args) {
String key = "57067125438768260656188878670043";
@oyekanmiayo
oyekanmiayo / MinimumWindowSubstring.java
Last active October 14, 2020 23:24
Minimum Window Substring
class Solution {
// This approach is O(n), where n = length of string s
// The sliding window approach uses two pointers to traverse a string in linear time. Each character is visited
// at most twice
// There's a method `mapHasAllChars` whose time complexity may not be intuitive, so it's worth mentioning. At most
// each map will contain all the characters from the ascii set (0 - 255), so we know that at most we will always visit 256
// keys every time we call this method. So note this =>
// AS LONG AS WE KNOW THE WORST CASE FOR NUMBER OF LOOP ITERATIONS BEFOREHAND, THAT LOOP'S TIME COMPLEXITY IS CONSTANT
public String minWindow(String s, String t) {
//Edge Cases
@oyekanmiayo
oyekanmiayo / UniquePathsIII.java
Created August 9, 2020 18:06
Solution to "Unique Path III" on Leetcode
class Solution {
/*
Approach:
- Find start position
- Count number of visitable nodes in the grids
- A path is only valid if we read end node && all visitable nodes have been visited
- Perform dfs, everytime we visit a cell, we mark as visited.
- We cannot visit a cell more than once
- Handle boundary edge cases too
@oyekanmiayo
oyekanmiayo / RobotRoomCleaner.java
Last active August 9, 2020 21:52
Solution to "Robot Room Cleaner" on Leetcode
/**
* // This is the robot's control interface.
* // You should not implement it, or speculate about its implementation
* interface Robot {
* // Returns true if the cell in front is open and robot moves into the cell.
* // Returns false if the cell in front is blocked and robot stays in the current cell.
* public boolean move();
*
* // Robot will stay in the same cell after calling turnLeft/turnRight.
* // Each turn will be 90 degrees.
@oyekanmiayo
oyekanmiayo / FindMinInArrayII.java
Last active August 9, 2020 06:26
Solution to " Find Minimum in Rotated Sorted Array II" on Leetcode
class Solution {
// Final solution
public int findMin(int[] nums) {
int start = 0;
int end = nums.length - 1;
while(start < end){
int mid = start + (end - start) / 2;
if(nums[mid] < nums[end]){