Skip to content

Instantly share code, notes, and snippets.

View wjlafrance's full-sized avatar
🐶
Wondering if Github is becoming a social network.

William LaFrance wjlafrance

🐶
Wondering if Github is becoming a social network.
View GitHub Profile
@wjlafrance
wjlafrance / NSData+DebugOutput.h
Last active March 5, 2018 16:03
WJLSocket: Objective-C wrapper for BSD Sockets on iOS / Mac
#import <Foundation/Foundation.h>
@interface NSData (DebugOutput)
- (NSString *)debugOutput;
@end
Last login: Mon Feb 10 13:47:39 on console
bre[13:48:54] [lafrance@defiant ~]$ brew install wine
Error: wine dependency jpeg not installed with:
--universal
[13:49:48] [lafrance@defiant ~]$ brew uninstall jpeg; brew install jpeg --universal
Uninstalling /usr/local/Cellar/jpeg/8d...
==> Downloading http://www.ijg.org/files/jpegsrc.v8d.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/jpeg/8d
==> make install
@wjlafrance
wjlafrance / Main.java
Last active August 29, 2015 13:57
Rot13 in Java using Lambdas
package net.wjlafrance.lambdarot13;
import java.util.stream.Collectors;
/**
* Created by lafrance on 3/25/14.
*/
public class Main
{
# List all SSH logs
{ gunzip -c /var/log/system.log.*.gz; cat /var/log/system.log; } | grep 'sshd'
# List most frequent invalid username attempts
{ gunzip -c /var/log/system.log.*.gz; cat /var/log/system.log; } | grep 'sshd\[[[:digit:]]*\]: Invalid' | awk '{print $8}' | sort | uniq -c | sort -r
91 bin
88 oracle
63 test
#include "m.h"
#define NEXT_FIELD b=strchr(b,';')+1;
G g;
L l[8];
R r[28];
char a[1024];
char *b = a;
@wjlafrance
wjlafrance / DebugOut.java
Created May 28, 2014 14:56
Java debug output
private static void debugOutput(byte[] bytes) {
for (int i = 0; i < bytes.length; i += 16) {
for (int j = i; j < (i + 16); j++) {
if (j < bytes.length) {
System.out.format("%02x ", bytes[j]);
} else {
System.out.print(" ");
}
}
System.out.print(" ");
@wjlafrance
wjlafrance / BridgeHeader.h
Created June 3, 2014 21:48
Swift example - Debug Output
#import <Foundation/Foundation.h>
@interface NSData (DebugOutput)
- (NSString *)debugOutputObjc;
- (NSString *)debugOutputSwift;
@end
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
# Incomplete list of packages used
sudo apt-get install --assume-yes \
python-django-tagging python-ldap python-memcache python-txamqp \
@wjlafrance
wjlafrance / gist:9422399438be6972d3c2
Last active April 25, 2019 14:23
Optional - Java vs Swift

Java 8: java.util.Optional

private abstract Optional<String> methodThatReturnsOptionalString();

private void useOptionalString() {
	Optional<String> myOptionalString = methodThatReturnsOptionalString();
	if (myOptionalString.isPresent()) {
		String myUnboxedString = myOptionalString.get();
		System.out.format("Optional string had value: %s\n", myUnboxedString);

} else {

@wjlafrance
wjlafrance / gist:840473da3b4eb0b9a9a3
Last active August 29, 2015 14:02
WWDC Video List Utils
# List all sessions available for download
curl https://developer.apple.com/videos/wwdc/2014/ | grep '>Session\ ' | sed 's/<li class="thumbnail-title">//' | sed 's/<\/li><li\ class="thumbnail-id">Session//' | sed 's/<.*$//' | awk '{id=$NF; $NF=""; print id, $0}'
# List all files available for download (includes SD, HD, and PDF)
curl https://developer.apple.com/videos/wwdc/2014/ | sed 's/ | /\'$'\n/' | grep devstreaming | sed 's/[[:space:]]*<a href="//' | sed 's/?dl=1.*$//' | awk 'BEGIN{FS="/"} { print $8 ": " $0 }' | sort