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 os | |
import re | |
import sys | |
import argparse | |
renaming_enabled = False | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | |
def rename_file(file_name, new_file_name): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 replace_unsplash_urls(width, height) { | |
var url = ''; | |
var prev_url = ''; | |
var links = document.querySelectorAll('#gridMulti a'); | |
for(var i = 0; i < links.length; i++) { | |
var item = links.item(i); | |
url = links.item(i).style.getPropertyValue('background-image'); | |
console.log(i, url) | |
if (url) { |
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 urllib2 | |
from bs4 import BeautifulSoup | |
if BeautifulSoup(urllib2.urlopen( | |
'http://ambru.nl/priem_not/index.php' | |
).read()).findAll('td', {'class': 'tab4_3_not3'}): | |
print '\033[95m YAHOOO! \033[m\n' |
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
from webtest.forms import Field | |
# ... | |
extra_field = Field(form, tag='input', name='new_field', pos=0, value='new_value') | |
form.fields['new_field'] = [extra_field] | |
form['new_field'] = 'new_value' | |
form.field_order.append(('new_field', extra_field)) | |
# How to add a form to formset: https://github.com/kmike/django-webtest/pull/17 |
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
from bs4 import BeautifulSoup | |
import bleach | |
def _delinkify(self, text): | |
""" | |
Converts <a href="http:my.url">Text</a> to | |
<a href="http:my.url">Text: http:my.url</a> | |
""" | |
soup = BeautifulSoup(text) | |
for link in soup.find_all('a'): |
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 python | |
# -*- coding: utf-8 -*- | |
import datetime | |
from mock import patch | |
from django.test import TestCase | |
from django.utils import timezone | |
class DatesTestCase(TestCase): |
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
from django.core.files.uploadedfile import SimpleUploadedFile | |
class UploadTestCase(TestCase): | |
def test_can_upload_file(self): | |
self.client.logout() | |
self.client.login(username='[email protected]', password='demo') | |
attachment = SimpleUploadedFile('attachment.pdf', 'file_content', content_type='application/pdf') | |
response = self.client.post( |
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
#!/bin/bash | |
# Redirect output to stderr. | |
exec 1>&2 | |
# enable user input | |
exec < /dev/tty | |
consoleregexp='console.log' | |
printregexp='print ' | |
# CHECK |
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 os | |
import zipfile | |
import cStringIO as StringIO | |
class ContractDownloadGalleryDetailView(LoginRequiredMixin, DetailView): | |
model = Contract | |
def render_to_response(self, context, **httpresponse_kwargs): | |
contract = self.object |
NewerOlder