Skip to content

Instantly share code, notes, and snippets.

View ddikman's full-sized avatar

David Dikman ddikman

View GitHub Profile
@ddikman
ddikman / ShortenStringExtension.cs
Created September 15, 2016 02:42
Helper extension method to cut a string down to a certain length.
public static class ShortenStringExtension
{
public static string Shorten(this string input, int maxLength)
{
if (string.IsNullOrEmpty(input))
return input;
return input.Length <= maxLength ? input : input.Substring(0, maxLength);
}
}
@ddikman
ddikman / AddingTrustedRanges.ps1
Created November 15, 2016 09:43
Rework/addition to the AddingTrustedSites.ps1 from Microsoft. Adds the specified IP ranges to trusted sites in Internet Explorer.
#---------------------------------------------------------------------------------
# This script is an addition to the AddingTrustedRanges.ps1 script provided by Microsoft
#---------------------------------------------------------------------------------
#requires -version 2.0
<#
.SYNOPSIS
The PowerShell script which can be used to add trusted IP ranges in Internet Explorer.
.DESCRIPTION
@ddikman
ddikman / conflu-table-links.html
Created June 13, 2017 05:36
Javascript snippet to iterate confluence table rows and create anchor links for each row
@ddikman
ddikman / anchor-headers.html
Created July 18, 2017 11:18
Small script to anchor headers on a page and highlight them if linked to.
<script type="text/javascript">
// add linked anchors to all the headers
jQuery("#content h1, #content h2, #content h3").each(function(e){
var header = jQuery(this);
var text = header.text();
@ddikman
ddikman / modify_time.sh
Created May 3, 2018 03:24
Helper to offset timezone of files in OSX.
#!/bin/bash
# Helper to modify a file modification date in case timezone is wrong.
# I noticed that when moving files from my camera whilst travelling the time zone was off and needed to bulk adjust them.
# Written and tested on osx bash, in GNU this script is superfluous since touch can do a relative -d '-2 hours' flag which osx shell doesn't support..
set -euo pipefail
SCRIPT_NAME=`basename "$0"`
# helper to log to stderr
@ddikman
ddikman / logstash-example.conf
Last active June 19, 2018 16:47
Example of a filebeat to logstash to elasticsearch config
input {
beats {
port => 9300
type => beats
}
}
filter {
grok {
match => { "message" => "%{TOMCAT_DATESTAMP:DATETIME} \[%{WORD:level}\]%{SPACE}%{GREEDYDATA:message}" }
overwrite => [ "message" ]
const fs = require('fs')
const exec = require('child_process').execSync
// SUMMARY:
// This simple script uses gtranslate npm cli tool to translate an input file
// of countries in json format to another format with translated country names
// the expected input would be [ { "country": "name" } ]
let inputCountries = JSON.parse(fs.readFileSync('countries.json'))
<script type="text/javascript">
// This is a modified version of the script Davin Studer from
// http://iamdav.in/2014/10/24/bookmarklet-creating-csv-html-table/
// I added in a BOM mark to allow for non-english table contents export as well as
// wrapped it in a script snippet to be appended at them end of a confluence page in a html block
function downloadCSVFile(filename, mime, text) {
if (window.navigator.msSaveOrOpenBlob){
// IE 10+
var blob = new Blob([decodeURIComponent(encodeURI(text))], {
type: 'text/csv;charset=utf-8'
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1" width="450">
<label t="translate(0,346)">
@ddikman
ddikman / loading_overlay.dart
Created July 25, 2020 06:49
A brief overlay progress spinner to use for async functions
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LoadingOverlay {
BuildContext _context;
void hide() {
Navigator.of(_context).pop();
}