Skip to content

Instantly share code, notes, and snippets.

View cirocosta's full-sized avatar

Ciro S. Costa cirocosta

View GitHub Profile
@cirocosta
cirocosta / hash-table.c
Last active January 31, 2024 14:02
glibc hash table example
/**
* Compile with -D_GNU_SOURCE
* Note: we're using static keys here and we don't plan to add
* new items to the table. In such case using a perfect
* hash generator (e.g, gperf) would clearly outperform
* this simple example w/ the cost of first running gperf
* (and other tradeoff that must be considered)
*
* Note: it's up to you to manage those resources contained in
* the hash table. Also, hsearch does NOT provide a
@cirocosta
cirocosta / iframe.html
Last active January 6, 2024 23:02
Sending messages from child iframe to parent webpage
<!DOCTYPE html>
<html>
<head>
<title>My Iframe</title>
</head>
<body>
<button>Botão</button>
<script type="text/javascript">
@cirocosta
cirocosta / ela.py
Created July 6, 2015 03:47
Error Level Analysis in Python
#!/usr/bin/python
from __future__ import print_function
from PIL import Image, ImageChops, ImageEnhance
import sys, os
import threading
import argparse
parser = argparse.ArgumentParser(description="""
Performs Error Level Analysis over a directory of images
@cirocosta
cirocosta / stress-test.sh
Created July 9, 2015 18:58
naive http server stress tester using cURL
#!/bin/bash
#### Default Configuration
CONCURRENCY=4
REQUESTS=100
ADDRESS="http://localhost:8080/"
show_help() {
cat << EOF
@cirocosta
cirocosta / get-image-config.sh
Created November 26, 2017 12:30
Retrieves the configuration of images pushed to Docker registries - see https://ops.tips/blog/inspecting-docker-image-without-pull/ for more information
#!/bin/bash
# Retrieves image configuration using
# private registries without authentication
set -o errexit
# Address of the registry that we'll be
# performing the inspections against.
# This is necessary as the arguments we
---
apiVersion: v1
kind: Namespace
metadata:
name: git-serve-controller
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: git-serve-controller
@cirocosta
cirocosta / containerd-prune
Created January 30, 2020 13:09
prune containerd stuff
#!/bin/bash
set -o errexit
set -o xtrace
main() {
local namespaces=$(list_namespaces)
for namespace in $namespaces; do
local tasks=$(list_tasks $namespace)
@cirocosta
cirocosta / MANUSEANDO-ARQUIVOS.md
Last active July 22, 2022 19:57
Manuseando Arquivos com Nodejs

Manuseando arquivos com compabilidade entre SOs

Criar Pastas

Para criação de pastas o mais conveniente (unix) é utilizar mkdir -p, o qual:

-p, --parents no error if existing, make parent directories as needed

tem-se então o semelhante como módulo de node, o mkdirp.

#!/bin/bash
set -o errexit
# Address of the registry that we'll be
# performing the inspections against.
# This is necessary as the arguments we
# supply to the API calls don't include
# such address (the address is used in the
# url itself).
@cirocosta
cirocosta / status.lua
Last active January 8, 2022 17:23
Returns a 200OK as a status check (haproxy)
status = {}
status.version = "0.0.1"
status.startup = function()
core.Info("[status] status script v" .. status.version);
end
status.run = function(applet)
local response = "200 OK"