Skip to content

Instantly share code, notes, and snippets.

Ruslan Strazhnyk Desperado

  • Berlin
View GitHub Profile
View parse_yaml.sh
#!/bin/bash
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
View 30-income-calculon.pl
use strict;
use warnings;
use Text::TabularDisplay;
use List::Util qw(sum);
my $start = 30_000 || $ARGV[0];
my $end = 100_000 || $ARGV[1];
my $step = 1_000 || $ARGV[2];
my @data;
View gist:5403645
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.add_extension('JSErrorCollector.xpi')
ff=webdriver.Firefox(profile)
ff.get('http://www.somepage.com')
ff.execute_script('return window.JSErrorCollector_errors.pump()')
View gist:5345039
# in features/support/env.rb
require 'selenium/webdriver'
# we need a firefox extension to start intercepting javascript errors before the page
# scripts load
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
# see https://github.com/mguillem/JSErrorCollector
profile.add_extension File.join(Rails.root, "features/support/extensions/JSErrorCollector.xpi")
Capybara::Selenium::Driver.new app, :profile => profile
View gist:5344880
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.add_extension('JSErrorCollector.xpi')
ff=webdriver.Firefox(profile)
ff.get('http://www.somepage.com')
ff.execute_script('return window.JSErrorCollector_errors.pump()')
View Completely Static App
application: oliverfoxmurals
version: 1
runtime: python
api_version: 1
handlers:
- url: /
static_files: static/index.html
upload: static/index.html
@Desperado
Desperado / googl.py
Created Aug 8, 2012 — forked from pamelafox/googl.py
Shortening URLS using goo.gl
View googl.py
import cgi
import urllib, urllib2
import logging
from django.utils import simplejson
class Googl():
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://www.googleapis.com/urlshortener/v1/url?key=%s' % self.api_key
@Desperado
Desperado / countryinfo.py
Created Aug 8, 2012 — forked from pamelafox/countryinfo.py
Python list of country codes, names, continents, capitals, and pytz timezones
View countryinfo.py
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai
@Desperado
Desperado / views.py
Created Aug 8, 2012 — forked from pamelafox/views.py
Facebook logout (Flask)
View views.py
@login_required
def handle_logout():
import facebook
if g.user.facebook_id:
base_domain = util.get_base_domain()
default_fb_data = FB_DATA['appspot.com']
fb_app_id = FB_DATA.get(base_domain, default_fb_data).get('appid')
fb_app_secret = FB_DATA.get(base_domain, default_fb_data).get('appsecret')
cookie = facebook.get_user_from_cookie(request.cookies, fb_app_id, fb_app_secret)
@Desperado
Desperado / base_tests.py
Created Aug 8, 2012 — forked from jeremi/base_tests.py
Python Selenium Base TestCase
View base_tests.py
import unittest
import datetime
from sys import *
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import login_dom
class BaseTests(unittest.TestCase):
You can’t perform that action at this time.