-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz_misc.js
182 lines (124 loc) · 4.93 KB
/
z_misc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
var moment = require('moment');
var words = require('./words');
var classifier = require('./classifier.js');
var helper = require('./helper');
var _ = require('lodash');
var str = '2016-03-12T11:31:41-03:00';
var str2 = '2016-04-12T22:31:45-03:00';
var str3 = 'Wed Jun 06 20:07:10 +0000 2012';
var date = new Date(str);
console.log(date);
// var date_tmp = moment('Wed Jun 06 20:07:10 +0000 2012', 'DD-MM-YYYY').format();
var m = moment(str, 'ddMMM DD HH:mm:ss ZZ YYYY', 'en');
var m = moment();
moment.locale('en');
setTimeout(function () {
// console.log(moment().isSame(new Date(str2), 'day'));
}, 1);
// var r = new RegExp('(?!https\:\/\/twitter.com)(https|http)', 'i');
var result = /(?!https\:\/\/twitter.com)(https|http)/gi.test('http://twitter.com https://twitter.com ');
console.log(result);
// console.log(result ? true : false);
var text = '@nodejs,Judiciary has lost its independence. Hope of common man is gone #BuhariIsADisaster #FreeNnamdiKanu';
var result2 = /(?!https\:\/\/twitter.com)(https|http)/g.test(text);
console.log(result2);
var urlNotTwitterPattern = /(?!https\:\/\/twitter.com|http\:\/\/twitter.com|http\:\/\/.*\.(png|jpg|jpeg|gif))(https|http)/g;
var urls = [
{
url:'https://twitter.com/googlecloud/status/690305876364763136'
},
{
url:"http://creative-punch.net/2013/12/create-a-modern-flat-metro-style-menu-with-flip-effect-using-the-css3-transform-property"
// url:'https://twitter.com/googlecloud/status/690305876364763136'
},
{
url: 'http://bit.ly/1jZKmmI'
}
];
var testUrl = _.filter(urls, function(o){
console.log('-->', urlNotTwitterPattern.test(o.url));
return urlNotTwitterPattern.test(o.url);
});
console.log(testUrl);
console.log('----------------- String in array ----------------------------');
var text = 'RT @KendrickColeman: get your learn on for free… Docker, CoreOS, Cloud Foundry, Kubernetes and OpenStack via @edXOnline https://t.co/YM3Cw…';
// var text2 = 'RT @KendrickColeman: get your learn on for free… Docker, CoreOS, Cloud Foundry, Kubernetes and OpenStack via @edXOnline https://t.co/YM3Cw…';
var text2 = 'RT get @KendrickColeman :yoaur learn for free… Docker, CoreOS, on Cloud Foundry, and OpenStack via Kubernete s@edXOnline https://t.co/YM3Cw…';
var textArr = text.split(' ');
var textArr2 = text2.split(' ');
// console.log(textArr);
var index = 0;
var resultStringinArray = _.filter(textArr, function(i){
// console.log('*** Primeiro Filter');
return _.some(textArr2, function(j){
// console.log('*** Primeiro Filter');
// console.log('i', i);
// console.log('j', j);
if(i === undefined || j === undefined) return false;
//
if(i.toLowerCase() === j.toLowerCase()) {
console.log('IGUAL', i);
index = textArr2.indexOf(j);
textArr2.splice(index, 1);
// console.log('REMOVED');
return true;
}
return false;
});
});
console.log(resultStringinArray);
console.log(textArr.length);
console.log(textArr.length * 70 / 100);
console.log(resultStringinArray.length);
console.log(resultStringinArray.length >= textArr.length * 70 / 100);
console.log('--------------------------------- isEmpty ------------------------------');
var isEmpty = _.isEmpty([undefined]);
console.log('isEmpty', isEmpty);
console.log('------------------------ JOIN ---------------------------');
var joinArr = [
'(?!',
'https\:\/\/twitter.com.*',
'|',
'http\:\/\/twitter.com.*',
'|',
'https\:\/\/stackoverflow.com.*',
'|',
'http\:\/\/stackoverflow.com.*',
'|',
'http\:\/\/.*\.(png|jpg|jpeg|gif))',
'(https.*|http.*)'
].join('');
console.log(joinArr);
var urlBlackList = new RegExp ([
'(?!',
'https\:\/\/twitter.com.*',
'|',
'http\:\/\/twitter.com.*',
'|',
'https\:\/\/stackoverflow.com.*',
'|',
'http\:\/\/stackoverflow.com.*',
'|',
'http\:\/\/.*\.(png|jpg|jpeg|gif))',
'(https.*|http.*)'
].join(''), 'i');
var urls = 'http://twitter.com https://twitter.com https://stackoverflow.com/questions/3622837';
console.log(urls.match(urlBlackList));
console.log(' ------------------------ some -----------------------');
var someText = 'RT @AngularJS_News: The 3 best ways to learn Angular2 DebugMe Blog - AngularJS News - AngularJS News - AngularJS News - AngularJS News http…';
console.log(words.userBlacklistRTPattern);
console.log(someText.match(words.userBlacklistRTPattern));
console.log('--------------------------- obj -------------------------');
var obj = {
'a': 0
};
if (classifier.isUserBlacklist('docker')) {
console.log('--> ', 'docker');
}
console.log(3 - (3 * 50 / 100));
console.log(_.round(1.5))
console.log(moment().minutes())
console.log(_.max([10, 10]))
var m = 'RT @smashingmag dadfadf'.match('.*RT @\\w+\\s');
console.log(m);
console.log('andorrala vella'.match('andorra\\s*la\\s*vella'));