Skip to content

Instantly share code, notes, and snippets.

View Tolerant's full-sized avatar
🎯
Focusing

Alexandr Tolerant

🎯
Focusing
View GitHub Profile
@ruanbekker
ruanbekker / promtail_docker_logs.md
Last active July 16, 2024 18:43
Docker Container Logging using Promtail
@lhuxman-lhux
lhuxman-lhux / yt.php
Last active June 15, 2023 19:06
youtube download
<?php
if (file_exists('sig1.php')) {
unlink('sig1.php');
}
function getc($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
@kunicmarko20
kunicmarko20 / Article.php
Last active November 16, 2023 07:52
Symfony Second Level Cache
<?php
namespace AppBundle\Entity;
/**
* @package AppBundle\Entity
* @ORM\Entity()
* @ORM\Table()
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
@n1lesh
n1lesh / fcm1.js
Last active May 31, 2023 12:24
Firebase Cloud Messaging with Node.js
'use strict'
const app = require('express')(),
request = require('request'),
mongo = require('mongodb'),
bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: false
@thedaviddias
thedaviddias / Preload CSS - Not blocking CSS.html
Last active February 1, 2024 08:24
Preload CSS and don't block the DOM with your CSS file request.
<link rel="preload" href="css/global.min.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="css/global.min.css"></noscript>
<script>
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(a){"use strict";var b=function(b,c,d){function j(a){if(e.body)return a();setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
/*! loadCSS rel=preload po
@bosunolanrewaju
bosunolanrewaju / test.retry.php
Last active May 9, 2022 17:21 — forked from mudge/test.retry.php
A retry function for PHP.
<?php
require_once dirname(__FILE__) . '/../lib/simpletest/autorun.php';
// Retries $f (A function) with arguments ($args as array)
// 3 ($retries) times after 10 secs $delay
// Usage:
// retry( 'function_name', array('arg1', 'arg2'), 15, 5 );
// #=> Retries function_name 5 times with arg1 and $arg2 as arguments at interval of 15 secs
function retry($f, $args = null, $delay = 10, $retries = 3)
{
@luruke
luruke / smashingmagazine.js
Last active January 12, 2022 15:34
Source code of the demo "Improving User Flow Through Page Transitions" on Smashing Magazine.
/*
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/
You can copy paste this code in your console on smashingmagazine.com
in order to have cross-fade transition when change page.
*/
var cache = {};
function loadPage(url) {
if (cache[url]) {
@zettca
zettca / insta.js
Last active May 22, 2018 00:54
Instagram auto-liker
(function (delay, type) {
const g = (c) => document.getElementsByClassName(c);
const pics = g('_si7dy');
function iteration() {
const heart = g((type === 'like') ? 'coreSpriteHeartOpen' : 'coreSpriteHeartFull')[0];
heart && heart.click();
g('coreSpriteRightPaginationArrow')[0].click();
}
@spolischook
spolischook / kotoblog_set-default-locale-in-silex-by-parsing-http-accept-language-header.php
Last active March 4, 2021 03:25
Set prefer language by parsing HTTP_ACCEPT_LANGUAGE header in Silex
<?php
$app->register(new Silex\Provider\TranslationServiceProvider(), [
'locale_fallbacks' => ['en', 'uk', 'ru'],
]);
$app->before(function() use ($app) {
$locales = $app['translator']->getFallbackLocales();
$prefLocales = array_reduce(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']), function ($res, $el) { list($l, $q) = array_merge(explode(';q=', $el), [1]); $res[$l] = (float) $q; return $res; }, []);
asort($prefLocales);