Skip to content

Instantly share code, notes, and snippets.

View HeathHopkins's full-sized avatar

Heath Hopkins HeathHopkins

View GitHub Profile
@HeathHopkins
HeathHopkins / ValueConverterGroup.cs
Created February 23, 2018 13:37 — forked from QiMata/ValueConverterGroup.cs
Reuse converters by chaining them together with a custom converter.
public class ValueConverterGroup : List<IValueConverter>, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
@HeathHopkins
HeathHopkins / ResizeWithSkia.cs
Created March 22, 2018 01:09 — forked from xoofx/ResizeWithSkia.cs
Resize an image and draw some overlay text with SkiaSharp
// You need to configure your C# project with x86 or x64 platform (Tools\Configuration Manager\Create new Platform on the project)
// otherwise the native libSkiaSharp.dll will not get copied
using System;
using System.IO;
using SkiaSharp;
namespace TestSkia
{
class Program
{
@HeathHopkins
HeathHopkins / bulk.cs
Created October 10, 2018 16:10 — forked from felipensp/bulk.cs
Oracle bulk insert for Dapper .NET
private static int OracleBulkExecuteImpl<T>(this IDbConnection cnn, ref CommandDefinition command)
{
object param = command.Parameters;
IEnumerable multiExec = GetMultiExec(param);
Identity identity;
CacheInfo info = null;
if (multiExec != null)
{
int total = 0;
bool wasClosed = cnn.State == ConnectionState.Closed;
@HeathHopkins
HeathHopkins / delete_all.sql
Created November 13, 2018 15:51 — forked from mmattozzi/delete_all.sql
Delete all objects in an Oracle Schema
BEGIN
FOR cur_rec IN (SELECT object_name, object_type
FROM all_objects
WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE') AND
owner = '<schema_name>')
LOOP
BEGIN
IF cur_rec.object_type = 'TABLE' THEN
EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' "' || cur_rec.object_name || '" CASCADE CONSTRAINTS';
ELSE
@HeathHopkins
HeathHopkins / README-tomcat-as-systemd-service.md
Created August 13, 2019 13:13 — forked from drmalex07/README-tomcat-as-systemd-service.md
An example configuration for Tomcat as systemd service. #tomcat #systemd #systemd.service

README

Let Tomcat is download and installed under /opt/tomcat. Also, let tomcat be a non-provileged user under which the server will be running.

We assume that we keep server's binaries under /opt/tomcat and we will create a server instance named foo under /var/tomcat/ (carrying its own conf, logs, webapps, work, lib directories). See also https://dzone.com/articles/running-multiple-tomcat.

Create a template service unit file at /etc/systemd/system/[email protected]:

@HeathHopkins
HeathHopkins / JS-LINQ.js
Created January 31, 2020 20:54 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@HeathHopkins
HeathHopkins / use-nprogress.js
Created June 13, 2020 23:59 — forked from sergiodxa/use-nprogress.js
Hook to use NProgress in a Next.js application
import { useRef, useEffect } from "react";
import NProgress from "nprogress";
import Router from "next/router";
function useNProgress(showAfterMs = 300, options = {}) {
const timer = useRef(null);
function routeChangeStart() {
const { showAfterMs } = this.props;
clearTimeout(timer.current);
@HeathHopkins
HeathHopkins / mysql-docker.sh
Created July 10, 2020 20:12 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@HeathHopkins
HeathHopkins / ubuntu-vnc-activate-remote.sh
Created April 9, 2021 13:04 — forked from samba/ubuntu-vnc-activate-remote.sh
Activate VNC support in Ubuntu, from command-line (for active sessions)
#!/bin/sh
# This assumes you have access to the system via SSH already, and need
# remote VNC access as the same user, and you want only the primary display.
export DISPLAY=:0
# Encoded password with http://www.motobit.com/util/base64-decoder-encoder.asp
export VNC_PASSWORD="dm5jX3Bhc3N3b3JkNzE=" # vnc_password71
export VNC_PASSWORD="dm5jX3Bhc3M=" # vnc_password (a character limit is enforced?)
# Sadly many common VNC clients don't support encryption.
@HeathHopkins
HeathHopkins / Python3 Virtualenv Setup.md
Created March 3, 2022 21:47 — forked from pandafulmanda/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3