2015/07/24

C# WebBrowser control - document does not contain html input control

Working solution is here: http://stackoverflow.com/a/22262976/991058 Another solutions is to invoke java sript functions from code behind that operates on html elements and return result to code behind.

2015/07/22

How to log all queries in mysql ?

-- enable db table logging
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
-- table with logs
select * from mysql.general_log
-- disable logging
SET GLOBAL general_log = 'ON';
-- enable file logging
SET GLOBAL log_output = "FILE"; -- which is set by default.
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
Thanks to: http://stackoverflow.com/a/678310/991058

2015/07/18

How to serialize / deserialize object to json in C# ?

// Install-Package Newtonsoft.Json
using Newtonsoft.Json;
public static void SerializeJson(this object obj, string filePath)
{
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.WriteLine(json);
}
}
public static T DeserializeJson<T>(this T obj, string jsonFilePath)
{
string json = null;
using (StreamReader sr = new StreamReader(jsonFilePath))
{
json = sr.ReadToEnd();
}
return JsonConvert.DeserializeObject<T>(json);
}
view raw gistfile1.cs hosted with ❤ by GitHub

2015/07/09

How to invoke object method with arguments passed as argument in PHP ?

class Test
{
public function f1(array $keywords)
{
foreach($keywords as $keyword)
{
echo "f1():" . $keyword . "<br/>";
}
}
public function f2(array $keywords)
{
foreach($keywords as $keyword)
{
echo "f2():" . $keyword . "<br/>";
}
}
public function start()
{
$this->run([$this, 'f1'], ['aaa', 'bbb']);
$this->run([$this, 'f2'], ['aaa', 'bbb']);
}
public function run($func, $args)
{
$func($args);
}
}
$test = new Test();
$test->start();
// output
// f1():aaa
// f1():bbb
// f2():aaa
// f2():bbb
view raw gistfile1.php hosted with ❤ by GitHub