Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jon Knopp jknopp

🏠
Working from home
View GitHub Profile
@jknopp
jknopp / DebugService.cs
Last active Feb 5, 2021
Determine if running in DEBUG mode
View DebugService.cs
public interface ISystemService
{
bool IsRunningInDebugMode();
}
public class SystemService : ISystemService
{
private bool _debugging;
public bool IsRunningInDebugMode()
@jknopp
jknopp / DataTableExtensions.cs
Last active Feb 2, 2021
Helpful DataRow/DataTable Extensions
View DataTableExtensions.cs
public static class DataTableExtensions
{
public static List<T> ToList<T>(this DataTable table) where T : new()
{
IList<PropertyInfo> properties = typeof(T).GetProperties().ToList();
List<T> result = new List<T>();
foreach (var row in table.Rows)
{
var item = CreateItemFromRow<T>((DataRow)row, properties);
@jknopp
jknopp / index.js
Created Jan 6, 2021
Example Webpack config
View index.js
// https://github.com/PButcher/flipdown
import { FlipDown } from 'flipdown';
View .zshrc
# https://youtube.com/c/cognitivesurge
export ZSH="/Users/karl/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(
git
bundler
dotenv
osx
View kitty.conf
# setup font settings
font_family FuraCode Nerd Font
font_size 18.0
# no bells. Ever.
enable_audio_bell no
bell_on_tab no
# default layout is vertical splits only
enabled_layouts splits
@jknopp
jknopp / index.js
Created Dec 12, 2020
Randomly Select Item from Array Based on Frequency
View index.js
// Define our array of object we want to randomly select from
const fallingItems =
[{
id: 1,
value: 150,
image: 'rare.png',
velocity: 5000,
size: 60
},
{
@jknopp
jknopp / settings.json
Created Dec 4, 2020 — forked from chrisdias/settings.json
Chris Dias' settings.json for VS Code
View settings.json
{
/*
USER (GLOBAL) SETTINGS
~/Library/Application Support/Code-Insiders/User/settings.json
*/
/*
***************
*** WARM UP ***
***************
@jknopp
jknopp / sqlpackage.md
Created Oct 22, 2020 — forked from anova/sqlpackage.md
Sqlpackage.exe samples
View sqlpackage.md

Export

Creates a .bacpac file from live database.

"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /a:Export /scs:"Data Source=SERVER;Initial Catalog=db_name;Integrated Security=False;Persist Security Info=False;User ID=db_user;Password=db_password" /tf:"D:\backup\database_backup.bacpac"

Import

Import from .bacpac file to database.

@jknopp
jknopp / webpack.config.js
Created Jul 28, 2020 — forked from versedi/webpack.config.js
Webpack Encore + Sass + MiniCSSExtractPlugin + PurgeCSS + OptimizeCss + Babel + Typescript
View webpack.config.js
/* eslint-disable no-useless-escape */
const Encore = require('@symfony/webpack-encore');
const TerserPlugin = require('terser-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const HtmlCriticalWebpackPlugin = require('html-critical-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PurgeCssPlugin = require('purgecss-webpack-plugin');
const WebpackBar = require('webpackbar');
const path = require('path');
@jknopp
jknopp / ValueInjecterExtensions
Created Sep 6, 2019 — forked from Ablecken/ValueInjecterExtensions
ValueInjecter Create Type On Inject
View ValueInjecterExtensions
using System;
using Omu.ValueInjecter;
namespace Infrastructure.Extensions
{
public static class ValueInjecterExtensions
{
/// <summary>
/// Will create a new instance of TResult, then inject from object
/// </summary>