Skip to content

Instantly share code, notes, and snippets.

View smartree's full-sized avatar

JasonSmartree smartree

View GitHub Profile
@smartree
smartree / udpserv.go
Created October 15, 2019 10:46 — forked from miekg/udpserv.go
Simple udp server in Go
package main
import (
"log"
"net"
)
func main() {
// listen to incoming udp packets
pc, err := net.ListenPacket("udp", ":1053")
@smartree
smartree / coredns.yaml
Created October 15, 2019 10:46 — forked from miekg/coredns.yaml
CoreDNS kubernetes deployment yaml
apiVersion: v1
kind: Service
metadata:
name: coredns
spec:
ports:
- name: coredns
port: 53
protocol: UDP
targetPort: 53
@smartree
smartree / udpserv.c
Created September 29, 2019 12:40 — forked from miekg/udpserv.c
udp server in C
/*
* udpserver.c - A simple UDP echo server
* usage: udpserver <port>
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
@smartree
smartree / Makefile
Created September 29, 2019 12:38 — forked from PhirePhly/Makefile
A crazy simple SMTP server, for educational purposes only.
default:
cc ccsmtp.c -o ccsmtpd -lpthread
@smartree
smartree / ABOUT.md
Created September 17, 2019 01:21 — forked from laobubu/ABOUT.md
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@smartree
smartree / client.js
Created September 2, 2019 07:17 — forked from linuxlewis/client.js
Example 1: Simple WebSocket Client/Server
var ws = new WebSocket("ws://localhost:8000/")
var msg = JSON.stringify({"test": "data"})
ws.send(msg)
@smartree
smartree / Test.java
Created June 20, 2019 12:40 — forked from nogweii/Test.java
A quick test to see if you have the JCE Unlimited Strength Jurisdiction Policy files installed. If you don't, in Java 6 you'll see 128. If you do, you'll see 2147483647. Thanks to http://stackoverflow.com/questions/11538746/check-for-jce-unlimited-strength-jurisdiction-policy-files
import javax.crypto.Cipher;
class Test {
public static void main(String[] args) {
try {
System.out.println("Hello World!");
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
System.out.println(maxKeyLen);
} catch (Exception e){
System.out.println("Sad world :(");
@smartree
smartree / ffmpeg.md
Created June 19, 2019 02:15 — forked from v5tech/ffmpeg.md
ffmpeg视频合并、格式转换、截图

使用ffmpeg合并MP4文件

ffmpeg -i "Apache Sqoop Tutorial Part 1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i "Apache Sqoop Tutorial Part 2.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "Apache Sqoop Tutorial Part 3.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate3.ts
ffmpeg -i "Apache Sqoop Tutorial Part 4.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate4.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|intermediate3.ts|intermediate4.ts" -c copy -bsf:a aac_adtstoasc "Apache Sqoop Tutorial.mp4"
@smartree
smartree / web-servers.md
Created June 18, 2019 08:57 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@smartree
smartree / ssdp.py
Created June 11, 2019 06:02 — forked from dankrause/ssdp.py
Tiny python SSDP discovery library with no external dependencies
# Copyright 2014 Dan Krause
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,