Skip to content

Instantly share code, notes, and snippets.

View nisanthchunduru's full-sized avatar

Nisanth Chunduru nisanthchunduru

View GitHub Profile
@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 22, 2024 08:47
Run Llama-2-13B-chat locally on your M1/M2 Mac with GPU inference. Uses 10GB RAM. UPDATE: see https://twitter.com/simonw/status/1691495807319674880?s=20
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build it
make clean
LLAMA_METAL=1 make
# Download model
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin
@runofthemill
runofthemill / README.md
Created March 3, 2020 20:40
Lazy loaded NVM version in iTerm2 Status Bar component

Source custom.zsh in your zsh profile, then in iTerm 2 go to Preferences -> Profiles -> Session, and under Miscellaneous check "Status bar enabled" then click "Configure Status Bar".

Add an Interpolated String component, then configure the String Value to be \(user.nodeVersion) (adjust to match the name of the variable set in iterm2_print_user_vars(), if different)

Now when you load a new session with the configured profile, the Status Bar will show "unset" until node is loaded from nvm, and will show the correct version whenever nvm use is called.

@supix
supix / postgres_recovery.md
Last active April 22, 2024 20:37
Postgres error: Missing chunk 0 for toast value in pg_toast

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.

@nisanthchunduru
nisanthchunduru / clone_and_restore_server_harddisk.md
Last active August 1, 2023 07:52
Clone and restore a physical server's harddisk

Clone a server's harddisk

Login to Hetzner's web interface https://robot.your-server.de/ and activate the Rescue System for the server whose disk you wish to clone.

Ssh into the Rescue System (Replace 1.2.3.4 in the command below with the actual ip address of the server)

ssh -o HostKeyAlias=hetzner-rescue.1.2.3.4 root@1.2.3.4
@fastdivision
fastdivision / userstyle.css
Last active June 5, 2017 16:39
Sane Flowdock Redesign with Stylebot (Browser) or userstyle.css (Native Flowdock OS X App)
/*
* Sane Flowdock Redesign Overrides
* Option 1: Copy and paste CSS into Stylebot
* Option 2: Save file as `userstyle.css` inside ~/Library/Application Support/Flowdock, hit CMD+R to reload app
*/
body {
font-family: -apple-system, BlinkMacSystemFont, Arial, Helvetica, sans-serif !important;
}
@jessedobbelaere
jessedobbelaere / userstyle.css
Last active June 1, 2017 19:14
Flowdock Classic (<May 2017) theme
/**
* On 2017-05-30, Flowdock did some UI changes. This is an attempt to ease the pain.
* Save this file as userstyle.css and put it inside ~/Library/Application Support/Flowdock/, then hit CMD+R to reload Flowdock.
*
* https://gist.github.com/jessedobbelaere/95c02699b2e0acd35762d204797b74f9
* @author Jesse Dobbelaere (@JesseDobbelaere)
*/
/* Improve the font */
body {
@narath
narath / faraday_post.rb
Created May 8, 2017 17:24
How to do a x-www-form-urlencoded post with Faraday
require 'faraday'
require 'uri'
data = {
:your_data => "YOUR DATA"
}
url = "some url"
response = Faraday.post(url) do |req|
@masutaka
masutaka / circle.yml
Created April 16, 2017 10:25
capistrano deployment using CircleCI 2.0
version: 2
jobs:
build:
docker:
- image: ruby:2.3.3-alpine
working_directory: /home/circleci/masutaka.net
steps:
- setup_remote_docker:
# https://circleci.com/docs/2.0/docker-layer-caching/
reusable: true
@pigeonflight
pigeonflight / README.rst
Created April 16, 2017 04:22
Script to mount hetzner backup space

Setup

All commands here are run as root Install sshfs and autofs :

apt-get update
apt-get install sshfs autofs

Ensure you have an ssh key:

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.