Skip to content

Instantly share code, notes, and snippets.

View bulkan's full-sized avatar
🇯🇵

Savun Bulkan Evcimen bulkan

🇯🇵
View GitHub Profile
@bulkan
bulkan / qc.py
Created May 9, 2011 23:46
Export test cases in QC using Python
import win32com, win32com.client
import HTMLParser
class MLStripper(HTMLParser.HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, d):
import subprocess
class MyOwnKeywords(object):
def run_cmd(self, cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = p.communicate()[0]
if p.wait() != 0:
print "*WARN* %s failed" %cmd
return output
[
{
'end_time': '2012-05-07T07: 00: 00+0000',
'value': 79
},
{
'end_time': '2012-05-08T07: 00: 00+0000',
'value': 121
},
{
@bulkan
bulkan / gist:2873524
Created June 5, 2012 08:08
capture unittest output
import sys
import unittest
import StringIO
class DumbestTest(unittest.TestCase):
def test_dumber(self):
self.assertEqual(True, True)
if __name__ == '__main__':
@bulkan
bulkan / gist:3606776
Created September 3, 2012 04:50
rq job attributes
job = Job.fetch(job_id)
job.my_attr = ['one', 'two']
job.save()
# re-fetch job
job = Job.fetch(job_id)
print type(job.my_attr)
<type 'str'>
@bulkan
bulkan / gist:3712331
Created September 13, 2012 06:25
CommonLibrary.py
from robot.libraries.OperatingSystem import OperatingSystem
from robot.libraries.BuiltIn import BuiltIn
class CommonLibrary(object):
''' Common keywords that can be used by any test case'''
def __init__(self):
self.oslib = OperatingSystem()
self.builtin = BuiltIn()
server {
listen 80;
server_name <url>;
root /var/www/html;
location / {
@bulkan
bulkan / gist:4221633
Created December 6, 2012 03:48
How To Create a Django MultiWidget

What are MultiWidgets ?

A MultiWidget is a widget that contains more than one widget and bundles it into one. Sometimes you require two or more inputs from the user where the data is not mutually exclusive. For example the expiry date on a credit card or a phone number with the area code.

This blog post will show and explain how to create a MultiWidget for an expiry date that accepts a month and a year.

I heard you like Widgets so I put a Widget into your Widget so you can Widget

Creating a MultiWidget is similar to creating a custom Widget. Here is the code for an expiry date multiwidget that accepts two values the month and year that a credit card expires.

def getLocationMap():
locations=Location.objects.all().order_by('-date')
location_array={}
for location in locations:
location_array[location.id]=[str(location.longitude),(location.latitude),location.note,location.title]
return location_array
//JAVASCRIPT
var location_array= $.parseJSON("{{ location_array }}");
from datetime import datetime, timedelta
created_at = datetime(2012, 12, 19, 13, 5, 20, 213002)
if created_at >= datetime.now - timedelta(days=14):
print "two weeks has past since created_at"