Skip to content

Instantly share code, notes, and snippets.

View klipitkas's full-sized avatar

Konstantinos Lypitkas klipitkas

View GitHub Profile
// Controller method...
public function download()
{
return response()->streamDownload(function () use ($invoice) {
$token = config('services.cloudflare.api_token');
$accountId = config('services.cloudflare.account_id');
$cloudflareApi = 'https://api.cloudflare.com/client/v4';
echo Http::withToken($token)
->post($cloudflareApi.'/accounts/'.$accountId.'/browser-rendering/pdf', [
@klipitkas
klipitkas / image.html
Created December 12, 2020 19:35
Image file to base64
<html>
<body>
<form>
<input type="file" class="image" name="image">
</form>
<script>
const image = document.querySelector('.image');
const toBase64 = file => new Promise((resolve, reject) => {
const reader = new FileReader();
@klipitkas
klipitkas / cache php
Last active January 10, 2020 14:29
Small cache implementation in PHP
<?php
define('CACHE_TIME_DEFAULT', 10000); // in seconds.
function cache_get($key) {
$path = sys_get_temp_dir() . "/cache-$key";
if (!file_exists($path)) {
return false;
}
$file = unserialize(file_get_contents($path));
@klipitkas
klipitkas / System Design.md
Created February 25, 2019 08:37 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@klipitkas
klipitkas / permfix-wp.sh
Created August 17, 2018 07:31
WordPress permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER="$1" # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
@klipitkas
klipitkas / GW_Submission_Limit
Last active May 4, 2018 06:55
Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value) - Gravity Forms 2.3
/**
* Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
*
* Limit the number of times a form can be submitted per a specific time period. You modify this limit to apply to
* the visitor's IP address, the user's ID, the user's role, a specific form URL, or the value of a specific field.
* These "limiters" can be combined to create more complex limitations.
*
* @version 2.15
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
@klipitkas
klipitkas / convert-p12-to-pem.md
Created April 18, 2018 14:23
Convert APNS p12 certificate to PEM for use in PHP script

openssl pkcs12 -in aps_cert.p12 -out aps_cert.pem

@klipitkas
klipitkas / debian-9360-install-notes.md
Created March 23, 2018 21:40 — forked from mogenson/debian-9360-install-notes.md
Installing Debian Stretch + Mate + i3-gaps on a Dell XPS 9360

Installation and setup notes for Debian 9 on Dell XPS 9360

Using Mate DE and i3-gaps WM

May 4th 2017

Installation

Use Debian Stretch RC3 Installer: https://www.debian.org/devel/debian-installer/

  • Non-graphical install
  • Ignore warning about firmware not found for wireless card
@klipitkas
klipitkas / .vimrc
Last active September 13, 2017 07:33 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
@klipitkas
klipitkas / README.md
Created February 4, 2017 20:28 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/