Skip to content

Instantly share code, notes, and snippets.

@stantoxt
stantoxt / docx2md.md
Created September 29, 2019 06:19 — forked from vdavez/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in Two Moves

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

The Solution

As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.

@stantoxt
stantoxt / WSL-ssh-server.md
Created December 14, 2019 14:46 — forked from dentechy/WSL-ssh-server.md
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@stantoxt
stantoxt / wsl-redis-start.md
Created December 14, 2019 14:48 — forked from cromat/wsl-redis-start.md
Run redis inside WSL as background service on Windows startup

Step by step guide to run redis-server inside WSL(Windows Subsystem for Linux) on Windows

I have tried to setup redis as starting background task with wsl-autostart, Task Scheduler and with lot vbs scripts including one described here but none of them seemed to work.

In the end I have manually created a simple one that does the job. This script basically starts a hidden Ubuntu Window and starts redis-server inside it.

  1. Install WSL (this is tested with Ubuntu 18.04 version)
  2. Install redis-server inside WSL sudo apt install redis-server
  3. Add sudo permission to your user to execute service command without password
@stantoxt
stantoxt / MimeTypeLookup.cs
Created February 28, 2020 19:05 — forked from ChristianWeyer/MimeTypeLookup.cs
.NET MIME type lookup - 1200 well known MIME types in a C# helper class - thx to https://github.com/PawelGerr !
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
/*
MIT License
Copyright (c) 2014 Christian Weyer
@stantoxt
stantoxt / mime.html
Created February 29, 2020 04:55 — forked from topalex/mime.html
How to check real mime type of image in javascript
<html>
<head>
<script type="text/javascript" src="/jquery.min.js"></script>
<title>Mime type checker</title>
<script>
$(function () {
var result = $('div#result');
if (window.FileReader && window.Blob) {
$('span#submit').click(function () {
var files = $('input#file').get(0).files;
@stantoxt
stantoxt / package.json
Created March 20, 2020 18:25 — forked from adamreisnz/package.json
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",
@stantoxt
stantoxt / walksync.js
Created March 21, 2020 15:11 — forked from kethinov/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(dir + file).isDirectory()) {
filelist = walkSync(dir + file + '/', filelist);
}
else {
@stantoxt
stantoxt / detectBrowserLanguage.js
Created June 2, 2020 06:21 — forked from leipert/detectBrowserLanguage.js
Detect browser language in javascript (utilizing lodash)
// These window.navigator contain language information
// 1. languages -> Array of preferred languages (eg ["en-US", "zh-CN", "ja-JP"]) Firefox^32, Chrome^32
// 2. language -> Preferred language as String (eg "en-US") Firefox^5, IE^11, Safari,
// Chrome sends Browser UI language
// 3. browserLanguage -> UI Language of IE
// 4. userLanguage -> Language of Windows Regional Options
// 5. systemLanguage -> UI Language of Windows
var browserLanguagePropertyKeys = ['languages', 'language', 'browserLanguage', 'userLanguage', 'systemLanguage'];
@stantoxt
stantoxt / chrome_39.js
Created June 2, 2020 06:21 — forked from ksol/chrome_39.js
Language detection in javascript
window.navigator.language // -> "fr"
window.navigator.languages // -> ["fr-FR", "fr", "en-US", "en", "es", "de"]
window.navigator.userLanguage // -> undefined
window.navigator.browserLanguage // -> undefined
window.navigator.systemLanguage // -> undefined
@stantoxt
stantoxt / gist:2d1f01a5fd443c903efa465d80052a09
Created July 1, 2020 09:04 — forked from RuanAragao/gist:7343846
Alternative Javascript WYSIWYG editors
h2. Lightweight versions
* PunyMCE, from the authors of TinyMCE "http://github.com/spocke/punymce":http://github.com/spocke/punymce
* NicEdit "http://nicedit.com/":http://nicedit.com/
* WysiHat (Prototype) "http://github.com/37signals/wysihat":http://github.com/37signals/wysihat
* widgEditor "http://code.google.com/p/widgeditor/":http://code.google.com/p/widgeditor/
* WYMeditor (jQuery) "http://www.wymeditor.org/":http://www.wymeditor.org/
* jWYSIWYG (jQuery) "http://code.google.com/p/jwysiwyg/":http://code.google.com/p/jwysiwyg/
* ggEdit (MooTools) "http://code.google.com/p/ggedit/":http://code.google.com/p/ggedit/
* YUI Rich Text Editor - SimpleEditor (YUI) "http://developer.yahoo.com/yui/editor/":http://developer.yahoo.com/yui/editor/