Skip to content

Instantly share code, notes, and snippets.

Rogers rogersguedes

Block or report user

Report or block rogersguedes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rogersguedes
rogersguedes / public-ip-tracker.sh
Created Oct 15, 2019
This script check your public IP on checkip.dyndns.org and logs its changes
View public-ip-tracker.sh
#/bin/bash
LOGFILE_NAME=whatismyip.log
GATEWAY_IP=192.168.0.1
IP_PAGE_URL=checkip.dyndns.org
LAST_IP=`curl -s ${IP_PAGE_URL} | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`
echo "Initial IP: ${LAST_IP}"
while true
@rogersguedes
rogersguedes / openocd-config-backup.sh
Created Sep 12, 2019
this scripts copies the first file modified in current folder. It was used to backup a config file generated by SW4STM32 during the OpenOCD firmware upload invocation.
View openocd-config-backup.sh
#!/bin/bash
# this scripts copies the first file modified in current folder. It was used to backup a config file generated by
# SW4STM32 during the OpenOCD firmware upload invocation.
# 'inotifywait' binary is part of 'inotify-tools' package on Ubuntu 18.04.1 LTS
EVT_OUTPUT=`inotifywait -e modify,create,delete -r .`
FILE_NAME=`echo ${EVT_OUTPUT} | sed "s/[^ ]\+\s\+[^ ]\+\s\+\([^ ]\+\)/\1/g"`
cp ${FILE_NAME} ${FILE_NAME}.bak
@rogersguedes
rogersguedes / gs.sh
Created Aug 28, 2019 — forked from esrever10/gs.sh
gstreamer send and receive h264 rtp stream
View gs.sh
# linux send h264 rtp stream:
gst-launch-1.0 -v ximagesrc ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! udpsink host=127.0.0.1 port=5000
# Macos send h264 rtp stream:
gst-launch-1.0 -v avfvideosrc capture-screen=true ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! udpsink host=127.0.0.1 port=5000
# receive h264 rtp stream:
gst-launch-1.0 -v udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! autovideosink
View arduino-ir.cpp
/*
* File....... IRanalyzer.pde
* Purpose.... Records up to 128 signal changes
* Author..... Walter Anderson
* E-mail..... wandrson@walteranderson.us
* Started.... 18 May 2007
* Updated.... 18 May 2007
*
*
*/
View main.c
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h> //close()
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>// select(), fd_set, FD_* macros
View non-blocking-connect.c
/*
* Example on how to work with a non-blocking connect. Uses fixed input and
* should show all 3 situations we care about - a successful connect, a refused
* connect, and a timeout.
*
* (c) jp@devnull.cz, vlada@devnull.cz
*/
#include <sys/types.h>
#include <sys/socket.h>
@rogersguedes
rogersguedes / vm-settime.sh
Created Aug 15, 2019
Sets the date in a VirtualBox VM given a time offset in seconds.
View vm-settime.sh
#!/bin/bash
#thanks to https://winaero.com/blog/how-to-set-the-bios-date-in-virtualbox/
if [[ -z ${1} || -z ${2} ]]
then
echo ${0} " Usage:"
echo " ${0} <vm-name> <time-offset>"
echo " Example: ${0} projectVM -36000000"
exit
fi
@rogersguedes
rogersguedes / timeoffset-to.sh
Last active Aug 15, 2019
calculates the time between current time and a given date time.
View timeoffset-to.sh
#!/bin/bash
if [[ -z $1 ]]
then
echo $0 " Usage:"
echo " ${0} <date>"
echo " Example: ${0} 1990-09-21"
exit
fi
past_secs=$(date --date ${1} +%s)
View generate_toc.rb
#!/usr/bin/env ruby
File.open("your_file.md", 'r') do |f|
f.each_line do |line|
forbidden_words = ['Table of contents', 'define', 'pragma']
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ }
title = line.gsub("#", "").strip
href = title.gsub(" ", "-").downcase
puts " " * (line.count("#")-1) + "* [#{title}](\##{href})"
@rogersguedes
rogersguedes / non-blocking-echo-server.c
Last active Jul 30, 2019
Socket server in C with attempt to be non blocking
View non-blocking-echo-server.c
/**
* Snippet from https://www.binarytides.com/multiple-socket-connections-fdset-select-linux/
*/
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> //close
#include <arpa/inet.h> //close
#include <sys/types.h>
You can’t perform that action at this time.