Skip to content

Instantly share code, notes, and snippets.

View mraaroncruz's full-sized avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@Manzanit0
Manzanit0 / ci-simple.yaml
Last active October 11, 2023 20:24
Elixir CI with Github Actions
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
env:
MIX_ENV: test
jobs:
@andrebrait
andrebrait / keychron_linux.md
Last active April 23, 2024 19:51
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@mupkoo
mupkoo / SocketContextWithRef.ts
Created April 21, 2020 20:26
Using React Hooks for Phoenix Socket/Channels
import React, { createContext, useContext, useRef } from 'react';
import { Socket } from 'phoenix';
import AuthContext from './AuthContext';
const SocketContext = createContext<Socket>({} as Socket);
const SocketConsumer = SocketContext.Consumer;
const SocketProvider: React.FC = ({ children }) => {
let token = useContext(AuthContext).token!;
let socketRef = useRef<{
@Sheikh2Imran
Sheikh2Imran / decorators.py
Last active December 21, 2021 14:28
Custom method decorator in Django
def authentication_decorator(function):
def wrap(request, *args, **kwargs):
user_token = request.META.get('HTTP_AUTHORIZATION')
user_response, status_code = backend_obj.get_user(user_token)
if status_code == 200:
kwargs = user_response
return function(request, *args, **kwargs)
return wrap
@sivers
sivers / podcast.rb
Created October 29, 2019 21:30
Podcast RSS generator in Ruby
#!/usr/bin/env ruby
require 'date'
require 'xml'
def htmlit(infile)
lines = File.readlines(infile)
/<!--\s+(.+)\s+-->/.match lines.shift
lines.unshift('<h2>%s</h2>' % $1)
html = ''
lines.each do |line|
@AnatomicJC
AnatomicJC / zfs-docker.md
Last active December 14, 2023 00:33
ZFS and Docker

Create a dedicated ZFS docker pool with deduplication disabled in case of dedup enabled on your system:

zfs create -o mountpoint=/var/lib/docker -o dedup=off rpool/docker

Sometimes, you don't want ZFS for docker storage. ZFS can be sadly quite painful with Docker in Docker and similar scenarios. It might be best to avoid the problem by creating a volume in your ZFS pool, formatting that volume to ext4, and having docker use "overlay2" on top of that, instead of "zfs".

zfs create -s -V 30G rpool/docker

mkfs.ext4 /dev/zvol/rpool/docker

@alvinncx
alvinncx / config.exs
Last active February 4, 2021 12:30
Getting Phoenix.PubSub & Phoenix.LiveView to work together
# Configures the endpoint
config :example, Example.Endpoint,
...
pubsub: [name: Example.PubSub, adapter: Phoenix.PubSub.PG2],
...
@mraaroncruz
mraaroncruz / ethereum.rb
Created November 8, 2018 12:24
Use your key with a contract in ruby
key = Eth::Key.new(priv: YOUR_PRIVATE_KEY)
client = Ethereum::HttpClient.new(...)
client.default_account = key.address
contract = Ethereum::Contract.create(...)
contract.key = key
@mraaroncruz
mraaroncruz / iam_admin_policy.json
Last active September 10, 2018 13:32
S3 Policies
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
@vdbelt
vdbelt / cloudflare-purge-cache-service-worker.js
Created August 21, 2018 11:43
A CloudFlare service worker that proxies purge cache requests. Example: https://example.com/__purge_cache?zone=XX
addEventListener('fetch', event => {
event.respondWith(purgeCache(event.request))
})
async function purgeCache(request) {
const url = new URL(request.url)