Skip to content

Instantly share code, notes, and snippets.

View renorram's full-sized avatar
🚀
being awesome

Renorram Brandão renorram

🚀
being awesome
  • Enschede, Netherlands
View GitHub Profile
function calculadoraAdicaoSubtrcao(numero, outroNumero, operacao) {
// Verifica se a váriavel operação é diferente de "-" e "+",
// caso seja, é retornado zero pois a função só realiza some e subtração
if (operacao !== "-" && operacao !== "+") {
return 0;
}
// Se a a váriavel operação é igual a "+" retornamos o resultado da soma
if (operacao === "+") {
return numero + outroNumero;
#include <stdio.h>
#include <stdlib.h>
int main() {
double r = 0, pi = 3.14159;
char buffer[100];
fgets(buffer, 100, stdin);
// disparando
(function($) {
var element = $(window.activePageId + ' #{{obj.id}}');
var event = new Event('{{obj.id}}');
event.relatedTarget = element;
document.dispatchEvent(event);
})(jQuery);
// escutando
document.addEventListener('coeSubCategoryHeader', function(e) {
@renorram
renorram / exercicios.scm
Last active April 12, 2018 22:46
Imprime o ultimo elemento e enésimo elemento de uma lista usando Scheme.
(define (ultimo lis)
(cond
((null? lis) (display "Lista nula!"))
((null? (cdr lis)) (display (car lis)))
(else (ultimo (cdr lis)))
)
)
(ultimo '(A B C D E F B A D Z))
(newline)
@renorram
renorram / replace_str_accented.php
Created December 1, 2017 14:05
Replace accented characters
<?php
/**
* Replace accented characters
* @param $string
*
* @return string
*/
public function stripAccents($string)
{
return preg_replace('/[`^~\'"]/', null, iconv('UTF-8', 'ASCII//TRANSLIT', $string));
@renorram
renorram / replace_str_by_ascii.php
Created December 1, 2017 14:03
Replace language-specific characters by ASCII-equivalents.
<?php
/**
* Replace language-specific characters by ASCII-equivalents.
* @see http://stackoverflow.com/a/16427125/529403
* @param string $s
* @return string
*/
public static function normalizeChars($s)
{
$replace = array(
@renorram
renorram / str_mask.php
Last active August 30, 2017 14:13
Aplica máscara em string. (en) Apply mask on a string.
<?php
/**
* Aplica uma máscara a string
*
* @param $str
* @param $mask
*
* @return string
*/
function str_mask($str, $mask) {
@renorram
renorram / permission.sh
Created June 2, 2017 19:42
Script to restore files and directories permissions in a Drupal installation.
#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.
@renorram
renorram / magentoTest.php
Created April 26, 2017 13:39
minimum for run indiscriminated code in magento
<?php
// Show all errors
ini_set('display_errors', 1);
/**
* Compilation includes configuration file
*/
define('MAGENTO_ROOT', getcwd());
// Include bootstrap file and Mage Class file
require MAGENTO_ROOT . '/app/bootstrap.php';
$(".views-exposed-form #edit-cor .form-item label").each(function(){
var color = $(this).text();
$(this).parent('div.form-item').addClass(filterColor(color));
});
function filterColor(color){
if(typeof color === 'string'){
if($.inArray(color, Drupal.settings.avanz.colors)!== -1){
return cleanString(color.toLowerCase().replace(/ +/g, "-"));
}