Skip to content

Instantly share code, notes, and snippets.

@jarednova
jarednova / gist:6095599
Created July 27, 2013 17:32
Twig / Timber if/else
{% if post.thumbnail %}
<img src="{{post.thumbnail.src}}" />
{% elseif post.heroimage %}
<img src="{{post.heroimage.src}}|resize(300, 300)" />
{% else %}
<img src="/wp-content/themes/mytheme/default-image.jpg" />
{% endif %}
@devorbitus
devorbitus / README.md
Last active April 30, 2024 15:02
AWS Fargate Volume Mount a file

THIS MIGHT NOT BE FULLY ACCURATE

To volume mount a single file into an AWS Fargate container, you can use the secrets or environment files feature of AWS Fargate. Here's how you can accomplish this:

  1. Create a new file with the desired content that you want to mount into the container. Let's call this file config.txt.

  2. Upload the config.txt file to AWS Systems Manager Parameter Store or AWS Secrets Manager. These services allow you to securely store and manage configuration data or secrets.

    • For Systems Manager Parameter Store, create a new parameter and store the content of config.txt as the value.
    • For Secrets Manager, create a new secret and store the content of config.txt as the secret value.
@bluewalk
bluewalk / GetNordVPNWireGuardDetails.md
Last active April 30, 2024 15:01
Getting NordVPN WireGuard details

About

Instructions to obtain WireGuard details of your NordVPN account. These can be used to setup a WireGuard tunnel on your router to NordVPN.

Source: https://forum.gl-inet.com/t/configure-wireguard-client-to-connect-to-nordvpn-servers/10422/27

Prerequisites

If you have any linux machine, use that or install a vm if you don't have one.

Get their official linux app installed. Make sure you have wireguard installed too. And set the used technology to Nordlynx by running nordvpn set technology nordlynx

@Killeroid
Killeroid / gpg-import-and-export-instructions.md
Created October 18, 2017 11:51
How to export and import gpg keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Gotten from the RedHat GPG migration manual

Backup the public and secret keyrings and trust database

## Export all public keys

gpg -a --export >mypubkeys.asc

@islander
islander / fsck_qcow2.md
Last active April 30, 2024 15:00
Recover a qcow2 image using fsck

Recover a qcow2 image using fsck

Load network block device module:

# modprobe nbd max_part=8

Poweroff machine:

# virsh destroy virtual-machine

@v-fox
v-fox / NVMe_tweaks.md
Last active April 30, 2024 14:59
Linux kernel optimizations for NVMe

By default Linux distros are unoptimized in terms of I/O latency. So, here are some tips to improve that.

The performance can be checked by:

  • fio --name=read --readonly --rw={read/randread} --ioengine=libaio --iodepth={jobs_per_each_worker's_command} --bs={4k/2M} --direct={0/1} --numjobs=<number_of_parallel_workers> --runtime={10/30/60} --group_reporting --filename=/dev/nvme<device> - to simulate an optimized app;
  • dd_rescue /dev/nvme<device> /dev/null -b {4k/2M} {-d} - to simulate a stupid app.

Appropriate settings are changed in appropriate places, such as:

  • /etc/tuned/<custom-profile>/tuned.conf:
@bryanltobing
bryanltobing / zod-file-validation.tsx
Last active April 30, 2024 14:57
Zod schema to validate input type file
import { z } from "zod"
const schema = z.object({
file:
typeof window === "undefined" // this is required if your app rendered in server side, otherwise just remove the ternary condition
? z.undefined()
: z
.instanceof(FileList)
.refine(file => file.length !== 0, {
message: "File is required",
@silgon
silgon / 2d_curve_fit.py
Last active April 30, 2024 14:56
Python curve_fit function with 2d data
# curvefit with non linear least squares (curve_fit function)
import numpy as np
from scipy.optimize import curve_fit
def func(x, a, b, c):
return a*np.sin(x[0])+b*np.cos(x[1])+c
limits = [0, 2*np.pi, 0, 2*np.pi] # [x1_min, x1_max, x2_min, x2_max]
side_x = np.linspace(limits[0], limits[1], 100)
side_y = np.linspace(limits[2], limits[3], 100)
@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active April 30, 2024 14:54
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.

@SuperFlue
SuperFlue / AudioAffinity.xml
Created August 9, 2023 20:38
Scheduled task template for automatically setting core affinity on the audiodg service
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2021-03-13T14:05:56.3414408</Date>
<Author>SuperFlue</Author>
<URI>\AudioAffinity</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>