Skip to content

Instantly share code, notes, and snippets.

View nicopace's full-sized avatar

Nicolás Pace nicopace

View GitHub Profile
@nicopace
nicopace / ubuslisten.html
Created April 25, 2019 13:47
Server-sent events for openwrt on pure lua
<html>
<!-- this one goes in /www/ubuslisten.html -->
<meta charset="UTF-8">
<body></body>
<script>
var source = new EventSource("/cgi-bin/ubuslisten.lua");
source.addEventListener('message', function(e) {
console.log(e.data);
}, false);
@nicopace
nicopace / upload.php
Created December 10, 2018 13:38
Simple php file uploader
<?PHP
if(!empty($_FILES['uploaded_file']))
{
$path = "uploads/";
$path = $path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['uploaded_file']['name']).
" has been uploaded";
} else{
@nicopace
nicopace / publisher.lua
Created July 9, 2017 07:46
Pub/Sub messaging over ubus with Lua
#!/usr/bin/env lua
require "ubus"
require "uloop"
uloop.init()
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubus")
@nicopace
nicopace / limit.js
Created January 27, 2016 16:54 — forked from PatrickJS/limit.js
PubNub Rate Limiting vs. Throttling Messages in AngularJS http://stackoverflow.com/questions/18364918/throttling-pubnub-requests-in-angluarjs
//
// Listen for messages and process all messages at steady rate limit.
//
pubnub.subscribe({
channel : "hello_world",
message : limit( function(message) {
// process your messages at set interval here.
}, 500 /* milliseconds */ )
modprobe v4l2loopback video_nr=3
gst-launch-1.0 -v ximagesrc startx=1 starty=1 endx=320 endy=240 ! videoconvert ! "video/x-raw,format=YUY2" ! tee ! v4l2sink device=/dev/video3
# you can also use gst-launch to select a window https://superuser.com/questions/709866/ffmpeg-x11grab-a-single-window
<script>
window.erxesSettings = {
messenger: {
brand_id: "st3FrK",
},
};
(function() {
var script = document.createElement('script');
@nicopace
nicopace / gist:21e33fb89f217023f827b1ebd25b122e
Last active March 16, 2020 13:45
WebRTC P2P apps without centralized servers
1. Use local app server and mdns/bonjour/zeroconf to announce it for signalling
2. use webrtc for p2p udp communications
https://github.com/bykof/cordova-plugin-webserver
https://github.com/floatinghotpot/cordova-httpd
https://github.com/becvert/cordova-plugin-zeroconf
https://github.com/cjb/serverless-webrtc
Uses:
* use pouchdb to sync dbs p2p for coordination
@nicopace
nicopace / gist:945cb03f3868c8b249b8b0e446d049cc
Created February 24, 2020 03:01
Run raspberry pi on qemu emulation
qemu-system-arm -kernel ~/Downloads/kernel-qemu-4.19.50-buster -cpu arm1136-r2 -M versatilepb -dtb ~/Downloads/versatile-pb.dtb -no-reboot -append "root=/dev/sda2 panic=1" -drive format=raw,file=2020-02-23-wiki-lite-qemu.img -nographic
<html>
<body>
<script src="https://togetherjs.com/togetherjs-min.js"></script>
<button onclick="TogetherJS(this); return false;">Start TogetherJS</button>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('browsingSession').href = 'https://tmate.io/t/' + window.location.hash.substring(1);
});
</script>
@nicopace
nicopace / _workflows.md
Last active February 8, 2019 23:01
Workflows

This document will discribe a set of worklows I am implementing.