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 / WhatsAppGroupContactExport.js
Created February 13, 2025 12:44 — forked from mzahidriaz/WhatsAppGroupContactExport.js
WhatsApp Group Contacts Export: This will download the members of group with their phone number, whatsapp name and if contact is stored on phone
class ContactFinder {
#db;
#chatToFind;
#dbName = "model-storage";
#chatsCol = "chat";
#contactCol = "contact";
#groupCol = "participant";
constructor(chatGroupName) {
this.#chatToFind = chatGroupName;
@crunchie84
crunchie84 / elasticsearch-nest-geoquery-example.cs
Last active January 30, 2023 17:18
Easy example of indexing geo-based domain objects to ElasticSearch via #nest
using Nest;
using System;
using System.Globalization;
namespace elasticsearch_nest_geoindex_demo
{
public class Location
{
public string Name { get; set; }
@crunchie84
crunchie84 / BasicAuthHttpConnection.cs
Last active August 11, 2022 19:55
Basic HTTP-auth ElasticSearch with Nest client
namespace Elasticsearch.Net.Connection
{
using System.Globalization;
using System;
using System.Text;
/// <summary>
/// HttpConnection with basic auth usage
/// </summary>
public sealed class BasicAuthHttpConnection : HttpConnection
@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>()
/**
This middleware verifies that the AWS api gateway authorizer lambda has been configured and executed
this middleware is meant to make sure that the seam between IaC and the implementation do not go out of sync
and for whatever reason this lambda is exposed without authorization logic having happened before
in the lambda authorizer
*/
export function assertAuthorizerExecuted() {
return ({
before: (handler, next) => {
const event = handler.event; //unbox middy
@crunchie84
crunchie84 / script.sh
Created January 21, 2021 14:11
Git Surgery blogpost - rewriting histories
# part one, put on your scrubs
mkdir git-surgery
cd git-surgery
git clone git@github.com:crunchie84/blogpost-git-surgery-source.git source
cd source
# extract our application from the source repository
git subtree split -P Configuration/application-1 -b rewritten-history-application-1
# Prepare our new repository
@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
}), {})
@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
@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;