Skip to content

Instantly share code, notes, and snippets.

View Godoy's full-sized avatar

Adriano Godoy Godoy

View GitHub Profile
@Godoy
Godoy / kcat.md
Last active September 14, 2023 17:07
Using kcat with jq to read a kafka topic message

Given a message like this:

{ "message": {"accountId":1,"timestamp":"1694709688878","amount":1001,"sentFromClientAt":1694709688913}, "delivered_at": 1694709688954 }

The kcat command can be used with jq to format message, even a calculated attribute:

kcat -C -b localhost:31090 -f '{ "message": %s, "delivered_at": %T } \n' -t input-topic -u | jq '. + { "took": "\(.delivered_at - .message.sentFromClientAt) ms" }'
@Godoy
Godoy / keybindings.json
Last active March 22, 2021 18:31
toggle terminal on vs code
[
{
"key": "ctrl+alt+t",
"command": "workbench.action.closePanel",
"when": "terminalFocus"
},
{
"key": "ctrl+alt+t",
"command": "workbench.action.toggleMaximizedPanel",
"when": "!terminalFocus"
@Godoy
Godoy / iterm.md
Last active February 23, 2023 17:22
ohmyzsh configurations and plugins
@Godoy
Godoy / spark.py
Created February 3, 2019 16:28
python function to transform spark dataframe to pandas using limit
def pshow(sparkDf, limit=10):
return sparkDf.limit(limit).toPandas()
### Keybase proof
I hereby claim:
* I am godoy on github.
* I am agodoy (https://keybase.io/agodoy) on keybase.
* I have a public key ASCHj9JiLOg-r_EGv-cMa4ShYioCiFoF3Pd8pcahky6v_go
To claim this, I am signing this object:
<script>
(function(t,r,a,c,k) { t[k]=t[k]||function(){ (t[k].q = t[k].q||[]).push(arguments) }
var ts=r.createElement(a);ts.type='text/javascript';ts.async=true;
ts.src=c; var s=r.getElementsByTagName(a)[0];s.parentNode.insertBefore(ts, s); })(window, document,
'script','//rawgit.com/Godoy/776586faf5389d2276aebc179801c0e7/raw/441601291b272a1b5bea191b54e13cce159d7dbf/my_async_plugin.js', 'my_track')
my_track('acessou página');
</script>
<a href="#" onclick="my_track('clicou no link');">Link</a>
@Godoy
Godoy / application.rb
Created September 29, 2016 19:57
ruby on rails - disable automatic generators
module MyAppRails
class Application < Rails::Application
# ...
config.generators.test_framework false
config.generators.javascripts false
config.generators.helper false
config.generators.stylesheets false
end
end
@Godoy
Godoy / image_magick_example.rb
Created July 25, 2016 20:20
Example with image magick - load font, background, caption
def image_generate
# composite compartilhar.png ab.png abc.png
# convert a.png b.png -append ab.png
# composite -font Raleway-Regular.ttf -size 380x200 -gravity east label:Joaquim abc.png abcd.png
file = Tempfile.new(['image1', '.png'])
file.binmode
fileAux = Tempfile.new(['image2', '.png'])
@Godoy
Godoy / main.js
Created May 5, 2016 16:46
jquery mask phone telefone 9 digitos
// https://github.com/igorescobar/jQuery-Mask-Plugin/tree/master/dist
$(function () {
$('.phone').mask(PhoneMaskBehavior, spOptions);
});
var PhoneMaskBehavior = function (val) {
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
},
spOptions = {
onKeyPress: function (val, e, field, options) {
(function () {
// Pop the call queue...
q = window['my_function'].q;
while(a = q.pop()){
my_real_function(a);
}
//copy the complete function under old that was stacking queue
my_function = my_real_function;
})();