Skip to content

Instantly share code, notes, and snippets.

View boycgit's full-sized avatar
🎯
Focusing

JSCON boycgit

🎯
Focusing
View GitHub Profile
@boycgit
boycgit / hello.cpp
Created October 15, 2013 04:59
使用引用、指针操作变量(C++)
#include <iostream>
using namespace std;
int main()
{
int a = 20; //声明一个int变量
int &b = a; //声明一个int引用
int *p = &a;//声明一个int指针
@boycgit
boycgit / stray_pointer.cpp
Created October 15, 2013 05:19
内存泄露与迷途指针(C++)
#include <iostream>
using namespace std;
int main(){
int *p = new int; //在堆里创建指针
*p = 10; //将值赋给指针所指向的地址
cout<<"*p="<<*p<<endl;
// delete p;
p = new int; //内存泄露:没有释放之前的内存
@boycgit
boycgit / class_overwrite.cpp
Created October 15, 2013 06:34
子类中调用基类方法(C++)
#include <iostream>
using namespace std;
class Animal
{
public:
void move() const {cout<<"Animal move one step\n";}
void move(int distance) const{
cout<<"Animal move "<<distance;
cout<<" steps."<<endl;
@boycgit
boycgit / three_column.html
Created October 21, 2013 04:11
三列布局,分为中间列定宽和中间列自适应两种情况(CSS)
<!Doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=320px;initial-scale=1.0;"/>
<title>三列布局</title>
</head>
<style>
/*第一种布局样式*/
@boycgit
boycgit / BinSearch.cpp
Last active December 26, 2015 12:19
非递归二分查找算法
#include <iostream>
using namespace std;
/**
* 非递归二分查找
* @author Boychenney
* @date 2013-10-24T11:02:43+0800
* @param r 数组指针
* @param n 数组大小
* @param k 待查找的值
@boycgit
boycgit / QuickSort.cpp
Created October 25, 2013 07:37
快排算法
#include <iostream>
using namespace std;
/**
* 一趟快排算法
* @author Boychenney
* @date 2013-10-25T10:54:47+0800
* @param s 待排序的数组
* @param l 开始索引
* @param r 结尾索引
@boycgit
boycgit / bootstrap.coffee
Created November 5, 2013 12:14
用于RequireJS的自定义bootstrap组件,用在Yeoman中
require.config
paths:
'jquery':'../bower_components/jquery/jquery',
'bootstrap-affix':"../bower_components/bootstrap/js/affix",
'bootstrap-transition':"../bower_components/bootstrap/js/transition",
"bootstrap-alert":"../bower_components/bootstrap/js/alert",
"bootstrap-button":"../bower_components/bootstrap/js/button",
"bootstrap-collapse":"../bower_components/bootstrap/js/collapse",
"bootstrap-dropdown":"../bower_components/bootstrap/js/dropdown",
"bootstrap-modal":"../bower_components/bootstrap/js/modal",
@boycgit
boycgit / Gruntfilejs for multi-pages
Created November 17, 2013 13:04
用于多页面的Gruntfile.js文件,重点在RequireJS部分
// Generated on 2013-11-05 using generator-bootstrap-less 3.1.0
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
@boycgit
boycgit / gulpfile.js
Created April 14, 2014 06:24
a gulp config file template
/**
** inspired by markgdyr, http://markgoodyear.com/2014/01/getting-started-with-gulp/
* date:2014年4月14日
* creator:玄农
* mail:bocheng.zbc@alibaba-inc.com
**/
// Load the plugins
var gulp = require("gulp"),
less = require("gulp-less"),
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="数据魔方第一版" />
<meta charset="utf-8">
<title>数据魔方第一版</title>
<script type="text/javascript" src="http://g.tbcdn.cn/kissy/k/1.4.2/seed-min.js" charset="utf-8"></script>
</head>
<body>
<!-- 卖家成长魔方 -->