Skip to content

Instantly share code, notes, and snippets.

@selmi-karim
selmi-karim / redis.sh
Created June 4, 2020 17:06
script to get, update and extend the TTL value of all the redis keys
## extend all the redis TTL keys
redis-cli keys '*' | xargs -n1 -I {} /bin/bash -c 'redis-cli expire {} $(redis-cli ttl {} | xargs -I{} echo {} + EXTEND_VALUE | bc)'
## update all the redis keys with new ttl value
redis-cli KEYS '*' | xargs -I{} redis-cli EXPIRE {} EXPIRE_VALUE
## get all the redis TTL keys
redis-cli KEYS '*' | xargs -I{} redis-cli TTL {}
@colorfield
colorfield / drupal8-links.php
Last active January 17, 2026 04:27
Drupal 8 links, or where is my l() function
@DarrylDias
DarrylDias / default
Last active November 6, 2021 23:32
NGINX configuration for Grav CMS.
server {
listen 80;
server_name localhost; # Change this with your domain name
root /var/www/grav; # The place were you have setup your Grav install;
index index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;

The Laracasts PHPStorm theme - modified.

This is a slightly modified version of the great Laracasts PHPStorm theme. I've added some styles for Verions Control (add, modified, deleted line...) and fixed some missing things like warnings.

Download

image

Mac: Add to ~/Library/Preferences/WebIde80/colors

@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active July 24, 2025 16:11
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@colthreepv
colthreepv / guake-start.sh
Last active July 2, 2019 08:31
guake script to startup with tabs.
#!/bin/bash
# guake-start.sh
guake --rename-tab="home" &
sleep 3
guake --new-tab=2 --rename-tab="projects" --execute-command="cd ~/projects" &
sleep 1
guake --new-tab=3 --rename-tab="develop" --execute-command="cd ~/projects" &
sleep 1
guake --new-tab=4 --rename-tab="git" --execute-command="cd ~/projects" &
sleep 1
@cmsx
cmsx / VideoThumb.php
Last active October 3, 2025 08:17
Класс для получения превью и информации о ролике RuTube, Vimeo, Youtube по ссылке.
<?php
/**
* Использование:
* $v = new VideoThumb($link);
* $v->getVideo(); //Ссылка на видео
* $v->getTitle(); //Название ролика
* $v->fetchImage($path) //Скачать самое большое превью ролика
*
* Прогнать тест:
@ashitvora-zz
ashitvora-zz / html.macros.php
Created November 28, 2012 13:00
Laravel macro to display flash alert messages
/**
* Display Error / Success / Warn / Info messages
*
* These messages are set using Session::flash(<message_type>, <message>);
*/
HTML::macro("alert", function(){
$alerts = array();
$alert_types = array("error", "success", "warn", "info");
foreach ($alert_types as $type) {
if( Session::has($type) ){
@fomigo
fomigo / gist:2382775
Created April 14, 2012 07:59
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.