Skip to content

Instantly share code, notes, and snippets.

@HereChen
HereChen / set_ip_address.bat
Last active February 4, 2017 02:45
Windows set ip address
REM netsh interface ipv4 set address name="YOUR INTERFACE NAME" static IP_ADDRESS SUBNET_MASK GATEWAY
REM netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER
netsh interface ipv4 set address name="Local Area Connection" static 192.168.100.252 255.255.255.0 192.168.100.1
netsh interface ipv4 set dns name="Local Area Connection" static 114.114.114.114
REM refer: http://www.howtogeek.com/103190/change-your-ip-address-from-the-command-prompt/
@HereChen
HereChen / demo.html
Created April 6, 2016 05:15
12行代码的DoS攻击分析及防御
<!DOCTYPE html>
<html>
<body>
<!--from infoQ: 12行代码的DoS攻击分析及防御-->
<script type="text/javascript">
var total = "";
for (var i=0; i<100000000; i++){
total = total + i.toString();
history.pushState(0,0,total);
}
@HereChen
HereChen / cinAndSaveToArray.cpp
Created October 26, 2015 02:03
input data -> save to array -> display
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int array[100][2], count, cina, cinb;
count = 0;
cout << "input:" << endl;
while ( cin >> cina >> cinb ){
array[count][0] = cina;
@HereChen
HereChen / chararray.cpp
Created October 26, 2015 01:55
char * - string
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
const char *p = "shuoming"; // note: const
cout << "sizeof(p): " << sizeof(p) << endl;
while (*p){
cout << "p++: " << p++ << endl;
}
@HereChen
HereChen / gulpfile.js
Last active October 26, 2015 01:56
gulp demo - less compile and compressed
var gulp = require('gulp');
/* plugins:
** npm install --save-dev
** gulp-uglify gulp-rename gulp-concat gulp-sass
** gulp-minify-css gulp-autoprefixer
*/
var uglify = require('gulp-uglify'), // js compress
rename = require('gulp-rename'), // file rename
concat = require('gulp-concat'), // file combine
@HereChen
HereChen / convert-image-to-base64.js
Last active March 29, 2022 11:31
convert image to base64
/**
* version1: convert online image
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat='image/png']
* @author HaNdTriX
* @example
convertImgToBase64('http://goo.gl/AOxHAL', function(base64Img){
console.log('IMAGE:',base64Img);
})
@HereChen
HereChen / window_onLoad.js
Last active August 29, 2015 14:28 — forked from tao4yu/window_onLoad.js
Javascript : window.onload 绑定多个事件
/*
*假设有2个函数firstFunction和secondFunction需要在网页加载完毕时执行, 需要绑定到window。onload。如果通过:
*
* window.onload = firstFunction;
* window.onload = secondFunction;
* 结果是只有secondFunction会执行,secondFunction会覆盖firstFunction。
*/
/*
*正确的方式是:
@HereChen
HereChen / Jekyll add active class to navbar
Created October 11, 2014 11:18
Jekyll add active class to navbar
{% assign current = page.url | downcase | split: '/' %}
<nav>
<ul>
<li><a href='/about' {% if current[1] == 'about' %}class='current'{% endif %}>about</a></li>
<li><a href='/blog' {% if current[1] == 'blog' %}class='current'{% endif %}>blog</a></li>
<li><a href='/contact' {% if current[1] == 'contact' %}class='current'{% endif %}>contact</a></li>
</ul>
</nav>
@HereChen
HereChen / gist:0291738ad3d2846624c3
Created August 10, 2014 13:31
[Git] Change Git Home Path
# modify etc/profile
# normalize HOME to unix path
HOME="/e/GitRep"
HOME="$(cd "$HOME" ; pwd)"
cd
export PATH="$HOME/bin:$PATH"
@HereChen
HereChen / insert_date.py
Created June 9, 2014 15:03
sublime: insert time
import datetime, getpass
import sublime, sublime_plugin
class InsertDatetimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") } )
# self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S %a") } )