Skip to content

Instantly share code, notes, and snippets.

@JcBernack
JcBernack / BigDecimal.cs
Last active May 13, 2024 05:33
BigDecimal
using System;
using System.Numerics;
namespace Common
{
/// <summary>
/// Arbitrary precision decimal.
/// All operations are exact, except for division. Division never determines more digits than the given precision.
/// Source: https://gist.github.com/JcBernack/0b4eef59ca97ee931a2f45542b9ff06d
/// Based on https://stackoverflow.com/a/4524254
@rjescobar
rjescobar / extend-trial-jetbrains-windows.bat
Created August 31, 2021 02:53
JetBrains IDE trial reset windows
REM Delete eval folder with licence key and options.xml which contains a reference to it
for %%I in ("WebStorm", "IntelliJ", "CLion", "Rider", "GoLand", "PhpStorm", "Resharper", "PyCharm") do (
for /d %%a in ("%USERPROFILE%\.%%I*") do (
rd /s /q "%%a/config/eval"
del /q "%%a\config\options\other.xml"
)
)
REM Delete registry key and jetbrains folder (not sure if needet but however)
rmdir /s /q "%APPDATA%\JetBrains"
@Vanchel
Vanchel / outlined_input_border.dart
Last active May 13, 2024 05:23
Border with label placed inside
import 'dart:math' as math;
import 'dart:ui';
import 'package:flutter/material.dart';
class OutlinedInputBorder extends InputBorder {
/// Creates a rounded rectangle outline border for an [InputDecorator].
///
/// If the [borderSide] parameter is [BorderSide.none], it will not draw a
/// border. However, it will still define a shape (which you can see if
class DataIdGenerator {
constructor() {
this.count = 0;
}
generateDataId() {
this.count++;
return this.formatDataId(this.count);
}
@sainipray
sainipray / filter.py
Created February 27, 2020 09:53
Custom Django rest framework Ordering Filter
from rest_framework.filters import OrderingFilter
class CustomOrderFilter(OrderingFilter):
allowed_custom_filters = ['user_city', 'user_country']
fields_related = {
'user_city': 'user__city__name', # ForeignKey Field lookup for ordering
'user_country': 'user__country__name'
}
def get_ordering(self, request, queryset, view):
@jeremychone
jeremychone / rust-xp-02-postgresql-sqlx.rs
Created May 11, 2021 05:48
Rust to PostgreSQL with SQLX | Rust By Example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use sqlx::postgres::{PgPoolOptions, PgRow};
use sqlx::{FromRow, Row};
// Youtube episode: https://youtu.be/VuVOyUbFSI0
// region: Section
// Start postgresql server docker image:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Delete Boxes</title>
<style>
.box {
width: 100px;
height: 100px;
@iccir
iccir / SimStatusBar.sh
Last active May 13, 2024 05:15
iOS Simulator Status Bars
# iPhone with home button
xcrun simctl status_bar booted clear
xcrun simctl status_bar booted override \
--time "9:41 AM" \
--wifiBars 3 --cellularBars 4 --operatorName ""
xcrun simctl spawn booted defaults write com.apple.springboard SBShowBatteryPercentage 1
# iPhone X
xcrun simctl status_bar booted clear
xcrun simctl status_bar booted override --time "9:41" --wifiBars 3 --cellularBars 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Delete Boxes</title>
<style>
.box {
width: 100px;
height: 100px;
@djangobeatty
djangobeatty / countEmailsWithSearchTermsMonthly
Last active May 13, 2024 05:09
Google Apps Script - count emails with keywords to see trends
function countEmailsWithSearchTermsMonthly() {
var searchTerms = ['spearheading', 'delve']; // Replace with your actual search terms
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Clear previous data (if any)
var lastRow = sheet.getLastRow();
if (lastRow > 1) {
sheet.getRange(2, 1, lastRow - 1, sheet.getLastColumn()).clear();
}