Skip to content

Instantly share code, notes, and snippets.

@mikeplavsky
mikeplavsky / Request credentials
Created December 3, 2010 15:56
How to re-request credentials in the Browser
@never_cache
def login(request):
num = request.session.setdefault( 'Authentication-Attempts', 1 ); # in default added request.session[ 'Authentication-Attempts' ] = 1;
request.session[ 'Authentication-Attempts' ] += 1;
def http_unauthorized():
response = HttpResponse( status = 401 );
response[ "WWW-Authenticate" ] = "NTLM";
@mikeplavsky
mikeplavsky / load.js
Created December 8, 2010 12:25
loading scripts in right order
$( function() {
$( 'iframe' ).bind( 'load', function inject() {
var doc = $( 'iframe' ).contents()[0];
doc.body.appendChild( $('<ol id="qunit-tests">' )[0] );
function loadScript(path, callback) {
var scr = $( '<script>' ).attr( 'src', path );
@mikeplavsky
mikeplavsky / gist:1070072
Created July 7, 2011 17:40
Ruby examples
class Range
def by(step)
each {|x| yield x}
end
end
Range.instance_methods.each {|x| puts x if x =~ /l/ }
(1...5).by(10) {|x| p x }
colorscheme koehler
set backspace=3
set autoread
set ignorecase
set nocompatible
set showfulltag
set showmode
set expandtab
@mikeplavsky
mikeplavsky / .vimrc
Created August 12, 2011 17:46
ubuntu vimrc
map fw :w<CR>
map fr :!ruby %<CR>
map fu :nohlsearch<CR>
map fn :bn<CR>
map fp :bp<CR>
colorscheme koehler
set nocompatible
@mikeplavsky
mikeplavsky / gist:2665607
Created May 12, 2012 09:57
How to make django faster
#there are at least two options I use both - not sure why :)
#option 1
from django.db import connection
cursor = connection.cursor()
cursor.execute( "PRAGMA temp_store = MEMORY" )
cursor.execute( "PRAGMA synchronous=OFF" )
@mikeplavsky
mikeplavsky / gist:2665611
Created May 12, 2012 09:59
how to configure django for tests
import sys, os
sys.path.append( os.path.dirname(__file__) + '/../..' )
from django.conf import settings
settings.configure()
dir = os.path.dirname(__file__) + '/../database/'
test_db = dir + 'test_model.db'
test_db_journal = dir + 'test_model.db-journal'
@mikeplavsky
mikeplavsky / gist:5386562
Last active December 16, 2015 05:48
Pivotal Tracker Burndown
getActualReleaseBurndownData = function() {
var e, n, i, r, a = this.project().stories().get(this.get("release")),
s = this.project().stories().scope().inRelease(a),
o = s.points(),
l = this.project().get("time_zone"),
c = [], u = {};
for (e = a.releaseStartDate(), n = new t.DateTime(e).atMidnight().getTime(), i = a.get("accepted_at") ||
(new t.DateTime).getTime(), s = s.value(), c.push({y: o,x: n}); i >= n; ) {
package main
import "fmt"
func main() {
var z interface{}
var z1 *int64
z = z1
package main
import "fmt"
func main() {
z := [12]int64{}
fmt.Println(z)
z1 := z[4:10]