Skip to content

Instantly share code, notes, and snippets.

@arikfr
arikfr / README.md
Last active April 26, 2024 10:07
Setting up HTTPS with LetsEncrypt for Redash Docker Deployment
  1. Make sure the domain you picked points at the IP of your Redash server.
  2. Switch to the root user (sudo su).
  3. Create a folder named nginx in /opt/redash.
  4. Create in the nginx folder two additional folders: certs and certs-data.
  5. Create the file /opt/redash/nginx/nginx.conf and place the following in it: (replace example.redashapp.com with your domain name)
    upstream redash {
        server redash:5000;
    }
    
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
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=
@notwaldorf
notwaldorf / 👀.md
Last active February 18, 2024 21:13
Advice for new developers

Someone sent me an email asking me what advice I had for new developers. I get this question a bunch, so I wanted to put all my thoughts in one place, that I can update as I get more ideas!

I answered this a bunch on my AMA repo, so here's some initial general answers, before I get to some of the specific questions:

@solancer
solancer / mod_pagespeed .htaccess
Last active January 11, 2023 07:25
mod_pagespeed .htaccess configuration
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
2014-02-12 14:01:35 @aendu: Ich frage mich ja, wo die Wurzel DIESES Übels liegt. https://twitter.com/madmenna/status/433585834193715200 …
2014-02-12 13:58:13 @MadMenNa: Entschuldigung, aber das geht definitiv zu weit. https://twitter.com/andbhold/status/433563855596556289 …
2014-02-12 12:30:53 @andbhold: Jetzt fängt der @Ugugu auch noch an damit: https://twitter.com/Ugugu/status/433563375721660417 …
2014-02-12 12:28:58 @Ugugu: spinnen jetzt alle? https://twitter.com/patman27/status/433559982853066752 …
2014-02-12 12:15:29 @patman27: krass!!
https://twitter.com/sixtus/status/433558970494496768 …
2014-02-12 12:11:28 @sixtus: Boah! Nerv! Und jetzt auch noch das! https://twitter.com/ReichelS/status/433557896753082368 …
2014-02-12 12:07:12 @ReichelS: genau das ist der grund, warum twitter vor die hunde geht: https://twitter.com/mspro/status/433556778983624704 …
2014-02-12 12:02:45 @mspro: orrr, muss das sein? https://twitter.com/totalreflexion/status/433543227249926144 …
2014-02-12 11:08:54 @totalreflexion: Warum
@cpjolicoeur
cpjolicoeur / gist:3590737
Created September 1, 2012 23:15
Ordering a query result set by an arbitrary list in PostgreSQL

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri