Skip to content

Instantly share code, notes, and snippets.

View phedoreanu's full-sized avatar
🏠
Working from home

Adrian Fedoreanu phedoreanu

🏠
Working from home
View GitHub Profile
package main
import (
"fmt"
)
func xorSwap(x, y *int) {
if x != y {
*x ^= *y;
*y ^= *x;
package main
import (
"fmt"
)
func insertionSort(a []int, asc bool) {
for i := 1; i < len(a); i++ {
for j := i; j > 0; j-- {
switch asc {
package main
import "fmt"
func main() {
s := "Let's hack together!"
fmt.Printf("%# x\n", s)
fmt.Println([]byte(s))
}
go fmt
warnings=`golint`
if [[ $warnings != "" ]]; then
echo $warnings
exit 1
fi
exit 0
@phedoreanu
phedoreanu / pfblockerng_import_v3.php
Created September 7, 2016 14:49
pfBlockerNG import script
<?php
/*
pfBlockerNG_import.php
pfBlockerNG
Copyright (C) 2014 BBcan177@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Login

cf login -a https://api.run.pivotal.io -u adrian.fedoreanu@gmail.com

Push a single app (with or without a manifest):

cf push APP_NAME [-b BUILDPACK_NAME] [-c COMMAND] [-d DOMAIN]

[-f MANIFEST_PATH] [--docker-image DOCKER_IMAGE]

[-i NUM_INSTANCES] [-k DISK] [-m MEMORY] [--hostname HOST] [-p PATH]
raspivid -o - -t 0 -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/$KEY
./mjpg_streamer -o "output_http.so" -i "input_raspicam.so -x 1920 -y 1080 -fps 30"
sudo ./mjpg_streamer -i "input_uvc.so -d /dev/video1 -r 1280x720 -f 30 -q 85" -o "output_http.so"
sudo ffmpeg -f v4l2 -video_size 1920x1080 -i /dev/video0 -f v4l2 -video_size 1920x1080 -i /dev/video1 -filter_complex "[0:v]setpts=PTS-STARTPTS[background];[1:v]setpts=PTS-STARTPTS,scale=iw/2:-1[foreground];[background][foreground]overlay=main_w-overlay_w-10:main_h-overlay_h-10" -c:v libx264 -crf 18 -preset ultrafast -c:a copy output.mkv
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo
# Dockerfile
FROM scratch
#ADD ca-certificates.crt /etc/ssl/certs
ADD app / # add binary
ENV LISTEN_PORT 7905
ENTRYPOINT [ "/app" ]
#!/bin/sh
## Clean up any stale tempfile
echo "Removing old files..."
[ -f /tmp/hosts.working ] && rm -f /tmp/hosts.working
## Awk regex to be inverse-matched as whitelist
# - Project Wonderful does unobtrusive ads on a lot of webcomics
# - SolveMedia is needed for captchas on some websites
#whitelist='/(projectwonderful.com|api.solvemedia.com)/'
package main
import (
"fmt"
"io/ioutil"
"bufio"
"bytes"
"strings"
"strconv"
)