Skip to content

Instantly share code, notes, and snippets.

Avatar

Wenbert Del Rosario wenbert

View GitHub Profile
@wenbert
wenbert / Python save image from URL
Created Dec 29, 2010
Python save image from URL
View Python save image from URL
import cStringIO # *much* faster than StringIO
import urllib
import Image
try:
file = urllib.urlopen('http://freegee.sourceforge.net/FG_EN/src/teasers_en/t_gee-power_en.gif')
im = cStringIO.StringIO(file.read()) # constructs a StringIO holding the image
img = Image.open(im)
img.save('/home/wenbert/uploaderx_files/test.gif')
except IOError, e:
View gist:fc1cb6538b4d9fdb26177574e46faad9
FROM php:7.0-fpm
RUN docker-php-ext-install pdo_mysql
# Install mbstring
RUN docker-php-ext-install mbstring
# Install bcmath
RUN docker-php-ext-install bcmath
# Install mcrypt
View .bash_profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
View gist:4014610
## the Controller
<?php
class FormfieldsController extends AppController {
public $helpers = array('Html', 'Form', 'Formfield');
public $components = array('RequestHandler');
public function beforeFilter() {
parent::beforeFilter();
$this->Security->csrfExpires = '+1 hour';
@wenbert
wenbert / README.md
Created Jul 25, 2012 — forked from melanke/README.md
watch the changes of some object or attribute
View README.md

Watch.js 1.0.13

##compatibility Works with: IE 9+, FF 4+, SF 5+, WebKit, CH 7+, OP 12+, BESEN, Rhino 1.7+ If you want a similar API that works for all browser try MultiGetSet

About

Watch.JS is a small library that brings a lot of possibilities. Maybe you know the design pattern called "Observer", imagine the possibility of executing some function always that some object changes. Well, already exists other libraries that do this, but with Watch.JS you will not have to change your way to develop. Give a chance to Watch.JS, take a look at the examples and how is simple to embody Watch.JS to your routine.

View gist:1626569
## error
AllergiesControllerTest:
FAIL should create allergy (0.40s)
"Allergy.count" didn't change by 1.
<3> expected but was
<2>.
## test
test "should create allergy" do
assert_difference('Allergy.count') do
View controller
# GET /allergies/new
# GET /allergies/new.json
def new
@patient = Patient.find(params[:patient_id])
@allergy = @patient.allergies.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @allergy }
View gist:1626619
class AllergiesControllerTest < ActionController::TestCase
setup do
@allergy = allergies(:allergy_one)
@sample_allergy = {
:name => "allergy_name_sample",
:desc => "allergy_desc_sample",
:patient_id => @allergy.patient_id
}
end
View gist:1583321
wenberts-MacBook-Pro-17:md wenbert$ rake test:functionals
Loaded suite /Users/wenbert/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
AllergiesControllerTest:
PASS should create allergy (0.23s)
PASS should destroy allergy (0.01s)
PASS should get edit (0.13s)
ERROR should get index (0.05s)
RuntimeError: [#<Allergy id: 298486374, name: "MyString", desc: "MyText", created_at: "2012-01-09 15:07:28", updated_at: "2012-01-09 15:07:28", patient_id: 1>]
View gist:1582890
class AllergiesControllerTest < ActionController::TestCase
setup do
@allergy = allergies(:one)
@allergy.patient = patients(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:allergies)