Skip to content

Instantly share code, notes, and snippets.

View andrioid's full-sized avatar

Andri Óskarsson andrioid

View GitHub Profile
@chaiyujin
chaiyujin / ubuntu_update_booting_kernel.md
Created December 8, 2020 12:42
Ubuntu: Install Kernel and Set GRUB Default Kernel

Ubuntu: Install Kernel and Set GRUB Default Kernel

Install Kernel

Install the default kernel:

sudo apt install linux-generic

Set GRUB Default Kernel

  1. Find entrance from /boot/grub/grub.cfg
    • Get the $menuentry_id_option:
@JosimarCamargo
JosimarCamargo / README.md
Last active April 6, 2024 15:39
How to setup a Postgres replication with docker and docker-compose

How to setup a Postgres replication with docker and docker-compose

How to use

To run you will need docker and docker-compose installed, and run the command docker-compose up on a folder within this file named docker-compose.yml(attached in this Gist)

How the PGAudit is enable, you will see the queries log and in which database is running which query, this is the main purpose of this Gist, along with have a database with replication working out of the box

To add user with just reading rights to access the database on slave replica

@IanColdwater
IanColdwater / twittermute.txt
Last active May 23, 2024 18:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@devloco
devloco / download-pdf.js
Last active January 10, 2024 11:09
Download a PDF via POST with Fetch API
let fnGetFileNameFromContentDispostionHeader = function (header) {
let contentDispostion = header.split(';');
const fileNameToken = `filename*=UTF-8''`;
let fileName = 'downloaded.pdf';
for (let thisValue of contentDispostion) {
if (thisValue.trim().indexOf(fileNameToken) === 0) {
fileName = decodeURIComponent(thisValue.trim().replace(fileNameToken, ''));
break;
}
<?
// this script receives a Stripe dispute / chargeback and:
//
// - immediately refunds the payment
// - closes the user's account (in my DB, add your own code there)
//
// this is to automate dispute handling (because you never win a dispute on Stripe anyway)
// and by refunding avoiding the chargeback fee
//
@adymitruk
adymitruk / trello-cqrs-es.fish
Last active October 23, 2023 20:19
Trello in CQRS/ES in fish shell
#set up the dir structure if it doesn't exist
set t ~/.trello; mkdir -p $t
function if_exist # we don't want to litter our code with ifs if a read model or events are not there yet. Return /dev/nul for empty
if test -e $t/$argv[1]; echo $t/$argv[1]; else; echo /dev/null; end
end
function list # provide lists from our tab delimited entries with filtering and line item numbers to make choices
set list $argv[1]; set column_to_show $argv[2]; set filter $argv[3]; set count 1
cat (if_exist $list) | grep -e "$filter\$" | while read line
set -l line_items (string split \t $line)
echo $count\) $line_items[$column_to_show]
@schmich
schmich / ducky.md
Last active May 23, 2024 09:46
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

@troyharvey
troyharvey / deployment.yml
Last active May 9, 2024 10:55
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@gregblass
gregblass / App.js
Last active September 21, 2019 17:30
Expo/React Navigation - Google Analytics Integration
import React, { Component } from 'react'
import { RootNavigator } from './navigators'
import { GoogleAnalyticsTracker } from './utils/analytics'
import { GA_TRACKING_ID } from './constants'
class App extends Component {
// gets the current screen from navigation state
getCurrentRouteName = (navigationState) => {
if (!navigationState) {
return null