Skip to content

Instantly share code, notes, and snippets.

View wearethefoos's full-sized avatar

Wouter de Vos wearethefoos

View GitHub Profile
@wearethefoos
wearethefoos / chatgpt.md
Created September 26, 2024 07:32
Rust Reverse Proxy WebSocket

Sure! Below is a Rust program that acts as a reverse proxy in front of a website, supports WebSockets, and serves static files. We'll use the warp framework, which is a powerful and easy-to-use web framework for Rust.


Step 1: Create a New Rust Project

First, create a new Rust project:

cargo new reverse_proxy
@wearethefoos
wearethefoos / light-festival.ino
Last active November 5, 2022 19:10
Light Festival Demo Code
const byte rgb_8_r = 13;
const byte rgb_8_b = 15;
const byte rgb_8_g = 2;
const byte rgb_7_r = 0;
const byte rgb_7_b = 4;
const byte rgb_7_g = 16;
const byte rgb_6_r = 17;
const byte rgb_6_b = 5;
const byte rgb_6_g = 18;
const byte rgb_5_r = 23;
@wearethefoos
wearethefoos / rewrite-host-lambda.js
Created April 15, 2019 11:32
Lambda function to force a specific Host header to be sent to the origin
'use strict';
// force a specific Host header to be sent to the origin
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
request.headers.host[0].value = 'jobs.mycompany.com';
return callback(null, request);
};
@wearethefoos
wearethefoos / syntax.md
Created November 4, 2016 11:24
Ruby vs JS vs ES6

Variables

Ruby

Name a value.

color = "red"
#!/usr/bin/env ruby
require 'net/http'
require 'json'
class Search
TOPICS = ["Day 1 - Frontend", "Day 2 - Basic Programming", "Day 3 - Loops & Breaks", "Day 4 - OOP", "Day 5 - Intro to Web with Sinatra & Git", "Day 6 - Intro to Ruby on Rails", "Day 7 - Hackathon I", "Day 08 - Rails, Deployment, Pull requests, Code review", "Day 09 - ActiveRecord", "Day 10 - Rails Testing with RSpec", "Day 11 - Users with Devise & Authorization with CanCan(Can)", "Day 12 - File uploads with Carrierwave", "Day 13 - Javascript 1", "Day 14 - SQL and Relations", "Day 15 - Javascript 2 & JQuery", "Day 16 - AJAX & REST", "Day 17 - Integration testing", "Day 18", "Day 19", "Day 20", "Day 21", "Day 22", "Day 23 - Javascript 3", "Day 24 - React 1", "Day 25 - React 2", "Day 26 - React 3", "Day 27 - Testing with Enzyme", "Day 28. FeathersJS", "Advanced Session :: Introduction to d3", "Advanced Session :: Introduction to Docker", "Advanced Session :: Redux", "Advanced Session :: Styling with Sass", "Codaisseur Cloud", "Git & Github",
# Description
# Translate erb (html) into a slim version
#
# Commands
# learnbot erb2slim <your code here>
#
# Authors:
# Aeshta and Rosiene
module.exports = (robot) ->
require 'rails_helper'
describe BingeSerie do
it { should validate_presence_of :title}
it { should validate_presence_of :description}
it { should validate_presence_of :image}
it { should have_many :binge_episodes}
describe "#seasons" do
let(:series) { create(:binge_serie) }
import SocketClient from 'socket.io-client';
import Feathers from 'feathers-client';
import Utils from '../lib/Utils';
const API_HOST = "http://localhost:3030";
class BaseModel {
defaults() { return {}; }
constructor(resource_name, host = API_HOST) {
class Utils {
uuid() {
var i, random;
var uuid = '';
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += '-';
}
const feathers = require('feathers');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
// const errors = require('feathers-errors');
const bodyParser = require('body-parser');
var MongoClient = require('mongodb').MongoClient;
const service = require('feathers-mongodb');
// Create a feathers instance.
const app = feathers()