Create database with specific owner in psql
Create database with specific owner in psql
1 | CREATE DATABASE databasename WITH OWNER username ENCODING='utf-8';
|
Discover code snippets, tutorials, and programming insights
Create database with specific owner in psql
1 | CREATE DATABASE databasename WITH OWNER username ENCODING='utf-8';
|
Delete table row
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | (function($){
$(document).ready(function(){
$('.delete').on('click', function(e){
e.preventDefault();
var that = $(this);
var url = $(this).attr('href');
var c = confirm("Delete the object");
if (c == true) {
$.post(url, function( data ) {
$(that).parent().parent().fadeOut();
});
}
return false;
})
});
})(jQuery)
|
Login protected CBV Django
1 2 3 4 5 6 7 8 | from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
class ProtectedViewMixin(object):
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(ProtectedViewMixin, self).dispatch(*args, **kwargs)
|
psql connect to database
1 | \c datbase name;
|
Fibonacci iterator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | class Fibonacci(object):
def __init__(self, count):
self.count = count
def __iter__(self):
a, b = 0, 1
for x in range(self.count):
if x < 2:
yield x
else:
c = a + b
yield c
a, b = b, c
for x in Fibonacci(10):
print(x)
|