Skip to content

Instantly share code, notes, and snippets.

View crunchie84's full-sized avatar
🦑
Focusing

Mark van Straten crunchie84

🦑
Focusing
View GitHub Profile
@crunchie84
crunchie84 / gist:8e6bc9fe3ac76ceec890
Created November 13, 2014 13:50
install logstash 1.4.2 ubuntu 14.04
partial from http://blog.dimaj.net/content/howto-view-and-analyze-your-logs-web-page
cd ~
wget https://download.elasticsearch.org/logstash/logstash/logstash-1.4.2.tar.gz
tar xzvf logstash-1.4.2.tar.gz
sudo mv logstash-1.4.2 /opt/logstash
sudo adduser --system --disabled-login --no-create-home --group logstash
sudo usermod -a -G adm logstash
#auto start script for logstash
@crunchie84
crunchie84 / installation.md
Last active May 11, 2016 15:13
Install the ELK stack on an ubuntu-x64 machine on Azure

install the ELK stack on an ubuntu-x64 machine on Azure

This guide has been revised 06-03-2015. Start with a clean ubuntu 14.04LTS-x64 machine and get it updated

sudo su
apt-get update && apt-get dist-upgrade
reboot
@crunchie84
crunchie84 / init.cs
Created December 3, 2015 14:20
Serilog config for RX pushing to redis
public class MvcApplication : HttpApplication
{
private static void initializeLogging()
{
var loggerConfiguration = new LoggerConfiguration()
.Enrich.WithProperty("type", "application")
.Enrich.WithProperty("application", "my-app-name")
.Enrich.WithProperty("application_version", "1.2.3.4")
.Enrich.WithProperty("environment", "development")
.Enrich.With<Serilog.Extras.Web.Enrichers.HttpRequestIdEnricher>()
@crunchie84
crunchie84 / keybase.md
Created February 19, 2016 10:25
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@crunchie84
crunchie84 / rx-collection-compare.js
Last active February 23, 2018 23:03
Rxjs5 test compare
const assert = require('chai').assert;
/**
* parts of code taken from https://github.com/Reactive-Extensions/RxJS/blob/master/tests/helpers/reactiveassert.js#L32
*
* and modified to work with the rxjs5 testing shim which has no differentiation between values and predicates
*/
exports.assertEqual = function assertEqual(actual, expected) {
const comparer = require('./is-equal'); // copied and adapted from https://raw.githubusercontent.com/Reactive-Extensions/RxJS/master/src/core/internal/isequal.js
let isOk = true;
@crunchie84
crunchie84 / rx-bitcoin-price-ticker.js
Last active September 29, 2020 05:21
RxJs bitcoin stock ticker example
Rx.Observable.timer(0, 10 * 1000)
.switchMap(_ => fetch('https://blockchain.info/ticker?cors=true')
.then(res => res.json())
.then(parsed => parsed.EUR.buy)
)
.distinctUntilChanged()
.scan((acc, curr) => ({
delta: Math.round((acc.value - curr || 0) * 100) / 100,
value: curr
}), {})

LCD Digits

Your task is to create an LCD string representation of an integer value using a 3x3 grid of space, underscore, and pipe characters for each digit. Each digit is shown below (using a dot instead of a space)

._.   ...   ._.   ._.   ...   ._.   ._.   ._.   ._.   ._.
|.|   ..|   ._|   ._|   |_|   |_.   |_.   ..|   |_|   |_|
|_| ..| |_. ._| ..| ._| |_| ..| |_| ..|
@crunchie84
crunchie84 / fibonacci.js
Created January 2, 2018 11:56
Find fibonacci numbers using perfect square formula
/**
* The question may arise whether a positive integer x is a Fibonacci number. This is true if and only if one or both of 5x^{2}+4 or 5x^{2}-4 is a perfect square.
* https://en.wikipedia.org/wiki/Fibonacci_number#Recognizing_Fibonacci_numbers
*/
// the first 20 fibonacci numbers are found 0->6765
Array.from(generate(6765+1))
.map((i, idx) => ({number: i, isFibonacci: isFibonacciNumber(i)}))
.filter(kv => kv.isFibonacci)
.map((kv, index) => console.log(`found ${1+index}th fibonacci number: ${kv.number}`));
@crunchie84
crunchie84 / debug.ts
Created April 4, 2018 19:08
RxJs5 lifecycle debug operator
import 'rxjs/add/observable/empty';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/concat';
import 'rxjs/add/operator/finally';
import { Observable } from "rxjs";
/**
*
* Lifecycle debugging for your stream, sub/unsubscribe,complete and values
*
@crunchie84
crunchie84 / .gitconfig.aliases
Created April 21, 2020 12:48
git alias for the win 💪
#
# Include this in your own .gitconfig by using the
# [include] directive with the path to this file
#
# [include]
# path = ~/.gitconfig.aliases
#
# If you don't have any existing includes, you can add this via the following command
#
# git config --global include.path ~/.gitconfig.aliases