Skip to content

Instantly share code, notes, and snippets.

View tychio's full-sized avatar

Zhang zhengzheng tychio

View GitHub Profile
@tychio
tychio / grep_part.sh
Created May 13, 2020 21:15
Search some string in one line minimized file
grep -oE ".{0,20}mysearchstring.{0,20}" myfile
brew install r
brew install mariadb-connector-c
r
install.packages("RMySQL")
install.packages("lme4")
@tychio
tychio / validEmail
Created October 19, 2013 06:41
strict validating unicode email.
/**
/* Using regular expression to validate email address.
/* According to http://en.wikipedia.org/wiki/Email_address.
/* Base on http://jsfiddle.net/cattail/bYZcL/light/ - cattail[[email protected]]
/* Renders a fragment RegExp for unicode from XRegexp http://xregexp.com/
/**/
window.isEmail = (function() {
'use strict';
var unicode = '\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF
@tychio
tychio / symbol printor
Last active December 23, 2015 07:59
Print my name only symbol not number,letter and quotation mark.
// It's all string:)
var Infinity = (~[])/(-![])+{};
var object = []+{};
var NaN = []/[]+{};
var undefined = [][{}]+{};
var false = ![]+{};
var true = !![]+{};
var "" = []+[];
var construct =
([]+{})[(-~[]<<-~[]<<-~[])-~[]] + // c
@tychio
tychio / backtop.js
Created April 11, 2013 07:55
go to page top
var backtop = document.getElementById('backtop');//need a button id is 'backtop'
backtop.onclick = function () {
backTimer = setInterval(_back, 30);
};
var backTimer;
function _back () {
var _body = document.documentElement;
if (!_body.scrollTop) {
_body = document.body;
}
@tychio
tychio / puzzle.js
Created March 28, 2013 07:04
a javascript puzzle , and try to work out the alert result
var output1 = new Array;
var output2, output3;
var pushArr = function (c) {
if (!c) {
c = 0;
}
output1.push(c);
};
var a = 1;
@tychio
tychio / position.js
Created March 15, 2013 04:25
get province and city
/**
/* @param get callback for province and city
/* @param lat latitude
/* @param lng longitude
**/
function getPosition (get, lat, lng) {
if (lat === undefined) {//auto get, if lat and lng was undefined
if (navigator.geolocation) {//html 5 geolocation
navigator.geolocation.getCurrentPosition(function (p_pos) {
(function ($, undefined) {
var mouse = {
x: -1,
y: -1
};
document.addEventListener('pointerlockchange', change, false);
document.addEventListener('mozpointerlockchange', change, false);
document.addEventListener('webkitpointerlockchange', change, false);
//you need a canvas tag in html files
$("#canvas").click(function () {
@tychio
tychio / constellation.js
Last active December 14, 2015 11:39
month and day to constellation
/**
* get constellation string
* @param p_m[number] month 1-12
* @param p_d[day] 1-31
* @return[string] constellation name
**/
function constellation (p_m, p_d) {
var _name = '魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯';
var _day = [20,19,21,20,21,22,23,23,23,24,23,22];
var _sign = p_m * 2 - (p_d < _day[p_m - 1] ? 2 : 0);