Skip to content

Instantly share code, notes, and snippets.

View ezirmusitua's full-sized avatar
🎯
Focusing

ezirmusitua ezirmusitua

🎯
Focusing
View GitHub Profile
@ezirmusitua
ezirmusitua / copy-string.cpp
Last active September 10, 2019 21:43
[Copy string] copy string #C++ #string
// with stl
int a[] = { 1, 2, 3, 4, 5 };
int b[5];
std::copy(std::begin(a),std::end(a),std::begin(b));
for(auto e:b) cout << e << " "; // 1 2 3 4 5
// array container (C++11)
std::array<int,5> arr = { 1, 2, 3, 4, 5 };
std::array<int,5> copy;
copy = arr;
@ezirmusitua
ezirmusitua / compare-object.js
Created January 21, 2019 02:37
[Compare object] compare object in javascript #javascript #node #object
function isEqual(obj1, obj2) {
return JSON.stringify(obj1) === JSON.stringify(obj2);
}
@ezirmusitua
ezirmusitua / rnd.js
Created January 21, 2019 02:38
[Generate random number] generate random integer arbitrary #math #random #javascript #node
// Reference: https://stackoverflow.com/questions/1527803/generating-random-whole-numbers-in-javascript-in-a-specific-range
/**
* Returns a random number between min (inclusive) and max (exclusive)
*/
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
/**
* Returns a random integer between min (inclusive) and max (inclusive).
@ezirmusitua
ezirmusitua / install-yaourt.sh
Created January 30, 2019 03:54
[Install yaourt] install yaourt in archlinux #linux #tools
echo "[archlinuxcn]" >> /etc/pacman.conf
echo "Server=https://mirrors.ustc.edu.cn/archlinuxcn/$arch" >> /etc/pacman.conf
sudo pacman -Sy
sudo pacman -S yaourt
sudo pacman -S archlinuxcn-keyring
@ezirmusitua
ezirmusitua / set-tty-font.sh
Created January 30, 2019 03:56
[Set tty font] set tty console font #linux #font
# list available fonts
ls /usr/share/kbd/consolefonts
# try font
setfont lat2-10
# persist font
## vim /etc/vconsole.conf
FONT=lat2-10
## :wq
@ezirmusitua
ezirmusitua / disable-vim-sound-bell.sh
Last active January 31, 2019 04:04
[Disable sound bell] disable sound bell in vim #vim
# add following lines in .vimrc
set visualbell
set noerrorbells
# or enter in command mode
:set visualbell
:set noerrorbells
@ezirmusitua
ezirmusitua / mongod-service.cmd
Last active April 10, 2019 04:26
[Run mongod as service] Run mongod as windows service #mongo #windows
# create service
mongod --dbpath "E:\MongoDB\data" --logpath "E:\MongoDB\log\logs.txt" --install --serviceName "MongoDB"
# delete service
mongod --remove --serviceName "MongoDB"
sc delete "MongoDB"
@ezirmusitua
ezirmusitua / docker-exec.sh
Created January 31, 2019 04:09
[Run command in running container] run command in running container #docker #shell
# container must run bash at first
docker run -it -d shykes/pybuilder /bin/bash
# use exec to run command
docker exec -it <container_id_or_name> echo "Hello from container!"
@ezirmusitua
ezirmusitua / speed-up-pip-in-pycharm.md
Created January 31, 2019 04:15
[Replace PyCharm pypi source] replace pycharm pypi source to speed up download #IDE #python
  1. Open Settings
  2. Switch to Project/Python Interpreter/Install
  3. Click MANGE REPOSITORIES
  4. Click Add
  5. Enter https://pypi.tuna.tsinghua.edu.cn/simple/ in popup
  6. Save
@ezirmusitua
ezirmusitua / csvstr2array.py
Created January 31, 2019 04:16
[Convert csv string to array] Convert csv string to array in python with StringIO #python
try:
# for Python 2.x
from StringIO import StringIO
except ImportError:
# for Python 3.x
from io import StringIO
import csv
scsv = """text,with,Polish,non-Latin,lettes
1,2,3,4,5,6