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 Component(elementId, data, propTemplate) { | |
var ctx = this; | |
var container = document.getElementById(elementId); | |
var template = propTemplate || container.innerHTML; | |
this.data = {}; | |
this.setData = this.render = function(option, doRender) { | |
if (Array.isArray(option)) this.data = []; | |
for (var key in option) this.data[key] = option[key]; | |
if (doRender != false) render(); |
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 path = require('path'); | |
var fs = require('fs'); | |
var express = require('express'); | |
var app = express(); | |
// Load all route files | |
var routes_path = path.join(__dirname, 'routes'); | |
fs.readdirSync(routes_path).forEach((route) => { | |
app.use('/' + route.slice(0,-3), require(routes_path + '/' + route) ); |
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) |