Skip to content

Instantly share code, notes, and snippets.

View chuprik's full-sized avatar
:shipit:
Squirrel. StrongSquirrel.

Constantine Chuprik chuprik

:shipit:
Squirrel. StrongSquirrel.
View GitHub Profile
@chuprik
chuprik / docker.md
Last active September 13, 2017 11:17

Stop all containers

docker stop $(docker ps -a -q)

Remove all containers

docker rm $(docker ps -a -q)

Clear all containers logs

<?php
namespace app\commands;
use yii\console\Controller;
use yii\db\ColumnSchema;
class PhpDocController extends Controller
{
public function actionIndex()
@chuprik
chuprik / install-composer.sh
Last active April 24, 2016 07:23
One command composer install
#!/bin/bash
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php -r "if (hash_file('SHA384', 'composer-setup.php') === '7228c001f88bee97506740ef0888240bd8a760b046ee16db8f4095c0d8d525f2367663f22a46b48d072c816e7fe19959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
@chuprik
chuprik / json.go
Last active April 3, 2019 08:43
golang, echo, application/json request
package utils
import (
"encoding/json"
"io/ioutil"
"github.com/labstack/echo"
)
func BodyToJson(c echo.Context) (map[string]interface{}, error) {
<?php
function dumpQuery(\yii\db\ActiveQuery $query)
{
echo '<pre>';
var_export($query->prepare(\Yii::$app->db->queryBuilder)->createCommand(\Yii::$app->db)->rawSql);
echo '</pre>';
Yii::$app->end();
}
const (
twilioAuth = "Basic {base64}" // https://www.twilio.com/docs/quickstart/php/lookups
)
// doTwilioCheck returns true if exists
func doTwilioCheck(number string) (exists bool, err error) {
url := fmt.Sprintf("https://lookups.twilio.com/v1/PhoneNumbers/%s", number)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
// file /Users/kotchuprik/Projects/Work/project/nginx.conf
server {
listen 80;
server_name webto.local webto.ru 192.168.0.100 localhost;
client_max_body_size 20M;
access_log /Users/kotchuprik/Projects/Work/project/access.log;
// file ~/Projects/projects.conf
include /Users/kotchuprik/Projects/Work/project/nginx.conf;
include /Users/kotchuprik/Projects/Freelance/project1/nginx.conf;
include /Users/kotchuprik/Projects/Freelance/project2/nginx.conf;
// file /usr/local/etc/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 130;
proxy_buffers 8 64k;
proxy_buffer_size 128k;
@chuprik
chuprik / Base.php
Last active August 29, 2015 14:06
camelCase in where magic of the Laravel.
<?php
abstract class Base extends \Eloquent
{
/**
* Get a new query builder instance for the connection.
*
* @return Builder
*/
protected function newBaseQueryBuilder()