Skip to content

Instantly share code, notes, and snippets.

View boyzhujian's full-sized avatar
🎯
Focusing

Damon boyzhujian

🎯
Focusing
  • Cisco
  • Suzhou Jiangsu China
View GitHub Profile
package main
import (
"bufio"
"fmt"
"log"
"os"
)
// readLines reads a whole file into memory
package utils
import (
"bytes"
"log"
"os/exec"
"syscall"
)
import cx_Oracle
conn_str="user/password@server:port/service"
conn=cx_Oracle.connect(conn_str)
print conn.version
@boyzhujian
boyzhujian / pysendmail
Created October 26, 2017 08:08
pysendemail with to list and attatch file list support
import smtplib
from os.path import basename
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
def send_mail(send_from, send_to, subject, text, files=None,
server="pek02mda.webex.com.cn"):
@boyzhujian
boyzhujian / golangserver.go
Last active October 27, 2017 03:07
gohttpserver
package main
import (
"io"
"net/http"
)
func hello(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world!")
}
@boyzhujian
boyzhujian / main.go
Created December 4, 2017 02:40 — forked from husobee/main.go
simple golang http middleware chaining example
package main
import (
"fmt"
"net/http"
"time"
"golang.org/x/net/context"
"github.com/husobee/backdrop"
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
//https://stackoverflow.com/questions/44471749/golang-enter-ssh-sudo-password-on-prompt-or-exit
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"strings"
@boyzhujian
boyzhujian / init-single-node-ceph.sh
Created February 2, 2018 03:00 — forked from kofemann/init-single-node-ceph.sh
Single node CEPH setup
#
# Enable CEPH repos as described at http://ceph.com/docs/master/install/get-packages/#rpm
# Install ceph-deploy package
#
export DATA_DEV=sdb
export JRNL_DEV=sdc
export FS_TYPE=xfs
export CEPH_S_NODE=ceph-s
export CEPH_RELEASE=giant
###test.js
var express = require('express');
var router = express.Router();
router.get('/test', function (req, res) {
res.json(200, {'test': 'it works!'});
});
module.exports = router;