Skip to content

Instantly share code, notes, and snippets.

View rhagni's full-sized avatar

Rhagni Oliveira rhagni

View GitHub Profile
@rhagni
rhagni / diff_floor_bitwiseOr.php
Created July 11, 2016 23:27
Difference between floor and bitwise OR, normally used to check status code of a request, being of category 2xx
<?php
// https://3v4l.org/XCGmc
$code = 204;
$equals_to = 2;
// define("DEBUG", 1);
@rhagni
rhagni / ultimate_str_replace.php
Created August 30, 2016 15:31
Some combinations of recommendations to str_replace catches from comments of official documentation
<?php
/**
* Fastest and multimes str_replace
*
* Faster than str_replace when subject is an array and replace many times
* is possible from subject
*
*<code>
* $example = "<ht<html>ml> Malicious code </<html>html> etc";
* echo ultimate_str_replace(["<html>", "</html>"], "", $example);
@rhagni
rhagni / yaml2json.js
Last active May 24, 2017 20:00
Convert a YAML file to JSON using Nodejs
"use strict";
// npm install yamljs
const YAML = require("yamljs");
const fs = require("fs");
const readline = require("readline");

Keybase proof

I hereby claim:

  • I am rhagni on github.
  • I am rhagni (https://keybase.io/rhagni) on keybase.
  • I have a public key whose fingerprint is 8540 55AC FE8F 31D4 327F 8DA2 BFFF D67F 4983 5071

To claim this, I am signing this object:

@rhagni
rhagni / server.ino
Last active October 21, 2018 00:24
ESP8266 NodeMCU example, simple http server blinking board led (First blinks at http request, second led keep blinking at interval)
#include <ESP8266WiFi.h>
#define Sprintf(data...) { \
Serial.printf(data); \
}
#define INITIATE_LED(led) { \
pinMode(led, OUTPUT); \
digitalWrite(led, LED_STATE_ON); \
}
@rhagni
rhagni / .vimrc
Created April 11, 2018 00:00
Personal .vimrc
let g:python_host_prog="C:\\bin\\python3\\python.exe"
let g:python3_host_prog="C:\\bin\\python3\\python.exe"
set nocompatible
filetype off
set rtp+=$HOME/.vim/bundle/Vundle.vim
call vundle#begin("\$HOME/.vim/bundle/")
Plugin 'VundleVim/Vundle.vim'
@rhagni
rhagni / adhoc.cmd
Created April 11, 2018 04:30
Windows 8 & 10 AdHoc command line helper
@ECHO OFF
IF "%1" EQU "check" GOTO:CHECK
IF "%1" EQU "setup" GOTO:SETUP
IF "%1" EQU "start" GOTO:START
IF "%1" EQU "stop" GOTO:STOP
IF "%1" EQU "show" GOTO:SHOW
IF "%1" EQU "enable" GOTO:ENABLE
IF "%1" EQU "disable" GOTO:DISABLE
IF "%1" EQU "help" GOTO:HELP