Skip to content

Instantly share code, notes, and snippets.

View Techmind's full-sized avatar

Bogunov Ilya Techmind

View GitHub Profile
mysql -uroot -p123 -e "CREATE USER 'homestead'@'%' IDENTIFIED BY 'secret';"
mysql -uroot -p123 -e "GRANT ALL PRIVILEGES ON * . * TO 'homestead'@'%';"
<?php
$a = mysql_connect('127.0.0.1', 'root');
if (pcntl_fork()) {
sleep(10);
var_dump($a);
var_dump(mysql_query('SELECT 1;'));
var_dump(mysql_error());
} else {
var_dump('ending');
}
@Techmind
Techmind / gist:3958454
Created October 26, 2012 12:14
demo google play parser
<?php
$content = file_get_contents('https://play.google.com/store');
var_dump(strlen($content));
preg_match_all("~<a href=\"(/store/apps/category/[A-Z_]*)~", $content, $matches);
$cats = array_unique($matches[1]);
@Techmind
Techmind / gist:2776250
Created May 23, 2012 16:36
Riak something like merge sort
After we compiled this module on all nodes - http://en.literateprograms.org/Merge_sort_(Erlang)
{ok, Client} = riak:local_client().
Client:put(riak_object:new(<<"sort_test">>, <<"1">> 1)).
Client:put(riak_object:new(<<"sort_test">>, <<"2">> 2)).
Client:put(riak_object:new(<<"sort_test">>, <<"3">> 3)).
Get = fun(G, _, _) -> [riak_object:get_value(G)] end.
Msort = fun(ReduceList, none) -> mergesort:msort_gte(ReduceList) end.
@Techmind
Techmind / gist:2761654
Created May 21, 2012 10:12
google-reader-pming
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Techmind: подписки в Google Reader</title>
</head>
<body>
<outline title="pming" text="pming">
<outline text="2PM" title="2PM" type="rss"
xmlUrl="http://feeds.feedburner.com/2pm" htmlUrl="http://2pm.kz"/>
<outline text="a-Jail" title="a-Jail" type="rss"
Key = <<"X">.
%% -------------------------------------------------------------------
%%
%% basho_bench: Benchmarking Suite
%%
%% Copyright (c) 2009-2010 Basho Techonologies
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
./cli jobs/tools/multi_run --count=8 --code='$db = $factory->getDaemonActionsBackend("riak"); $redis = $factory->getRedis();$file = $factory->getDaemonActionsBackend("file"); while ($id = $redis->popFromList("testList2")) { $actions = $file->getUserActions($id, null, array(), 5000); $actions[0] = array_reverse($actions[0]); $db->writeActions($actions[0], $id);}'
./cli jobs/tools/multi_run --count=8 --code='$db = $factory->getDaemonActionsBackend("db_sharded"); $redis = $factory->getRedis();$file = $factory->getDaemonActionsBackend("file"); while ($id = $redis->popFromList("testList3")) { $actions = $file->getUserActions($id, null, array(), 5000); $actions[0] = array_reverse($actions[0]); $db->writeActions($actions[0], $id);}'
ALTER TABLE actions_0 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_1 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_10 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_100 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_101 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_102 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_103 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_104 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_105 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_106 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_0 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_1 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_10 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_100 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_101 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_102 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_103 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_104 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_105 DROP INDEX `type`, DROP INDEX `param`;
ALTER TABLE actions_106 DROP INDEX `type`, DROP INDEX `param`;