Skip to content

Instantly share code, notes, and snippets.

View bernardobarreto's full-sized avatar

Bernardo bernardobarreto

  • Brazil
View GitHub Profile
#include <stdio.h>
#include <time.h>
int main(){
char dateStr [9];
char borndate [9];
int i,j;
int year, bornyear, age;
age=year-bornyear;
_strdate(dateStr);
printf( "The current date is %s \n", dateStr);
@bernardobarreto
bernardobarreto / devise_request_spec_helpers.rb
Last active August 30, 2016 21:12
helpers for devise rails capybara spec
module DeviseRequestSpecHelpers
def create_and_login_user(email=nil, password=nil)
email = email || Faker::Internet.email
password = password || Faker::Internet.password(8)
visit new_user_registration_path
fill_in 'user_email', with: email
fill_in 'user_password', with: password
fill_in 'user_password_confirmation', with: password
click_button 'cadastrar'
@bernardobarreto
bernardobarreto / web-fonts-asset-pipeline.md
Created May 5, 2016 16:40 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@bernardobarreto
bernardobarreto / database.yml.example mysql2
Created February 16, 2016 04:49 — forked from erichurst/database.yml.example mysql2
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@bernardobarreto
bernardobarreto / gist:ddb977312d445dfa436d
Created November 15, 2015 15:11 — forked from alisterlf/gist:3490957
JAVASCRIPT:Remove Accents
function RemoveAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
@bernardobarreto
bernardobarreto / github_followers.html
Created September 13, 2014 00:56
Get followers from GitHub's user using AngularJs
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>GitHub Followers</title>
</head>
<body data-ng-app data-ng-controller='followersController'>
Username:
<input data-ng-model='username' placeholder='username'></input>
<a href='#' ng-click='getFollowers()'> Get Followers </a>
<br/>
@bernardobarreto
bernardobarreto / tablib_ods_usage.py
Last active December 14, 2015 14:29
How to create an ods file using python tablib
#Bernardo B. Marques (bernardofire) 06/03/2013
#Dep: [sudo] pip install tablib
def create_ods(data):
data = tablib.Dataset(*data)
with open('output.ods', 'wb') as f:
f.write(data.ods)
rows = [['Bernardo', 'Fire'], ['Quase', 'Nada'], ['Rick', 'Rocks', 'Sunshine']]
@bernardobarreto
bernardobarreto / list_compre.py
Created February 14, 2013 03:06
basic list comprehension
from random import randint
def matilha():
return [Dog(("Dog%s" % i), randint(0,15)) for i in range(100)]
class Dog(object):
def __init__(self, name, age):
self.name = name
self.age = age
@bernardobarreto
bernardobarreto / bola.py
Created February 14, 2013 00:02
basic python test
# bola.py
class Bola(object):
def __init__(self, cor):
self.cor = cor
# bola_test.py
import unittest
from should_dsl import should
@bernardobarreto
bernardobarreto / splinter_webdriver_refactoring.diff
Created November 28, 2012 21:49
splinter_webdriver_refactoring.diff
diff --git a/splinter/driver/webdriver/__init__.py b/splinter/driver/webdriver/__init__.py
index 86622b9..e35ae2b 100644
--- a/splinter/driver/webdriver/__init__.py
+++ b/splinter/driver/webdriver/__init__.py
@@ -60,23 +60,22 @@ class BaseWebDriver(DriverAPI):
def evaluate_script(self, script):
return self.driver.execute_script("return %s" % script)
- def is_element_present(self, finder, selector, wait_time=None):
+ def check_element_presence(self, finder, selector, wait_time, should_present):