Skip to content

Instantly share code, notes, and snippets.

View ngnguyen1's full-sized avatar

Nga Nguyen ngnguyen1

  • FPT - Silicon Labs
  • Hà Nội
  • 16:03 (UTC +07:00)
  • LinkedIn in/nga-nguyen
View GitHub Profile
Map
.find({
artistId: Utils.convertToObjectId(user._id)
})
.select("nameUrl status mapType created sliders")
.populate({
path: 'sliders',
select: 'name No createdAt works',
populate: [{
path: 'works',
[nginx]
name=nginx repo
#baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[mongodb-org-3.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1
-module(mutual_recursion).
-compile([export_all]).
even(1) -> false;
even(X) -> odd(X-1).
odd(1) -> true;
odd(X) -> even(X-1).
%% This is linear recursion
plus(X,0) -> X;
plus(X,Y) -> 1 + plus(X,Y-1).
%% This is tail recursion
tail_plus(X,Y) -> tail_plus(X,Y,X).
tail_plus(_,0,Acc) -> Acc;
tail_plus(X,Y,Acc) ->
tail_plus(X,Y-1,1+Acc).
%% fold here
fold(_, Start, []) -> Start;
fold(F, Start, [H|T]) -> fold(F, F(H,Start), T).
%% Use fold to write the map function.
map(F,L) -> fold(fun(X, Acc) -> [F(X)|Acc] end, [], L).
%% Exp: map(fun(X) -> X+1 end, lists:seq(1,3)). => [2,3,4]
%% This is the functions used to find min, max number and to calculate sum of a list without use fold.
%% find the maximum number of the list
max([H|T]) -> max2(T, H).
max2([], Max) -> Max;
max2([H|T], Max) when H > Max -> max2(T, H);
max2([_|T], Max) -> max2(T, Max).
! `xev` and `showkey` to see which keycode is pressed
!old keys
!xmodmap -pke |grep Something
!keycode 50 = Shift_L ISO_Prev_Group Shift_L ISO_Prev_Group
!keycode 62 = Shift_R ISO_Next_Group Shift_R ISO_Next_Group
!keycode 66 = Caps_Lock NoSymbol Caps_Lock
!keycode 22 = BackSpace BackSpace BackSpace BackSpace NoSymbol NoSymbol Terminate_Server
!keycode 37 = Control_L NoSymbol Control_L
Tổng hợp những kiến thức trong 2 ngày (28-29/4-2016)
Vấn đề:
Thư viện Webtorrent hiện tại chỉ support WebRTC protocol, (không support tcp/udp protocol do lý do bảo mật) điều đó có nghĩa là sẽ không thể lấy các pieces từ các client mà sử dụng giao thức tcp/udp, đồng thời có nghĩa rằng nếu trong torrent không có bất kì client nào sử dụng giao thức WebRTC thì sẽ người dùng sẽ không thể nào lấy được nội dung torrent.
Các giải quyết:
Đầu vào chúng ta là một magnetURI của một torrent mà không có client nào sử dụng giao thức WebRTC.
Ví dụ:
magnet:?xt=urn:btih:359c6570ffc6e5cd6c06e2a0bea75624ddbb7121&dn=alan.mp4&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=http%3A%2F%2Flocalh
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,07,00,00,00,1d,00,38,00,38,00,1d,00,1d,e0,38,e0,38,e0,1d,e0,3a,00,01,00,01,00,3a,00,00,00,00,00
// This is comments, pls don't paste your file
// Create file named your-file.reg
// This file will swap my keys map: ESCAPE to CAPSLOCK, and control to alt keys.
// Windows Registry Editor Version 5.00 => this line to indicate that registry editor version, it's for windows 7, 8. (not sure worked in windows 10)
// Follow registry editor version line must be blank line.