Skip to content

Instantly share code, notes, and snippets.

View yarkovaleksei's full-sized avatar
🏠
Working from home

Yarkov Aleksey yarkovaleksei

🏠
Working from home
  • Russia, Rostov-on-Don
View GitHub Profile
@yarkovaleksei
yarkovaleksei / js-crypto-libraries.md
Created December 25, 2015 08:20 — forked from jo/js-crypto-libraries.md
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

I start with a list and plan to create a comparison table.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@yarkovaleksei
yarkovaleksei / random.js
Created April 15, 2016 08:56 — forked from kerimdzhanov/random.js
Javascript get random number in a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {float} a random floating point number
*/
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
@yarkovaleksei
yarkovaleksei / urlobject.js
Created April 20, 2016 07:36 — forked from aymanfarhat/urlobject.js
JS utility function that: - Breaks down url to an object with accessible properties: protocol, parameters object, host, hash, etc... - Converts url parameters to key/value pairs - Convert parameter numeric values to their base types instead of strings - Store multiple values of a parameter in an array - Unescape parameter values
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
option_key,
i,
urlObj,
get_param,
key,
@yarkovaleksei
yarkovaleksei / aes.js
Created June 2, 2016 22:42
AES Crypto module
(typeof Crypto=="undefined"||!Crypto.util)&&function(){var d=window.Crypto={},a=d.util={rotl:function(c,f){return c<<f|c>>>32-f},rotr:function(c,f){return c<<32-f|c>>>f},endian:function(c){if(c.constructor==Number){return a.rotl(c,8)&16711935|a.rotl(c,24)&4278255360}for(var f=0;f<c.length;f++){c[f]=a.endian(c[f])}return c},randomBytes:function(c){for(var f=[];c>0;c--){f.push(Math.floor(Math.random()*256))}return f},bytesToWords:function(g){for(var h=[],c=0,f=0;c<g.length;c++,f+=8){h[f>>>5]|=(g[c]&255)<<24-f%32}return h},wordsToBytes:function(f){for(var g=[],c=0;c<f.length*32;c+=8){g.push(f[c>>>5]>>>24-c%32&255)}return g},bytesToHex:function(f){for(var g=[],c=0;c<f.length;c++){g.push((f[c]>>>4).toString(16)),g.push((f[c]&15).toString(16))}return g.join("")},hexToBytes:function(f){for(var g=[],c=0;c<f.length;c+=2){g.push(parseInt(f.substr(c,2),16))}return g},bytesToBase64:function(h){if(typeof btoa=="function"){return btoa(b.bytesToString(h))}for(var i=[],c=0;c<h.length;c+=3){for(var f=h[c]<<16|h[c+1]<<8|h[c+2]
@yarkovaleksei
yarkovaleksei / parse-options.sh
Created June 10, 2016 10:24 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
// Идем на страницу http://www.useragentstring.com/pages/useragentstring.php?name=All, открываем консоль и вставляем туда этот код.
// Потом жмем на ссылку DOWNLOAD USERAGENT LIST! и список скачан ))
function getAllUA(){
let liArray = document.querySelectorAll("li>a[href*='?id=']");
let uaList = [];
[].forEach.call(liArray, function(el){
let ua = el.innerText;
uaList.push(ua);
});
@yarkovaleksei
yarkovaleksei / screenshot.md
Created June 11, 2016 09:13 — forked from jeefave/screenshot.md
javascript

Js express screenshot

$.getScript('https://github.com/niklasvh/html2canvas/releases/download/0.4.1/html2canvas.js', function(){
   html2canvas(document.body, {
       //height: 1024,
       //width: 768,
       //background: '#fff',
       onrendered: function(canvas) {
           window.open(canvas.toDataURL( /* "image/jpeg" */ ));

}

Javascript Public, Private Instance Methods

    
    var array = [];
    
    var object = {};
    
    var method = function () {};
    
    var instance = new function (privateField, a, b) {
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list
apt-get -y update
apt-get -y install mongodb-10gen
#sudo service mongodb start
var str = "My top secret phrase!"
String.prototype.rot13 = function(){
return this.replace(/[a-zA-Z]/g, function(c){
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
});
};
alert(str.rot13());