Skip to content

Instantly share code, notes, and snippets.

View malixsys's full-sized avatar
💻
Coding

Martin Alix malixsys

💻
Coding
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
@joeddav
joeddav / chatgpt.py
Last active August 5, 2023 14:29
Simple ChatGPT
import openai
class ChatGPT:
""" A very simple wrapper around OpenAI's ChatGPT API. Makes it easy to create custom messages & chat. """
def __init__(self, model="gpt-3.5-turbo", completion_hparams=None):
self.model = model
self.completion_hparams = completion_hparams or {}
self.history = []
self._messages = []
anonymous
anonymous / flatten.js
Created February 28, 2018 20:00
An array flattener
/**
* @param arr the array to flatten
* @param ret used internally, a starting point if passed
* @returns {Array} a flattened array such that `. [[1,2,[3]],4] -> [1,2,3,4]`
* @example
* const flatten = require('./flatten');
* console.warn(flatten([1, [2, [3, [4]], 5]]));
* // [1, 2, 3, 4, 5]
*/
const flatten = (arr, ret = []) => {
@addyosmani
addyosmani / workbox.md
Last active January 20, 2024 16:14
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()
@rakannimer
rakannimer / add-react-jest-airbnb-linting.sh
Last active August 14, 2018 07:42
Adding react-airbnb styleguide linting to create-react-app
( export PKG=eslint-config-airbnb; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add -D "$PKG@latest"; )
yarn add babel-eslint
echo "{
\"parser\": \"babel-eslint\",
\"env\": {
\"browser\": true,
\"node\": true,
\"jest\": true,
},
\"extends\": \"airbnb\",
@didierfranc
didierfranc / Dokku.sh
Last active May 30, 2023 08:20
Get Dokku working with Ubuntu 16.04 LTS
sudo sh -c "
wget -nv -O - https://packagecloud.io/gpg.key | apt-key add -
echo 'deb https://packagecloud.io/dokku/dokku/ubuntu/ trusty main' | tee /etc/apt/sources.list.d/dokku.list
apt-get update -qq > /dev/null
apt-get install sigil -t trusty # We're using the Ubuntu 14.04 package ;)
apt-mark hold sigil
wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh
bash bootstrap.sh
"
@dblock
dblock / dokku-mongo-export.sh
Last active June 11, 2020 12:20
Backup MongoDB databases with Dropbox and Dokku
#!/bin/bash
set -e
echo "Backing up MongoDB databases to Dropbox ..."
dt=$(date +"%Y-%m-%d")
echo " today is $dt"
@gaearon
gaearon / ReduxMicroBoilerplate.js
Last active March 26, 2020 00:35
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------