Skip to content

Instantly share code, notes, and snippets.

View marcosnakamine's full-sized avatar

Marcos Nakamine marcosnakamine

View GitHub Profile
@marcosnakamine
marcosnakamine / script.js
Created November 25, 2016 23:36
Fancybox - Trigger open image
$.fancybox.open({
href:'image.jpg'
});
@marcosnakamine
marcosnakamine / date.php
Created November 27, 2016 16:35
PHP - Compare two dates
<?php
if(strtotime(date('d-m-Y')) > strtotime('27-11-2016')) {
echo 'OK';
}
@marcosnakamine
marcosnakamine / 000-default.conf
Last active January 24, 2017 16:24
Apache 2.4 - Localhost configuration
#/etc/apache2/sites-available/000-default.conf
DocumentRoot /home/user/Projects
<Directory /home/user/Projects/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
@marcosnakamine
marcosnakamine / wetransfer.sh
Created February 3, 2017 11:07
Shell - Download with command line
#!/bin/bash
wget --user-agent Mozilla/4.0 'wetransferlink' -O file.zip
@marcosnakamine
marcosnakamine / index.php
Created February 3, 2017 12:28
PHP - Google Recaptcha
<?php
if ( isset( $_POST['g-recaptcha-response'] ) ) {
// ENVIA INFORMAÇÕES POR POST PARA TESTAR O CAPTCHA
$result = file_get_contents( 'https://www.google.com/recaptcha/api/siteverify', false, stream_context_create( array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query( array(
@marcosnakamine
marcosnakamine / index.php
Created February 15, 2017 18:13
PHP - Sending header in cURL
<?php
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'http://url.com' );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml' ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );
var_dump( $output );
@marcosnakamine
marcosnakamine / download.sh
Created February 9, 2017 10:40
Shell - Download with wget authentication
#!/bin/bash
wget --auth-no-challenge --user='user' --password='pass' 'url'
@marcosnakamine
marcosnakamine / functions.php
Last active March 6, 2017 18:44 — forked from jameskoster/functions.php
WooCommerce - Change number of products per row
<?php
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
@marcosnakamine
marcosnakamine / index.php
Last active March 10, 2017 13:18
WooCommerce - Get product tags, image and permalink with ACF
<?php
$cat = get_categories( array(
'taxonomy' => 'product_tag'
) );
foreach( $cat as $key => $value ){
var_dump( get_field( 'imagem', 'product_tag_'.$value->term_id ) );
echo get_term_link( $value->term_id, 'product_tag' );
}
@marcosnakamine
marcosnakamine / functions.php
Last active March 10, 2017 13:18 — forked from jameskoster/functions.php
WooCommerce - Change number of columns on archives
<?php
add_filter( 'projects_loop_columns', 'jk_projects_columns', 99 );
function jk_projects_columns( $cols ) {
$cols = 3;
return $cols;
}