Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
rogersguedes / ssh-agent-snippets.sh
Created June 11, 2018 00:19 — forked from alexras/ssh-agent-snippets.sh
Bash snippets to automatically start and stop an ssh-agent process on login and logout
#!/bin/bash
## in .bash_profile
SSHAGENT=`which ssh-agent`
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
<?php
$filename = dirname('.') . $_SERVER['PHP_SELF'];
if (isset($_GET['download-source'])) {
header("Content-type: application/force-download");
$file = fopen(__FILE__, 'r');
$content = fread($file, filesize(__FILE__));
print $content;
die();
}
@rogersguedes
rogersguedes / symfony3-rest-api.md
Created July 11, 2018 00:43 — forked from diegonobre/symfony3-rest-api.md
Basic RESTful API with Symfony 3 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 3 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authenticationu
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 3 framework. The following SF2 bundles are used :

C Sheet

Data Types

Type Bytes Min. range Max. range Has Unsigned
char 1 -128 127 yes
int 2 -32,768 32,767 yes
short 2 -32,768 32,767 no
float 4 1.2E-38 3.4E+38 no
//unidades:
//distancia: metros (m)
//angulo: radianos
clear //apaga todas as variáveis do escopo atual
clc // limpa a tela
function deg = radToDeg(rad)
deg = rad * 180 / %pi;
endfunction
function rad = degToRad(deg)
@rogersguedes
rogersguedes / tmux_local_install.sh
Created August 13, 2018 14:59 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
@rogersguedes
rogersguedes / write_bmp.c
Last active August 21, 2018 20:53 — forked from binshengliu/write_bmp.c
Writing bmp in C. see http://pastebin.com/qCRHiPEZ
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
//define pixelformat of windows bitmap, notice the unusual ordering of colors
typedef struct {
unsigned char B;
unsigned char G;
unsigned char R;
#!/bin/sh
# udhcpc config script
# $interface is the name of the device udhcpc is using
# $router is the (space_separated) list of gateways
# $broadcast is the broadcast address
# $ip is the ip address that we get from the dhcp server
# $dns is the list of dns servers we get from the dhcp server
# $domain is the domain of the network
@rogersguedes
rogersguedes / backup.sh
Last active January 29, 2019 13:35
Rsync folder backup script.
#!/bin/bash
rsync -uvazh --append-verify --progress
@rogersguedes
rogersguedes / capture_raw_frames.c
Last active December 4, 2018 17:04 — forked from maxlapshin/capture_raw_frames.c
v4l2 capture example
/*
* V4L2 video capture example
*
* This program can be used and distributed without restrictions.
*
* This program is provided with the V4L2 API
* see http://linuxtv.org/docs.php for more information
*/
#include <stdio.h>