Skip to content

Instantly share code, notes, and snippets.

@olee12
olee12 / quick_sort.cpp
Last active October 13, 2021 16:26
quick sort from CLRS
#include <iostream>
#include <vector>
using namespace std;
int partition(vector<int> &vec, int p, int r) ;
void quickSort(vector<int> &vec, int p, int r) {
if(p < r) {
int q = partition(vec, p, r);
quickSort(vec, p, q - 1);
@olee12
olee12 / cloudera-docker.md
Created April 13, 2021 07:26 — forked from davideicardi/cloudera-docker.md
Running Cloudera with Docker for development/test
@olee12
olee12 / curl_post_json.md
Created January 10, 2021 10:34 — forked from ungoldman/curl_post_json.md
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@olee12
olee12 / robert_morris_algo.go
Created December 31, 2020 14:33
Robert Morris algo
package main
// Robert Morris algo
import (
crand "crypto/rand"
"fmt"
"io"
"math/rand"
"time"
)
@olee12
olee12 / race_condition_pointer_of_pointer.go
Created August 10, 2020 11:51
Wrong Try to update config using pointer of pointer
package main
import (
"context"
"fmt"
"math/rand"
"reflect"
"sync"
"time"
"unsafe"
gcloud container clusters list
gcloud container clusters resize $CLUSTER_NAME --num-nodes=0
export KUBECONFIG=/path/to/admin.conf
@olee12
olee12 / google oauth.go
Created January 7, 2020 03:05
google oauth
package main
import (
"context"
"crypto/rand"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/gorilla/sessions"
"github.com/prometheus/common/log"
@olee12
olee12 / iterm2.md
Created November 5, 2019 07:17 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@olee12
olee12 / max sliding window.cpp
Created October 20, 2019 08:59
max sliding window
vector<int> maxSlidingWindow(vector<int>& nums, int k) {
deque<pair<int,int>> q;
vector<int> ret;
for(int i = 0;i<nums.size();i++) {
while(q.size() && q.back().first <= nums[i]) q.pop_back();
q.push_back({nums[i],i});
while(q.front().second <= (i-k)) q.pop_front();
if(i + 1 >= k) ret.push_back(q.front().first);
}
return ret;
@olee12
olee12 / pair min priority_queue.cpp
Created October 20, 2019 07:45
pair min priority_queue
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
/*
top : 9 4
top : 10 5
top : 10 8
top : 15 10
*/