Skip to content

Instantly share code, notes, and snippets.

View fernyb's full-sized avatar

Fernando Barajas fernyb

View GitHub Profile
# 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 / 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 )
@fernyb
fernyb / gist:8982285
Created February 13, 2014 19:39
CSS to Xpath
Nokogiri::CSS.xpath_for('#foo')
@fernyb
fernyb / gist:6fbbb50decb2ea1bf441
Created May 7, 2014 13:47
Close current tab iPad Simulator
tell application "System Events" to tell process "iPhone Simulator"
tell application "iPhone Simulator" to activate
delay 1
tell window "iOS Simulator - iPad Retina / iOS 7.1 (11D167)"
--get the name of window 1
--get every window
click button 8
--get every button
@fernyb
fernyb / gist:4caec5950d95998ab5a4
Last active August 29, 2015 14:01
Remote Debugging Protocol
# View the messages sent to the websocket
# https://developers.google.com/chrome-developer-tools/docs/debugger-protocol
#
_old_send = function(msg) { console.log(msg); console.log(" "); WebInspector.socket.send(msg); };
InspectorFrontendHost.sendMessageToBackend = _old_send;
WebInspector.socket.onmessage = function(message) { console.log(message.data); console.log(" "); InspectorBackend.dispatch(message.data); };
Sent:
# http://git-scm.com/book/en/Git-Basics-Undoing-Things
# Undo a merge
git revert -m 1 commit_hash
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
Capture HTTP Headers
sudo tcpdump -l -s0 -w - tcp dst port 80 | strings
@fernyb
fernyb / gist:2e8348ab916dd240a39c
Last active August 29, 2015 14:10
Mac OSX Settting Proxy via Command Line
Show the active interface:
ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'
List All Network Services with information which interface they use:
sudo networksetup -listnetworkserviceorder
To set the Proxy:
sudo networksetup -setwebproxystate "Wi-Fi" off
sudo networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8080
@fernyb
fernyb / gist:18a6654c1a526138367f
Created November 28, 2014 00:31
mitmproxy (mitmdump) script to print response body
import sys
import cStringIO
from PIL import Image
from libmproxy.protocol.http import decoded
def response(context, flow):
content_type = flow.response.headers.get_first("content-type", "")
sys.stdout.write("Content Type: "+ content_type +"\n\n")
if content_type.startswith("text"):
sys.stdout.write("Response Content: "+ flow.response.content +"\n\n")