Skip to content

Instantly share code, notes, and snippets.

View hpneo's full-sized avatar

Gustavo Leon hpneo

View GitHub Profile
import parser from 'uri-template';
function buildURL(url, data) {
const uriTemplate = parser.parse(url);
return uriTemplate.expand(data);
}
function immutableFetchHypermediaRecursive(root, paths = [], data = {}) {
return fetch(root).then((partResponse) => {
@hpneo
hpneo / test.js
Last active June 7, 2017 20:00
Load terminal in background
window.addEventListener('codebasket:ready', function() {
var terminal = _.find(codeBasket.items, function(item) { return item.type === 'terminal' }),
currentConsole = CodePicnic.consoles["flask-id-example"];
terminal.location = currentConsole.console.terminalUrl + '?token=' + currentConsole.console.terminalToken;
terminal.tabPage.refs.frame.addEventListener('load', function() {
codeBasket.send('ls -la');
codeBasket.on('pty:data', function(message) {
console.log(ansi_up.ansi_to_text(message.data));
});
@hpneo
hpneo / app.rb
Last active March 17, 2017 01:59
Back-end
post '/lessons/:id/test' do
content_type :json
session_id = "console_lesson_#{params[:id].gsub(/-/, '_')}".to_sym
@token = CodePicnic.token
@console = CodePicnic::Console.new(container_name: session[session_id])
logger.info @console.container_name
input_file = Tempfile.new('input.js')
input_file.write(params[:input])
@hpneo
hpneo / ui.js
Last active February 11, 2017 18:09
CodeBite's addLibrary
function addLibrary(newConsole, library) {
newConsole.libraries.push(library);
var libs = newConsole.bites[0].preTag.dataset['libs'] || '';
libs = libs.split(';');
if (libs.length === 1 && libs[0] === '') {
libs.length = 0;
}
@hpneo
hpneo / ui.js
Last active February 11, 2017 18:09
CodeBite's buildUI
function buildUI(newConsole) {
var fragment = document.createDocumentFragment(),
fragmentRoot = document.createElement('section');
fragmentRoot.className = 'bite-container';
fragmentRoot.id = 'bite-container-' + newConsole.name;
var fragmentRootHTML = '';
fragmentRootHTML += '<aside class="bite-container-sidebar-container">';
@hpneo
hpneo / commandSender.js
Created June 19, 2016 20:25
Old CodeBite
var ansi = require('ansi_up'),
framebus = require('framebus'),
prompts = require('./constants').prompts,
ansiToText = ansi.ansi_to_text,
newLinePrompts = require('./constants').newLinePrompts;
function sendCommandBatch(batch) {
this.commands = batch;
this.sendCommandInput(this.commands.shift());
}
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@hpneo
hpneo / gist:81ebcbef943d782c2f5fddfa83ff8b13
Created June 15, 2016 03:16
Notes from Boston Amazon Web Services Meetup (June): AWS Security and Visibility with VPC Flow Logs and Amazon Inspector
Bo Bayles
[email protected]
observable.net
github.com/obsrvbl
https://observable.net/company/resources/aws-meetup-boston-2016-slides/
no encryption: dpi is possible
encryption: dpi is impossible
dpi: deep packet inspection
@hpneo
hpneo / gist:e75b37788869b7279a2685cbbf55b423
Created June 9, 2016 01:32
Notes from Boston CSS Meetup (June): HTML Secrets: HTML can do whaaaat?!
caniuse.com
github.com/search?q=feature+polyfill -> sort by stars
<a download="foo.js">
<a href="application/octet-stream,alert('foo')">
<input type="file" multiple accept="image/png"> -> HTML 4
<input type="file" multiple accept="image/*"> -> HTML 5
<input type="file" multiple accept=".png, .jpg, .gif"> -> HTML 5
{
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/mocha",
"build:css": "node_modules/.bin/node-sass app/assets/sass/index.scss public/css/index.css",
"watch:css": "node_modules/.bin/nodemon -e scss -x \"npm run build:css\"",
"build:js": "browserify app/assets/javascripts/index.js -t babelify -o public/js/index.js --debug --verbose",
"watch:js": "watchify app/assets/javascripts/index.js -t babelify -o public/js/index.js --debug --verbose",
"start": "node_modules/.bin/parallelshell \"npm run watch:js\" \"npm run watch:css\" \"node_modules/.bin/nodemon index.js\""
},