Skip to content

Instantly share code, notes, and snippets.

(define (enumerate-interval low high)
(if (> low high)
'()
(cons low (enumerate-interval (+ low 1) high))))
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
@yang-qu
yang-qu / fizzbuzz_prime_splitlist.scm
Created April 29, 2011 13:47
an exercise in http://programmingpraxis.com/2011/04/26/miscellanea/ including fizzbuzz, prime words, and split a list
;;http://programmingpraxis.com/2011/04/26/miscellanea/
;FizzBuzz
(define (enumerate-interval low high)
(if (> low high)
'()
(cons low (enumerate-interval (+ low 1) high))))
(define (fizz-buzz n)
(for-each (lambda (x) (display x) (newline))
@yang-qu
yang-qu / kill_connections_db.sql
Created June 10, 2011 01:08
kill all connections for a database on ms sql server
--kill all connections for a database on ms sql server
SET NOCOUNT ON
DECLARE @DBName varchar(50)
DECLARE @spidstr varchar(8000)
DECLARE @ConnKilled smallint
SET @ConnKilled=0
SET @spidstr = ''
Set @DBName = 'databasename'
IF db_id(@DBName) < 4
@yang-qu
yang-qu / all_size.sql
Created August 9, 2011 01:45
get all tables size in a SQL Server database
--get all tables size in a SQL Server database
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
@yang-qu
yang-qu / rebuilddbstats.sql
Last active October 1, 2015 08:28
rebuild sqlserver index and update stats
EXEC sp_MSforeachtable @command1="print '?'", @command2="ALTER INDEX ALL ON ? REBUILD WITH (ONLINE=OFF)"
GO
EXEC sp_updatestats
GO
@yang-qu
yang-qu / removedotsvn.ps1
Last active October 1, 2015 11:28
powershell -- delete .svn
gci c:\yourdirectory -include .svn -Recurse -Force | Remove-Item -Recurse -Force
;run in chez scheme 8.4
;http://programmingpraxis.com/2013/01/15/translate-csv-to-html/
;TODO: read csv file
; parse csv file to a list
(define (string-split sep str)
(define (f cs xs) (cons (list->string (reverse cs)) xs))
(let loop ((ss (string->list str)) (cs '()) (xs '()))
(cond ((null? ss) (reverse (if (null? cs) xs (f cs xs))))
((char=? (car ss) sep) (loop (cdr ss) '() (f cs xs)))
(else (loop (cdr ss) (cons (car ss) cs) xs)))))
@yang-qu
yang-qu / ShowGitBranch.sh
Created April 8, 2013 03:24
Show git branch name in bash prompt
export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \n\[\033[01;34m\]$\[\033[00m\] '
@yang-qu
yang-qu / dockedmenu.html
Created June 5, 2013 03:59
An example to keep menu bar on top while scrolling vertically
<html>
<head>
<title>Docked Menu</title>
<style>
body {
text-align: center;
}
#header {
@yang-qu
yang-qu / git_show_files_changed
Last active December 27, 2015 03:19
git show files changed between 2 commits
git archive -o /c/deploy/latest.zip 76cd4788 $(git diff --name-only da43a85 76cd4788)