Skip to content

Instantly share code, notes, and snippets.

View OJezu's full-sized avatar

Christopher Chrapka OJezu

View GitHub Profile
@OJezu
OJezu / dump-users.sh
Created June 4, 2020 12:25
Dump all users and priviledges on MySQL server
#!/bin/sh
mysql "$@" -AN <<'SQL'
SELECT CONCAT('CREATE USER ', QUOTE(user), '@', QUOTE(host), ' IDENTIFIED WITH ', QUOTE(plugin), ' AS ', QUOTE(authentication_string), ';')
FROM mysql.user WHERE user<>'' AND host<>''
ORDER BY user, host
;
SQL
@OJezu
OJezu / minimal-reproduction.js
Created December 17, 2019 10:44
Azure/azure-sdk-for-js#6577 cannot copy zero-length files
const {BlobServiceClient, generateBlobSASQueryParameters} = require("@azure/storage-blob");
require("dotenv").config();
const connectionString = process.env.AZURE_TEST_CONNECTION_STRING;
const containerName = process.env.AZURE_TEST_CONTAINER;
// MAGIC VALUE, empty buffer causes errors/timeouts, non-empty buffer is copied
const content = Buffer.from('');
async function getSignedUrl(blobClient){
@OJezu
OJezu / main.ts
Created October 25, 2019 14:28
Nest.js logger not available by default
import {Injectable, Logger, Module} from '@nestjs/common';
import {NestFactory} from '@nestjs/core';
import {NestExpressApplication} from '@nestjs/platform-express';
@Injectable()
class TestService {
constructor(private readonly logger: Logger){
this.logger.log("UP");
}
}
@OJezu
OJezu / BUT_WAIT_THERE_IS_MORE.php
Last active October 25, 2018 10:21
PHP IS SOOO GREAT
function getPDO(): \PDO
{
return new \PDO("mysql:dbname=solidsnake_dev;host=db", "solidsnake_dev", "solidsnake_dev", [
PDO::ATTR_PERSISTENT => true,
]);
}
$pdo = getPDO();
$pdo->exec('CREATE TEMPORARY TABLE temp_test (id INT NOT NULL PRIMARY KEY)');
In Validate.php line 105:
[InvalidArgumentException]
'connectionString' can't be NULL or empty.
Exception trace:
MicrosoftAzure\Storage\Common\Internal\Validate::notNullOrEmpty() at /vendor/microsoft/azure-storage/src/Common/Internal/ConnectionStringParser.php:78
MicrosoftAzure\Storage\Common\Internal\ConnectionStringParser::parseConnectionString() at /vendor/microsoft/azure-storage/src/Common/Internal/ServiceSettings.php:86
MicrosoftAzure\Storage\Common\Internal\ServiceSettings::parseAndValidateKeys() at /vendor/microsoft/azure-storage/src/Common/Internal/StorageServiceSettings.php:365
$ steam
Running Steam on debian 9 64-bit
STEAM_RUNTIME is enabled automatically
Pins up-to-date!
[2017-09-08 20:27:01] Startup - updater built Sep 6 2017 20:37:15
Looks like steam didn't shutdown cleanly, scheduling immediate update check
[2017-09-08 20:27:01] Checking for update on startup
[2017-09-08 20:27:01] Checking for available updates...
[2017-09-08 20:27:02] Download skipped: /client/steam_client_ubuntu12 version 1504757234, installed version 1504757234
[2017-09-08 20:27:02] Nothing to do
rm: cannot remove '/home/krzysztofchrapka/.steam/steam': Is a directory
rm: cannot remove '/home/krzysztofchrapka/.steam/bin': Is a directory
Installing breakpad exception handler for appid(steam)/version(1504757234)
Installing breakpad exception handler for appid(steam)/version(1504757234)
Gtk-Message: Failed to load module "gail"
Gtk-Message: Failed to load module "atk-bridge"
(steam:4604): Gtk-WARNING **: Unable to locate theme engine in module_path: "adwaita",
/usr/share/themes/Adwaita/gtk-2.0/main.rc:733: error: unexpected identifier `direction', expected character `}'
<?php
namespace OJezu\FormatResponseBundle\Annotation\Controller;
/**
* @Annotation
*/
class FormatResponse
{
# delete remote merged branches
git branch -r --merged | grep origin | grep -v '>' | grep "^ origin/\(hotfix\|feature\|bugfix\)" | xargs -L1 | cut -d"/" -f 2- | xargs -r git push origin --delete
# delete local merged branches
git branch --merged | grep "^ \(hotfix\|feature\|bugfix\)" | xargs -L1 | xargs -r git branch -d
@OJezu
OJezu / gist:ac68284ff5191e9df365
Last active September 26, 2015 18:56
Clean up some php code in repository
#convert leading 4-spaces to tabs
for i in $(seq 15); do
find . -! -path "*/.git/*" -! -path "*/bower_components/*" -type f -! -path "./img/*" -! -path "./_log/*" -! -path "./download/*" -! -path "./fonts/*" -exec sed -i "s/^\(\( \)*\)\( \)/\1\t/" \{\} \;
done
#remove trailing whitespace
find . -! -path "*/.git/*" -! -path "*/bower_components/*" -type f -! -path "./img/*" -! -path "./_log/*" -! -path "./download/*" -! -path "./fonts/*" -exec \
sed -i "s/\(\t\| \)\+\$//" \{\} \;
#remove multiple empty lines