Skip to content

Instantly share code, notes, and snippets.

@Ntropish
Ntropish / index..js
Last active December 24, 2021 00:11
Remix with Socket.io Recipe
// This approach uses:
// - Remix's Express Adapter
// - An external Socket.io server on port 3050
// - http-proxy-middleware
//
// install http-proxy-middleware and apply these lines to `server/index.js`:
//
const { createProxyMiddleware } = require("http-proxy-middleware");
// Add the middleware before remix's catch-all '*' route
//=============================================================================
// Original
//=============================================================================
var scrKeys = Object.keys(source)
return collection.filter(obj => srcKeys.map(key => obj[key] === souce[key])
.map(key => obj[key] === souce[key]).
reduce((a, b) => a && b
)
)
/*
handlers: {
start(time) {},
stop(time) {},
schedule(from, to, currentTime) {}
}
context: AudioContext
*/
const createScheduler = handlers => context => {
let lastSchedule = context.currentTime
const express = require('express')
const bodyParser = require('body-parser')
const uuidv4 = require('uuid/v4')
const app = express()
const images = {}
// This is middleware that lets you get the post body in your endpoint handlers below
app.use(bodyParser.json())
var Core = artifacts.require('Core')
var Contract2 = artifacts.require('Contract2')
var Contract1 = artifacts.require('Contract1')
module.exports = async function (deployer) {
deployer.deploy(Contract2)
deployer.deploy(Core).then(function () {
deployer.deploy(Contract1, Core.address, 250)
})
}
subscription {
Game(filter: {
node: {
id: "cj5pmeixz2n8d0187a67a51jo"
}
}) {
mutation
updatedFields
node {
started
@Ntropish
Ntropish / drag.js
Created April 16, 2017 19:54
A drag directive for Vue
import handle from './handle'
document.handlers = handle(document)
export default {
bind(el, binding, {context: {_uid: id}}) {
el.handlers = handle(el)
el.handlers.mousedown = downHandler
// Namespaced handler
const mutations = {
SET_SELECTED(state, newSelectedThing) {
state.item = newSelectedThing
Vue.set(state, 'item', newSelectedThing)
},
UPDATE_SELECTED(state, {type, name, value}) {
if (!state.item) throw new Error(`No item selected while trying to update`)
if (!state.item[type]) throw new Error(`Missing property type: ${type}`)
// If no name given update the type, else update type.name
<html>
<head>
<!-- css, page title goes in here-->
</head>
<body>
<center>
<img id="sadface" src="http://balance3e.com/Images/sad.gif">
<br>
<button onclick="Changeimg(http://balance3e.com/Images/happy.gif);">Smile</button>
</center>
console.log('Seems correct!');