2015/12/13
How to add existing project to existing solution in TFS ?
Source Control -> Right click on solution folder -> Add Items to folder
2015/12/12
How to remove repository in TFS Online ?
1. Navigate to: https://{your_account_name}.visualstudio.com/DefaultCollection/_admin
2. Choose your repository+ right click + choose delete
2. Choose your repository
2015/12/10
How to remove Softonic Web Search from computer, chrome, firefox, ie ?
a/ | unistall all programs that might install Softonic Web Search on your computer: SafeFinder (I had a problem with deletion of this prog so I had to do point g/) |
b/ | [optional] I have not noticed any help but I did it: Install and run Yeat Another Cleaner http://www.yac.mx/ |
c/ | Install and run: AdwCleaner - link on this site: http://www.malwareremovalguides.info/remove-sonicsearch-adware-free-virus-removal-guide/ |
d/ | I found that there is a suspected service called Lightzap running on start of my system: C:\ProgramData\\Lightzap\\Lightzap.exe -f "C:\ProgramData\\Lightzap\\Lightzap.dat" -l -a I removed it and its dependant folder. |
e/ | I reset chrome settings and ie settings with "Delete personal settings" option choosed |
f/ | restart computer |
g/ | Recover your last good system settings: Control Panel -> Recovery -> Configure System Restore -> System restore -> choose wright restoring point |
2015/12/04
2015/12/03
2015/10/12
2015/09/12
2015/09/11
How to compress and decompress directory in Linux ?
1/
Compress and pack directory:
tar -zcvf archive.tar.gz directory/
c (create) - an archive from the files in directory (tar is recursive by default),
z (gzip) - compress it using the gzip algorithm,
f (file) - store the output as a named archive.tar.gz,
v(verbosely) list all the files it adds to the archive.
2/
Decompress and unpack the archive into the current director:
tar -zxvf archive.tar.gz
Compress and pack directory:
tar -zcvf archive.tar.gz directory/
c (create) - an archive from the files in directory (tar is recursive by default),
z (gzip) - compress it using the gzip algorithm,
f (file) - store the output as a named archive.tar.gz,
v(verbosely) list all the files it adds to the archive.
2/
Decompress and unpack the archive into the current director:
tar -zxvf archive.tar.gz
2015/09/01
Polish characters in HTML encoding
Polish characters in HTML encoding:
Ą - Ą
ą - ą
Ć - Ć
ć - ć
Ę - Ę
ę - ę
Ł - Ł
ł - ł
Ń - Ń
ń - ń
Ó - Ó
ó - ó
Ś - Ś
ś - ś
Ż - Ż
ż - ż
Ź - Ź
ź - ź
Source: http://unicode-table.com/
Ą - Ą
ą - ą
Ć - Ć
ć - ć
Ę - Ę
ę - ę
Ł - Ł
ł - ł
Ń - Ń
ń - ń
Ó - Ó
ó - ó
Ś - Ś
ś - ś
Ż - Ż
ż - ż
Ź - Ź
ź - ź
Source: http://unicode-table.com/
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 |
2015/06/28
Update from sqlserver example
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
UPDATE t | |
SET t.col1 = other_table.col1, | |
t.col2 = other_table.col2 | |
FROM Table t INNER JOIN | |
OtherTable other_table ON (t.id = other_table.id) |
2015/06/23
How to cut body content from HTML using regular expressions 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
preg_match('/<body[^>]*>(.*?)<\/body>/s', $content, $matches); |
2015/06/20
How to send mail using SwiftMailer library through your gmail account in PHP ?
Swift mailer library:http://swiftmailer.org/
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
$transport = \Swift_SmtpTransport::newInstance("smtp.gmail.com", 465, "ssl"); | |
$transport->setUsername("alias@gmail.com"); | |
$transport->setPassword("password"); | |
$email_body = \Swift_Message::newInstance() | |
->setSubject("Mach2 - error reporting") | |
->setFrom(["src_alias@gmail.com" => "Mach2"]) | |
->setTo("dest_alias@gmail.com") | |
->setBody($message, 'text/html'); | |
$mailer = \Swift_Mailer::newInstance($transport); | |
$ret = $mailer->send($email_body); |
2015/06/18
How to redirect https request to http for domain ?
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
RewriteCond %{HTTPS} on | |
RewriteCond %{HTTP_HOST} ^(www\.)?domainname\.com$ [NC] | |
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] |
2015/06/12
How to give alias to namespace in using instruction ?
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
using DbAzure = JobOffers.EF.Azure; |
How to perform SET IDENTITY INSERT ON from Entity Framework ?
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
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) | |
{ | |
using (var conn = new System.Data.SqlClient.SqlConnection(_connectionstring)) | |
{ | |
conn.Open(); | |
using (Context context = new Context(conn, false)) | |
{ | |
context.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [dbo].[TableName] ON"); | |
context.TableName.AddRange(items); | |
context.SaveChanges(); | |
context.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [dbo].[TableName] OFF"); | |
scope.Complete(); | |
} | |
} | |
} |
2015/06/08
How to send email using gmail account 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
MailMessage mail = new MailMessage("senuto.development@gmail.com", "mwlasny@gmail.com"); | |
SmtpClient client = new SmtpClient() | |
{ | |
Port = 587, | |
DeliveryMethod = SmtpDeliveryMethod.Network, | |
UseDefaultCredentials = false, | |
Host = "smtp.gmail.com", | |
Credentials = new NetworkCredential("senuto.development@gmail.com", "@stron@ut@"), | |
EnableSsl = true, | |
}; | |
mail.Subject = "test"; | |
mail.Body = "test"; | |
client.Send(mail); |
2015/06/03
How to match GMT date using regular expression 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
// GMT date format 3 Jun 2015 06:59:23 | |
preg_match("/(?<day>\d{1,2}) (?<month>[a-zA-Z]{3}) (?<year>\d{4}) (?<hours>\d{1,2}):(?<minutes>\d{2}):(?<seconds>\d{2})/", $date, $match); | |
2015/05/25
How to list all errors in C# MVC 5 ?
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
var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); |
2015/04/24
How to zip unzip directory in Linux ?
Pack:
tar -zcvf archive.tar.gz directory/
c - create an archive from files in directory (recursive by default)
z - compress above archive with gzip
f - store the output as a file
v - list all the files
Unpack:
tar -zxvf archive.tar.gz
tar -zcvf archive.tar.gz directory/
c - create an archive from files in directory (recursive by default)
z - compress above archive with gzip
f - store the output as a file
v - list all the files
Unpack:
tar -zxvf archive.tar.gz
2015/04/11
How to send mail from PHP using swiftmailer library ?
Download swiftmailer library from here
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
require_once "swiftmailer/swiftmailer/lib/swift_required.php"; | |
private function send_mail($total_google_num){ | |
$subject = 'Subject'; | |
$from = array('example_1@gmail.com' =>'Your Name'); | |
$to = array('example_2@gmail.com' => 'Recipient1 Name'); | |
$text = "text message"; | |
$html = "html message"; | |
$transport = \Swift_SmtpTransport::newInstance("smtp.gmail.com") | |
->setPort(465) | |
->setEncryption('ssl') | |
->setUsername(your_gmail_username) | |
->setPassword(your_gmail_password); | |
$swift = \Swift_Mailer::newInstance($transport); | |
$message = (new \Swift_Message($subject)) | |
->setFrom($from) | |
->setBody($html, 'text/html') | |
->setTo($to) | |
->addPart($text, 'text/plain'); | |
$failures = null; | |
if ($recipients = $swift->send($message, $failures)) | |
{ | |
echo 'Message successfully sent!'; | |
} else { | |
echo "There was an error:\n"; | |
print_r($failures); | |
} | |
} |
2015/04/10
How to select records that has unix_timestamp and differs in minutes 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
SELECT * | |
FROM proxy | |
WHERE status = 'active' | |
AND TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(blocking_date), CURRENT_TIMESTAMP) > 60 * 4)) | |
ORDER BY total_ping_counter |
2015/03/15
How to remove directory with all its child subdirectories and files 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
function delete_dir($dirPath) { | |
$dir = opendir($dirPath); | |
while(($file = readdir($dir)) !== false) { | |
if (( $file != '.' ) && ( $file != '..' )) { | |
if ( is_dir($dirPath . '/' . $file) ) { | |
delete_dir($dirPath . '/' . $file); | |
} | |
else { | |
unlink($dirPath . '/' . $file); | |
} | |
} | |
} | |
rmdir($dirPath); | |
closedir($dir); | |
} |
2015/02/25
How to clear file name from disallowed characters on Windows
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
// Clears given filename from disallowed characters on Windows: https://msdn.microsoft.com/en-us/library/aa365247 | |
function clearFileName($fileName){ | |
$fileName = str_replace("<", "", $fileName); | |
$fileName = str_replace(">", "", $fileName); | |
$fileName = str_replace(":", "", $fileName); | |
$fileName = str_replace("/", "", $fileName); | |
$fileName = str_replace("\\", "", $fileName); | |
$fileName = str_replace("|", "", $fileName); | |
$fileName = str_replace("?", "", $fileName); | |
$fileName = str_replace("*", "", $fileName); | |
return $fileName; | |
} |
2015/02/24
How to perform login to onet.pl using curl php ?
Download this library
https://github.com/php-curl-class/php-curl-class
It may need some changes so you can download this working lib
https://drive.google.com/file/d/0Bw4oKsVETs62ZEdTNzJqcV9OVnM/view?usp=sharing
version with appropriate changes made by me and check below example:
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
public static function curlOnetLogin(){ | |
$url = 'https://konto.onet.pl/login.html?app_id=poczta.onet.pl.front'; | |
$login = 'YOUR_LOGIN@onet.pl'; | |
$password = 'YOUR_PASSWORD'; | |
$f = fopen('onet_request.txt', 'a+'); | |
fwrite($f, "\n==========\n[".date("Y-m-d H:i:s", time())."]\n"); | |
// open login page and save cookies | |
$curl = new curl(); | |
$cookieName = dirname(__FILE__).'/onetCookie.txt'; | |
$curl -> setCookieFile($cookieName); | |
$curl -> setOpt(CURLOPT_COOKIEFILE, $cookieName); | |
$curl -> setOpt(CURLOPT_STDERR, $f); | |
$curl -> setOpt(CURLOPT_VERBOSE, true); | |
$curl -> setOpt(CURLOPT_SSL_VERIFYPEER, false); | |
$curl -> setOpt(CURLOPT_SSL_VERIFYHOST, false); | |
$curl -> setOpt(CURLOPT_FOLLOWLOCATION, true); | |
$curl -> setOpt(CURLOPT_RETURNTRANSFER, true); | |
$curl -> setOpt(CURLOPT_TIMEOUT, 30); | |
$curl -> setOpt(CURLOPT_URL, $url); | |
$pageContent = $curl -> exec(); | |
while($curl -> response_headers['Location']){ | |
$curl -> setOpt(CURLOPT_URL, $curl -> response_headers['Location']); | |
$curl -> exec(); | |
} | |
// perform login | |
$curl -> setOpt(CURLOPT_POST, true); | |
$curl -> setOpt(CURLOPT_URL, $url); | |
$curl -> setOpt(CURLOPT_POSTFIELDS, http_build_query( array( | |
'noscript' => true, | |
'login' => $login, | |
'password' => $password, | |
'perm' => 0, | |
'perm' => 1, | |
'provider' => "", | |
'access_token' => "", | |
'referrer' => "", | |
'cookie' => 'onet_ubi, onetzuo_ticket, onet_cid, __gfp_64b, onet_cinf, onet_sid, __utma, __utmc, __utmz, __utma, __utmc, __utmz, onet_uoi, onet_crt_adtech', | |
'script' => 226, | |
'adblock' => 1 | |
), '', '&')); | |
$pageContent = $curl -> exec(); | |
fclose($f); | |
return $pageContent; | |
} |
2015/02/04
Email validation with regulara expressions 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
static string cutEmail(string str) | |
{ | |
string email = null; | |
Regex rx = new Regex(@"(?<email>[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3})))", RegexOptions.None); | |
Match match = rx.Match(str); | |
if (match.Success) | |
email = match.Groups["email"].Value; | |
return email; | |
} |
2015/01/07
How to sort list of object by property with linq 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
class Person | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
} | |
List<Person> list = new List<Person>(); | |
list.Add(new Person() { FirstName = "Mike", LastName = "Smith" }); | |
list.Add(new Person() { FirstName = "John", LastName = "Fiolkowsky" }); | |
list.Add(new Person() { FirstName = "Andrew", LastName = "Dawson" }); | |
list.Sort((p1, p2) => p1.LastName.CompareTo(p2.LastName)); |
Subscribe to:
Posts (Atom)