This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'jekyll' | |
gem 'rack-jekyll', :git => 'https://github.com/adaoraul/rack-jekyll' | |
gem 'coderay' | |
gem 'thin' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: set ft=python : | |
from __future__ import print_function | |
import json | |
import sys | |
import datetime | |
from redis import StrictRedis as Redis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[^>]*>$/)) { |