Skip to content

Instantly share code, notes, and snippets.

steerapi /
Created March 13, 2015 21:19
pycuda Mac OS X 10.10
BOOST_PYTHON_LIBNAME = ['boost_python-py27']
BOOST_THREAD_LIBNAME = ['boost_thread']
CUDA_ROOT = '/usr/local/cuda'
yono /
Last active December 26, 2017 08:57
fabric で踏み台サーバ越しに ssh アクセス


  • [local] -> [admin] -> [prod]
  • [admin] -> [prod] の鍵は事前に配置済み
  • $HOME/.ssh/config で設定
  • 踏み台サーバ(admin)、目的のサーバ(prod) どちらにも鍵認証でログイン


  • $HOME/.ssh/config だけだと実行終了時の DONE で固まる
dannyvassallo / 20160216211105_create_images.rb
Created February 16, 2016 21:32
Use tinymce-rails & tinymce-rails-imageupload with carrierwave & fog
# db/migrate/filename.rb
# generate with >> rails g model image alt:string hint:string file:string
class CreateImages < ActiveRecord::Migration[5.0]
def change
create_table :images do |t|
t.string :alt
t.string :hint
t.string :file
duhaime /
Last active March 1, 2023 08:41
Compare image similarity in Python using Structural Similarity, Pixel Comparisons, Wasserstein Distance (Earth Mover's Distance), and SIFT
import warnings
from skimage.measure import compare_ssim
from skimage.transform import resize
from scipy.stats import wasserstein_distance
from scipy.misc import imsave
from scipy.ndimage import imread
import numpy as np
import cv2
fchollet /
Last active September 13, 2023 03:34
Fine-tuning a Keras model. Updated to the Keras 2.0 API.
'''This script goes along the blog post
"Building powerful image classification models using very little data"
It uses data that can be downloaded at:
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
turadg / subdomains.rb
Last active January 21, 2024 19:45 — forked from rtekie/subdomains.rb
Drop-in utility to test your app subdomains with Capybara, Rspec, and a Javascript driver (Poltergeist, Webkit, or Selenium)
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
# (e.g. save as spec/support/subdomains.rb)
def switch_to_subdomain(subdomain)
# always resolves to
hostname = subdomain ? "#{subdomain}" : ""
Capybara.app_host = "http://#{hostname}"
ghandic /
Last active March 15, 2024 14:16
Load image from S3 directly into memory as PIL image and write to S3 directly from memory from PIL image
import boto3
from PIL import Image
from io import BytesIO
import os
class S3ImagesInvalidExtension(Exception):
class S3ImagesUploadFailed(Exception):
kylehounslow /
Last active April 23, 2024 10:58
Send and receive images using Flask, Numpy and OpenCV
from __future__ import print_function
import requests
import json
import cv2
addr = 'http://localhost:5000'
test_url = addr + '/api/test'
# prepare headers for http request
content_type = 'image/jpeg'
aronwc /
Last active April 30, 2024 06:54
Example using GenSim's LDA and sklearn
""" Example using GenSim's LDA and sklearn. """
import numpy as np
from gensim import matutils
from gensim.models.ldamodel import LdaModel
from sklearn import linear_model
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
bwhite /
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
Learning to Rank for Information Retrieval (Tie-Yan Liu)
import numpy as np