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 ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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'; |
2015/07/18
How to serialize / deserialize object to json in C# ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
2015/07/16
How to copy table in MySql ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE proxy_20150716 AS SELECT * FROM proxy |
2015/07/09
How to invoke object method with arguments passed as argument in PHP ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Subscribe to:
Posts (Atom)