Skip to content

Instantly share code, notes, and snippets.

View fernyb's full-sized avatar

Fernando Barajas fernyb

View GitHub Profile
@fernyb
fernyb / gist:8982285
Created February 13, 2014 19:39
CSS to Xpath
Nokogiri::CSS.xpath_for('#foo')
@fernyb
fernyb / appium_selenium_webdriver.rb
Created February 2, 2014 04:41
Selenium WebDriver for Appium settings
server_url= "http://127.0.0.1:4723/wd/hub"
driver = Selenium::WebDriver.for(:remote, :desired_capabilities => {
platform: 'Mac',
app: 'safari',
device: 'iPad Simulator',
# version: '7.0',
},
:url => server_url )
# https://sites.google.com/site/jimmyxu101/testing/use-tcpdump-to-monitor-http-traffic
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
@fernyb
fernyb / gist:7751198
Created December 2, 2013 15:31
Make DVD disc image
# Current path should have VIDEO_TS directory
#
mkisofs -dvd-video -o ~/Desktop/back-to-the-future.iso .
@fernyb
fernyb / gist:7745388
Created December 2, 2013 05:10
Burn DVD from command line - Ubuntu
fernyb@fernyb-SD30V10:~/sources$ wodim --devices
wodim: Overview of accessible drives (1 found) :
-------------------------------------------------------------------------
0 dev='/dev/sg0' rwrw-- : 'TSSTcorp' 'CDDVDW SH-S203B'
-------------------------------------------------------------------------
wodim dev=/dev/sg0 -v -data ~/the-dictator.iso
@fernyb
fernyb / gist:7130154
Last active December 26, 2015 09:29
Reset Postgres Counter
skatr_development=# \d spots
Table "public.spots"
Column | Type | Modifiers
-------------+-----------------------------+----------------------------------------------------
id | integer | not null default nextval('spots_id_seq'::regclass)
ALTER SEQUENCE spots_id_seq RESTART WITH 1;
@fernyb
fernyb / gist:6371782
Created August 28, 2013 21:50
Remove lots of files from git
git rm $(git ls-files --deleted)
@fernyb
fernyb / gist:5953514
Created July 8, 2013 23:56
Get file mime type using command line
# Get file mime type using command line
file --mime-type -b Transcodez-license.transcodez
@fernyb
fernyb / gist:5922306
Created July 3, 2013 20:04
Parse JSON in Rails
@response = ActiveSupport::JSON.decode(@data.body)
@fernyb
fernyb / email_validator.rb
Last active December 17, 2015 20:19
Validator Email Address Validator
#validates :email, :presence => true, :email => true
require 'mail'
class EmailValidator < ActiveModel::EachValidator
def validate_each(record,attribute,value)
begin
m = Mail::Address.new(value)
# We must check that value contains a domain and that value is an email address
r = m.domain && m.address == value
t = m.__send__(:tree)