Skip to content

Instantly share code, notes, and snippets.

View bwangelme's full-sized avatar
🚀
把 Star 当做收藏在用,点起来很随性。GitHub 全是各种 Tutorial 和 Demo

bwangel bwangelme

🚀
把 Star 当做收藏在用,点起来很随性。GitHub 全是各种 Tutorial 和 Demo
View GitHub Profile
@bwangelme
bwangelme / shift.c
Created July 23, 2016 10:28
csapp 2.1.10笔记
#include<stdio.h>
int main(int argc, char *argv[])
{
/* 大多数编译器默认对有符号数的右移采用算数右移 */
int a = -32;
int result = a >> 1;
printf("The result is %d\n", result);
@bwangelme
bwangelme / index.html
Created July 24, 2016 01:29
canvas学习笔记,canvas是基于状态绘制的!
window.onload = function () {
var canvas = document.getElementById('canvas');
canvas.width = 1024;
canvas.height = 768;
if(canvas.getContext("2d") ) {
var context = canvas.getContext('2d');
// 使用context绘制
@bwangelme
bwangelme / log.py
Created August 24, 2016 23:34
set log name
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
LOG_BASE_NAME = 'snmp_info.log'
INDEX = 0
while True:
@bwangelme
bwangelme / solve
Last active September 2, 2016 03:30
use python to solve the single-equation
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def solve(eq,var='x'):
"""利用Python来解一元方程。
代码来源:https://python-china.org/t/1152#
程序的思路就是把x当做了复数的虚部,然后利用虚部运算出x的系数
剩下的实数就是复数的实部,然后实部除以虚部,就得出x的解了。
@bwangelme
bwangelme / test.sh
Created September 9, 2016 11:11
MySQL基准测试记录环境的脚本
#!/bin/bash
#History:
# Michael Sep,09,2016
#Program:
#
INTERVAl=5
PREFIX=$INTERVAl-sec-status
RUNFILE="/tmp/mysql-test-running"
mysql -e 'SHOW GLOBAL VARIABLES' -u root -pdeepin >> mysql-variables
@bwangelme
bwangelme / nginx.conf
Created September 14, 2016 15:19
Nginx 配置文件服务器
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8082; #端口
@bwangelme
bwangelme / smb.conf
Created September 15, 2016 11:42
Ubuntu 配置Samba服务器
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no
[Anonymous]
path = /tmp
@bwangelme
bwangelme / context.js
Created September 17, 2016 23:25
nodejs中new的说明
function pet(words) {
this.words = words;
console.log(this.words);
console.log(this === global); // true
}
pet('...');
function Pet(words) {
@bwangelme
bwangelme / call_extend.js
Created September 17, 2016 23:35
nodejs中的call函数实现继承
// call函数的作用就是改变某个函数执行时的上下文(this),变成一个指定的变量。
function Pet(words) {
this.words = words;
this.speak = function() {
console.log('say' + ' ' + this.words);
}
}
@bwangelme
bwangelme / crawler.js
Created September 18, 2016 14:59
慕课网教程相关代码
var http = require('http');
var cheerio = require('cheerio');
var url = 'http://www.imooc.com/learn/348';
var assert = require('assert');
function deleteBlank(string) {
results = []
lines = string.split('\r\n');
lines.forEach(function (line) {
if(! /^\s*$/.test(line)) {