Skip to content

Instantly share code, notes, and snippets.

View surfmuggle's full-sized avatar
💭
Browsing stuff

surfmuggle surfmuggle

💭
Browsing stuff
View GitHub Profile
@surfmuggle
surfmuggle / Main.kt
Last active January 23, 2024 21:49 — forked from Da9el00/Main.kt
Kotlin - Making API Calls in Kotlin Without External Libraries
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URI
import java.net.URL
fun main() {
val apiUrl = "https://catfact.ninja/fact" //API endpoint
// add proxy support if your pc is behind a corporate proxy
System.setProperty("java.net.useSystemProxies", "true");
@surfmuggle
surfmuggle / main.dart
Last active September 22, 2023 15:47
keen-nebula-4294
import 'dart:convert' as convert;
import 'package:http/http.dart' as http;
void main(List<String> arguments) async {
final urlHttpBin = Uri.https('httpbin.org', '/basic-auth/myuser/mypasswd');
const base64Encoder = convert.Base64Encoder();
var creds64 = base64Encoder.convert('myuser:mypasswd'.codeUnits);
// https://pub.dev/documentation/http/latest/http/Client-class.html
@surfmuggle
surfmuggle / Serialize_Json_Custom_handle_Strings_with_value_NULL.linq
Created December 20, 2022 10:21
C# JsonSerializer.Deserialize fails if property has string value "null" despite JsonIgnoreCondition.WhenWritingNull
void Main()
{
// Linqpad program to test the custom serializer to handle strings with value null: string foo = "\"null\"";
// based on this answer https://stackoverflow.com/a/74857003/819887
try
{
//TestClass.Test();
foreach (var jsonWithConfig in GetJson())
{
jsonWithConfig.Dump("jsonWithConfig");
@surfmuggle
surfmuggle / class_werkzeug.php
Last active January 31, 2020 14:40
PHP foo
class Werkzeug extends Werkzeug__Standard {
static private $A_Cache = array();
const PARAMETER_BAUJAHR = 1;
const PARAMETER_FAHRZEUGPROJEKT = 2;
const PARAMETER_HERSTELLER = 3;
static function Get_Data_Baujahr(){
@surfmuggle
surfmuggle / panel.html
Created December 24, 2019 12:40
Firefox sidebar extension does not work
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="panel.css"/>
</head>
<body>
@surfmuggle
surfmuggle / LogFile of command
Last active September 2, 2019 23:38
PHP Static analysis with noverify exe
2019/09/03 01:20:24 -exclude-checks arraySyntax, PHPDocC:\Dev\PHP\ResourceSpace_9_0_13357\include
2019/09/03 01:20:25 error using cmnd.CombinedOutput()
2019/09/03 01:20:25 exit status 2
2019/09/03 01:20:25 what does this mean?
2019/09/03 01:20:25 2019/09/03 01:20:24.418022 Started
2019/09/03 01:20:24.931815 Indexing [C:\Dev\PHP\ResourceSpace_9_0_13357\include]
2019/09/03 01:20:25.243995 Linting
<critical> INFO phpdocLint: PHPDoc is incorrect: use int type instead of integer on line 4 at C:\Dev\PHP\ResourceSpace_9_0_13357\include\annotation_functions.php:9
function getAnnotation($ref)
^^^^^^^^^^^^^
@surfmuggle
surfmuggle / Todo.razor
Last active August 30, 2019 21:06
Todo List with server side blazor / balzor components
@page "/todo"
<h1>Todo (@todos.Count(todo => !todo.IsDone))</h1>
<ul>
@foreach (var todo in todos)
{
<li>
<input type="checkbox" @bind="todo.IsDone" />
@surfmuggle
surfmuggle / extension-content-script.js
Last active January 23, 2019 01:46
Firefox Extension - why does it log page.renderTime -1548207097891 instead of something like = 885
document.onreadystatechange = function () {
console.log("content script was fired onreadystatechange ");
class PageMeasurement {
constructor(url) {
this.url = url;
this.date = Date.now();
var t = window.performance.timing;
@surfmuggle
surfmuggle / pageLoadTime with greasemonky - alpha
Created October 29, 2018 10:05
This is an incomplete snippet - idea is to use greasemonky to measure the pageloadtime
// With GreaseMonkey create a new script that would look like the following:
// ==UserScript==
// @name test
// @description test desc
// @include *://www.mysite.com/*
// @grant none
// @version 0.1
// ==/UserScript==
"use strict"
// MIT Licence a snippet to be run inside the chrome dev tools
// not fully working yet
// see https://stackoverflow.com/questions/47686564/chrome-devtools-run-snippet-to-load-pages
function getPerformanceTimings()
{
var t = window.performance.timing;
var timings = [];