Skip to content

Instantly share code, notes, and snippets.

View rebelmachina's full-sized avatar

rebelmachina rebelmachina

  • San Francisco
  • 07:14 (UTC -12:00)
View GitHub Profile
@rebelmachina
rebelmachina / get_comments_by_user.sh
Created August 12, 2024 23:37
get comments for a user
token=""
username="@me"
curl -H "Authorization: Bearer ${token}" \
"https://api.github.com/search/issues?q=is:issue+commenter:${username}"
@rebelmachina
rebelmachina / recursive_bucket_sort.py
Last active August 23, 2022 05:20
recursive_bucket_sort
import random
def sort_helper(lst, idx, max_idx, reversed):
# base case
if not lst or len(lst) == 1:
return lst
if idx >= max_idx:
return lst
@rebelmachina
rebelmachina / opencv.md
Created September 20, 2018 14:37
install opencv with pip
pip install opencv-python
@rebelmachina
rebelmachina / templated_class_derivation.cpp
Created December 14, 2017 18:03
templated class derivation example
#include <cstdio>
#include <utility>
#include <iostream>
template<class T>
class Addition {
protected:
T a_;
public:
@rebelmachina
rebelmachina / templated_functions
Last active November 10, 2017 15:45
templated functions in c++
// my_type.hpp
template<typename T>
void foo(T n) { }
// my_type.cpp
#include "my_type.hpp"
#include<iostream>
@rebelmachina
rebelmachina / stripSurroundingSpaces.cpp
Created August 21, 2017 23:40
strip surrounding spaces in C++
string stripSurroundingSpaces(string s) {
int i = 0;
while(i<s.size() && s[i] == ' ') {
i++;
}
int j = s.size()-1;
while(j >= 0 && s[j] == ' ') {
j--;
}
@rebelmachina
rebelmachina / tokenize_in_c++11.cpp
Created August 20, 2017 14:39
tokenize a string by a separator in C++11
#include <bits/stdc++.h>
using namespace std;
vector<string> tokenize(string data, string sep = " ") {
vector<string> tokens;
if(data.empty()) {
return tokens;
}
size_t lpos = 0, rpos;
while(true) {
@rebelmachina
rebelmachina / Read_N_Characters_Given_Read4_II.cpp
Created August 17, 2017 15:55
Read N Characters Given Read4 II - Call multiple times: LEETCODE SOLUTION
// Forward declaration of the read4 API.
int read4(char *buf);
class Solution {
public:
/**
* @param buf Destination buffer
* @param n Maximum number of characters to read
* @return The number of characters read
*/
@rebelmachina
rebelmachina / strategy_pattern_with_std_function.cpp
Created July 24, 2017 22:14
Strategy Pattern with std::function
#include <bits/stdc++.h>
using namespace std;
class Number{
private:
int _val;
std::function<void(Number&,int)> _strategy;
public:
Number() : _strategy(nullptr) {}
Install Anaconda, graphical or command-line installer. If you have command-line installer, then make sure to have ~/.bash_profile:
```
export PATH="/Users/yourusername/anaconda3/bin:$PATH"
```
Then type in the terminal:
```
conda create -n cv_env numpy scipy scikit-learn matplotlib python=3
source activate cv_env