Skip to content

Instantly share code, notes, and snippets.

@dozsolti
dozsolti / flatListCurrentIndex.js
Created December 18, 2021 22:38
How to get current index in FlatList - React Native
<FlatList
data={images}
horizontal
pagingEnabled
keyExtractor={...}
renderItem={...}
onMomentumScrollEnd={(event) => {
const index = Math.floor(
event.nativeEvent.contentOffset.x /
event.nativeEvent.layoutMeasurement.width
@dyejon
dyejon / debootstrap-focal-plasma.md
Created April 12, 2021 18:37
Debootstrap Ubuntu 20.04 with Plasma, without LiveUSB or netboot image

Ubuntu 20.04 LTS with minimal KDE

Netboot images are deprecated (not available at all for 20.10+) so debootstrap utility is used instead. I will install minimal Plasma desktop and enable OEM mode. Then I can create my user account from within OEM session.

Security notice

It seems like Chromium DEB is no longer updated, which is a huge security risk (v87 in repos, v89 upstream). "Sources list from 18.04" section is now removed, it is recommended to use Flatpak instead.

@bmatthewshea
bmatthewshea / certbot_pip_install-debian_ubuntu.md
Last active May 2, 2024 13:43
Debian/Ubuntu - CERTBOT without SNAP/SNAPD

CERTBOT - Install using Python PIP

Install Certbot using Python PIP (Package Installer for Python) - without using SNAP, APT or SYSTEMD. (Debian/Ubuntu)


This guide will help you install LetsEncrypt / Certbot using venv PIP under Debian/Ubuntu.

  • This guide has been tested up to Debian 12 / Bookworm.
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 2, 2024 13:42
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@DanielSWolf
DanielSWolf / Program.cs
Last active May 2, 2024 13:41
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@alexpchin
alexpchin / restful_routes.md
Last active May 2, 2024 13:40
7 Restful Routes
URL HTTP Verb Action
/photos/ GET index
/photos/new GET new
/photos POST create
/photos/:id GET show
/photos/:id/edit GET edit
/photos/:id PATCH/PUT update
/photos/:id DELETE destroy
@rain-1
rain-1 / On Llamafile.md
Last active May 2, 2024 13:39
On Llamafile

On Llamafile not making sense

The LLamafile project doesn't make sense.

The claim is that it is "bringing LLMs to the people", but you could already run an LLM - which is a large binary file containing lots of floating point numbers - by using llama.cpp.

Llamafile joins a compiled binary program to run LLMs with a weights binary into a single file. This isn't a useful goal. you could simply distribute a zip containing an .exe and a weights file together. Or better still: Decouple the program that runs these chatbots from the chatbot weights.

Imagine if PNG files were also an executable that could pop open a window that displays a PNG on your computer. There is a reason we don't do this: It's not good engineering.

@rash0
rash0 / puppeteer_twitterLogin.js
Last active May 2, 2024 13:37
Automate login to twitter with Puppeteer
const puppeteer = require("puppeteer");
const user_email = "email@example.com";
const user_handle = "@example"; //either your handle or phone number
const password = "theEndisNear";
async function fkTwitter() {
const browser = await puppeteer.launch({
headless: false,
});
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@JARVIS-AI
JARVIS-AI / GitHub-SSH.md
Created February 23, 2021 13:31
GitHub SSH Windows 10 WSL2

Add SSH to GitHub

Why another tutorial about SSH on Windows 10 for GitHub ?!

Because EVEN official documentation is messy (At least for me)

So I make a cheatsheet for myself and share it for you