Skip to content

Instantly share code, notes, and snippets.

View borkor's full-sized avatar

Borko Rastović borkor

  • Infostud 3 d.o.o.
  • Subotica, Serbia
View GitHub Profile
@eoli3n
eoli3n / encryption.php
Last active April 1, 2024 20:08
Encrypt - Decrypt AES from/to Python PyCryptodome from/to PHP openssl
<?php
// use to generate key : 'openssl rand -hex 32'
function my_encrypt($data, $passphrase) {
$secret_key = hex2bin($passphrase);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$encrypted_64 = openssl_encrypt($data, 'aes-256-cbc', $secret_key, 0, $iv);
$iv_64 = base64_encode($iv);
$json = new stdClass();
$json->iv = $iv_64;
@psviderski
psviderski / settings.py
Created June 25, 2018 13:52
Python structlog with Sentry and Logstash integration
# This list contains all the attributes listed in
# http://docs.python.org/library/logging.html#logrecord-attributes
LOG_RECORD_ATTRIBUTES = {
'args', 'asctime', 'created', 'exc_info', 'exc_text', 'filename',
'funcName', 'levelname', 'levelno', 'lineno', 'message', 'module',
'msecs', 'msg', 'name', 'pathname', 'process', 'processName',
'relativeCreated', 'stack_info', 'thread', 'threadName',
}
BASIC_TYPES = (str, bool, int, float, type(None))
@kandadaboggu
kandadaboggu / HistoryWrapper.js
Last active March 1, 2018 11:02
The `History.js` triggers `statechange` event for `pushState` and `replaceState` API calls. There is no way to distinguish between Back button events and API generated events. The dev branch of the library has fixed this issue. I wanted a simple fix until the fix is public. This is my attempt.
if (History && History.enabled) {
// START OF WRAPPER SECTION
var HistoryWrapper = {
apiEventInProgress: false,
isBrowserEvent: function () {
return !this.apiEventInProgress;
},