Skip to content

Instantly share code, notes, and snippets.

View AlbertSuarez's full-sized avatar
🙃
In the Upside Down

Albert Suarez AlbertSuarez

🙃
In the Upside Down
View GitHub Profile
@daleu
daleu / wordcount.sh
Last active October 8, 2020 09:48
Counting strings on all the files in a directory
#!/usr/bin/env bash
grep -Ro "word_to_search" directory_path | wc -w
@bnekolny
bnekolny / migtrate_data.py
Last active December 15, 2021 14:46
MLFlow migration script from filesystem to database tracking data
import os
import yaml
## Execution for me was:
## `python migrate_data.py > ./migration_inserts.sql`
## `sed -i '' 's/None/NULL/' ./migration_inserts.sql`
## `psql -f ./migration_inserts.sql`
## NOTE: A few things to know about the script here:
## - Artifacts were stored remotely, so no artifact migration
@0xjac
0xjac / private_fork.md
Last active May 24, 2024 12:57
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@sheershoff
sheershoff / dcsl
Last active June 14, 2023 18:05
Docker-compose logs sorted by time
#!/bin/bash
usage="Input piped docker-compose logs -t, or a file created from this command, to show logs lines sorted by time.\n\n Usage:\n\n $(basename "$0") [-h|--help] - this message\n $(basename "$0") - runs default docker-compose logs -t and sorts'em\n docker-compose logs -t|$(basename "$0") - pipe logs to this command\n $(basename "$0") my-compose.log - or choose file with logs to display\n\n"
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
case "$1" in
-h|--help) printf "$usage"
exit
;;
esac
if [ -t 0 ]; then
docker-compose logs -t|sort -t "|" -k +2d
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@PurpleBooth
PurpleBooth / README-Template.md
Last active May 24, 2024 06:43
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@bsmirnov
bsmirnov / README.md
Created August 1, 2012 18:36 — forked from exupero/README.md
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing 127.0.0.1 to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. ipfw seems to work, though its manpage claims it's deprecated and pfctl is the way to go. I wasn't able to figure