Skip to content

Instantly share code, notes, and snippets.

View amir-rahnama's full-sized avatar

Amir Rahnama amir-rahnama

  • Stockholm, Sweden
View GitHub Profile
@amir-rahnama
amir-rahnama / gulpfile.js
Last active July 16, 2018 14:54
Minimal gulpfile.js with Server, LiveReload and Watch Task for JS and Sass/Css
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
connect = require('gulp-connect'),
livereload = require('gulp-livereload'),
paths = {
scripts: ['scripts/*.js'],
html: ['*/*.html'],
style_css: 'styles/css',
style_sass: 'styles/sass'
},
@amir-rahnama
amir-rahnama / knn.ipynb
Last active November 30, 2018 13:30
An implementation of KNN based on Numpy and Pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amir-rahnama
amir-rahnama / create-ngrams.R
Last active February 21, 2019 18:54
Create N-grams for large text-files (very fast)
source("fast-ngrams.R")
con <- file("path_to_file", "r")
data <- readLines(con, encoding = 'UTF-8')
close(con)
data <- clean(data)
onegram <- text_to_ngrams(decode(data), 1)
bigram <- text_to_ngrams(decode(data), 2)
trigram <- text_to_ngrams(decode(data, 3))
@amir-rahnama
amir-rahnama / README.md
Last active June 5, 2019 14:07
A simple Webpack (with Dev Server) + Gulp Configuration + LiveReload + Babel to playground where you can code ES6 without the need for React

A simple Webpack + Gulpfile configuration wihtout any need for React.js that assumes you have the following project structure:

node_modules/ bower_components/ scripts/

Entry script is in scripts/entry.js

You should run gulp && gulp build-dev and you are good to go.

@amir-rahnama
amir-rahnama / dataset.py
Created December 6, 2016 20:39
Write Your Own Custom Image Dataset for Tensorflow
"""A generic module to read data."""
import numpy
import collections
from tensorflow.python.framework import dtypes
class DataSet(object):
"""Dataset class object."""
def __init__(self,
@amir-rahnama
amir-rahnama / cross_validation.py
Last active November 5, 2020 09:32
Cross validation with pure numpy
import numpy as np
np.random.seed(0)
def cross_validation(X, y, cv_size=0.1):
"""Run cross validation on a numpy ndarray and return corresponding indices as well
@param: X data in the form of numpy ndarray
@param: y labels in the form of numpy ndarray
@param: cv_size size of the test set
@amir-rahnama
amir-rahnama / docker-compose.yml
Created August 16, 2016 14:26
OSRM Docker-Compose file for a Stack with OSRM and Nominatim (Data container included)
osrm:
command: './start.sh Sweden http://download.geofabrik.de/europe/sweden-latest.osm.pbf'
image: 'irony/osrm5:latest'
ports:
- '5000:5000'
volumes_from:
- osrm-data
osrm-data:
image: 'irony/osrm5:latest'
volumes: