Skip to content

Instantly share code, notes, and snippets.

@Stevie-O
Stevie-O / getbroadcastaddr.pl
Created July 2, 2021 17:11
Perl script for getting the broadcast address from an IP address and netmask
#!/usr/bin/perl -s
our $v;
use Socket qw/inet_ntoa inet_aton/;
if (@ARGV[0] =~ s#(/\d+)$##) { $ARGV[1] = $1; }
@ARGV >= 2 or die "Usage: perl $0 <address> <netmask>\n
netmask may be of the form '255.255.255.0' or '/24'
<Query Kind="Program">
<NuGetReference>Microsoft.Build</NuGetReference>
<NuGetReference>Microsoft.Build.Framework</NuGetReference>
<NuGetReference>Microsoft.Build.Tasks.Core</NuGetReference>
<NuGetReference>Microsoft.Build.Utilities.Core</NuGetReference>
<NuGetReference>Microsoft.CodeAnalysis.CSharp</NuGetReference>
<NuGetReference>Microsoft.CodeAnalysis.CSharp.Workspaces</NuGetReference>
<NuGetReference>Microsoft.CodeAnalysis.Workspaces.MSBuild</NuGetReference>
<NuGetReference>NuGet.Build.Tasks</NuGetReference>
<NuGetReference>System.ValueTuple</NuGetReference>
use strict;
use warnings;
use Irssi qw/settings_add_int settings_get_int settings_set_int signal_add/;
use constant { LESS_THAN_10 => "less_than_10" };
# test case based on pushover.pl
# https://github.com/hansnielsen/irssi-scripts/blob/108490bd3d2ad6a1b91ca58e5f866d01b64a9962/pushover.pl
@Stevie-O
Stevie-O / gist:c52286f3eab940854e5e91545732847f
Created September 14, 2016 13:00
Bookmarklet for Trimps to get current portal statistics
javascript:(function(){var summary = ''; for (var x in game.stats) { var s = game.stats[x]; if (s.value === undefined) continue; var v = (typeof(s.value) == 'function' ? s.value() : s.value.toString()); summary += s.title + ': ' + v + '\n'; } summary += 'Helium: ' + game.resources.helium.owned + '\n'; summary += 'Time: ' + updatePortalTimer(true); tooltip('Export', null, 'update'); document.getElementById('exportArea').value = summary;})()
@Stevie-O
Stevie-O / gist:68d7886cc2c72af2694d
Created December 15, 2015 21:40
Creation of a bipartite graph with an Eulerian path
Theorem:
For 3 <= p and 3 <= q, any complete bipartite graph P<->Q (with p nodes in
subset P linked to q nodes in subset Q) can be converted to a graph with an
Eulerian path simply by deletion of edges.
Corollaries/Definitions/Related theorems:
Let an 'odd' node be a node with an odd number of edges.
Let an 'even' node be a node with an even number of edges.
@Stevie-O
Stevie-O / gist:e9d78c27c46974a2d342
Created November 24, 2014 18:14
Strange rebasing issue
Commit sequence (chronological/commit order):
bedf5ed7be6407b75ce3eb8226663f4748192d06 [master]
4f4c68fa5df97cade596e5f64793a72062e045ba
Modify files T and W
b60ebdfcd23bd2c13f4202334507e840e960442a
Add file C, which should have been added in bedf5ed7be6407b75ce3eb8226663f4748192d06 (master)
028bfacebfbe0f9945c67635ac8f8b057743f6c6
Changes to several files, including file C
Several more commits after this