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
SELECT R.session_id, DatabaseName = db_name(R.database_id), S.text, R.Status, R.Command, | |
R.percent_complete, | |
CAST(CAST(DATEADD(mi, R.total_elapsed_time/60000.0, 0) AS TIME) AS CHAR(5)) runTime, | |
CAST(CAST(DATEADD(mi, R.estimated_completion_time/60000.0, 0) AS TIME) AS CHAR(5)) remain, | |
R.reads, R.writes, R.cpu_time, R.status, R.wait_type | |
FROM sys.dm_exec_requests R | |
CROSS APPLY sys.dm_exec_sql_text(R.sql_handle) S | |
WHERE R.session_id <> @@SPID |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<filetype binary="false" default_extension="" description="SQL" name="SQL"> | |
<highlighting> | |
<options> | |
<option name="LINE_COMMENT" value="--" /> | |
<option name="COMMENT_START" value="/*" /> | |
<option name="COMMENT_END" value="*/" /> | |
<option name="HEX_PREFIX" value="" /> | |
<option name="NUM_POSTFIXES" value="" /> | |
<option name="HAS_BRACKETS" value="true" /> |
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
" Vim syntax file | |
" Language: SQL, PGSQL (postgres 9.1) | |
" Last Change: 2012 May 21st | |
" Maintainer: Grégoire Hubert <greg DOT hubert AT gmail DOT com> | |
" Based on the work of Paul Moore <pf_moore AT yahoo.co.uk> | |
" For version 5.x: Clear all syntax items | |
" For version 6.x: Quit when a syntax file was already loaded | |
if version < 600 | |
syntax clear |
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
# dump | |
pg_dump testdb | pv -c -s $(psql -tc "SELECT pg_database_size('testdb')") -N dump | gzip > testdb.sql.gz | |
# restore | |
pv testdb_20120501.sql.gz | zcat | psql testdb |
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 | |
import redis | |
import random | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6389) | |
REDIS_SETGET = False | |
REDIS_HSET = False |
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
# I am a scientist who has been using R for about 2 years. Today I achieved a measure of enlightenment into | |
# the zen of R, and I want to share it with you. | |
# I was simulating a set of independent random walks, which are formed by a multiplicative process. Here is | |
# the code I had built up over a few months of working on it and modifying it on and off as research | |
# questions changed: | |
TimeSteps <- 1000 | |
Walks <- 100 | |
ErrorMagnitude <- 0.03 |
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
file=$1 | |
nextDB="" | |
nextStart=0 | |
nextEnd=0 | |
lastDB="" | |
lastStart=0 | |
for i in `grep -n "^CREATE DATABASE" $file | awk '{print $1":"$7}' | sed "s/CREATE://g"` | |
do |
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 multiprocessing, os, sys, time | |
from itertools import izip | |
import redis | |
rr = None | |
def process_chunk(chunk): | |
global rr | |
if rr is None: | |
rr = redis.Redis() # Create one connection per process | |
print 'PID %d' % os.getpid() |
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
param ($bakpath, $dbname, $instance, $datapath, $logpath, [switch]$norecovery, [switch]$replace, [switch]$rollback, [switch]$standby, [switch]$test) | |
# Restore latest backup from wildcard path, optionally forcing out open connections | |
# Used to restore backups copied to a standby or test server | |
"" | |
# SQL 2008 PS module imports | |
#[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null | |
#if ((get-pssnapin sqlserverprovidersnapin100 -ErrorAction "SilentlyContinue") -eq $NULL) { add-pssnapin sqlserverprovidersnapin110 } | |
#if ((get-pssnapin sqlservercmdletsnapin100 -ErrorAction "SilentlyContinue") -eq $NULL) { add-pssnapin sqlservercmdletsnapin110 } |
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
# http://openmymind.net/Paging-And-Ranking-With-Large-Offsets-MongoDB-vs-Redis-vs-Postgresql/ | |
lids = ['4fe907f1210b2e9e3080f001', '4fe907f1210b2e9e3080f002', '4fe907f1210b2e9e3080f003', '4fe907f1210b2e9e3080f004', '4fe907f1210b2e9e3080f005'] | |
insert the data | |
open('data.csv', 'w') do |f| | |
6000000.times do |i| | |
f.puts "#{lids.sample},user_#{i},#{(rand() * 10000000).to_i}" | |
end | |
end |
OlderNewer