Skip to content

Instantly share code, notes, and snippets.

View peterfarrell's full-sized avatar
🏠
Working from home

PJ Farrell peterfarrell

🏠
Working from home
View GitHub Profile
@peterfarrell
peterfarrell / icheck_selenium_python_js_version.py
Created August 13, 2015 21:45
Select a icheck v2.-0 with Selenium python (javascript version)
def icheck(self, selector, retry=True):
"""
Helper for iCheck radio inputs. N.B. We are using iCheck 2.0.x RC
Example:
self.icheck("#id-element")
:param selector: The id of the icheck target.
:type selector: str
:return: None
@peterfarrell
peterfarrell / drag_and_drop_helper.js
Last active August 29, 2015 14:27 — forked from rcorreia/drag_and_drop_helper.js
drag_and_drop_helper.js
(function( $ ) {
$.fn.simulateDragDrop = function(options) {
return this.each(function() {
new $.simulateDragDrop(this, options);
});
};
$.simulateDragDrop = function(elem, options) {
this.options = options;
this.simulateEvent(elem, options);
};
- name: Download Telegram
shell: "wget https://tdesktop.com/linux -O telegram.tar.xz"
args:
chdir: "./bootstrap/files"
creates: "telegram.tar.xz"
- name: Unarchive Telegram
sudo: yes
unarchive: src=telegram.tar.xz dest=/opt
@peterfarrell
peterfarrell / install_latest_vagrant_via_ansible
Last active February 5, 2017 16:06
Install latest Vagrant with Ansible (x86_64)
- name: Compute Vagrant latest version
sudo: yes
shell: wget -qO - https://dl.bintray.com/mitchellh/vagrant/|sed -n 's/.*href=\"\([^"]*\).*/\1/p'|grep x86_64\.deb|tail -1|cut -d'#' -f2
register: vagrant_file_name
- name: Download Vagrant latest version
shell: "wget https://dl.bintray.com/mitchellh/vagrant/{{ vagrant_file_name.stdout }} -O {{ vagrant_file_name.stdout }}"
args:
chdir: "./bootstrap/files"
creates: "{{ vagrant_file_name.stdout }}"
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@peterfarrell
peterfarrell / test.py
Last active August 29, 2015 14:20 — forked from jeremi/test.py
from selenium import webdriver
def select_from_chosen(driver, id, value):
chosen = driver.find_element_by_id(id + '_chzn')
results = chosen.find_elements_by_css_selector(".chzn-results li")
found = False
for result in results:
if result.text == value:
@peterfarrell
peterfarrell / gist:fc3a5853d8b109041b83
Created March 6, 2015 07:12
django-cms urls.py error on Django 1.7.4 with Postgres when CMS has app_hooks.
00:50:04.391 2015-03-06 06:50:04.020323+00:00 app web.1 - - Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
self.load_middleware()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 46, in load_middleware
mw_instance = mw_class()
File "/app/.heroku/python/lib/python2.7/site-packages/django/middleware/locale.py", line 23, in __init__
for url_pattern in get_resolver(None).url_patterns:
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 372, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in urlconf_module
@peterfarrell
peterfarrell / gist:8adba7e1f6f388987a6b
Created January 21, 2015 08:45
Django-CMS3 develops issue with cmsplugin_filer and table renames
> cmsplugin_filer_folder:0003_move_view_option_to_style
Error in migration: cmsplugin_filer_folder:0003_move_view_option_to_style
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
@peterfarrell
peterfarrell / Django-CMS 3 - Copy Site to New Site
Last active August 29, 2015 14:13
Django-CMS 3 - Copy Site to New Site
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from django.contrib.sites.models import Site
from django.db import transaction
from cms.models import Page
class Command(BaseCommand):
  1. generate an empty migration
  2. move the migration from old_app to new_app
  3. edit the migration file to change all instances of old_app to new_app
  4. add a forward migration to rename the table from something to something_else
  5. add a backward migration to do the opposite
  6. move models.py from old_app to new_app
  7. apply the migration