Skip to content

Instantly share code, notes, and snippets.

View qmaruf's full-sized avatar
🤖
Training robot

Quazi Marufur Rahman qmaruf

🤖
Training robot
View GitHub Profile
help(str)
@qmaruf
qmaruf / gist:4983293
Created February 19, 2013 05:18 — forked from djq/gist:2846196
#!/bin/bash
#
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit)
# updated to PostGIS 2.0.1
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
@qmaruf
qmaruf / gist:4988031
Created February 19, 2013 17:34 — forked from djq/gist:2846196
#!/bin/bash
#
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit)
# updated to PostGIS 2.0.1
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
before_validation :upcase_title
validates_presence_of :title
def upcase_title
title.upcase if title.present?
end
require "rubygems"
require "active_merchant"
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::PaypalGateway.new(
:login => "seller_1229899173_biz_api1.railscasts.com",
:password => "FXWU58S7KXFC6HBE",
:signature => "AGjv6SW.mTiKxtkm6L9DcSUCUgePAUDQ3L-kTdszkPG8mRfjaRZDYtSu"
)
@qmaruf
qmaruf / gist:8694621
Last active August 29, 2015 13:55
Jasmine test failing
describe("display alert for unsaved publisher content", function(){
it('should display confirm dialog if text exists in status message', function(){
$('#status_message_fake_text').val('Hello world');
spyOn(window, 'confirm');
$(window).trigger('confirm')
expect(window.confirm).toHaveBeenCalled();
});
});
@qmaruf
qmaruf / gist:8717053
Last active August 29, 2015 13:55
Unsaved navigation alert
$(window).on('beforeunload unload', _.bind(_this._unsavedPublisherWarning, _this));
_unsavedPublisherWarning : function(){
var publisherTextLength = this.el_input.val().trim().length;
if(publisherTextLength){
return "navigation_warning";
}
}
@qmaruf
qmaruf / gist:8717089
Created January 30, 2014 19:38
jasmine test for unsaved redirection
describe("display alert for unsaved publisher content", function(){
it('should display confirm dialog if text exists in status message', function(){
$('#status_message_fake_text').val('Hello world');
spyOn(window, 'confirm');
$(window).trigger('beforeunload')
expect(window.confirm).toHaveBeenCalled();
});
});
line = " Hello World!! "
print line.strip() #remove empty spaces from start and end
print line.lstrip() #remove empty spaces from start
print line.rstrip() #remove empty spaces from end
mylist = ['apple', 'orange', 'mango']
print ', '.join(mylist)
mylist = [1, 2, 3]
print str(mylist).strip('[]')
mylist = ['1', '2', '3']
print [int(item) for item in mylist]