Skip to content

Instantly share code, notes, and snippets.

@bladeSk
bladeSk / SQLite-PHP-quickstart.php
Last active June 28, 2025 02:27
SQLite3 PHP Quickstart Tutorial
<?php
// This file walks you through the most common features of PHP's SQLite3 API.
// The code is runnable in its entirety and results in an `analytics.sqlite` file.
// Create a new database, if the file doesn't exist and open it for reading/writing.
// The extension of the file is arbitrary.
$db = new SQLite3('analytics.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
// Errors are emitted as warnings by default, enable proper error handling.
@supakazes
supakazes / CSS-transform-blurry-fix.css
Created April 13, 2017 15:26
CSS transform blurry fix
/* translateZ + scale = fix font blurry */
-webkit-font-smoothing: subpixel-antialiased;
transform: translate3d(-50%, -50%, 0) scale(2, 2);
zoom: 0.5;
@tzmartin
tzmartin / embedded-file-viewer.md
Last active June 22, 2025 01:25
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@gunnarlium
gunnarlium / guzzle-retry.php
Created December 17, 2015 16:23
Example of how to create a retry subscriber for Guzzle 6
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request as Psr7Request;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Psr\Log\LoggerInterface;
const MAX_RETRIES = 2;
@pafnuty
pafnuty / init.php
Last active June 5, 2017 17:43
Вывод отладки в Bitrix через Kint
<?
# /local/php_interface/init.php
/**
* Вывод дебага через класс Kint
* @author Павел Белоусов <[email protected]>
*
* @param mixed $var Данные, которые требуется вывести
* @param string $function Функция, вызываемая из класса Kint. По умолчанию 'd'. Можно передать s, cd или ddd
* @param boolean $bAllUsers True — выводить всем пользователям (по умолчанию только для админов)
@Integralist
Integralist / convert-p12-pem-formats.bash
Created November 17, 2015 12:57
Convert a P12 into a PEM and vice versa
# Convert p12 to pem
openssl pkcs12 -in certificate.p12 -out certificate.pem -clcerts -nodes
# Convert pem to p12
openssl pkcs12 -export -in certificate.pem -out certificate.p12 -passout pass:password
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@Thinkscape
Thinkscape / EffectiveUrlMiddleware.php
Last active October 4, 2022 18:30
getEffectiveUrl() replacement for Guzzle 6.*
<?php
namespace Thinkscape\Guzzle;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class EffectiveUrlMiddleware
{
/**
* @var Callable
@wpscholar
wpscholar / vagrant-cheat-sheet.md
Last active June 26, 2025 12:26
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@johandouma
johandouma / gist:73b5da17334773138d60
Last active January 16, 2016 08:12
Craft CMS + Foundation Top Bar Twig Macro
{% macro menu(entries, active, level) %}
{% if entries|length %}
{% set level = level|default(1) %}
<ul class="level-{{ level }} {{ level > 1 ? "dropdown sub" : "left top" }}">
{% for n in entries %}
<li class="{{ loop.first ? "first" : "" }} {{ loop.last ? "last" : "" }}
{%- if n.children|length %}has-dropdown{% endif %}
{%- if active is defined and (active.descendantOf(n) or active.id == n.id) %} active{% endif %}">
<a href="{{ n.url }}">
{{ n }}