Skip to content

Instantly share code, notes, and snippets.

View cuibonobo's full-sized avatar

Jen Garcia cuibonobo

View GitHub Profile
@cuibonobo
cuibonobo / centos_python_install.md
Last active April 30, 2024 13:13
Install Python 2.7.15 on CentOS 6

These instructions were mostly taken from here, though I've modified them to install Python 2.7.15 and the latest setuptools package.

# Install dependencies
yum groupinstall -y 'development tools'
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget

# Download the Python source and unpack it
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
tar -xvzf Python-2.7.15.tgz
@cuibonobo
cuibonobo / Large-app-how-to.md
Last active March 6, 2024 18:40
How to structure a large application in Flask. Taken from the Flask wiki: https://github.com/mitsuhiko/flask/wiki/Large-app-how-to

Here's an example application that uses the pattern detailed below: https://github.com/tantastik/talent-curator


This document is an attempt to describe the first step of a large project structure with flask and some basic modules:

  • SQLAlchemy
  • WTForms

Please feel free to fix and add your own tips.

@cuibonobo
cuibonobo / instagram-private-api.md
Created March 22, 2015 02:00
Reverse-engineered Instagram API for posting photos

Original write-up here: http://lancenewman.me/posting-a-photo-to-instagram-without-a-phone/

Helper functions

function SendRequest($url, $post, $post_data, $user_agent, $cookies) {
    $ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://instagram.com/api/v1/'.$url);
	curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@cuibonobo
cuibonobo / CmdInit.cmd
Created June 13, 2018 18:54
Windows CMD.exe customization
@echo off
rem Place this file wherever you want, then create a new `AutoRun` string in
rem `Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor` that points to its location
rem This will print the username in magenta
set userprompt=$E[35m%username%$E[0m
rem This will print the current directory in green
set pathprompt=$E[32m$p$E[0m
@cuibonobo
cuibonobo / bluetooth_kivy.py
Last active October 10, 2023 12:19 — forked from tito/bluetooth.py
Bluetooth example with Kivy. A more fleshed-out example here: https://github.com/tito/android-demo. A more modern way of doing it: https://github.com/kivy/plyer. And this guy used Kivy to connect to an Arduino: https://github.com/brean/arduino-kivy-bluetooth. Native Kivy code (?): https://groups.google.com/d/msg/kivy-users/n_cMbFzf_1A/5edKgQgycx0J
# Same as before, with a kivy-based UI
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
@cuibonobo
cuibonobo / half-size-booklet.sh
Last active January 24, 2023 20:36
Process a PDF to allow for half-size booklet printing
# Get the number of pages in the PDF. (On a Mac you can do `pages=$(mdls -raw -name kMDItemNumberOfPages $PDF)`)
pages=$(pdftk $PDF dump_data | grep NumberOfPages | awk '{print $2}')
# Get the number of 16-page booklets
booklets=$(($pages/16))
if [[ $(($pages%16)) -gt 0 ]]; then
booklets=$(($booklets+1))
fi
# Determine where to split the book for the half-size
booksplit=$(($booklets/2))
# Determine at what page to split the book
@cuibonobo
cuibonobo / stable-diffusion-optimized.md
Last active October 2, 2022 03:46
Instructions for installing an optimized version of Stable Diffusion. Use this guide if your GPU has less than the recommended 10GB of VRAM for the 'full' version.

stable-diffusion (optimized)

Instructions for installing an optimized version of Stable Diffusion. Use this guide if your GPU has less than the recommended 10GB of VRAM for the 'full' version.

The optimized version is from basujindal/stable-diffusion. See that repo for additional img2img and inpaint commands, plus an explanation of the arguments supplied to each command.

Pre-requisites

  • A graphics card that supports NVIDIA CUDA
  • The CUDA Toolkit has been installed
  • Miniconda has been installed for all users
  • The conda command is available on the command line. Usually this means that Miniconda's condabin directory is in your PATH system environment variable.
@cuibonobo
cuibonobo / ffmpeg_test.py
Created May 29, 2021 18:32
Small script to figure out the ffmpeg command that Kitsu uses to generate videos: https://github.com/cgwire/zou/blob/9ed714b47e71b56c2fafab46dbc5cb68d0fc8516/zou/utils/movie.py#L92-L108
import ffmpeg
# Project settings
width = 1920
height = 1080
fps = 24
# Input movie settings
movie_path = "/tmp/zou/33d9712d-d093-478f-89e6-537bea667535.mp4.tmp"
w = 960
@cuibonobo
cuibonobo / documentation.html
Last active May 23, 2021 20:49
A simple documentation boilerplate
<html>
<head>
<title>Documentation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/purecss@0.6.1/build/base-min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/atom-one-light.min.css">
<style type="text/css">
body {
@cuibonobo
cuibonobo / eve-event-hooks.py
Created March 30, 2014 16:49
A good example of using event hooks to modify Eve data. Taken from: https://github.com/nicolaiarocci/eve/issues/270
# settings
settings = {...}
# authentication
from eve.auth import TokenAuth
import requests
from flask import request, g
class TokenAuth(TokenAuth):
def check_auth(self, token, allowed_roles, resource, method):
# check token against user api