Skip to content

Instantly share code, notes, and snippets.

View rafaelbeckel's full-sized avatar
🦀

Rafael Beckel rafaelbeckel

🦀
View GitHub Profile

Last updated 2020/03/04

Some links from twitter on the topic of parsing PSD files (haven't looked into them in details). PSD include a flattened rasterized image so this is easy to load if that's the only thing you need. Most software / librairies have support for extracting this flattened data (e.g. stb_image.h does).

However if you want access to individual layers, render non-rasterized layers, emulate every photoshop features, extract or apply effects with more granularity, more code is needed. May range from easy to lots-of-work depending on what exactly you need.

As far as I know there isn't a trivial stb-like ready-to-use C++ library to do that sort of things. Posting all links here. Some are probably bloated or hard to use into your project, some lacking features.

TODO: Actually look into the pros/cons of all those.

@rafaelbeckel
rafaelbeckel / tail_recursion_with_branching.py
Created February 25, 2020 09:58
A more powerful version of the tail recursion decorator with branching support
from functools import wraps
from collections import deque
"""
Implements tail recursion decorator to overcome Python's recursive limit.
This is similar to my previous, simpler one:
https://gist.github.com/rafaelbeckel/4ed8d7822d22cf6fe4103cc08b19621b
The difference of this version is that it now adds support for stacking up
@rafaelbeckel
rafaelbeckel / tail_recursion.py
Last active February 25, 2020 10:02
A simple tail recursive class to overcome Python's recursion limit
"""
Implements tail recursion decorator to overcome Python's recursive limit.
This is a simple version that supports single-loop recursion functions like
fibonacci or factorial. There is also a more complex decorator with support
for branching published here:
https://gist.github.com/rafaelbeckel/9849184c5a8e7832b659e3c0e3ee7d3e
Usage:
------
@rafaelbeckel
rafaelbeckel / golang_new_project.sh
Created January 30, 2020 03:03
Create new Golang project and Github repository with one single command
# put that in your .bash_profile
function ng() {
mkdir $GOPATH/src/github.com/rafaelbeckel/$1 &&
cd $GOPATH/src/github.com/rafaelbeckel/$1 &&
git init &&
curl -u 'rafaelbeckel' https://api.github.com/user/repos -d "{\"name\":\"$1\", \"private\":true, \"gitignore_template\": \"Go\" }" &&
git remote add origin https://github.com/rafaelbeckel/$1
&& git pull origin master
&& touch main.go
/*
The MIT License (MIT)
Copyright (c) 2014 Ismael Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@rafaelbeckel
rafaelbeckel / gist:67a55b28961df538ce4cdc515482f058
Created September 19, 2019 23:14
JS Number between function
Number.prototype.between = (min, max) => this >= min && this <= max;
@rafaelbeckel
rafaelbeckel / GLSL_contrast
Created May 22, 2019 19:06 — forked from yiwenl/GLSL_contrast
Greyscale in glsl
float contrast(float mValue, float mScale, float mMidPoint) {
return clamp( (mValue - mMidPoint) * mScale + mMidPoint, 0.0, 1.0);
}
float contrast(float mValue, float mScale) {
return contrast(mValue, mScale, .5);
}
vec3 contrast(vec3 mValue, float mScale, float mMidPoint) {
return vec3( contrast(mValue.r, mScale, mMidPoint), contrast(mValue.g, mScale, mMidPoint), contrast(mValue.b, mScale, mMidPoint) );
@rafaelbeckel
rafaelbeckel / LICENSE
Created May 3, 2019 15:43 — forked from kjlubick/LICENSE
Exports a THREE.js scene mesh to STL, making it suitable for 3d printing
The MIT License
Copyright © 2010-2016 three.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@rafaelbeckel
rafaelbeckel / Eng-manager.md
Created May 3, 2019 02:43
Engineering Manager Role Description

From JimDabell's comment on Hacker News: https://news.ycombinator.com/item?id=18355568

Off the top of my head, these are the kinds of things engineering managers often have to deal with:

Hiring:

  • Writing job specs.
  • Dealing with recruiters
  • Reading CVs/résumés
  • Interviews
@rafaelbeckel
rafaelbeckel / readvar.sh
Created March 17, 2018 20:11
Bash Script - Read variable from .env file
#!/bin/bash
read_var() {
VAR=$(grep $1 $2 | xargs)
IFS="=" read -ra VAR <<< "$VAR"
echo ${VAR[1]}
}
MY_VAR=$(read_var MY_VAR .env)