Skip to content

Instantly share code, notes, and snippets.

View blacktaxi's full-sized avatar
🇺🇦
russia is a terrorist state, russians are a terrorist nation

Serhii Yavnyi blacktaxi

🇺🇦
russia is a terrorist state, russians are a terrorist nation
View GitHub Profile
@blacktaxi
blacktaxi / webkit-speech-recognition.js
Created April 17, 2017 00:24
webkitSpeechRecognition API usage example
// copy-paste this into a Chrome new tab console and allow mirophone input
// when prompted
var r = new webkitSpeechRecognition()
r.continuous = true
r.interimResults = true
r.onresult = e =>
console.log(
[...e.results].map(
@blacktaxi
blacktaxi / .gitconfig
Created March 23, 2017 23:49
git alias for tagging commits with Jira ticket IDs
[alias]
# commit with Jira ticket ID tag in commit message.
# current branch name has to start with a valid Jira ticket ID, in upper case.
c = "!f() { \
if [[ -z $1 ]]; \
then \
echo "Error: No commit message provided."; \
exit 1; \
else \
local ticketId=$(git rev-parse --abbrev-ref HEAD | grep -Eo "^[A-Z]+-[0-9]+"); \
@blacktaxi
blacktaxi / gist:aa8a9190d8eff09b1847
Created March 22, 2013 23:03
Scala, pattern matching and Seq <-> List variance.
scala> def withList[T](x: List[T]) = x match { case Seq(1, 2, 3) => 1 }
withList: [T](x: List[T])Int
scala> withList(List(1, 2, 3))
res6: Int = 1
scala> withList(Seq(1, 2, 3))
<console>:9: error: type mismatch;
found : Seq[Int]
required: List[?]
@blacktaxi
blacktaxi / psc-ide-0.8.2.md
Last active March 11, 2016 18:55
Fixing IDE support for PureScript 0.8.2

PureScript includes the IDE tools (psd-ide-server, psc-ide-client) with the compiler package since 0.8.2. The purescript package on npm for version 0.8.2 doesn't ship with psc-ide-* executables. So if you're using PureScript by globally installing it from npm (npm install -g purescript), you may find that your editor integration will not work. To fix this, you'll need to build and install PureScript from sources. It can be a pain to use Cabal for this, so we will use Stack. But since PureScript has not updated to 0.8.2 yet in the LTS Stackage, we will need to tweak the stack's global config a bit.

  1. Uninstall npm installation of PureScript: npm uninstall purescript
  2. Install Stack
  3. In your ~/.stack/global/stack.yaml, add this line: extra-deps: ["purescript-0.8.2.0"]
  4. Run stack install purescript
  5. Check that it worked by running psc --version, psc-ide-server.
@blacktaxi
blacktaxi / UncaughtTypeError.elm
Last active February 26, 2016 17:55
Uncaught TypeError with Maybe recursion in Elm
-- This gives an 'Uncaught TypeError: three is not a function' at runtime, when
-- ran in the view function of a start-app app (probably irrelevant).
-- A better error message would certainly help.
one = Just <| three ()
two = one |> Maybe.map identity
three () = two |> Maybe.map (always ())
@blacktaxi
blacktaxi / elm-package-install.py
Created January 16, 2016 18:21
elm-package install that works in Docker
#!/usr/bin/env python2.7
import tempfile, os, sys, shutil, json
from subprocess import call
ELM_STUFF = 'elm-stuff'
DEPS_PATH = 'exact-dependencies.json'
def download_to(url, fileName):
call('wget -O "{fileName}" "{url}"'.format(**locals()), shell=True)
@blacktaxi
blacktaxi / nltk-pwd-gen.py
Created September 10, 2012 23:55
Modern password generation with NLTK
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import random
>>> random.seed()
>>> import nltk
>>> from nltk.corpus import wordnet as wn
>>> nouns, verbs, adjectives, adverbs = [list(wn.all_synsets(pos=POS)) for POS in [wn.NOUN, wn.VERB, wn.ADJ, wn.ADV]]
>>> def gen_phrase(*pattern): return [random.choice(i) for i in pattern]
@blacktaxi
blacktaxi / ninject-dynamic-get.cs
Last active December 24, 2015 11:59
Ninject ConstructorArguments as named parameters to a dynamic invoke
namespace Ninject
{
public static class NinjectExtensions
{
private class DynKernel : DynamicObject
{
private readonly IKernel kernel;
public DynKernel(IKernel inner)
{
@blacktaxi
blacktaxi / signextlib.bat
Created September 17, 2013 10:30
Shell script to sign a .NET assembly.
@echo off
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -q -vf "%1" > NUL
if ERRORLEVEL 1 goto NOT_SIGNED
:SIGNED
echo Already signed: %~nx1
goto END
:NOT_SIGNED
@blacktaxi
blacktaxi / markdown_block.rb
Created August 30, 2013 08:54
Inline markdown blocks in Jekyll layouts/pages.
module Jekyll
class MarkdownBlock < Liquid::Block
def initialize(tag_name, text, tokens)
super
end
require "kramdown"
def render(context)
content = super
"#{Kramdown::Document.new(content).to_html}"
end