Skip to content

Instantly share code, notes, and snippets.

View andersevenrud's full-sized avatar
🤘
w^w^^w^w

Anders Evenrud andersevenrud

🤘
w^w^^w^w
View GitHub Profile
@andersevenrud
andersevenrud / index.js
Created September 12, 2020 20:41
Parse fstab
/**
* Parse fstab from either string (from file) or an array of lines
* @author Anders Evenrud <andersevenrud@gmail.com>
* @license MIT
*/
const parse = input => (input instanceof Array ? input : input.split('\n'))
.map(line => line.replace(/\s+/g, ' ').replace(/(\s+)?,(\s+)?/g, ',').trim())
.filter(line => line.length > 0 && line.substring(0) !== '#')
.map(line => line.split(/\s/g))
.map(([dev, dir, type, options, dump, fsck]) => ({
@andersevenrud
andersevenrud / iframe.html
Created July 27, 2020 22:31
PoC to do bi-directional communiction between a parent and iframe document
<html>
<body>
<img id="image" />
<script>
const image = document.getElementById('image')
const postMessage = (data) => {
top.postMessage(JSON.stringify(data), '*')
}
@andersevenrud
andersevenrud / index.js
Created February 25, 2020 19:42
OS.js Webcam application example (localhost or https only)
//
// 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 July 24, 2021 06:07
OS.js x-frame-bypass iframe example
/*
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 December 24, 2019 23:42
Very basic OS.js Chat application

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 April 26, 2024 00:57
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
@andersevenrud
andersevenrud / index.js
Last active April 1, 2019 19:41
Simple OS.js Application w/Server API
//
// 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});
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 February 2, 2019 18:56
Adding custom icon to OS.js v3 package

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

@andersevenrud
andersevenrud / README.md
Created January 29, 2019 21:40
DanialdNishazmi Example

Screenshot