Skip to content

Instantly share code, notes, and snippets.

View grvoyt's full-sized avatar
🌌
Working

George grvoyt

🌌
Working
View GitHub Profile
<?php
$output = array();
$q = $modx->newQuery('modTemplateVarResource');
$q->select('DISTINCT(`modTemplateVarResource`.`value`)');
$q->innerJoin('modTemplateVar', 'tv', "tv.id = modTemplateVarResource.tmplvarid");
$q->innerJoin('modResource', 'res', 'res.id=modTemplateVarResource.contentid');
$q->where(array(
'tv.name' => 'category',
'res.context_key' => $modx->resource->context_key,
function bytes($a) {
$unim = array("B","KB","MB","GB","TB","PB");
$c = 0;
while ($a>=1024) {
$c++;
$a = $a/1024;
}
return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c];
}
PS1='\[\e[1;32m\]\u\[\e[1;32m\]@\[\033[1;32m\]\h \[\e[1;32m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'
docker run -d -p443:443 --name=mt -e SECRET=935ddceb2f6bbbb78363b224099f75c8 -e TAG=d482b679405543ad111c0f9a6bd3c2c8 --privileged --restart=always -v proxy-config:/data telegrammessenger/proxy:latest
@grvoyt
grvoyt / json_response.php
Last active February 7, 2019 14:46
a little function to response json for ajax call
function json_response($data = array()) {
// clear the old headers
header_remove();
// set the actual code
http_response_code(200);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
// treat this as json
header('Content-Type: application/json');
header('Status: 200');
#!/bin/bash
api='' #api key
chat_id='' #chat_id
curl -d "chat_id=$chat_id&text=$1" https://api.telegram.org/bot$api/sendMessage > /dev/null 2>&1
find www/ -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r > dates.txt
@grvoyt
grvoyt / redirect all mobile
Created January 8, 2019 13:24
htaccess redirect all mobile devices
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} android [NC,OR]
RewriteCond %{HTTP_USER_AGENT} opera\ mini [NC,OR]
RewriteCond %{HTTP_USER_AGENT} blackberry [NC,OR]
RewriteCond %{HTTP_USER_AGENT} iphone [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (pre\/|palm\ os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (iris|3g_t|windows\ ce|opera\ mobi|windows\ ce;\ smartphone;|windows\ ce;\ iemobile) [NC,OR]
RewriteCond %{HTTP:Accept} (text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml) [NC,OR]
RewriteCond %{HTTP:Profile} .+ [NC,OR]
RewriteCond %{HTTP:Wap-Profile} .+ [NC,OR]
@grvoyt
grvoyt / create_html_bash
Last active February 17, 2019 08:51
little bash to create project folder ( and for modx )
#!/bin/bash
name=$1
modx=$2
mkdir $name &&
cd $name &&
mkdir html psd &&
cd html &&
touch index.html
if( window.history && window.history.pushState ){
history.pushState( "nohb", null, "" );
$(window).on( "popstate", function(event){
if( !event.originalEvent.state ){
history.pushState( "nohb", null, "" );
return;
}
});
}