Skip to content

Instantly share code, notes, and snippets.

View bernardoamc's full-sized avatar

Bernardo de Araujo bernardoamc

View GitHub Profile
# if you have a directory of files that look like:
# 2015-03-21 11.23.39.jpg
# 2015-04-15 09.55.20.jpg
# 2015-03-21 11.23.42.jpg
# 2015-05-12 13.14.59.png
#
# this Rakefile will move all the files into subdirectories for year/month
task :default do |task|
file_list = FileList['*.jpg', '*.png']
@bernardoamc
bernardoamc / chat.rb
Created April 19, 2016 14:26 — forked from HoneyryderChuck/chat.rb
Simple Chat Application, proof of concept for hybrid of thread-server http with evented-server SSE.
# chat.rb
require 'sinatra/base'
# this also loads celluloid io, let's keep that in mind
require 'celluloid/current'
require 'reel'
# The chat server, an IO Event Loop held by the actor
# Collects connections (Reel Event Streams)
#
# Contrary to EventMachine, there is no event callback for
@bernardoamc
bernardoamc / gist:a47699201eb7bb02b21cbfa4fbebd1c2
Created May 19, 2016 04:29 — forked from tonymtz/gist:714e73ccb79e21c4fc9c
Uninstall XQuartz.app from OSX Yosemite
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
# Log out and log in
@bernardoamc
bernardoamc / my_app.ex
Created June 9, 2016 11:07 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@bernardoamc
bernardoamc / watcher.sh
Created July 1, 2016 14:46 — forked from josevalim/watcher.sh
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | MIX_ENV=test mix do test --stale, run --no-halt -e "IO.gets(:stdio, ''); IO.puts 'Restarting...'; :init.restart()"
@bernardoamc
bernardoamc / phoenix_preact_polaris.md
Created November 7, 2017 03:46 — forked from joshnuss/Phoenix-Preact-Polaris.md
Setup a Phoenix Server with Preact & Polaris

HOWTO: Configure Phoenix with Preact & Polaris

  1. Create a Phoenix app
# create the app
mix phx.new my_app --no-ecto --module MyApp --app my_app

# go to my_app
@bernardoamc
bernardoamc / blog_link.rb
Created November 8, 2017 20:28
Custom delegation
@bernardoamc
bernardoamc / one-liners.md
Created January 17, 2018 19:30 — forked from KL-7/one-liners.md
Ruby one-liners

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123

bar

@bernardoamc
bernardoamc / xml-attacks.md
Created July 11, 2018 03:00 — forked from mgeeky/xml-attacks.md
XML Vulnerabilities and Attacks cheatsheet

XML Vulnerabilities

XML processing modules may be not secure against maliciously constructed data. An attacker could abuse XML features to carry out denial of service attacks, access logical files, generate network connections to other machines, or circumvent firewalls.

The penetration tester running XML tests against application will have to determine which XML parser is in use, and then to what kinds of below listed attacks that parser will be vulnerable.


@bernardoamc
bernardoamc / EchoServer.py
Created October 24, 2018 15:30 — forked from limingzju/EchoServer.py
A simple Python echo server, show how to write socket program use python.
# Echo server program
import socket
HOST = '' # Symbolic name meaning all available interfaces
PORT = 50007 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()