Skip to content

Instantly share code, notes, and snippets.

View savely-krasovsky's full-sized avatar

Savely Krasovsky savely-krasovsky

View GitHub Profile
@savely-krasovsky
savely-krasovsky / owncloud-nginx-pretty-urls.conf
Last active July 16, 2016 15:20 — forked from stevenmirabito/owncloud-nginx-pretty-urls.conf
Nginx configuration for ownCloud with support for URL rewriting (https://github.com/owncloud/core/pull/14081)
server {
listen 80;
listen [::]:80;
server_name shorten.pro;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
#!/bin/bash
# Trap Ctrl+C interupt
trap finish INT
exec_cmd_nobail() {
bash -c "$1"
}
exec_cmd() {
sudo letsencrypt certonly --standalone --email savely@krasovsky.me -d kraso.xyz --rsa-key-size 4096
sudo openssl dhparam -dsaparam -out /etc/letsencrypt/live/kraso.xyz/dhparam.pem 4096
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:10m;
sudo apt-get update
sudo apt-get install -t jessie-backports letsencrypt
sudo letsencrypt certonly --standalone --email mail@example.com -d example.com --rsa-key-size 4096
sudo openssl dhparam -dsaparam -out /etc/letsencrypt/live/example.com/dhparam.pem 4096
# '-dsaparam' key for very fast gen
@savely-krasovsky
savely-krasovsky / README.md
Last active February 5, 2023 14:04
Telegram webhooks with nginx reverse proxy

Make config file:

sudo nano /etc/nginx/sites-available/bot.conf

Then copy and paste bot.conf content and edit YOUR.DOMAIN strings. Now install Let's Encrypt on your server. For example in Debian you need to add jessie-backports and easily install it with apt-get:

sudo apt-get install -t jessie-backports letsencrypt

Then get cert for you domain:

Keybase proof

I hereby claim:

  • I am Lord-Protector on github.
  • I am kraso (https://keybase.io/kraso) on keybase.
  • I have a public key whose fingerprint is B8AA FC71 4640 A280 1A42 B36C D857 4D8C 8D86 5E4F

To claim this, I am signing this object:

@savely-krasovsky
savely-krasovsky / score.js
Last active October 16, 2023 13:07 — forked from fipso/score.js
Gamee Hacker Bot for Telegram
/**
* Created by fipso on 13.10.16.
*/
const CryptoJS = require('crypto-js');
const request = require('request-promise-native');
const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot('TOKEN', {polling: true});
r.table('users').changes()
.filter(r.row('new_val')('profile').ne(r.row('old_val')('profile')))
.then(function (cursor) {
cursor.each(async function (err, row) {
if (err) new Error(err);
сonsole.log('Feed change detected!');
await setLocale({from: {id: row.old_val.id}})
if (row.old_val && row.new_val && row.old_val.profile && row.new_val.profile) {

Keybase proof

I hereby claim:

  • I am lord-protector on github.
  • I am kraso (https://keybase.io/kraso) on keybase.
  • I have a public key ASBBl-NsYt44w44fQAlCQgpuDnp5B8wVd9UsXtSAEyUNGAo

To claim this, I am signing this object:

Golang Type Switch - Arbitrary JSON Array Parsing

I'm writing this mostly as a reference for myself. This could also be helpful to people who are new to GO.

Note 1:

Until Problem 3 we will assume we are dealing with a JSON for which we know the data types of key,value pairs. Only in Problem 3 we will look at how Type Switch is used to parse a 100% arbitary JSON

Note 2:

I know the following examples given here can be easily solved by declaring approprite structs and just decoding the PUT JSON into them, but, as im not able to come up with a better scenario, im going to stick with this to explain arbitrary JSON parsing.