Skip to content

Instantly share code, notes, and snippets.

View coderaiser's full-sized avatar

coderaiser coderaiser

View GitHub Profile

Try-catch oneliner

If you search npm with query try await you will find a big modules list (you can find it in the boottom).

What all this developers want is just more clear way to use try catch. All of them suggest to use:

const tryCatch = require('try-catch');
const [error, data] = tryCatch(JSON.parse, 'hello');
function reRequire(name) {
delete require.cache[require.resolve(name)];
return require(name);
}
@coderaiser
coderaiser / getAllTracksFromVK.html
Last active April 9, 2020 09:22
Get all tracks from profile on vk.com. http://jsfiddle.net/coderaiser/jdUSY/
<!doctype html>
<html>
<head>
<link href=//twitter.github.com/bootstrap/assets/css/bootstrap.css rel=stylesheet>
<link href=style.css rel=stylesheet>
</head>
<body>
<button id=login class="btn btn-success margin">Вход</button>
<div class="btn-group margin hidden">
<button id=logout class="btn btn-success">Выход</button>
alert('Hej. Napisz tu litere polskiego alfabetu i zobacz, jak ta litera sie pisze w jezyku ukrainskim')
function isRussian(a) {
return /[А-Яа-я]/.test(a)
};
const data = {
'a' : 'а',
'b' : 'б',
@coderaiser
coderaiser / webrtc.js
Last active October 9, 2018 19:43
Пример использования WebRTC
/*
* пример использования WebRTC
* http://rastacoding.kodingen.com/webrtc
*/
(function(){
'use strict'
/* определяем вариант функции getUserMedia в зависимости от браузера */
navigator.getUserMedia = navigator.getUserMedia || /* версия, которая останется */
navigator.webkitGetUserMedia || /* chrome и safari */
const fs = require('fs');
const readFile = promisify(fs.readFile);
readFile('./hello', 'utf8').then(console.log);
// outputs
'world';
function promisify(fn) {
return (...a) => {
return new Promise((resolve, reject) => {
#!/bin/sh
git clone git@github.com:cloudcmd/io-ru
cd io-ru
git submodule init
git submodule update
cd _layouts && git checkout master
cd ../..
(function() {
'use strict';
var fs = require('fs'),
exec = require('child_process').exec,
HEADER = '---' + '\n' +
'layout: default' + '\n' +
'---' + '\n';
cmd('git checkout master', function() {
@coderaiser
coderaiser / .bashrc
Last active December 18, 2015 16:39
PROMPT_COMMAND='echo -ne "\033]0;${C9_USER}@${C9_PROJECT}: ${PWD/#$HOME/~}\007"'
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]${PWD/#$HOME/~}\[\033[00m\]$(__git_ps1 " (%s)") $ '
alias ls='ls --color=auto -F'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
@coderaiser
coderaiser / .bash_profile
Last active December 16, 2015 04:29
.bash_profile
PROMPT_COMMAND='echo -ne "\033]0;${C9_USER}@${C9_PROJECT}: ${PWD/#$HOME/~}\007"'
PS1='\[\033[01;32m\]$\u@$\h\[\033[00m\]:\[\033[01;34m\]${PWD/#$HOME/~}\[\033[00m\]$(__git_ps1 " (%s)") $ '
alias ls='ls --color=auto -F'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'