Skip to content

Instantly share code, notes, and snippets.

View loicteixeira's full-sized avatar

Loic Teixeira loicteixeira

View GitHub Profile
@huytd
huytd / wordle.md
Last active May 2, 2024 12:13
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@jmatsushita
jmatsushita / README
Last active May 9, 2024 19:39
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
@josephmancuso
josephmancuso / README.md
Last active April 21, 2020 06:28
Deploy a Masonite application through a GitHub action

Instructions

This is a gist containing several files needed to get Masonite automatically deploying to your servers via GitHub pushes (or releases)

NOTE: This script will have a downtime of a few seconds between deployments. If your application requires no downtime you can see this GIST here for a bit more complex GIST for getting to zero downtime deployments through the use of uWSGI, unix sockets and managed config files

Requirements

  • NGINX installed (may or may not be fully configured)
  • Python 3 installed and everything needed to run a Masonite application (see Masonite documentation for requirements)
@ag-castro
ag-castro / image_validator.py
Created December 24, 2018 03:49
A validator image for Wagtail CMS
import os
from django.core.exceptions import ValidationError
from django.core.files.images import get_image_dimensions
from django.utils.deconstruct import deconstructible
from wagtail.images.models import Image # To get the image object from wagtail collections
@deconstructible
class ImageValidator:
"""ImageField dimensions validator."""
@MattSegal
MattSegal / super_and_subscript.py
Created June 19, 2018 03:29
Draftail Super and Subscript
# models.py
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
class MyModel(Page):
# ...
body = RichTextField(features=[
# ...
'subscript',
'superscript',
@mx-moth
mx-moth / test_data_helpers.py
Created February 6, 2018 03:19
Some helpers for making POST data for Wagtail / Django form tests
def _nested_form_data(data):
if isinstance(data, dict):
items = data.items()
elif isinstance(data, list):
items = enumerate(data)
for key, value in items:
key = str(key)
if isinstance(value, (dict, list)):
for child_keys, child_value in _nested_form_data(value):
@mvantellingen
mvantellingen / apps.py
Created November 22, 2016 09:58
wagtail performance hack
from django.apps import AppConfig
class CMSConfig(AppConfig):
name = 'myproj.apps.cms'
def ready(self):
from wagtail.wagtailcore.models import Site
root_paths = Site.get_site_root_paths()
--[[
* Copyright (c) 2011-2016 - Ashita Development Team
*
* Ashita is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ashita is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@evanwill
evanwill / gitBash_windows.md
Last active April 26, 2024 03:58
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

@carlos-jenkins
carlos-jenkins / multihooks.py
Last active August 10, 2023 22:12
Delegating script for multiple git hooks
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2017 Carlos Jenkins <carlos@jenkins.co.cr>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#