Skip to content

Instantly share code, notes, and snippets.

View luxcem's full-sized avatar
🚀

A luxcem

🚀
View GitHub Profile
@luxcem
luxcem / list.html
Last active November 24, 2023 08:43
Django quick and simple table pagination and sorting.
<table class="table">
<tr>
<th>{% ordering_link "pk" "#" %}</th>
<th>{% ordering_link "name" "Nom" %}</th>
</tr>
{% for item in page_obj %}
<tr>
<td>{{ item.pk }}</td>
<td>{{ item.name }}</td>
{% endfor %}
@luxcem
luxcem / llama-home.md
Created May 15, 2023 08:01 — forked from rain-1/llama-home.md
How to run Llama 13B with a 6GB graphics card

This worked on 14/May/23. The instructions will probably require updating in the future.

llama is a text prediction model similar to GPT-2, and the version of GPT-3 that has not been fine tuned yet. It is also possible to run fine tuned versions (like alpaca or vicuna with this. I think. Those versions are more focused on answering questions)

Note: I have been told that this does not support multiple GPUs. It can only use a single GPU.

It is possible to run LLama 13B with a 6GB graphics card now! (e.g. a RTX 2060). Thanks to the amazing work involved in llama.cpp. The latest change is CUDA/cuBLAS which allows you pick an arbitrary number of the transformer layers to be run on the GPU. This is perfect for low VRAM.

  • Clone llama.cpp from git, I am on commit 08737ef720f0510c7ec2aa84d7f70c691073c35d.
@luxcem
luxcem / gocryptfs_pam_mount.md
Created January 16, 2023 10:22
Mount gocryptfs volume on login with pam_mount

Auto mount an encrypted directory with gocryptfs and pam_mount.

Make sure to use your login password as a key for gocryptfs

Edit /etc/security/pam_mount.conf.xml and add this line before the </pam_mount> tag.

<volume user="YOURUSERNAME" fstype="fuse" options="nodev,nosuid,quiet"
path="/usr/bin/gocryptfs#/home/%(USER)/ENCRYPTED_DIRECTORY" mountpoint="/home/%(USER)/PLAIN_DIRECTORY" />

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@luxcem
luxcem / debounced-search.js
Last active April 4, 2019 12:41
Example of a React custom hooks for searching an api.
import axios from "axios";
import { useState } from "react";
import { useDebouncedCallback } from "use-debounce";
function useSearch() {
const [value, setValue] = useState("");
const [results, setResults] = useState([]);
const [debouncedCallback] = useDebouncedCallback(value => {
axios.get("/s/?q=" + value).then(res => {
setResults(res.data.map(e => e.ref));
@luxcem
luxcem / self-signed-certificate-with-custom-ca.md
Created April 4, 2018 09:27 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
/*
* This file handle the calls to the api and manage validation (csrf token)
* */
import 'whatwg-fetch';
export default {
getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# encoding: utf-8
import os
import argparse
import exifread
from path import path
import dateutil.parser
def main():
def html_diff(val1, val2):
from difflib import SequenceMatcher
if val1 is None or val2 is None:
return (val1, val2)
diff = SequenceMatcher(None, val1, val2)
op_codes = diff.get_opcodes()
offset1 = 0
offset2 = 0
for op_code in op_codes: