Skip to content

Instantly share code, notes, and snippets.

View llekn's full-sized avatar
🎯
Focusing

Camilo Flores llekn

🎯
Focusing
View GitHub Profile
@llekn
llekn / .eslintrc.json
Created March 24, 2017 03:01
ES5 compatible ESlint config file
{
"env": {
"es6": false,
"browser": true
},
"parserOptions": {
"ecmaVersion": 5
},
"plugins": [],
"globals": {
@llekn
llekn / server.rb
Created March 17, 2017 14:01
Websocket server using Eventmachine
require 'em-websocket'
EM.run do
EM::WebSocket.run(host: '0.0.0.0', port: 8080) do |ws|
ws.onopen do |handshake|
puts 'WebSocket connection open'
# Access properties on the EM::WebSocket::Handshake object, e.g.
# path, query_string, origin, headers
@llekn
llekn / server.rb
Last active March 17, 2017 14:02
Websocket server from scratch using TCPServer
# http://blog.honeybadger.io/building-a-simple-websockets-server-from-scratch-in-ruby/
require 'socket' # Provides TCPServer and TCPSocket classes
require 'digest/sha1'
server = TCPServer.new('localhost', 2345)
loop do
# Wait for a connection
@llekn
llekn / http-stdout-echo.py
Last active January 7, 2024 23:35
HTTP server that print what is requested to console. Useful for debugging purposes.
#!/usr/bin/env python3
'''Usage:
python3 http-stdout-echo.py -a <bind-address> -p <bind-port>
Examples:
python3 http-stdout-echo.py # (will listen at 127.0.0.1:8080 by default)
python3 http-stdout-echo.py -a 10.3.1.3 -p 5555'''
from http.server import HTTPServer, BaseHTTPRequestHandler
@llekn
llekn / for-each-dir.py
Last active August 29, 2015 14:20
Python script to execute a shell command on every sub-folder of current folder
#!/usr/bin/env python3
'''Receives a command as argument and executes it on
every sub-folder of current folder.
Useful for commands that should be run multiple times,
like doing a git fetch on a bunch of repos.
Usage: ./for-each-dir.py "command"
Example: ./for-each-dir.py "git fetch"
'''