[C#] Convert Secure String to String

This snippet describes code to convert a secure string into a regular string. Be cautious in it's use.
new System.Net.NetworkCredential(string.empty, "SECURE_STRING_VARIABLE").Password

Интеграция с Битрикс24

Автоматическое создание лидов в Битрикс24 при помощи входящего вебхука. https://gettotop.ru/crm/bitrix24-lidy-s-sajta-avtomaticheskoe-sozdanie-lidov/
для организации автоматической передачи лидов при помощи вебхуков необходимо:

1. Создать входящий вебхук.
2. Написать короткий код для перехвата и передачи данных.

Создать в Битрикс хук. Дать права на доступ к CRM.

Получить код авторизации вебхука.

Получить идентификатор пользователя для создания (лида).

Count storypoints in Jira

(function() {
    'use strict';

    function setColumnPoints(){
                var totalPoints = [];
       jQuery('.ghx-swimlane').each(function(index, swimlane){
            jQuery(swimlane).find('.ghx-columns li').each(function(index, column) {
                var points = 0;
                jQuery(column).find('[title="Story Points"]').each(function(index) {
                    var point = parseFloat(jQuery(this).text());
                    if(!isNaN(parseFloat(point)))
                        points += point;
                });
                totalPoints[index] = totalPoints[index] === undefined ? points : totalPoints[index] + points;
            })
        })
        $('.ghx-column-title').each(function(index) {
                                    jQuery("#ghx-estimate"+index+1).remove();
            jQuery(this).after('<aui-badge class="ghx-estimate f-estimate" id="ghx-estimate'+index+1+'">'+ totalPoints[index] +'</aui-badge>');
        })
                }

    setInterval

Obs map OK

    this.textures$ = this.referenceService.getMedicalTextures()
    .pipe(
      tap(test => console.log('test', test)),
      map(t => { return t.map(t => new Reference({...t, icon : `http://localhost:3000 ${t.icon}`}); })
    );

Wayback Machine

/* Wayback Machine , Website history , Deleted website show */
https://web.archive.org

PACT contract testing local setup

1. Setup consumer code (mock provider, pact test, interactions)
2. Spin up real provider instance (e.g. pph-svc-challenge, need to do: npm run dev)
3. Start up local DB, run: npm run set-up database
4. Seed the data using pph-seed-data

Cycle of writing tests 
- In consumer repo (e.g. h365-bff), run: npm run pact:create-pacts
- In consumer repo (e.g. h365-bff), run: npm run pact:publish:local
- Go to pph-svc-api-test, run: npm run pact:verify:local 

==================================================
seed-data-fixture-local.sh
==================================================

#!/usr/bin/env bash

set -eu

ENV="${1}"
DATABASE="${2}"

AVAILABLE_ENVS="development sit uat prod"

if [[ ! ${AVAILABLE_ENVS} =~ (^|[[:space:]])"$ENV"($|[[:space:]]) ]]; then
    echo "$ENV is not an available environment"
    exit 1
fi

USERNAME="bamboo_${DATABASE}_db_username_secret"
PASSWORD="bamboo_${DATABASE}_db_password"
BAMBOO_DATABASE="bamboo_${DATABASE}_db"
# Option -x exports the variable after it is 

Start Date to End Date bitween Dates List

<?php
$period = new DatePeriod(
    //yy-mm-dd
     new DateTime('2020-01-01'),    // Start Date
     new DateInterval('P1D'),
     new DateTime('2020-12-31')     // End Date
);

//Which should get you an array with DateTime objects. 

//To iterate
$bitweenDate = [];

foreach ($period as $key => $value) {
    $bitweenDate[] = $value->format('Y-m-d');
}

echo "<pre>";
print_r($bitweenDate);




/*
::OUTPUT::

Array
(
    [0] => 2020-01-01
    [1] => 2020-01-02
    [2] => 2020-01-03
    [3] => 2020-01-04
    [4] => 2020-01-05
    [5] => 2020-01-06
    [6] => 2020-01-07
    [7] => 2020-01-08
    [8] => 2020-01-09
    [9] => 2020-01-10
    [10] => 2020-01-11
    [11] => 2020-01-12
    [12] => 2020-01-13
    [13] => 2020-01-14
    [14] => 2020-01-15
    [15] => 2020-01-16
    [16] => 2020-01-17
    [17] => 2020-01-18
    [18] => 2020-01-19
    [19] => 2020-01-20
    [20] => 2020-01-21
    [21] => 2020-01-22
    [22] => 2020-01-23
    [23] => 2020-01-24
    [24] => 2020-01-25
    [25] => 202

Warning: require(): failed to open stream: No such file or directory in ../public/index.php on line 24


Warning: require(/opt/lampp/htdocs/teedu-api/public/../vendor/autoload.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/teedu-api/public/index.php on line 24

Fatal error: require(): Failed opening required '/opt/lampp/htdocs/teedu-api/public/../vendor/autoload.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/teedu-api/public/index.php on line 24






Solution

1. vendor not found  (composer install)

Изменение количества выводимых на странице постов через function.php

add_action('pre_get_posts', 'hwl_home_pagesize', 1 );
function hwl_home_pagesize( $query ) {
	// Выходим, если это админ-панель или не основной запрос.
	if( is_admin() || ! $query->is_main_query() )
		return;

	if( is_home() ){
		// Выводим только 1 пост на главной странице
		$query->set( 'posts_per_page', 1 );
	}

	if( $query->is_post_type_archive('movie') ){
		// Выводим 50 записей если это архив типа записи 'movie'
		$query->set( 'posts_per_page', 50 );
	}
}

ANTs registration example

antsRegistrationSyNQuick.sh \
  -d 3 \
  -f ${fixed} \
  -m ${moving} \
  -t s \
  -o ${out}_ \
  -n 16
antsApplyTransforms \
  -d 3 \
  -r ${fixed} \
  -i ${moving}.nii.gz \
  -e 0 -t ${out}_1Warp.nii.gz \
  -t ${out}_0GenericAffine.mat \
  -o ${out}.nii.gz

new&delete

动态分配内存与释放内存
#include<iostream>

int main()
{
	int i;
	int* p = nullptr;
	int* q{ nullptr };		//C++11 initializer list

	p = new int(520);
	q = new int[4];

	std::cout << *p << std::endl;

	for (i = 0; i < 4; i++)
	{
		std::cin>>*(q+i);
	}

	for (i = 0; i < 4; i++)
	{
		std::cout << *(q + i) << std::endl;
	}

	delete p;
	delete[]q;

	return 0;
}

Upload File to Google Drive Using Service Account Credentials

Used Google API and PyDrive module.
import logging
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from oauth2client.service_account import ServiceAccountCredentials

folder_id = 'YOUR FOLDER ID HERE'

def get_google_drive():
    gauth = GoogleAuth()
    api_scope = ['https://www.googleapis.com/auth/drive']
    json_file = 'service.json'
    gauth.credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file, api_scope)
    return GoogleDrive(gauth)


def send_text_file_to_google_drive(filename, file_content):
    drive = get_google_drive()
    _file = drive.CreateFile({'title': filename, 'parents': [{'id': folder_id}]})
    _file.SetContentString(file_content)
    _file.Upload()  # Upload the file.
    logging.debug('title: %s, id: %s' % (_file['title'], _file['id']))


def send_media_file_to_google_drive(filename):
    drive = get_google_drive()
    _file = drive.CreateFile({'parents': [{'id': folder_id}]})
    _file.SetContentFile(filename)
    _file.Uplo

Useful links

List of React hooks
https://reactjs.org/docs/hooks-reference.html

Simple Code Reuse with React Hooks
https://blog.bitsrc.io/simple-code-reuse-with-react-hooks-432f390696bf

Northwind Veritabanı

# Northwind Veritabanı
[instnwnd.zip](https://cdn.cacher.io/attachments/u/3dl5vny71p617/0JlLqydolrfhl2muDwzyj8mhABI3MFkq/instnwnd.zip)

SQL Server Notlarım

# SQL Notlarım
[sql notlarim.sql](https://cdn.cacher.io/attachments/u/3dl5vny71p617/nfgdKpkCBo1drwF4jDBMemXUtT0jFk2Y/sql_notlarim.sql)

Katmanlı Mimari

Burada uygulamanın GUI kısmı haricinde 3 farklı class library yer alıyor.

Bunlardan en alt kısımda, veritabanımızda ki modellerin tanımlandığı ProjeAdi.Entity class library bulunmaktadır.
Tabloya karşılık gelen modelleri bu yapının içerisinde bulundururuz.

Bir sonra ki katman ise DataAccess. Bu katmanda ise migration gibi işlemler yapılır.
DbContext sınıfıda bu katman içerisinde tutulur.
İçerisinde 2 farklı klasör bulunmaktadır. Abstract ve Concrete.
Abstract klasörü Interface dosyalarını tutarken, Concrete klasöründe ise bu Interface yapısını/yapılarını implement eden sınıfları buluruz.
Bu katmanda, Concrete içerisinde ki Repository sınıfında metodlar doldurulur.
Sınıfı doldurken (CI) gerekmez.

Bir üst katman ise Business katmanıdır. Bu katmanda bir alt katmandakine benzer.
Concrete ve Abstract klasörleri yer alır. 
Abstract içerisinde ki Interface, Data katmanında ki Interface ile aynıdır.
Ancak repository sınıfı düz işlemler yerine çeşitli kurallar içerebilir.
Genel olarak reposi