Skip to content

Instantly share code, notes, and snippets.

View arifqodari's full-sized avatar

Arif Qodari arifqodari

  • Indonesia
View GitHub Profile
@arifqodari
arifqodari / virtualenvwrapper-venv-aliases.sh
Last active February 8, 2021 15:02 — forked from FlipperPA/virtualenvwrapper-venv-aliases.sh
Shortcuts for Python 3's venv for virtualenvwrapper users.
export VENV_HOME=~/.venvs
export VENV_PYTHON=/usr/bin/python3
fn_workon() {
if [ -f "${VENV_HOME}/${1}/bin/activate" ]; then
export VENV_CURRENT="${VENV_HOME}/${1}"
# Run commands before activation
if [ -f "${VENV_CURRENT}/pre_activate.sh" ]; then
. "${VENV_CURRENT}/pre_activate.sh"
fi
# how to write do-while loop (kind of)
# starts with regular while loop
while True:
# call your function here
stuff()
if fail_condition:
# if fail condition met
# exit from while loop
break
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
0
0
1
0
0
0
1
0
1
0
@arifqodari
arifqodari / Dockerfile
Last active June 5, 2018 02:53
Dockerfile for python2.7 and OpenCV 3.4.1
FROM python:2.7
RUN apt-get update && apt-get install -y wget unzip build-essential cmake git libgtk2.0-dev pkg-config \
libavcodec-dev libavformat-dev libswscale-dev \
libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev \
libjasper-dev libdc1394-22-dev && pip install numpy && mkdir -p ~/opencv && cd ~/opencv && wget https://github.com/opencv/opencv/archive/3.4.1.zip && \
unzip 3.4.1.zip && cd opencv-3.4.1 && mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON_EXECUTABLE=/usr/local/bin/python \
@arifqodari
arifqodari / strided_convolution.py
Created May 15, 2018 08:41
Strided convolution using numpy
import numpy as np
from numpy.lib.stride_tricks import as_strided
def strided_convolution(image, weight, stride):
im_h, im_w = image.shape
f_h, f_w = weight.shape
out_shape = (1 + (im_h - f_h) // stride, 1 + (im_w - f_w) // stride, f_h, f_w)
out_strides = (image.strides[0] * stride, image.strides[1] * stride, image.strides[0], image.strides[1])
#!/bin/bash
mkdir -p bin
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '61069fe8c6436a4468d0371454cf38a812e451a14ab1691543f25a9627b97ff96d8753d92a00654c21e2212a5ae1ff36') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=bin --filename=composer
rm composer-setup.php
@arifqodari
arifqodari / copy_net.py
Created December 13, 2016 05:43
Copy Caffe Model
import caffe
import argparse
def show_net_info(net):
print '\n'
print 'layer output shape'
for layer_name, blob in net.blobs.iteritems():
print layer_name + '\t' + str(blob.data.shape)
@arifqodari
arifqodari / demo_matching.py
Created October 8, 2016 15:47
demo brute force image matching with SIFT features
import cv2
from sys import argv
from draw_matches import drawMatches
def main(image1_file, image2_file):
# load images
image1 = cv2.imread(image1_file, 0)
image2 = cv2.imread(image2_file, 0)
@arifqodari
arifqodari / caffe_graph_net.py
Created May 18, 2016 00:44 — forked from taoari/caffe_graph_net.py
CAFFE visualize net prototxt with graphviz
#!/usr/bin/env python
import caffe
from caffe.proto import caffe_pb2
from google.protobuf import text_format
class structtype:
pass
def loadSolver(fn):
with open(fn) as f:
# change the hardstatus settings to give an window list at the bottom of the
# screen, with the time and date and with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%= %{= kw}%?%-Lw%?%{r}(%{G}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][ %{G}%H %{g} %{B} %d/%m %{W}%c %{g}]'
# fix the altscren
altscreen on
defscrollback 10000