This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function syntaxHighlight(json) { | |
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | |
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import Image | |
import Levenshtein | |
class BWImageCompare(object): | |
"""Compares two images (b/w).""" | |
_pixel = 255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder