Friday, September 1, 2017

Lua rocks on Mac



Install macports, install readline.

Install luajit.

Install luarocks.

Edit luarocks_installed/etc/luarocks/config-5.1.lua to use libs from /opt/local (those from macports):

external_deps_dirs = {
"/opt/local",
}


In luarocks install inspect, prompt.

/luarocks_installed/bin/luap

Enjoy repl with history and autocomplete.

Saturday, August 5, 2017

lubuntu 16.04 experience, amd radeon integrated video hdmi sound problem

Lubuntu 16.04 on

GA-E2100N (rev. 1.0) | Motherboard - GIGABYTE 


AMD® E1-2100 dual-core APU with Radeon™ HD 8210 graphics SoC


- quick to boot, a bit over 200 MB RAM occupied when all is loaded.
- 3D acceleration works out of the box
- no HDMI sound, fixed by installing pulseaudio
- no video playback acceleration -- fixed by installing vdpau-mesa drivers and setting vdpau in the mplayer as output device.

Monday, July 3, 2017

Evaluating Lua

Three active verisons 5.1, 5.2, 5.3. LuaJIT as 5.1 with some nice C integration features.
The most viable is 5.1 because of luajit/lua implementation choice.

Simple scripts startup time is almost the same as a C program (python is way slower to start).
Memory consumption is low. Several interpreters can be run in the same process.
Syntax is simple and yet allows to be used for DSLs, sandboxing.

RTTI is almost not available apart from discovering if the object is a function, a string, a number or a table.
Standard library is almost non-existing, except for Penlight package from LuaRocks package manager.

Documenting tools are rather lacking and buggy (tried LDoc).

Great for prototyping but as soon as a program grows beyond a couple of modules, it needs proper docs tools, higher level objects (OOP) etc. Existing solutions are quite poor.

Could not find a good REPL implementation.

Sunday, May 14, 2017

premake5 android and ios support

newoption {
    trigger = 'platform',
    description = 'platform name',
    value = 'name',
    allowed = {
        { 'android', '' },
        { 'ios', '' },
    }
}

workspace 'mylib'
location '_build'
configurations { 'debug', 'release' }

-------------------
-- Android specific

filter { 'options:platform=android' }
toolset 'gcc'
gccprefix '~/arm14/bin/arm-linux-androideabi-'

if _OPTIONS['platform'] == 'android' then
    premake.override(premake.tools.clang, "gettoolname", function(base, cfg, tool)
        local basetool = base(cfg, tool)
        local toolchain_prefix = cfg.gccprefix
        print("prefix = " .. tostring(toolchain_prefix))
        if toolchain_prefix and basetool then
            return toolchain_prefix .. basetool
        end
        print('tool = ', tool, 'basetool = ', basetool)
        return nil
    end)
end

---------------
-- iOS specific

filter { 'options:platform=ios' }
xcodebuildsettings {
            --["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = "iPhone Developer",
            --IPHONEOS_DEPLOYMENT_TARGET = "10.2",
            SDKROOT = "iphoneos",
            OTHER_LDFLAGS = "-ObjC",
}

if _OPTIONS['platform'] == 'ios' then
--[[
/* Begin XCBuildConfiguration section */
C20C96B51EC86B9100D730E8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
SDKROOT = iphoneos;
         }

OTHER_LDFLAGS = "-ObjC";

--]]
end

------------------
-- Common

filter {}

project 'my_lib'
kind 'StaticLib'
language 'C'
files { '*.h', '*.c' }

filter { 'configurations:debug' }
defines { 'DEBUG' }
-- flags { 'Symbols' }
symbols 'On'

filter { 'configurations:release' }
defines { 'NDEBUG' }
optimize 'On'


Wednesday, April 12, 2017

my vim config

.vimrc:


set fileencodings=utf-8,ucs-bom,default,latin1
set et
set ai
set si
set ts=4
set shiftwidth=4
set nosmartindent
set tabstop=4
set expandtab
syntax on
set sessionoptions=buffers,sesdir,options,winsize

so ~/myvim.vim

execute pathogen#infect()

###########

myvim.vim:

"set guifont=Ubuntu\ Mono\ 12
"set guifont=Noto\ Mono\ 13
"set guifont=DejaVu\ Sans\ Mono\ 13
set guifont=Liberation\ Mono\ 14
set guioptions=aegimrLt
set colorcolumn=80
set lines=34 columns=134
"IndentGuidesEnable
colo evening
map ï :FSHere

imap :NERDTreeToggle
nmap :NERDTreeToggle

imap :Bufferlistsw
nmap :Bufferlistsw

" nimrod support

fun! JumpToDef()
  if exists("*GotoDefinition_" . &filetype)
    call GotoDefinition_{&filetype}()
  else
    exe "norm! \"
  endif
endf

" Jump to tag
nn :call JumpToDef()
ino :call JumpToDef()i

"IndentGuidesEnable
" end of numrod support

let g:clang_library_path="/usr/lib/"
let g:indent_guides_enable_on_vim_startup = 1

Sunday, April 2, 2017

linux incremental backup

duplicity --no-encryption --progress -vi --exclude '/home/yur/.cache' /home/yur file://./home_yur

Monday, March 27, 2017

ffmpeg cut video script

#!/bin/bash
echo " "
START="$3"
DURATION="$4"
INPUT="$1"
OUTPUT="$2"
shift 4
ffmpeg -ss "$START" -i "$INPUT" "$@" -acodec copy -vcodec copy -t "$DURATION" "$OUTPUT"