Skip to content

Instantly share code, notes, and snippets.

View italomaia's full-sized avatar

Italo Maia italomaia

View GitHub Profile
@italomaia
italomaia / mri_to_webp.py
Created March 2, 2019 21:14
Parses mri encrypted files to webp
import re
import struct
def parse_mri_data_to_webp_buffer(data):
size_list = [0] * 4
size = len(data)
header_size = size + 7
# little endian byte representation
@italomaia
italomaia / mri_to_webp.lua
Created March 2, 2019 18:36
Decrypts mangarock images into webp using lua programming language
local moses = require("moses")
local function parse_mri_data_to_webp_buffer (mri_data)
local size = #mri_data
local webp_size = size + 7
local webp_size_as_byte = string.pack("<I", webp_size)
local webp_buffer = {
82, -- R
local moses = require("moses")
local function parse_mri_to_webp(mri_path)
local name = string.match(mri_path, "(%w+)%.")
local fsi = io.open(mri_path, "rb")
local idata = fsi:read("*all")
fsi:close()
local size = #idata
local n = size + 7
@italomaia
italomaia / watch-moon.sh
Created November 18, 2018 19:28
If you're developing with lapis framework, this will help you keep your lua files in sync with moon files
#!/bin/sh
echo "watching moon files under $(pwd)";
inotifywait -m -r -q -e create -e close_write -e moved_from -e moved_to $(pwd) |
while read path action file; do
name="$path$file";
# ignore everything that is not a moonfile
if echo "$file" | grep -q ".moon$" ; then
@italomaia
italomaia / watch_the_moon.sh
Created November 11, 2018 23:35
watch and compile moon files
#!/bin/sh
inotifywait -m -r -q --exclude "" -e create -e close_write -e move $(pwd) |
while read path action file; do
if [[ $path == \.moon$ ]]; then
if [ $action = 'MOVED_FROM' ] || [ $action = 'DELETE' ]; then
rm "${path/\.moon$/.lua}"; # clean up lua file
else
moonc $path;
fi
fi
@italomaia
italomaia / gist:11309843
Created April 26, 2014 02:03
Name collision using flask-admin and modelview
from flask import Flask, Blueprint
from flask.ext.admin import Admin
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.admin.contrib.sqla import ModelView
app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)