Skip to content

Instantly share code, notes, and snippets.

View henriquegogo's full-sized avatar

Henrique Gogó henriquegogo

View GitHub Profile
@henriquegogo
henriquegogo / ViewModel.js
Last active May 24, 2016 05:21
Simplest view model with a third-part template engine
function ViewModel(target_selector) {
var ctx = this;
var target = document.querySelector(target_selector);
var template = target.innerHTML;
this.render = function() {
target.innerHTML = render(template, ctx); // render() should be the third-part template engine
};
}
@henriquegogo
henriquegogo / docker-x11.sh
Created February 13, 2016 18:49
Creating a docker ubuntu container with access to X11
docker run --name ubuntu -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -it ubuntu
@henriquegogo
henriquegogo / Makefile-WARSAW-FEDORA
Last active May 15, 2016 15:54
Makefile para instalar o warsaw no Fedora. Primeiro descompacte o .deb da Caixa.gov.br e então execute make install. Ainda não funciona.
install:
sudo cp etc/init.d/warsaw /etc/init.d/
sudo cp etc/xdg/autostart/warsaw.desktop /etc/xdg/autostart/
sudo cp -r usr/local/bin/warsaw /usr/local/bin/
sudo cp -r usr/local/etc/warsaw /usr/local/etc/
sudo cp -r usr/local/lib/warsaw /usr/local/lib/
sudo cp usr/share/fonts/truetype/Warsaw\ Bold.ttf /usr/share/fonts/
sudo chmod +x /etc/init.d/warsaw
uninstall:
@henriquegogo
henriquegogo / modelView.js
Last active September 23, 2019 20:23
Get all elements with id and return as a object model
var viewModel = [].reduce.call(document.querySelectorAll('[name]'), function(result, i) {
return Object.defineProperty(result, i.name, {
get: function() { return i.value },
set: function(value) { i.value = value },
configurable: true
});
}, {});
@henriquegogo
henriquegogo / edit-video-audio.sh
Last active August 28, 2015 01:15
Edit video audio
ffmpeg -i video.mp4 -i music.mp3 -map 0:v -map 1:a -c:v libx264 -c:a copy -pix_fmt yuv420p -shortest video-final.mp4
@henriquegogo
henriquegogo / useOrbit.lua
Last active August 5, 2018 17:42
How to create a simple webservice with Orbit and Lua
#!./bin/orbit
local orbit = require 'orbit'
module('app', package.seeall, orbit.new)
local routes = {
index = function(web)
return 'Start page<br><a href=/about>About</a>'
end,
@henriquegogo
henriquegogo / webkitExample.lua
Created June 3, 2015 02:58
A lgi (gobject) and webkit example with lua
#!./bin/lua
local lgi = require('lgi')
local gtk = lgi.require('Gtk', '3.0')
local webkit = lgi.require('WebKit', '3.0')
local webview = webkit.WebView.new()
local window = gtk.Window {
title = 'WebKit',
width = 800, height = 600,
@henriquegogo
henriquegogo / useSqlite3.lua
Last active May 24, 2024 19:54
LuaSQL-SQLite3 example
#!./bin/lua
local driver = require('luasql.sqlite3')
local env = driver.sqlite3()
local db = env:connect('db.sqlite')
db:execute[[
CREATE TABLE generic(
key varchar(50),
value varchar(150)
@henriquegogo
henriquegogo / luanova.sh
Last active February 19, 2020 16:08
Install a standalone Lua environment
#!/usr/bin/env sh
# Download this script and run:
# ./luanova.sh $destin_folder
# ($destin_folder is optional)
# THIS SCRIPT BUILD AND INSTALL A STANDALONE LUA AND LUAROCKS PACKAGE
# IF YOU CHANGE THE PATH, PLEASE RUN THIS SCRIPT AGAIN (BECAUSE LUAROCKS ABSOLUTE PATHS)
# FUNCTIONS
@henriquegogo
henriquegogo / makeRequest.lua
Created June 1, 2015 20:18
Http request with lua
#!./bin/lua
local http = require('socket.http')
local cjson = require('cjson')
local response = http.request('http://www.w3schools.com/website/customers_mysql.php')
local customers = cjson.decode(response)
for i,customer in pairs(customers) do
print(customer.Name ..', '.. customer.City ..' - '.. customer.Country)