Skip to content

Instantly share code, notes, and snippets.

View andrescevp's full-sized avatar
🏠
Working from home

Andres Cevallos andrescevp

🏠
Working from home
View GitHub Profile
@supersonictw
supersonictw / ollama-export.sh
Last active July 4, 2024 15:59
Ollama Model Export Script
#!/bin/bash
# Ollama Model Export Script
# Usage: bash ollama-export.sh vicuna:7b
# License: MIT (https://ncurl.xyz/s/RD0Yl5fSg)
# https://gist.github.com/supersonictw/f6cf5e599377132fe5e180b3d495c553
set -e
echo "Ollama Model Export Script"
echo "License: MIT (https://ncurl.xyz/s/RD0Yl5fSg)"
@ricky-lim
ricky-lim / grade.py
Created March 25, 2020 12:45
Composing classes with dataclass, instead of deep-nested dictionary
# From the book, effective python 2nd edition item 37
from collections import defaultdict
from dataclasses import dataclass, field
from typing import List, Dict
@dataclass
class Grade:
weight: int
@sanzoghenzo
sanzoghenzo / compare.py
Last active May 10, 2024 04:25
Compare Excel sheets with Pandas
"""
Compare two Excel sheets
Inspired by https://pbpython.com/excel-diff-pandas-update.html
For the documentation, download this file and type:
python compare.py --help
"""
import argparse
import pandas as pd
@stramel
stramel / HOWTO.md
Last active July 3, 2024 20:58
Installing Powerline fonts on Windows 10

Installing Powerline fonts on Windows 10

Steps

  1. Download and extract zip from here
  2. Press Windows + x
  3. Press a (Selects PowerShell (Admin))
  4. Navigate to directory where fonts were extracted to (cd ${HOME}\Downloads\fonts-master\fonts-master)
  5. Set Execution Policy Set-ExecutionPolicy RemoteSigned [1]
  6. Press y then Enter to accept
@sylvaincombes
sylvaincombes / index.html
Last active February 7, 2020 14:53
Ckeditor : Allow and preserve twig syntax
<script type="text/javascript">
// Allow and preserve twig syntax @see http://stackoverflow.com/questions/20977910/editing-twig-templates-in-ckeditor
// Can also be coupled with this plugin : http://ckeditor.com/addon/showprotected
CKEDITOR.config.protectedSource.push(/\{\{[\s\S]*?\}\}/g);
CKEDITOR.config.protectedSource.push(/\{\%[\s\S]*?%\}/g);
CKEDITOR.config.protectedSource.push(/\{\#[\s\S]*?#\}/g);
</script>
@rjkip
rjkip / monolog.json
Last active December 3, 2017 21:56 — forked from skowron-line/monolog.json
lnav Monolog format
{
"monolog": {
"title": "Monolog log file",
"description": "Monolog log format",
"url": "https://github.com/Seldaek/monolog",
"regex": {
"default": {
"pattern": "\\[(?P<timestamp>.*)\\] (?P<logger>.+?).(?P<level>\\w+): (?P<message>[^\\[\\{]+) (?P<context>[\\[\\{].*[\\]\\}]) (?P<extra>[\\[\\{].*[\\]\\}])"
}
},
@jotaelesalinas
jotaelesalinas / runcommand.py
Created May 12, 2016 23:20
Runs an external command in Python and returns exit code, stdout and stderr contents.
# runcommand.py
# Handy function that executes an external command in the shell
# and returns 3 values: exit code of the command, its standard output
# and its error output.
# If you run the script directly, an example is provided:
# first it will run a successful command and then one with errors
# (you may want to modify them if not running a Unix system).
import subprocess
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 22, 2024 20:31
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@palankai
palankai / specification.py
Last active March 29, 2024 10:02
Python Specification Pattern
class Specification:
def __and__(self, other):
return And(self, other)
def __or__(self, other):
return Or(self, other)
def __xor__(self, other):
return Xor(self, other)