Skip to content

Instantly share code, notes, and snippets.

View joeblack3108's full-sized avatar
🎯
Focusing

bunkovdenis joeblack3108

🎯
Focusing
View GitHub Profile
// draft / create simple project
public class WcfClientService<TProxy>
{
private static ChannelFactory<TProxy> channelFactory = new ChannelFactory<TProxy>("*");
public static TResult GetData<TResult>(Func<TProxy, TResult> codeBlock)
{
channelFactory.Endpoint.EnableChannelFactoryLog();
// draft
// required amplify
// required knockout
(function(ko) {
// for observableArray()
ko.extenders.localArrayStore = function(target, key) {
var value = amplify.store(key) || target();
//track the changes
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// this method call for each element on page
var webBrowser = sender as WebBrowser;
if (webBrowser != null && e.Url.AbsolutePath != webBrowser.Url.AbsolutePath)
return; // not ready
// ready!
}
using mshtml;
// C# 6+
public static void WebBrowserFindSelectAndScroll(WebBrowser webBrowser, string searchString)
{
// you can add check page load complette, if needed
IHTMLDocument2 document = webBrowser.Document?.DomDocument as IHTMLDocument2;
IHTMLTxtRange range = document?.selection.createRange() as IHTMLTxtRange;
if (range == null) return;
public static class HtmlRemoval
{
static readonly Regex TagsRegex = new Regex("<.*?>", RegexOptions.Compiled);
static readonly Regex ElementsRegex = new Regex("&.*?;", RegexOptions.Compiled);
/// <summary>
/// Remove <p> <br> ect
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public void OpenFileInWord(string wordFile, string searchText = null)
{
Application wordObject = GetWordApplication();
object file = wordFile;
Document thisDoc = wordObject.Documents.Open(ref file);
if (!string.IsNullOrEmpty(searchText))
{
// find, select and scroll
@joeblack3108
joeblack3108 / gist:87972083d088f5fb9487
Created July 17, 2015 12:15
jquery inputmask with knockoutjs
// jquery inputmask with knockoutjs
// mask always appiled like "+7 999 123 45 67"
// but submited unmasked value "9991234567"
ko.bindingHandlers.masked = {
init: function (element, valueAccessor, allBindingsAccessor) {
var mask = allBindingsAccessor().mask || {};
$(element).inputmask({ "mask": mask, 'autoUnmask': false });
ko.utils.registerEventHandler(element, 'focusout', function () {
var value = $(element).inputmask('unmaskedvalue');
@joeblack3108
joeblack3108 / targetNamespaceExample.xsd
Created April 24, 2014 07:58
targetNamespaceExample.xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://bunkovdenis.com"
targetNamespace="http://bunkovdenis.com" elementFormDefault="qualified">
<element name="РеестрДокументов" >
<complexType>
<sequence maxOccurs="unbounded">
<element ref="tns:Документ"/>
</sequence>
<attribute name="НомерРеестра" type="string" use="optional"/>
<attribute name="ДатаРеестра" type="date" use="optional"/>
@joeblack3108
joeblack3108 / linqpad AsExpandable() example 1.cs
Created April 8, 2014 11:04
linqpad AsExpandable Example.cs
Expression<Func<Operations, bool>> coverLimit = o => o.Discriminator == "CoverLimitOperation";
Expression<Func<Operations, bool>> financing = o => o.Discriminator == "FinancingOperation";
Deliveries.AsExpandable()
.Where(x => x.DeliveryOperations.Where(coverLimit.Compile()).Any(t => t.Value > 0))
.Where(x => !x.DeliveryOperations.Any(financing.Compile()))
.Dump();
@joeblack3108
joeblack3108 / gist:9617172
Last active August 29, 2015 13:57
EF Logs Example SQL.sql
SELECT
[Extent1].[EmailLogId] AS [EmailLogId],
[Extent1].[SentDate] AS [SentDate],
[Extent1].[Email] AS [Email],
[Extent1].[Name] AS [Name],
[Extent1].[Subject] AS [Subject],
[Extent1].[Body] AS [Body],
[Extent1].[ErrorMessage] AS [ErrorMessage]
FROM [dbo].[EmailLogs] AS [Extent1]
WHERE (N'my@company.com' = [Extent1].[Email]) AND ([Extent1].[Email] IS NOT NULL)