Skip to content

Instantly share code, notes, and snippets.

Avatar
🌚
Rien

Miroslav Franc mirekfranc

🌚
Rien
  • Prague, Czech Republic
View GitHub Profile
@mirekfranc
mirekfranc / proc_cpuinfo.pl
Last active Sep 30, 2019
get list of cpu flags for quick checking
View proc_cpuinfo.pl
use v5.10;
sub cpuinfo
{
my $flags;
open my $cpuinfo, "<", "/proc/cpuinfo" or die "failed to open /proc/cpuinfo: $!\n";
while (<$cpuinfo>)
{
if (/flags/)
View make_paths_relative_in_blends.py
#!/usr/bin/python3
import os
import bpy
DIRNAME = os.path.dirname(os.path.realpath(__file__))
FILES = [f for f in os.listdir(DIRNAME) if os.path.isfile(os.path.join(DIRNAME, f)) and f.endswith(('blend'))]
NEW_FILES_DIR = os.path.join(DIRNAME, 'ok')
os.mkdir(NEW_FILES_DIR)
@mirekfranc
mirekfranc / foo.sh
Last active May 20, 2019
macOS // facepalm
View foo.sh
abspath="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")"; pwd)"
echo $abspath
@mirekfranc
mirekfranc / cool.py
Created May 5, 2019
Dist usage from python
View cool.py
import os
import shutil
total, used, free = shutil.disk_usage('.')
print(total, used, free / (1024 * 1024 * 1024))
View copy_alpha_channel.sh
for i in *.jpg; do convert $i \( mask.png -channel a -separate +channel \) -compose copy_opacity -composite ${i%jpg}png;done
View fun.cc
int typedef Int, *pInt, **ppInt;
unsigned typedef char UChar;
int main()
{
UChar u = 25 * sizeof(UChar);
Int a = 17 * sizeof(UChar);
pInt b = &a;
ppInt c = &b;
return 0[c][0] + u;
@mirekfranc
mirekfranc / variadic_template.cc
Created Jun 7, 2018
fooing around with variadic templates...
View variadic_template.cc
#include <unordered_map>
#include <string>
#include <iostream>
struct foo;
struct bar;
struct baz;
template<typename T> struct uhm;
View empty_variant.cc
#include <variant>
#include <iostream>
#include <ios>
#define print(x) do { std::cout << #x << ": " << std::boolalpha << (x) << std::endl; } while (0)
struct IsEmptyVisitor
{
template<typename T>
bool operator()(const T&) const { return false; }
@mirekfranc
mirekfranc / CMakeLists.txt
Created May 4, 2018
compile each object file only once...
View CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
set(program_name an_experiment)
project(${program_name} CXX)
@mirekfranc
mirekfranc / char-type.cc
Created Apr 27, 2018
char != signed char && char != unsigned char
View char-type.cc
// x86_64-redhat-linux
#include <iostream>
template<typename T> struct foo;
#ifndef NO_CHAR
template<> struct foo<char> { void operator()() { std::cout << "char" << std::endl;} };
#endif
template<> struct foo<unsigned char> { void operator()() { std::cout << "unsigned char" << std::endl;} };
You can’t perform that action at this time.