Skip to content

Instantly share code, notes, and snippets.

View waldofe's full-sized avatar
🦾

Oswaldo Ferreira waldofe

🦾
View GitHub Profile
@waldofe
waldofe / xmlns.py
Created September 12, 2012 00:25
Xmlns simple parser.
from elementtree import ElementTree as ET
class XmlnsParser(object):
def __init__(self, path):
self.path = path
def tags_and_texts(self):
self.tags_n_text = {}
file = open(self.path, 'r')
@waldofe
waldofe / eisparser.py
Created September 13, 2012 18:44
A tool to parse eis pattern content from xml documents.
from elementtree import ElementTree as ET
from os.path import join, basename, dirname
from nltk.util import clean_html
from nltk.corpus.reader import PlaintextCorpusReader
import re
class EisParser(object):
def __init__(self, path):
self._name = basename(path)
@waldofe
waldofe / gist:3746828
Created September 19, 2012 00:01 — forked from hudsonsferreira/gist:3710053
modelo de patch para inserir no Yakindu
//deve ser inserido no metodo createStatechartModel da classe FactoryUtils
//path: org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/factories/FactoryUtils.java
State myState = SGraphFactory.eINSTANCE.createState();
myState.setName("Hudson");
region.getVertices().add(myState);
Node myStateNode = ViewService.createNode(
getRegionCompartmentView(regionView), myState,
SemanticHints.STATE, preferencesHint);
pt-BR:
views:
admin:
home:
name: Home
pagination:
previous: "« Anterior"
next: "Próximo »"
truncate: "…"
misc:
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@waldofe
waldofe / gist:9282553
Created March 1, 2014 00:04
Rspec failing tests rerun script
function zrun() {
SPEC_FILE=$1
SPEC_LOG=/tmp/rspec.log
if [ $SPEC_FILE ]; then
rspec $SPEC_FILE 2>&1 | tee $SPEC_LOG
else
cat $SPEC_LOG | grep "^rspec" | cut -d ' ' -f 2 | xargs rspec 2>&1 | tee $SPEC_LOG
fi
}
@waldofe
waldofe / application_helper.rb
Last active August 29, 2015 14:04
Simple alert error message helper
module ApplicationHelper
# Renders the first field error of an object attribute on a red alert.
#
# @param klass [Class Object] - This object needs to
# include ActiveModel::Validations (or be a normal ActiveModel)
# @param field_sym [Symbol] - Attribute or field name of the object
def show_error_message_for(klass, attribute)
if klass.errors[attribute].any?
%(
@waldofe
waldofe / gist:f7f867f956463531c296
Last active August 29, 2015 14:04
Simple input form for time mask helper
def simple_input_time_form(f, attribute_time, opts = {})
default_opts = {
value_field: f.object.send(attribute_time),
attr_error: attribute_time,
format_time: :time,
icon_time: 'fa-clock-o',
col_size: 4
}
opts = default_opts.merge(opts)
set number
set tabstop=2
set expandtab
# size of an indent
set shiftwidth=2
# a combination of spaces and tabs are used to simulate tab stops at a width
# other than the (hard)tabstop
set softtabstop=2
@waldofe
waldofe / gist:50b1d63e41de0ac46505
Created May 6, 2015 19:54
Testing Job call on model
# test
describe '#initialize_delayed_recharge_process' do
subject { create :transport_service_recharge_batch }
let(:calculation_job) do
instance_double(RH::TransportRechargeBatchCalculationJob)
end
it 'calls DelayedJob#enqueue on RH::TransportRechargeBatchCalculationJob' do
expect(RH::TransportRechargeBatchCalculationJob).to receive(:new).