This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --name ubuntu -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -it ubuntu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
}, {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./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, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./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) |