Skip to content

Instantly share code, notes, and snippets.

@technokid
technokid / meson.sh
Last active June 16, 2021 05:43
meson script install
#!/bin/bash
apt-get install wget -y
wget 'https://coldcdn.com/api/cdn/f2cobx/terminal/v2.5.1/meson-linux-amd64.tar.gz'
tar -zxf meson-linux-amd64.tar.gz
cd ./meson-linux-amd64
./meson service-install -token I0vOuOhJe1DBOn+/eC6Vog== -spacelimit 80 -port 19091
./meson service-start
./meson service-status
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@technokid
technokid / my.cnf
Created May 7, 2020 12:21
Enable logger slow query in mysql
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 1
log_queries_not_using_indexes
#then restart mysql server
@technokid
technokid / Docker command
Last active May 6, 2020 12:05
Docker command
#Stop and remove all Docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
#Remove all Docker images
docker rmi -f $(docker images -a)
#Remove unnecessary images before removing the image:
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
@technokid
technokid / MC mac os hot key
Created July 15, 2018 11:15
hot key for Midnight Commander at mac os
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@technokid
technokid / ConsoleRender
Created May 2, 2018 16:22
Yii console render file
<?php
/**
* Took the components necessary to render views from CController, adding it to a console command
*/
class RenderReadyConsoleCommand extends CConsoleCommand
{
protected $_widgetStack;
public function run($args) { }
public function renderPartial($view,$data=null,$return=true)
{
@technokid
technokid / Singleton.php
Created April 11, 2018 18:50
Best practice to create php singleton
<?php
trait Singleton {
static private $instance = null;
private function __construct() { /* ... @return Singleton */ } // Protect from creation through new Singleton
private function __clone() { /* ... @return Singleton */ } // Protect from creation through clone
private function __wakeup() { /* ... @return Singleton */ } // Protect from creation through unserialize
static public function getInstance() {
return
@technokid
technokid / Remove ssh pass.txt
Last active June 20, 2018 06:31
remove password from ssh key
Should also work for:
[v] any OpenSSH installation
Given, your key is in id_rsa
1
Passphrase is needed?
Try some host which has your public key (id_rsa.pub)
<?php
/**
* PHP-Shortcode is for creating bbcode like tags or what WordPress calls
* "shortcodes." The tag and attribute parsing or regular expression code is
* based on the Textpattern tag parser.
*
* A few examples are below:
*
* [shortcode /]
* [shortcode foo="bar" baz="bing" /]
<?php
//The content which should be parsed
$content = '<p>Hello, my name is John an my age is [calc-age day="4" month="10" year="1991"].</p>';
$content .= '<p>Hello, my name is Carol an my age is [calc-age day="26" month="11" year="1996"].</p>';
//The array with all the shortcode handlers. This is just a regular associative array with anonymous functions as values. A very cool new feature in PHP, just like callbacks in JavaScript or delegates in C#.
$shortcodes = array(
"calc-age" => function($data){
$content = "";
//Calculate the age