Skip to content

Instantly share code, notes, and snippets.

@sfinktah
sfinktah / PlayerWrapper.java
Created October 15, 2020 17:13
PlayerWrapper PlayerWrapper
package viewmodel;
import model.interfaces.Player;
import util.StringHelpers;
import java.awt.*;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
@sfinktah
sfinktah / PlayerList.java
Created October 15, 2020 17:14
PlayerList
package viewmodel;
import model.interfaces.Player;
import util.StringHelpers;
import javax.swing.*;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.*;
// ==UserScript==
// @name New script - stackoverflow.com
// @namespace SO Code Context Highlight
// @match https://stackoverflow.com/questions/*
// @downloadURL https://nt4.com/monkey/stackoverflow.user.js
// @version 0.5
// @description visual studio style highlight of terms matching cursor(mouse) position
// @author sfinktah
// @require https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.11.0/underscore-min.js
// @grant GM_addStyle
@sfinktah
sfinktah / python.snippets
Last active August 20, 2021 07:17
UltiSnips auto-completions that don't expand in comments
global !p
pythonZones = [ 'pythonStatement', 'pythonConditional', 'pythonRepeat',
'pythonOperator', 'pythonException', 'pythonInclude', 'pythonAsync',
'pythonDecorator', 'pythonDecoratorName', 'pythonFunction',
'pythonTodo', 'pythonString', 'pythonRawString', 'pythonQuotes',
'pythonTripleQuotes', 'pythonEscape', 'pythonNumber', 'pythonBuiltin',
'pythonExceptions', 'pythonSpaceError', 'pythonDoctest', 'pythonDoctestValue']
commentZones = ['pythonComment']
pythonZoneIds = vim.eval('map('+str(pythonZones)+", 'hlID(v:val)')")
commentZoneIds = vim.eval('map('+str(commentZones)+", 'hlID(v:val)')")
#!/usr/bin/env bash
function wan_ip_connection() {
local host=$1
result=$( curl -s "http://$host/upnp/control?WANIPConnection" \
-H 'SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress"' \
--data-binary '<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetExternalI
PAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:GetExternalIPAddress></s:Body></s:Envelope>'
)
REGEX='ExternalIPAddress>([0-9.]+)<'
Sub RefStuff()
' https://docs.microsoft.com/en-us/office/vba/api/word.selection.insertcrossreference
myHeadings = _
ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem)
For i = 1 To UBound(myHeadings)
MsgBox InStr(1, LTrim(myHeadings(i)), "(a)", 1) & ":" & myHeadings(i)
If InStr(LCase$(myHeadings(i)), "3.xxxx") Then
With Selection
.Collapse Direction:=wdCollapseStart
.InsertAfter "paragraph "
@sfinktah
sfinktah / autocomplete_sol2_lua.cpp
Created October 17, 2022 09:42
lua autocompletion for C++/sol3
#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>
#include <iostream>
#include <string>
#include <algorithm>
#include <pystring/pystring.h>
using namespace std::string_literals;
template <typename T>
bool is_in(const T& val, const std::initializer_list<T>& list) {
@sfinktah
sfinktah / markmission.md
Last active August 31, 2023 07:49
OpenAI's idea of how to create a PWA for offline/online submission of form data

Creating a Progressive Web App (PWA) to store contact details from a form and submit them when internet access is available involves a combination of technologies like HTML, CSS, JavaScript, and service workers. Below is a simplified example of how you can achieve this:

  1. HTML Form: Create an HTML form to collect contact details. You can create an index.html file.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
@sfinktah
sfinktah / generate_html_tables.md
Created September 8, 2023 13:48
Generate HTML Tables

To allow for the creation of rows with horizontal bars in the HTML table, you can add another parameter to the generateHTMLTable function to specify which rows should have horizontal bars and then add CSS classes accordingly. Here's the modified function:

<?php
function generateHTMLTable($data, $tableClass = '', $headerRowClass = '', $dataRowClass = '', $barRowIndices = []) {
    if (empty($data)) {
        return ''; // Return an empty string if the data array is empty
    }

    $html = '<table';
@sfinktah
sfinktah / build-php.sh
Created September 10, 2023 06:20
Building PHP 8.1 on Centos 8.5
sudo dnf install autoconf automake binutils bison curl-devel freetype-devel gcc \
gcc-c++ git glibc-devel libjpeg-devel libpng-devel libtool libwebp-devel \
libxml2-devel libzip-devel make openssl-devel sqlite-devel
sudo yum install re2c oniguruma-devel --enablerepo=powertools
git clone https://github.com/php/php-src.git --branch=PHP-8.1.23
cd php-src
./buildconf
make -j 4