Skip to content

Instantly share code, notes, and snippets.

View sokil's full-sized avatar
🇺🇦
sapere aude

sokil

🇺🇦
sapere aude
View GitHub Profile
@sokil
sokil / rsync.sh
Last active June 2, 2020 11:33
Sync remote files to local
#!/bin/sh
while true; do
read -p "Do you want to sync? (y/n): " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
#!/bin/sh
curl -XDELETE http://localhost:9200/mycol
curl -XPOST http://localhost:9200/mycol
curl -XPOST http://localhost:9200/mycol/_mapping/mytype -d '{"mytype": {"properties": {"loc": {"type": "geo_point"}}}}'
lat=-90;
while [ $lat -lt 91 ]
do
lon=-180;
<?php
interface IMessage
{
public function getBody();
}
class Message implements IMessage
{
private $body;
@sokil
sokil / MongoInsertBatch.php
Last active August 29, 2015 14:24
MongoInsertBatch
<?php
/**
* @link https://github.com/mongodb/mongo-php-driver/blob/v1.6/bson.c#L89
*/
// connection
$client = new MongoClient("mongodb://localhost");
$collection = $client->test->test;
@sokil
sokil / test.html
Created July 20, 2015 08:41
IE6-IE9 Limitation of css
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="a01.css" />
<link rel="stylesheet" type="text/css" href="a02.css" />
<link rel="stylesheet" type="text/css" href="a03.css" />
<link rel="stylesheet" type="text/css" href="a04.css" />
<link rel="stylesheet" type="text/css" href="a05.css" />
<link rel="stylesheet" type="text/css" href="a06.css" />
<link rel="stylesheet" type="text/css" href="a07.css" />
@sokil
sokil / CreateForm.php
Last active January 16, 2017 09:53
Create symfony form without prefix
<?php
$formFactory = $this->container->get('form.factory');
$form = $formFactory->createNamed(
null,
new RegistrationFormType('\Vendor\AcmeBundle\Entity\SomeEntity'),
$user,
[
'method' => $request->getMethod(),
]

Get list from mysql

mysql --defaults-extra-file=~/credentials.cnf -Nsqe "SELECT SQL_NO_CACHE * FROM ..." | pv -l | gzip > rows.gz

Get list from mysql, based on other list in file

zcat rows.gz | awk '{print $1}' | xargs -L 1000 | sed 's/ /\\",\\"/g' | xargs -I {} mysql --defaults-extra-file=~/credentials.cnf -Nsqe "SELECT SQL_NO_CACHE otherId FROM table WHERE id IN (\"{}\")" | pv -l | sort | uniq -c | sort -rn > otherIds
@sokil
sokil / xphp.sh
Last active October 7, 2016 11:53
export PHP_XDEBUG_ENABLED=1
export PHP_IDE_CONFIG="serverName=%PhpStormServerName%"
export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=%RemoteIp% remote_port=%RemotePort% remote_enable=1 remote_autostart=1"
php $@
@sokil
sokil / compile_js.sh
Created January 15, 2016 10:15
compile_js.sh
#!/bin/bash
# config
jsFilesDir=./../public/js/
compiledJsFilename=compiled.js
# init js files array
js=(
a.js
b.js
@sokil
sokil / nginx.conf
Last active November 8, 2016 06:31
server
{
listen 80; # default_server
server_name {SERVER_NAME};
# SSL.
# Uncomment to enable
# listen 443 ssl;
# ssl_certificate /path/to/ssl.crt;
# ssl_certificate_key /path/to/ssl.key;