Skip to content

Instantly share code, notes, and snippets.

View VvanGemert's full-sized avatar

Vincent VvanGemert

View GitHub Profile
@VvanGemert
VvanGemert / flux_on_potato.py
Last active August 20, 2024 06:29 — forked from AmericanPresidentJimmyCarter/flux_on_potato.py
how to run flux on your 16gb potato
# First, in your terminal.
#
# $ python3 -m virtualenv env
# $ source env/bin/activate
# $ pip install torch torchvision transformers sentencepiece protobuf accelerate
# $ pip install git+https://github.com/huggingface/diffusers.git
# $ pip install optimum-quanto
# $ pip install gradio
import torch
@VvanGemert
VvanGemert / crystal.rb
Last active November 19, 2018 11:46
Crystal build with OpenSSL formula for homebrew
class Crystal < Formula
desc "Fast and statically typed, compiled language with Ruby-like syntax"
homepage "https://crystal-lang.org/"
stable do
url "https://github.com/crystal-lang/crystal/archive/0.27.0.tar.gz"
sha256 "43c8ac1b5c59ccea3cd58c9bd2a7af07a56f96cf1eff1e54d93f648b5340e83a"
resource "shards" do
url "https://github.com/crystal-lang/shards/archive/v0.8.1.tar.gz"
@VvanGemert
VvanGemert / bulk_reindexer.rb
Created July 2, 2017 12:23
Asynchronous bulk reindexing module for Searchkick with Sidekiq
require 'sidekiq/api'
# BulkReindexer
module BulkReindexer
def self.reindex_model(model, promote_and_clean = true)
puts "Reindexing #{model.name}..."
index = model.reindex(async: true, refresh_interval: '30s')
puts "All jobs are in queue. Index name: #{index[:index_name]}"
loop do
# Check the size of queue
@VvanGemert
VvanGemert / mongoid.yml
Created June 1, 2017 13:21
MongoID config file with direct connection setting
development:
clients:
default:
database: floorplanner
options:
connect: :direct
hosts:
- localhost:27017
@VvanGemert
VvanGemert / mongo_check.sh
Created June 1, 2017 13:17
MongoDB Master check with xinetd.d
#!/bin/bash
output=`mongo --quiet --eval 'db.isMaster().ismaster'`
if [[ "$output" == 'true' ]]
then
http_type="HTTP/1.0 200 OK"
mongo="master"
else
http_type="HTTP/1.0 503 Service Unavailable"
mongo="slave"
@VvanGemert
VvanGemert / haproxy.cfg
Created June 1, 2017 13:15
MongoDB Haproxy configuration
listen mongodb *:27017
balance source
mode tcp
option tcpka
option httpchk
server db01 127.0.0.1:27017 check port 27020 inter 5s
server db02 127.0.0.2:27017 check port 27020 inter 5s
server db03 127.0.0.3:27017 check port 27020 inter 5s
@VvanGemert
VvanGemert / remove_column.rb
Last active June 1, 2017 12:41
Example Rails migration to identify problematic database column names
class RemoveColumns < ActiveRecord::Migration[5.1]
def change
working = false
columns = Answer.columns.map &:name
rm_cols = columns - %w[cols to keep]
rm_target = ''
until working || rm_cols.empty?
working = true
begin
puts "attempting to run query with #{rm_cols.first} column present"
@VvanGemert
VvanGemert / table_column.sql
Last active June 23, 2017 09:53
Identify column names equal to the table name
SELECT * FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'table_name'
AND TABLE_NAME = COLUMN_NAME;
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "Unknown"
HorizSync 28.0 - 33.0
VertRefresh 43.0 - 72.0
Option "DPMS"
Modeline "3184x2160" 590.04 3184 3440 3792 4400 2160 2161 2164 2235 -HSync +Vsync
EndSection
@VvanGemert
VvanGemert / image_processing_daemon.rb
Last active December 17, 2015 09:19
This script generates two simple daemons to process images with convert and uploads them to S3.
# Image processing daemons
# By VvanGemert
#
# Requirements:
# apt-get install imagemagick
# ruby 1.9.3 or higher
# gem install daemons
# gem install aws-s3
#
# Usage: