Skip to content

Instantly share code, notes, and snippets.

View Kein1945's full-sized avatar
:octocat:
Happening some things.

Kein Kein1945

:octocat:
Happening some things.
  • Bali
View GitHub Profile
@Kein1945
Kein1945 / .bashrc
Created May 17, 2020 13:26
Bash/Javascript currency converter. Use fixer.io
money() {
node <<EOF
const http = require('http');
const url = 'http://data.fixer.io/api/latest?access_key=API_KEY';
http.get(url, (res) => {
res.setEncoding('utf8');
let body = '';
res.on('data', (data) => {
body += data;
});
@Kein1945
Kein1945 / .bashrc
Created December 19, 2017 10:52
Encrypt and decrypt with aes algorithm with openssl cli in bash
encrypt() {
echo -n "$1" | openssl enc -e -aes-256-cbc -a -salt
}
decrypt (){
echo "$1" | openssl enc -e -aes-256-cbc -a -d -salt
}
@Kein1945
Kein1945 / gist:669b0aa0ffddef7329b4116bfd39958f
Last active May 17, 2020 13:29
[DEPRECATED] Bash currency converter, uses google conveter. Google closed that feature
money() {
to=${3:-rub}
from=${2:-usd}
count=${1:-1}
wget -qO- "http://www.google.com/finance/converter?a=$count&from=$from&to=$to" | sed '/res/!d;s/<[^>]*>//g';
}
alias m='money'
@Kein1945
Kein1945 / gist:8fb0fd4fbe4284c5c6607ad2ebea7743
Created February 12, 2017 11:10
Bash currency converter, uses google conveter.
money() {
to=${3:-rub}
from=${2:-usd}
count=${1:-1}
wget -qO- "http://www.google.com/finance/converter?a=$count&from=$from&to=$to" | sed '/res/!d;s/<[^>]*>//g';
}
alias m='money'
@Kein1945
Kein1945 / import_db.sh
Created December 3, 2016 20:02
Allow copy remote database to local mysql database throw ssh
#!/usr/bin/bash
mysql -u user -e 'DROP DATABASE IF EXISTS db_dev; CREATE DATABASE db_dev;'
ssh hlts -C -o CompressionLevel=9 'mysqldump -udeploy --password=password \
--skip-lock-tables \
crm | gzip -9 -c' | gunzip | mysql -u root db_dev
@Kein1945
Kein1945 / wait_until_hosts.sh
Last active December 30, 2015 12:12
Simple bash script that waiting hosts in environment. Usable with docker compose, when some containers not started and we doesn't have some host in environment.
#!/bin/bash
hosts=( "$@" )
total_hosts=${#hosts[@]}
while :
do
l_hosts=( ${hosts[@]} )
for i in ${!l_hosts[@]}
do
@Kein1945
Kein1945 / .bashrc
Last active January 11, 2017 11:36
Bashrc script for remote working
# Usage
# $ source /dev/stdin < <(curl url.this.bashrc)
PS1=$'\[\033]0;\u:${PWD##*/}\007\]'
PS1+=$'\[\e[0;32m\]\u\[\e[m\]\[\e[0;32m\]@\H\[\e[m\] \[\e[0;30;42m\] [home +\j] \[\e[m\]'
PS1+=$'\n\[\e[0;34m\]\w\[\e[m\] \[\e[0;32m\]\xe2\x98\x85\[\e[m\] \[\e[0;37m\] '
@Kein1945
Kein1945 / porter.js
Created April 26, 2015 18:25
Стеммер портера портированный с java http://www.algorithmist.ru/2010/12/porter-stemmer-russian.html
let RVRE = /^(.*?[аеиоуыэюя])(.*)$/;
let PERFECTIVEGROUND_1 = /(ив|ивши|ившись|ыв|ывши|ывшись)$/;
let PERFECTIVEGROUND_2 = /([ая])(в|вши|вшись)$/;
let REFLEXIVE = /(с[яь])$/;
let ADJECTIVE =/(ее|ие|ые|ое|ими|ыми|ей|ий|ый|ой|ем|им|ым|ом|его|ого|ему|ому|их|ых|ую|юю|ая|яя|ою|ею)$/;
let PARTICIPLE_1 = /(ивш|ывш|ующ)$/;
let PARTICIPLE_2 = /([ая])(ем|нн|вш|ющ|щ)$/;
let VERB_1 = /(ила|ыла|ена|ейте|уйте|ите|или|ыли|ей|уй|ил|ыл|им|ым|ен|ило|ыло|ено|ят|ует|уют|ит|ыт|ены|ить|ыть|ишь|ую|ю)$/;
let VERB_2 = /([ая])(ла|на|ете|йте|ли|й|л|ем|н|ло|но|ет|ют|ны|ть|ешь|нно)$/;
let NOUN = /(а|ев|ов|ие|ье|е|иями|ями|ами|еи|ии|и|ией|ей|ой|ий|й|иям|ям|ием|ем|ам|ом|о|у|ах|иях|ях|ы|ь|ию|ью|ю|ия|ья|я)$/;
@Kein1945
Kein1945 / backbone_logging.js
Last active December 25, 2015 18:19
Simple function that allow see events flow in dev console with stack trace and data.
var bind_logging = (function(strategies, loggers) {
var log_always = '#bind_logging' == document.location.hash;
var canWeLogThis = function(eventflow) {
return _.every(['on', 'off', 'trigger'], function(n){ return eventflow && _.isFunction(eventflow[n]) });
},
canWeLogHere = function() {
return _.every(['groupCollapsed', 'groupEnd', 'log', 'trace'], function(n){ return console && _.isFunction(console[n]) });
},
getLogger = function(ctx, args) {
for(var i = 0; i < strategies.length; i++) {
@Kein1945
Kein1945 / home_contorller.rb
Created May 11, 2014 11:39
Send emails in RoR via pdd.yandex.ru
class HomeController < ApplicationController
def contacts
UserMailer.notify_email( params[:text]).deliver
end
end