Skip to content

Instantly share code, notes, and snippets.

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

sokil

🇺🇦
sapere aude
View GitHub Profile

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 / 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(),
]
@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 / 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;
<?php
interface IMessage
{
public function getBody();
}
class Message implements IMessage
{
private $body;
#!/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;
@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
@sokil
sokil / cookie.js
Created January 30, 2015 07:01
Cookie inJavaScript
@sokil
sokil / server.js
Created December 31, 2014 18:11
Node.js server
var http = require('http');
// create server
var server = http.createServer();
// dispatch requests
server.on('request', function(request, response) {
response.writeHead(200, 'OK');
response.write('Requested ' + request.url);
response.end();
@sokil
sokil / Hashtable.sh
Last active April 3, 2018 07:39
Shell hashtable
CCList=(
"GBR:GB"
"USA:US"
"CAN:CA"
"NLD:NL"
"NZL:NZ"
"ZAF:ZA"
"IRL:IE"
"CZE:CZ"
"AUS:AU"