Skip to content

Instantly share code, notes, and snippets.

Avatar

Anders Evenrud andersevenrud

View GitHub Profile
@andersevenrud
andersevenrud / iframe.html
Created Jul 27, 2020
PoC to do bi-directional communiction between a parent and iframe document
View iframe.html
<html>
<body>
<img id="image" />
<script>
const image = document.getElementById('image')
const postMessage = (data) => {
top.postMessage(JSON.stringify(data), '*')
}
@andersevenrud
andersevenrud / index.js
Created Feb 25, 2020
OS.js Webcam application example (localhost or https only)
View index.js
//
// NOTE: THIS ONLY WORKS ON "localhost" OR A HOST WITH "https:"
//
import osjs from 'osjs';
import {name as applicationName} from './metadata.json';
const createVideoElement = () => {
const video = document.createElement('video');
video.style.width = '100%';
video.style.height = '100%';
@andersevenrud
andersevenrud / index.js
Last active Mar 16, 2020
OS.js x-frame-bypass iframe example
View index.js
/*
This is just a demonstration of how this browser hack could be used
to make a "browser".
NOTE: This just bypasses *some* of the ways a browser allows loading
content within an iframe. Most google services etc does not work as
expected, and might just crash or not load.
*/
import './index.scss';
@andersevenrud
andersevenrud / README.md
Last active Dec 24, 2019
Very basic OS.js Chat application
View README.md

Based on example from https://manual.os-js.org/v3/guide/framework/#react

Very basic chat application:

  • Uses a custom websocket server
  • Uses React to render UI
  • Uses event subscription model to handle websocket messages

THIS IS JUST FOR DEMONSTRATION PURPOSES

@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active Jul 7, 2019
True Color and Italics w/alacritty + tmux + vim
View alacritty-tmux-vim_truecolor.md

This should make true-color and italics work in your tmux session.

Tested successfully in bash and zsh with latest packages from Arch (with exception of Neovim from Git) 20019-07-07.

Notes

  1. Don't use &t_8f and &t_8b in your vim config
  2. Don't set $TERM in your zshrc, bashrc, etc. Let your terminal set this. So far xterm-256color has worked best for me.

Testing colors

@andersevenrud
andersevenrud / index.js
Last active Apr 1, 2019
Simple OS.js Application w/Server API
View index.js
//
// Just a standard OS.js application
//
// The "index.js" file.
//
import osjs from 'osjs';
import {name as applicationName} from './metadata.json';
const register = (core, args, options, metadata) => {
const proc = core.make('osjs/application', {args, options, metadata});
View index.js
import './index.scss';
import osjs from 'osjs';
import {name as applicationName} from './metadata.json';
import {h, app} from 'hyperapp';
import {Box, BoxContainer, Button, Toolbar, TextField, SelectField} from '@osjs/gui';
///////////////////////////////////////////////////////
// Custom GUI Elements
///////////////////////////////////////////////////////
@andersevenrud
andersevenrud / README.md
Created Feb 2, 2019
Adding custom icon to OS.js v3 package
View README.md

In your package

  1. Install webpack plugin to copy files npm install copy-webpack-plugin
  2. Place your icon.png in the directory
  3. Update webpack config -- see file below
  4. Update package metadata --- see file below
  5. Run npm run build

In your installation

View index.js
/*!
* OS.js - JavaScript Cloud/Web Desktop Platform
*
* Copyright (c) 2011-2019, Anders Evenrud <andersevenrud@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
You can’t perform that action at this time.