Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Anderson Fraga andersonfraga

🎯
Focusing
Block or report user

Report or block andersonfraga

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
View generics.java
class A<T> {
private T var;
public A(T elm) {
var = elm;
}
public void damm() {
// this.var para simplificar
fun((T) method.invoke(this.var);
View gist:74f57527d7397a1ec2a35aace79543b7
; vim /etc/apt/sources.list
deb http://http.debian.net/debian/ jessie main non-free contrib
deb-src http://http.debian.net/debian/ jessie main non-free contrib
; terminal
sudo apt update
sudo apt install gcc-4.8 g++-4.8
; vim /etc/apt/sources.list
#deb http://http.debian.net/debian/ jessie main non-free contrib
@andersonfraga
andersonfraga / start-displays.sh
Last active Mar 2, 2018
Xfce 4.12 it's dumb and stupid. So I need to manually inform the order of monitors and their panel's location
View start-displays.sh
#!/bin/bash
# source https://forum.xfce.org/viewtopic.php?pid=46361#p46361
#
# Check if our external monitor name is in the list connected displays
grep_output=`xrandr | grep "HDMI-1 connected"`
if [ "$grep_output" != "" ]; then
# The external monitor IS connected. Put it right of there internal and move xfce-panel there
View client.c
#include <string.h>
#include "headers.h"
int main(int argc, char const *argv[])
{
int id_shared, id_server;
char *psh_msg;
sem_t *sem_server;
View philosopher.c
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define NANO_SECOND_MULTIPLIER 1000000
typedef struct philosopher_sct {
int think;
int waited;
@andersonfraga
andersonfraga / cronjob.sh
Created May 27, 2016
Execute notify-send via cronjob
View cronjob.sh
#!/bin/bash
# * * * * * /bin/sh cronjob.sh "Teste 1 2 3"
{
PID=$(/usr/bin/pgrep gnome-session)
dbus=$(/bin/grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
export DBUS_SESSION_BUS_ADDRESS=$dbus
DISPLAY=:0.0 /usr/bin/notify-send --urgency=critical "Alert using crontab" "$1"
} >> $HOME/crontab/alert.log 2>&1
@andersonfraga
andersonfraga / divisible.go
Created May 17, 2016
Brincando com go... But, tem será maneira mais 'go-style' de fazer isso?
View divisible.go
package main
import "os"
import "fmt"
import "math"
import "strconv"
func main() {
number, _ := strconv.ParseFloat(os.Args[1:2][0], 64)
denom := float64(2)
View Lexica_01.flex
%%
/**
* Anderson Jean Fraga
* 13180375
* Compiladores - Trabalho 1 - Exercicio 1
*/
%public
%class Lexica_01
@andersonfraga
andersonfraga / index.php
Last active Aug 29, 2015
Busca a menor máscara possível em uma lista de CIDRs
View index.php
<?php
class IPv4Subnet
{
private $address, $mask;
function __construct($ip)
{
list($this->address, $this->mask) = $this->toBin($ip);
}
@andersonfraga
andersonfraga / ques.sml
Created Oct 9, 2014
E em 30mins brincando com esse tal de AliceML...
View ques.sml
(********************
Especifique a função mediaListaSemPares que recebe uma lista de inteiros umaLista e retorna a média dos elementos de umaLista, descartando os valores pares (listas com 1 ou nenhum elemento, retornam vazias)
********************)
fun listaSemPares umaLista = List.filter (fn x => x mod 2 <> 0) umaLista;
fun somaLista [] = 0
| somaLista (x::res) = x + somaLista res;
fun mediaListaSemPares [] = 0.0
| mediaListaSemPares umaLista =
You can’t perform that action at this time.