Skip to content

Instantly share code, notes, and snippets.

@hexadeciman
hexadeciman / reactive-c#-training.md
Created February 21, 2025 12:40
C# RX Exercises

Mastering Reactive Extensions (Rx) in C#

This document provides a comprehensive set of exercises to help you become proficient with Reactive Extensions (Rx) in C#. The exercises are organized by difficulty level: Beginner, Intermediate, Advanced, and Expert. Each exercise includes a description and its real-world application.


Beginner Level

1. Create a Simple Observable and Subscribe to It

  • Description: Create an observable sequence of integers (e.g., 1 to 10) using Observable.Range and subscribe to it. Print each value to the console.
@hexadeciman
hexadeciman / downloadData.js
Last active February 17, 2025 10:02
A robust utility function to download data as a JSON file, supporting large datasets, circular reference handling, optional timestamp inclusion, and automatic splitting into smaller chunks for oversized data.
/**
* Configuration options for JSON download
*/
interface DownloadJsonOptions {
filename?: string;
indent?: number;
includeTimestamp?: boolean;
prettify?: boolean;
chunkSize?: number; // Size in MB for splitting large data
}
@hexadeciman
hexadeciman / useHighlight.scss
Last active October 8, 2024 21:42
useHighlight - a hook that allows you to highlight new functionalities
/* Backdrop fade in/out */
.highlight-backdrop {
@apply fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-300 opacity-0 pointer-events-none;
z-index: 1000;
}
.backdrop-visible {
@apply opacity-100 pointer-events-auto; /* Show the backdrop */
}
@hexadeciman
hexadeciman / rename_upper_lower.sh
Created June 7, 2023 15:02
Rename files in a directory from upper to lowercase
#!/bin/bash
# Loop through all files in the directory
for file in *; do
# Check if the file exists and is a regular file
if [[ -f "$file" ]]; then
# Convert the file name to lowercase
lowercase_name=$(echo "$file" | tr '[:upper:]' '[:lower:]')
# Rename the file to lowercase
#!/bin/bash
# Specify the directory path
directory="./"
# Change to the specified directory
cd "$directory" || exit
# Define the mapping array
declare -A mapping=(
@hexadeciman
hexadeciman / chaining_rxjs.ts
Last active November 25, 2019 08:12
Chaining RXJS
const loginEpic = actions$ =>
actions$.ofType(ActionTypes.LOGIN_REQUESTED)
.switchMap(
(loginAction) => Observable.ajax(POSTOptions('/api/login', loginAction.credentials),
(action, r) => ([r, action])
)
.switchMap(
([loginResponse, action]) => Observable.ajax(
GETOptions('/api/provider', [loginResponse.response.userToken, action.serviceProviderId] )
)
@hexadeciman
hexadeciman / hideTwitterAvatar.js
Created May 20, 2015 15:22
hide twitter avatar
<script>
//hide twitter avatar
var hideTwitterAttempts = 0;
function hideTwitterBoxElements() {
setTimeout( function() {
if ( $('[id*=twitter]').length ) {
$('[id*=twitter]').each( function(){
var ibody = $(this).contents().find( 'body' );
ibody.find( '.avatar' ).css( 'height', 0 );
ibody.find( '.avatar' ).css( 'width', 0 );
'use strict';
function ChangeMachine() {
var coins = {
'75p' : 75,
'15p' : 15,
'3p' : 3,
'1p' : 1,
'1/2p' : 0.5,
var x = req.param('x');
var y = req.param('y');
var z = req.param('z');
var undef = x && y && z;
if(undef == "undefined")
return false;
return true;
var x = req.param('x');
var y = req.param('y');
var z = req.param('z');
if( typeof x == 'undefined'
|| typeof y == 'undefined'
|| typeof z == 'undefined' )
return false;
return true;