Skip to content

Instantly share code, notes, and snippets.

View Flatroy's full-sized avatar

George Daneke Flatroy

View GitHub Profile
@Flatroy
Flatroy / gist:160a8d77fc0affbff9936833524665b2
Last active February 14, 2024 14:46
A/B Tests with GTM (Google Tag Manager) and events to Google Analytics (GA)
// based on https://thenextweb.com/news/marketing-the-tnw-way-9-ab-testing-with-google-tag-manager
function createCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
}
class LineChart {
// LineChart by https://kevinkub.de/
constructor(width, height, values) {
this.ctx = new DrawContext();
this.ctx.size = new Size(width, height);
this.values = values;
}
_calculatePath() {
@Flatroy
Flatroy / Subscription.php
Created January 20, 2022 21:02 — forked from Shelob9/Subscription.php
Laravel Spark with Laravel Nova
<?php
namespace App\Nova;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

@Flatroy
Flatroy / README.md
Created July 27, 2021 09:02
Database Dumper

Database Dumper

  1. Copying files dumper.php and config.yaml.

  2. Seting up config.yaml

  3. Setting up cron. For example:

    0 4 * * * cd /var/www/backups && /usr/local/bin/php dumper.php config.yaml

  4. Or manual: php dumper.php config.yaml

  5. Profit!

@Flatroy
Flatroy / mail2telegram.js
Created April 11, 2021 15:32 — forked from ivanfgm/mail2telegram.js
Small script to send received emails to a telegram bot, easy piece thanks to: node-telegram-bot-api and mail-listener2
const makeBot = require('node-telegram-bot-api');
const mailListener = require("mail-listener2");
const config = {
// First get your telegram bot
telegramToken: 'Obtain your token talking to BotFather on telegram',
// Send a message to the bot and paste here your chat id (the response)
// TODO: login to avoid this step and allow multiple users
chatID = 'Chat ID',
// Gmail or Gsuite settings
@Flatroy
Flatroy / laravel.stpl
Created June 11, 2019 09:50 — forked from inerba/laravel.stpl
Laravel template VESTACP
# /usr/local/vesta/data/templates/web/apache2/laravel.stpl
<VirtualHost %ip%:%web_ssl_port%>
ServerName %domain_idn%
%alias_string%
ServerAdmin %email%
DocumentRoot %sdocroot%/public/
ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
Alias /vstats/ %home%/%user%/web/%domain%/stats/
// From https://github.com/kleampa/not-paid/blob/master/not-paid.js
(function(){
/* change these variables as you wish */
var due_date = new Date('2017-02-27');
var days_deadline = 60;
/* stop changing here */
var current_date = new Date();
var utc1 = Date.UTC(due_date.getFullYear(), due_date.getMonth(), due_date.getDate());
var utc2 = Date.UTC(current_date.getFullYear(), current_date.getMonth(), current_date.getDate());
@Flatroy
Flatroy / Kohana 3.X auth snippets.php
Created January 13, 2016 14:47 — forked from maid450/Kohana 3.X auth snippets.php
Kohana 3.X auth snippets
<?php
//Useful code snippets
//Here are some code snippets which show you the basics of Auth:
//Create a new user (e.g. if you have not set up any users yet and want to do that programmatically)
$model = ORM::factory('user');
$model->values(array(
'username' => 'admin',
'email' => '[email protected]',
'password' => 'admin',