Skip to content

Instantly share code, notes, and snippets.

View guinslym's full-sized avatar

Guinslym guinslym

View GitHub Profile
# Avoid problems when running Capybara specs before regular ones, and fix the
# "Could not find a valid mapping for X". Part of the solution is to use the
# Devise test helpers as explained on link A, but then you need to clear the
# fabricated objects, as explained on link B. Here's the equivalent code when
# using the Fabrication gem
#
# A - http://stackoverflow.com/questions/4230152/mocks-arent-working-with-rspec-and-devise
# B - http://stackoverflow.com/questions/6363471/could-not-find-a-valid-mapping-for-user-only-on-second-and-successive-t
if Rails.env.development? || Rails.env.test?
ActionDispatch::Callbacks.after do
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
@guinslym
guinslym / Gemfile
Created August 15, 2014 01:32 — forked from mshwery/Gemfile
source :rubygems
gem 'jekyll'
gem 'rack-jekyll', :git => 'https://github.com/adaoraul/rack-jekyll'
gem 'coderay'
gem 'thin'
@guinslym
guinslym / jdooxx.py
Created August 21, 2014 18:15 — forked from hzqtc/jdooxx.py
#!/usr/bin/env python
# Example:
# curl -s http://jandan.net/ooxx | ./jdooxx.py -o 5 -r 2.0 -u | wget -nv -i -
# This will download all pictures with oo >= 5 in the last page of Jiandan OOXX.
import HTMLParser
import sys
import getopt
import cv2
import cv2.cv as cv
def detect(img, cascade_fn='haarcascades/haarcascade_frontalface_alt.xml',
scaleFactor=1.3, minNeighbors=4, minSize=(20, 20),
flags=cv.CV_HAAR_SCALE_IMAGE):
cascade = cv2.CascadeClassifier(cascade_fn)
rects = cascade.detectMultiScale(img, scaleFactor=scaleFactor,
@guinslym
guinslym / .pythonrc
Last active August 29, 2015 14:06 — forked from dlo/.pythonrc
# vim: set ft=python :
from __future__ import print_function
import json
import sys
import datetime
from redis import StrictRedis as Redis
import string
import csv
"""
fil = open('C:\\Python27\\README.txt')
new_file = open('C:\Python27\\freq_list.txt', 'w')
"""
fil = open("/Users/StefanCelMare/Desktop/PythonReadme.txt")
# in controller
# for local files
send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment'
# for remote files
require 'open-uri'
url = 'http://someserver.com/path/../filename.jpg'
data = open(url).read
send_data data, :disposition => 'attachment', :filename=>"photo.jpg"
import sys
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
function formatXml(xml) {
var formatted = '';
var reg = /(>)(<)(\/*)/g;
xml = xml.toString().replace(reg, '$1\r\n$2$3');
var pad = 0;
var nodes = xml.split('\r\n');
for(var n in nodes) {
var node = nodes[n];
var indent = 0;
if (node.match(/.+<\/\w[^>]*>$/)) {