Skip to content

Instantly share code, notes, and snippets.

View marcosfreitas's full-sized avatar
🔥
Looking forward

Marcos Freitas marcosfreitas

🔥
Looking forward
View GitHub Profile
const useAuth = (): AuthContextInterface => {
const context = useContext(AuthContext);
if (!context) {
throw new Error('useAuth must be used within a AuthProvider');
}
return context;
};
@marcosfreitas
marcosfreitas / array_to_object.php
Last active May 20, 2022 04:25
Convert a multidimensional array to object recursively
<?php
/**
* Convert a multidimensional array to an object recursively.
* For any arrays inside another array, the result will be an array of objects.
*
* @author Marcos Freitas
* @param array|any $props
* @return array|any
*/
@marcosfreitas
marcosfreitas / multiple-modals-semantic.html
Created March 9, 2015 08:09
Creating Multiple Modals in Semantic UI :)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multiple Modals With Semantic UI</title>
<link rel="stylesheet" href="path_to_semantic/dist/semantic.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="path_to_semantic/dist/semantic.js"></script>
</head>
<body>
<?php
namespace App;
/**
* Esta classe é apenas um Wrapper para a classe SoapClient e realiza as requisições e recebe as respostas de forma padrão.
*/
class Soap {
public
$__client,
@marcosfreitas
marcosfreitas / sui-fixed-layout.html
Last active July 31, 2020 12:26
Fixed Layout with Semantic UI
<!DOCTYPE HTML>
<html>
<head>
<!-- add the semantic assets -->
</head>
<body>
<style>
/**
* Semantic UI don't have a fixed grid system, the solution to build fixed layouts is use a grid inside a fixed container.
*/
@marcosfreitas
marcosfreitas / wp-title.php
Created July 10, 2017 22:22
combinação de títulos para o title do html
<title>
<?php
if(is_home()):
bloginfo('name');
elseif( is_category() || is_tag() ):
single_cat_title(); echo ' &bull; '; bloginfo('name');
elseif( is_single() || is_page() ):
single_post_title();
else:
@marcosfreitas
marcosfreitas / search.html
Last active May 20, 2019 15:10
Autocomplete Search With Semantic UI
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Autocomplete Search With Semantic UI</title>
<link rel="stylesheet" href="semantic/dist/semantic.css">
</head>
<body>
@marcosfreitas
marcosfreitas / m3.sh
Last active March 30, 2019 19:27
press key to continue
function PressKeyToContinue() {
printf "\n";
question="Pressione S para continuar ou qualquer outra tecla para pular essa parte execução do script";
expected_key_pressed='s';
abort_script=false;
if [ ! -z "$1" ]; then
question="${1}";
@marcosfreitas
marcosfreitas / woocommerce-categories-list.php
Created August 13, 2014 15:08
Pega a lista de categorias do woocommerce de acordo com os parâmetros repassados na página de uma determinada categoria e forma um dropdown
/**
* Dropdown de categorias para design responsivo
* Pegando as categorias dos produtos de acordo com os argumentos passados
*/
$args = array( 'number' => $number, 'orderby' => $orderby, 'order' => $order, 'hide_empty' => true, 'include' => $ids );
$product_categories = get_terms( 'product_cat', $args );
?>
<ul id="list-widget-responsive">
<li id="" class="widget widget-responsive woocommerce widget_product_categories">
@marcosfreitas
marcosfreitas / isAlmostPalindrome.php
Created July 9, 2018 19:03
#training Is A Palíndrome word
<?php
# check for palindrome words
# if the word have almost 1 letter to be changed to be a plindrome, it will be a palíndrome.
function isAlmostPalindrome($word) {
$count_diference = 0;
$word_reverse = strrev($word);
$word_as_array = str_split($word);