Skip to content

Instantly share code, notes, and snippets.

View disalvo's full-sized avatar

Alexandre Di Salvo disalvo

View GitHub Profile
@disalvo
disalvo / delete-by-query-esapi.go
Created April 22, 2021 14:22
Golang delete (DeleteByQuery) docs on ElasticSearch using go-elasticsearch
func initElasticsearch() (*elasticsearch.Client, error) {
connectionString := fmt.Sprintf("%s:%s", "server-url", "server-port")
cfg := elasticsearch.Config{
Addresses: []string{connectionString},
Username: "username",
Password: "password",
}
es, err := elasticsearch.NewClient(cfg)
I fixed my problem with accents using PHPStorm. That is the solution which worked for me.
I'm using ElementaryOS, but the problem occours in Ubuntu too.
- Find phpstorm.sh
$> find -name phpstorm.sh
- Edit the most recent phpstorm.sh version
@disalvo
disalvo / PostMessageToSlackChannel.php
Created August 31, 2018 11:33 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar
@disalvo
disalvo / slack.php
Created August 31, 2018 11:31 — forked from stefanzweifel/slack.php
Slack.com Webhook Integration (PHP) - Simple snippet which tells you, how to build your payload array.
<?php
//Options
$token = 'YOUR_TOKEN_HERE';
$domain = 'YOUR_SLACK_DOMAIN_GOES_HERE';
$channel = '#general';
$bot_name = 'Webhook';
$icon = ':alien:';
$message = 'Your message';
jQuery.each($('input, select'), function() {
if($(this).prop('required')) {
$('label[for="'+$(this).attr('id')+'"]').after('<span style="color:red">*</span>');
}
});
@disalvo
disalvo / aes_enc_dec.php
Created December 21, 2015 17:10 — forked from turret-io/aes_enc_dec.php
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well