Skip to content

Instantly share code, notes, and snippets.

@paulmach
paulmach / serve.go
Last active March 28, 2024 15:31
Simple Static File Server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@sstur
sstur / backup-databases.cmd
Last active February 15, 2019 13:19
MySQL and MS SQL backup scripts for Windows
@echo off
cd "%~dp0"
backup-mysql.cmd
backup-mssql.cmd
@HenrikFrystykNielsen
HenrikFrystykNielsen / SelfHostWithAssembliesResolver.cs
Created June 10, 2012 23:56
ASP.NET Web API: Controlling assemblies loaded by providing own AssembliesResolver
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Dispatcher;
using System.Web.Http.SelfHost;
namespace SelfHost
{
@RobinWu
RobinWu / backup.rake
Created January 20, 2011 06:21
backup rails log and mysql rake script
# m h dom mon dow command
# 0 3 * * * cd /var/www/do8 && /usr/bin/rake backup:log:all > /dev/null 2>&1
# 5 3 * * * cd /var/www/do8 && /usr/bin/rake backup:db:mysql RAILS_ENV=production > /dev/null 2>&1
# https://gist.github.com/787497
require 'fileutils'
namespace :backup do
desc 'backup log'
namespace :log do
@tom2cjp
tom2cjp / install_ror
Created November 26, 2010 01:43 — forked from alvin2ye/install_ror
#!/bin/bash
sudo apt-get -y install dialog
DIALOG=${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
$DIALOG --backtitle "请选择您要安装的选项" \
--title "专业系统安装" --clear \
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@technoweenie
technoweenie / gist:498995
Created July 29, 2010 19:30
less crappy implementation that fixed a bug if the base64 included whitespace in the middle
@@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization)
# gets BASIC auth info
def get_auth_data
auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
if auth_key.present? && request.env[auth_key].to_s =~ /^Basic\s+(.*)/m
Base64.decode64($1).split(':')[0..1]
else
[nil, nil]
end
end
@alvin2ye
alvin2ye / .screenrc
Created July 5, 2010 02:30
.screenrc
# 启动时不显示欢迎屏幕
startup_message off
# 定义screen的功能键为Ctrl-Z。向终端输入Ctrl-Z时应按 Ctrl-Z z。
escape ^Zz
# 屏幕缓冲区 1024 行。
defscrollback 1024
# 关闭错误提示
@alvin2ye
alvin2ye / .vimrc
Last active September 4, 2015 11:55
How to install vim
"""""""""""""""""""""""""""""""""""""""
" URL: https://gist.github.com/alvin2ye/318212
" 安装方法
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
" curl -sL https://gist.githubusercontent.com/alvin2ye/318212/raw/.vimrc > ~/.vimrc
" Launch vim, run :BundleInstall
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"平台判断