Skip to content

Instantly share code, notes, and snippets.

View ivanwitzke's full-sized avatar
🙂
Let's write some code...

Anderson Ivan Witzke ivanwitzke

🙂
Let's write some code...
  • Paraná - Brazil
  • 21:50 (UTC -03:00)
View GitHub Profile
var Q = require('q');
var fs = require('fs');
var moment = require('moment');
var GoogleAuth = require('google-auth-library');
var google = require('googleapis');
var ConfigModel = require('../../app/config/model');
var _self;
const SCOPES = [
@ivanwitzke
ivanwitzke / random_uuid_generator.php
Created November 14, 2018 10:24
Generates a random unique string (like UUID)
<?php
/*
This function does not follow the RFC
https://tools.ietf.org/html/rfc4122
but creates a random pseudo-unique string
*/
function generateUUID() {
$str = md5(uniqid(rand(), true));
return sprintf(
'%08s-%04s-%04s-%04s-%12s',
@ivanwitzke
ivanwitzke / generate_keystore.txt
Created November 30, 2018 04:07
Generate Android keystore
keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias
@ivanwitzke
ivanwitzke / imagine_resize_fit.php
Created July 22, 2020 14:35
Uses Imagine with Imagick to resize an image so that it fits inside the new width and/or height, leaving a white border on the smallest side
<?php
require_once __DIR__ . '/../vendor/autoload.php';
// https://serverpilot.io/docs/how-to-install-the-php-imagemagick-extension/
use Imagine\Image\Box;
use Imagine\Image\Point;
use Imagine\Imagick\Imagine;
const OUTPUT_WIDTH = 1000;
@ivanwitzke
ivanwitzke / laravel_invalid_signature_fix.md
Last active August 5, 2020 17:05
Laravel signed routes invalid signature fix on reverse proxy

Enable Apache's mod_headers:

# a2enmod headers;

add to vhost file:

RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"

On TrustProxies Middleware, set $proxies = '*'; (or IP - can be array of IPs also)

@ivanwitzke
ivanwitzke / loading_watcher.js
Last active February 1, 2021 19:41
Simple JS Loading with watcher
const loading = {
get status() {
return this.value
},
set status(value) {
const old = this.value;
this.value = value;
(this.watchers || []).forEach(handler => {
handler(value, old);
});
@ivanwitzke
ivanwitzke / postgres_queries_and_commands.sql
Created October 17, 2024 11:31 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'