Skip to content

Instantly share code, notes, and snippets.

View mlavergn's full-sized avatar
🎯
Focusing

Marc Lavergne mlavergn

🎯
Focusing
View GitHub Profile
@mlavergn
mlavergn / Spectrum
Created June 22, 2021 15:09
Spectrum internet service
Modem:
http://192.168.100.1
Diag is locked down but can ping modem to determine hung / up
@mlavergn
mlavergn / anyconnect.md
Last active December 22, 2020 15:08
Cisco AnyConnect

For macOS clients, install the predeploy package bundled as a dmg

Versioning and downloads are available here:

Download

2020-12-22: latest == 4.9-05042

The download bundle may or may not have the predeploy text:

@mlavergn
mlavergn / cron.yml
Created November 6, 2020 16:01
GitHub cron based jobs
name: Scrape latest data
on:
push:
workflow_dispatch:
schedule:
- cron: '6,26,46 * * * *'
jobs:
scheduled:
@mlavergn
mlavergn / objcstructswift.md
Created September 21, 2020 16:10
C-structs in Swift

Swift briding is brittle when C-structs contain pointer types. Keep it simple or the type bridge will default to an opaque pointer with no member accessors

/// .h
struct CResult {
    NSArray * _Nullable value;
    NSError * _Nullable error;
};
@mlavergn
mlavergn / staticblock.m
Created September 18, 2020 15:07
Objective-C static block members
/*
* Objective-C static block members compatible with Swift closure syntax
* Two examples, A: with a return value and B: with parameters, can be combined
* Objective-C lacks associated types and tuples, thus NSArray* for return type
* Note that class specifiers do NOT synthesize getters / setters
*/
/// .h
@interface Foo
@mlavergn
mlavergn / macaddr.md
Created September 12, 2020 15:53
MAC address lookup
https://www.wireshark.org/assets/js/manuf.json
MAC first 3 pairs, lowercase, remove separators
{
  created_at: str,
  data: {
    macaddr: manufacturer,
  }
}
@mlavergn
mlavergn / proxypac.dart
Created September 8, 2020 20:21
Dart proxy.pac generator
import 'dart:io';
import 'dart:convert';
main() async {
var server = await HttpServer.bind(InternetAddress.loopbackIPv4, 8080);
print('Listening on localhost:${server.port}');
await for (HttpRequest request in server) {
var url = request.requestedUri;
var params = url.queryParameters;
@mlavergn
mlavergn / proxy.pac
Last active October 15, 2020 20:30
Proxy PAC
/*
curl -o /www/proxy.pac -L https://gist.github.com/mlavergn/5a03b23e8a92115ad6b206cbcf865fa9/raw/
networksetup -listallnetworkservices
networksetup -getautoproxyurl Wi-Fi
scp proxy.pac root@192.168.2.1:/www
networksetup -setautoproxystate Wi-Fi off
networksetup -setautoproxystate Wi-Fi on
*/
function FindProxyForURL(url, host) {
@mlavergn
mlavergn / socket.swift
Created September 3, 2020 05:16
Swift socket
// playing around with the Sharp Aquos protocol
import Foundation
enum Aquos: String {
case setup = "RSPW2 \r\n"
case powerOff = "POWR0 \r\n"
case powerOn = "POWR1 \r\n"
case channelUp = "CHUP0 \r"
case channelDown = "CHDW0 \r"
@mlavergn
mlavergn / ios13.swift
Created September 2, 2020 19:01
iOS13 Deprecations
// keyWindow
- UIApplication.shared.keyWindow
+ UIApplication.shared.windows.first { $0.isKeyWindow }
// alt via Scenes
- UIApplication.shared.keyWindow
+ UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.flatMap { $0.windows }.first { $0.isKeyWindow }
// statusBarFrame
- UIApplication.shared.statusBarFrame