Skip to content

Instantly share code, notes, and snippets.

@hom3chuk
hom3chuk / README.md
Last active June 1, 2019 15:05
Self-hosted Redash TLS setup @ EC2

Fixed https://gist.github.com/arikfr/64c9ff8d2f2b703d4e44fe9e45a7730e

  1. Connect to your redash EC2 (use ubuntu as username, rather than root proposed by AWS):
ssh -i ~/Downloads/your-ec2-cert.pem ubuntu@YOU.R.IP.HERE.eu-west-1.compute.amazonaws.com
  1. sudo su
  2. mkdir /opt/redash/nginx
  3. mkdir /opt/redash/nginx/certs
  4. mkdir /opt/redash/nginx/certs-data
@hom3chuk
hom3chuk / reddit-new-mtga-codes.js
Created May 1, 2019 13:57
small js script to check MTGA sub for new codes giveaway with Mac OS X notifications. Run with node
const {exec} = require('child_process')
var request = require('request');
var options = {
host: 'www.reddit.com',
path: '/r/MagicArena/new/',
followAllRedirects: true
};
var expired = [ // expired code posts titles
@hom3chuk
hom3chuk / badger.sh
Created September 8, 2018 13:56
pgbadger format for AWS RDS logs
pgbadger --prefix "%t:%r:%u@%d:[%p]:" postgresql.log #stolen from https://github.com/sportngin/rds-pgbadger/blob/master/rds-pgbadger.rb
var l=['keydown','keypress','keyup','fullscreenerror','resize','scroll','submit','copy','paste','mouseover','mousemove','mousedown','mouseup','auxclick','click','dblclick','contextmenu','wheel','mouseleave','mouseout','select','pointerlockchange','pointerlockerror','drag','dragend','dragenter','dragover','dragleave','drop'],a=false;
dfwp_unregister = function(){
l.map(function(el){window.removeEventListener(el,dfwp_initGtm)});
};
dfwp_initGtm = function(){
if (!a){
a=true;
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
@hom3chuk
hom3chuk / durov.html
Last active September 22, 2016 19:38
<!-- 1. Go to https://vk.com/audio -->
<!-- 2. Right click anywhere -> inspect -->
<!-- 3. Paste this snippet as a first element of <div class="_audio_rows_header audio_rows_header fixed" (anywhere goeas, actually) -->
<!-- 4. Press "prev/next", Ctrl/Cmd+C, right click "download" -> "save as", Ctrl/Cmd+V -->
<!-- ... -->
<!-- PROFIT -->
<div style="background: white; padding: 20px;"><input type="text" id="downloadbox" style="display:block"><button onclick="getAudioPlayer().playPrev();document.getElementById('downloadbox').value = getAudioPlayer()._currentAudio[4].replace('&amp;','&') + ' — ' + getAudioPlayer()._currentAudio[3].replace('&amp;','&');document.getElementById('downloadlink').href = getAudioPlayer()._currentAudio[2];document.getElementById('downloadbox').focus();document.getElementById('downloadbox').select();">prev</button><button onclick="getAudioPlayer().playNext();document.getElementById('downloadbox').value = getAudioPlayer()._currentAudio[4].replace('&amp;','&') + ' — ' + getAudioPlayer()._cu
.dash-eye { color: #b30f68; }
.dash-body { color: #88d2f3; }
.dash-body-stroke { color: #58a0dc; }
.dash-1 { color: #5e1e88; }
.dash-2 { color: #0e88cb; }
.dash-3 { color: #4bb136; }
.dash-4 { color: #e6e5a8; }
.dash-5 { color: #df6126; }
.dash-6 { color: #dd3534; }
// See https://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit, jQuery version with arrays and objects support
function post(path, parameters) {
var form = $('<form></form>');
form.attr("method", "post");
form.attr("action", path);
$.each(parameters, function(key, value) {
if ( typeof value == 'object' || typeof value == 'array' ){
$.each(value, function(subkey, subvalue) {
<?php
class ActiveRecord extends CActiveRecord
{
/**
* Updates cross-table for MANY_MANY relations, no AR class for cross-table needed.
* This method will delete all existing cross-table records not present in relatedIdList, then populate cross-table with new relations from relatedIdList in one transaction.
* @param string $relationName relation name to be updated (as given in CActiveRecord::relations())
* @param array $relatedIdList list of related ids OR list of related ARs
* @param string $idKey PK accessor for related entity (used only if list of ARs passed in relatedIdList). Defaults to `id`, which is ok for almost every AR.
@hom3chuk
hom3chuk / explain-weight.php
Last active August 29, 2015 14:00
Extend PostgreSQL query planner (EXPLAIN) logs with relative costs and times
#!/usr/bin/php5
<?php
/**
* Simple script to weight PostgreSQL query planner costs (`analyze` times included!) in explain log file.
* Handy for analyzing large query plans with a lot of subqueries.
* Example output (this scan took ~21% of total query run time, worth optimizing):
-> Seq Scan on public.tablename (cost=0.00..3919.54 rows=1 width=0) (actual time=64.232..86.516 rows=1 loops=1)
Cost: 0.00..22.35%
Time: 15.53..20.92%
Output: tablename.id, tablename.name, tablename.another_id
@hom3chuk
hom3chuk / sh.php
Created February 5, 2013 11:40
Quick PHP-shell for emergency server with No-SSH (i.e. FTP-only) evacuation
<?php
/**
* Created by JetBrains PhpStorm.
* User: chekan
* Date: 2/5/13
* Time: 5:53 PM
* To change this template use File | Settings | File Templates.
*/
if ( isset($_REQUEST['command']) ){