Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / install.sh
Last active Sep 3, 2021
Ubuntu - Install Strem.io
View install.sh
#!/usr/bin/env bash
sudo su
curl -SO# http://178.62.254.47/Stremio3.5.1.linux.tar.gz
mkdir -p /opt/stremio
tar -xvzf Stremio3.5.1.linux.tar.gz -C /opt/stremio
curl -SO# http://www.strem.io/3.0/stremio-white-small.png
mv stremio-white-small.png /opt/stremio/
curl -SO# https://gist.githubusercontent.com/claudiosmweb/797b502bc095dabee606/raw/52ad06b73d90a4ef389a384fbc815066c89798eb/stremio.desktop
mv stremio.desktop /usr/share/applications/
View exemplo-media-queries-condicoes.html
<!DOCTYPE html>
<html>
<head>
<title>Exemplo de Media Types</title>
<!-- todos os dispositivos -->
<link href="estilos.css" rel="stylesheet" type="text/css" media="all" />
<!-- monitores e com largura máxima de 600px (por exemplo tablets) -->
<link href="estilo1.css" rel="stylesheet" type="text/css" media="screen and (max-width: 800px)" />
<!-- apenas para monitores coloridos -->
<link href="estilo2.css" rel="stylesheet" type="text/css" media="only screen and (color)" />
@claudiosanches
claudiosanches / test.php
Last active Jul 30, 2021
Regex for test credit card brand
View test.php
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@claudiosanches
claudiosanches / plugin.php
Created May 2, 2017
WooCommerce - Send "New User Registration" email to admins when new customer is created.
View plugin.php
<?php
/**
* Send "New User Registration" email to admins when new customer is created on WooCommerce.
*
* @param int $id New customer ID.
*/
function my_wc_customer_created_notification( $id ) {
wp_new_user_notification( $id, null, 'admin' );
}
@claudiosanches
claudiosanches / add-to-cart.php
Last active Jul 14, 2021
WooCommerce - Template add-to-cart.php with quantity and Ajax!
View add-to-cart.php
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@claudiosanches
claudiosanches / django-runserver-ssl.md
Last active Jul 5, 2021
Django - SSL with runserver
View django-runserver-ssl.md

Instalation

[sudo] apt-get install stunnel

Configuration

cd path/to/django/project
@claudiosanches
claudiosanches / custom-my-account-endpoint.php
Last active Jun 24, 2021
Example of custom My Account endpoint.
View custom-my-account-endpoint.php
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@claudiosanches
claudiosanches / index.html
Last active Jun 8, 2021
HTML5 - Validar número de celular em São Paulo
View index.html
<div class="form-group">
<label for="phone">Telefone <span class="required">*</span></label>
<input type="text" class="form-control" id="phone" name="phone" placeholder="(99) 9999-9999" pattern="(\([0-9]{2}\))\s([9]{1})?([0-9]{4})-([0-9]{4})" title="Número de telefone precisa ser no formato (99) 9999-9999" required="required" />
</div>
@claudiosanches
claudiosanches / recebe.php
Created Sep 30, 2012
Exemplo de como adicionar ou atualizar dados com WPDB
View recebe.php
<?php
// Update table
function cs_add_data($competition, $date, $numbers) {
global $wpdb;
$table_name = $wpdb->prefix . 'nome da sua tabela';
$numbers = str_replace('/', '-', $numbers);
// Test variables
if (!is_numeric($competition))
wp_die('O número do concurso é inválido');
@claudiosanches
claudiosanches / functions.php
Last active May 9, 2021
WooCommerce - Change ajax variation threshold
View functions.php
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 10;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );