Skip to content

Instantly share code, notes, and snippets.

View justindarc's full-sized avatar

Justin D'Arcangelo justindarc

View GitHub Profile
@justindarc
justindarc / AppDelegate.swift
Created April 30, 2020 22:22
UIViewController on a second screen
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let secondStoryboard = UIStoryboard(name: "SecondScreen", bundle: nil)
let secondScreenVC = secondStoryboard.instantiateInitialViewController() as! SecondScreenViewController
secondScreenVC.loadViewIfNeeded()
@justindarc
justindarc / timestamp.sh
Created March 28, 2018 02:49
zsh/bash timestamp
timestamp () {
date -r $(echo "$1" | cut -c "1-10")
}
@justindarc
justindarc / Introducing FlyWeb.md
Created October 21, 2016 19:27
Introducing FlyWeb

Introducing FlyWeb

For the past several months, a small team at Mozilla has been working on an experimental new Web API and an accompanying browser feature called FlyWeb.

What does it do?

In short, FlyWeb provides an API for web pages to host local web servers for exposing content and services to nearby browsers. It also adds the ability to discover and connect to nearby local web servers to the web browser itself. This feature allows users to find and connect to nearby devices with embedded web servers such as printers, thermostats and televisions as well as local web servers hosted in web pages via the FlyWeb API.

Enabling web pages to host local servers and providing the ability for the web browser to discover nearby servers opens up a whole new range of use cases for web apps. With FlyWeb, we can finally reach a level of richness in cross-device interactions previously only attainable via native apps. In addition, the built-in service discovery feature in the browser offers device makers and hob

@justindarc
justindarc / txt2cdefine
Last active September 1, 2016 18:01
txt2cdefine: Encode multiline text files into C/C++ #define directives
#!/usr/bin/env node
/**
* txt2cdefine: Encode multiline text files into C/C++ #define directives
* https://gist.github.com/justindarc/efee6d3d09341618da5af6a58dfd7b69
*
* Node.js-based command-line utility for encoding HTML, JS, CSS and other
* text files into C/C++ #define directives. Useful for embedded hardware
* applications such as Arduino or ESP8266 where no file system is available
* for reading external files. The resulting output can saved as a ".h"
@justindarc
justindarc / hello-flyweb.js
Created March 29, 2016 19:45
hello-flyweb.js
navigator.publishServer('HelloFlyWeb').then((srv) => {
(window.srv = srv).onfetch = (evt) => {
evt.respondWith(new Response('<h1>Hello FlyWeb!!!</h1>', {
headers: { 'Content-Type': 'text/html' }
}));
};
});
@justindarc
justindarc / esp8266-ap-flyweb-temperature-server.ino
Created March 17, 2016 19:39
esp8266-ap-flyweb-temperature-server
// Install ESP8266 Board v2.1.0 by adding this
// to the "Additional Board Manager URLs" in
// "Preferences..." and then select it for
// installation via "Boards Manager..." under
// the "Tools" -> "Board: XXX" menu.
// http://arduino.esp8266.com/stable/package_esp8266com_index.json
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
@justindarc
justindarc / index.js
Created February 23, 2016 20:02
node-mdns-http-test
var http = require('http');
var mdns = require('mdns');
const HTTP_PORT = 8000;
var server = http.createServer(function(request, response) {
response.end('Hello world!');
});
server.listen(HTTP_PORT);
@justindarc
justindarc / .userconfig
Created April 20, 2015 19:02
B2G .userconfig
export B2G_DIR=${B2G_DIR:-$(cd $(dirname $0); pwd)}
# Uncomment for debugging
# export B2G_DEBUG=1
# b2g-inbound
# export GECKO_PATH=${B2G_DIR}/b2g-inbound
# export GECKO_OBJDIR=${B2G_DIR}/objdir-b2g-inbound
# mozilla-central
@justindarc
justindarc / enable_developer_mode.sh
Last active August 29, 2015 14:19
enable_developer_mode.sh
#!/bin/sh
adb shell "stop b2g"
adb shell "cd /data/b2g/mozilla/*.default/;echo 'user_pref(\"dom.apps.developer_mode\", true);' >> prefs.js;"
adb shell "cd /data/b2g/mozilla/*.default/;echo 'user_pref(\"network.disable.ipc.security\", true);' >> prefs.js;"
adb shell "start b2g"
@justindarc
justindarc / enable_wifi_direct.sh
Last active September 4, 2018 20:08
enable_wifi_direct.sh
#!/bin/sh
adb shell "mount -o rw,remount /system"
adb shell "stop b2g"
adb shell "echo \"ro.moz.wifi.p2p_supported=1\" >> /system/build.prop"
adb shell "mount -o ro,remount /system"
adb reboot