Skip to content

Instantly share code, notes, and snippets.

@shtrih
shtrih / Csv.php
Last active February 19, 2020 20:59
<?php
/**
* Created by PhpStorm.
* User: shtrih
* Date: 24.09.2017
* Time: 21:57
*/
namespace App\Util;
<?php
function getTmp() {
// returns file handle, similar to the one returned by fopen, for the new file or false on failure.
$handle = tmpfile();
$path = stream_get_meta_data($handle)['uri'];
var_dump(fwrite($handle, 'foo')); // 3
var_dump(fread($handle, 42)); // ""
var_dump(fgets($handle)); // false
var_dump(file_get_contents($path)); // "foo"
var_dump(file_exists($path)); // true
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
chown -R baka-user:www-data wp-content/uploads/
chmod -R 0775 wp-content/uploads/
chown baka-user:www-data wp-config.php
chmod 0640 wp-config.php
@shtrih
shtrih / CollapsibleEmbeds.plugin.js
Last active August 22, 2021 08:55
[Outdated] Plugin for BetterDiscord. Creates caret to hide image/video previews.
//META{"name":"CollapsibleEmbeds"}*//
/*
Check for Updates: https://gist.github.com/shtrih/59a8be1f9ff53f0499c2
How to install:
1. If you don't have it, get Discord from https://discordapp.com/apps
2. Download BetterDiscord for your platform on https://betterdiscord.net/home
3. Push the button «Raw» then Ctrl + S.
3. Place the plugin in %appdata%\BetterDiscord\plugins\.
4. Refresh Discord with Ctrl + Shift + R or just restart Discord completely.
5. Go to the BetterDiscord settings → plugins tab and check plugin.
@shtrih
shtrih / EmbedAV.plugin.js
Last active October 16, 2018 11:34
[Outdated since this is built in feature] Plugin for BetterDiscord. Creates player for audio and video files (mp3, mp4, webm etc.). Works only for https links. Screenshot in comments
//META{"name":"EmbedAV"}*//
/*
Check for Updates: https://gist.github.com/shtrih/8a72a36d513ec704c7a9
How to install:
1. If you don't have it, get Discord from https://discordapp.com/apps
2. Download BetterDiscord for your platform on https://betterdiscord.net/home
3. Push the button «Raw» then Ctrl + S.
3. Place the plugin in %appdata%\BetterDiscord\plugins\.
4. Refresh Discord with Ctrl + Shift + R or just restart Discord completely.
@shtrih
shtrih / slack-ignorer.user.js
Last active November 18, 2016 23:35
Add users to ignore list in channels. One separated black list for each channel.
// ==UserScript==
// @name Slack Ignore List (19.11.16)
// @namespace https://gist.github.com/shtrih/be922d9229925bb52617
// @version 1.4
// @description Add blacklists to channels
// @author shtrih
// @match https://*.slack.com/messages/*/
// @grant none
// ==/UserScript==
/* jshint -W097 */
@shtrih
shtrih / my-proxy.pac
Last active September 14, 2015 11:03
PAC for TunnelSwitch
function FindProxyForURL(url, host)
{
url = url.toLowerCase();
host = host.toLowerCase();
// whole site
var site_list = [
'local',
'lcl',
'localhost'
@shtrih
shtrih / gplus_img_link.user.js
Last active August 29, 2015 14:12
Добавляет кнопку для получения ссылки на полноразмерное изображение в G+: https://www.dropbox.com/s/6c0iza4m2tk2hhm/2014-12-24_06h03_40.png Устанавливать через Tampermonkey/Greazemonkey или аналоги.
<?php
require_once "fnc/inc/ajax.php";
$params = array(
'secret',
'from',
'message',
'message_id',
'sent_to',
#!/bin/bash
DBUSER=
DBPASS=
DBHOST=localhost
FILEPATH="/home/http/local"
DATE=$(date +"%Y-%m-%d-%H_%M")
cd ${FILEPATH}