Skip to content

Instantly share code, notes, and snippets.

View bryangarza's full-sized avatar

Bryan Garza bryangarza

View GitHub Profile
@bryangarza
bryangarza / squash.md
Created December 27, 2022 21:49 — forked from lpranam/squash.md
How to squash commits

What is squashing?

Squashing is a process in which we squeeze multiple commits into one pretending it is only a single commit.

Basically squashing commits means we are rewriting the history of commits to make them look like single commit.

squash-diagram.jpg

Why squashing commits is necessary?

import java.util.*;
import java.lang.*;
public class Solution {
public boolean canFinish(int numCourses, int[][] prerequisites) {
return !hasCycle(numCourses, prerequisites);
}
private boolean hasCycle(int numCourses, int[][] prerequisites) {
List<Integer>[] g = constructGraph(numCourses, prerequisites);

Keybase proof

I hereby claim:

  • I am bryangarza on github.
  • I am bryangarza (https://keybase.io/bryangarza) on keybase.
  • I have a public key ASCt5eIHhV21eg8RvqqUPeAYdcrIY6HZ65IXUO0guczM2Ao

To claim this, I am signing this object:

(* ctci 11.2: Write a method to sort an array of strings so that all the
* anagrams are next to each other. *)
let group_anagrams (xs : string array) : unit =
let join (xs : char array) : string =
String.concat_array (Array.map ~f:Char.to_string xs) in
let key (s : string) : string =
let chars = String.to_array s in
Array.sort chars ~cmp:Char.compare;
join chars in
open Printf
let fetch_ints (size : int) : int array =
Array.init size (fun x -> read_int())
let insertion_sort =
let size = read_int() in
let sizep = pred size
and arr = fetch_ints size in
let x = arr.(sizep) in
module FilterElems where
import Data.List
import Control.Monad
-- abstract tuple comparison
sortTup f =
case ord of
EQ -> snd f
_ -> ord
where ord = fst f
import Control.Monad (liftM2)
import Data.List (tails)
import Data.Maybe (fromMaybe, mapMaybe)
import Safe.Foldable (maximumMay)
prices = [10, 30, 42, 15, 20, 50, 10, 25]
profit :: [Integer] -> Integer
profit = fromMaybe 0 . maximumMay . mapMaybe (uncurry (liftM2 (-))) . large
#lang racket
(require racket/match)
;; initial-state :: State
;; State = (Missionaries on left, Cannibals on left, Boat on left?)
(define initial-state '(3 3 #t))
;; goal-state :: State
(define goal-state '(0 0 #f))
@bryangarza
bryangarza / salty.md
Created June 2, 2015 04:51
Please stop :/

Hi! This question may have already been asked (and answered). Please consider referring to any of the following threads, and remember to use search next time. Thank you :)

Just out of curiosity, which is better for development, Windows or Mac? I personally use windows and haven't used a Mac? So just wanted your opinion ? https://www.facebook.com/groups/hackathonhackers/permalink/1058602237528594/

Why should one get a macbook pro? Haven't used one ever. https://www.facebook.com/groups/hackathonhackers/permalink/1057089381013213/

Alright, Time for a new laptop for College. Mac or PC? Going to college for CS. https://www.facebook.com/groups/hackathonhackers/permalink/1056270107761807/

(require 'cl)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(evil