Skip to content

Instantly share code, notes, and snippets.

View liamkernighan's full-sized avatar
🎯
Focusing

liamkernighan

🎯
Focusing
View GitHub Profile
@liamkernighan
liamkernighan / AppDbContext.cs
Last active January 3, 2022 20:02
Entity Framework Bot State for Bot Framework SDKv4 (to store in SQL database IStorage implementation)
namespace DAL
{
public class AppDbContext : DbContext
{
private readonly string defaultConnectionString;
#region tables
public DbSet<EFBotState> BotStates { get; set; }
@liamkernighan
liamkernighan / RawSqlRepository.cs
Last active March 7, 2019 20:35
How to Entity Framework SqlQuery with a List of parameters
namespace Persistence.Store.SqlRepositories
{
public class RawMsSqlRepository : DbContextManipulator, IRawSqlRepository
{
public RawMsSqlRepository(string connectionString) : base (connectionString)
{
}
public T[] Query<T>(string sqlText, Dictionary<string, object> parametersDict)
@liamkernighan
liamkernighan / LoginActivity.kt
Last active February 8, 2020 11:31
LiveData MVI example
package com.nasladdin.partner.activities.login
import android.os.Bundle
import android.view.KeyEvent
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.nasladdin.partner.R
import com.nasladdin.partner.helpers.SnackbarFacade
package com.nasladdin.partner.services;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
package com.my.program; // сначала пэкэдж
import java.util.*; // Потом глобальные импорты
import java.system.*;
import com.my.program.animals.Animal; // Через пустую строку локальные импорты
import com.my.program.animals.CanWalk;
class Cat extends Animal implements CanWalk {
@liamkernighan
liamkernighan / StoreBase.kt
Created February 26, 2020 10:09
Coroutine exception handler
package com.nasladdin.partner.boilerplate
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import kotlinx.coroutines.*
import java.lang.Exception
import kotlin.coroutines.CoroutineContext
import { useTheme } from '@material-ui/core';
import { observer } from 'mobx-react';
import * as React from 'react';
import Select from 'react-select';
import { ValueType } from 'react-select/src/types';
import { SelectedOption, SelectorProps } from './Types';
type Props = SelectorProps & {
required?: boolean;
@liamkernighan
liamkernighan / AndroidCommunicator.d.ts
Created April 23, 2020 09:25
Android + WebView communication example
declare module 'AndroidCommunicator' {
global {
interface Window {
Android: AndroidCommunicator | undefined;
}
type AndroidCommunicator = {
setCallbackExists: (v: boolean) => void;
reload: () => void;
@liamkernighan
liamkernighan / CPCard.ts
Last active September 15, 2020 14:23
Криптограмма CloudPayments
import forge from 'node-forge'
export class CPCard {
private static readonly _pubKey = '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArBZ1NNjvszen6BNWsgyDUJvDUZDtvR4jKNQtEwW1iW7hqJr0TdD8hgTxw3DfH+Hi/7ZjSNdH5EfChvgVW9wtTxrvUXCOyJndReq7qNMo94lHpoSIVW82dp4rcDB4kU+q+ekh5rj9Oj6EReCTuXr3foLLBVpH0/z1vtgcCfQzsLlGkSTwgLqASTUsuzfI8viVUbxE1a+600hN0uBh/CYKoMnCp/EhxV8g7eUmNsWjZyiUrV8AA/5DgZUCB+jqGQT/Dhc8e21tAkQ3qan/jQ5i/QYocA/4jW3WQAldMLj0PA36kINEbuDKq8qRh25v+k4qyjb7Xp4W2DywmNtG3Q20MQIDAQAB\n-----END PUBLIC KEY-----'
private static readonly _keyVersion = '04'
private constructor(
private _number: string,
@liamkernighan
liamkernighan / ISO8601.ts
Created May 25, 2020 10:20
ISO8601 JS tester
constructor(props: object) {
super(props)
console.log(this.isISO8601('1'))
console.log(this.isISO8601('2020-08-01T00:00:00Z'))
console.log(this.isISO8601('2020-08-01T00:00:00.000345Z'))
console.log(this.isISO8601('2020-06-08T00:01:01+05:59'))
}