Skip to content

Instantly share code, notes, and snippets.

View vinigarcia87's full-sized avatar

Vinicius Oliveira Garcia vinigarcia87

View GitHub Profile
@Ocramius
Ocramius / User.php
Created October 23, 2011 14:22
Doctrine 2 @OneToMany @manytoone example
<?php
namespace HelloWorld;
use InvalidArgumentException;
/**
* This class is somewhere in your library
* @Entity
* @Table(name="users")
*/
@infojunkie
infojunkie / HelloPHPExcel.php
Last active March 23, 2018 14:04
HelloPOI - first experiment with Apache POI vs. PHPExcel
#!/usr/bin/php
<?php
require('PHPExcel/Classes/PHPExcel.php');
$workbook = PHPExcel_IOFactory::load($argv[1]);
$sheet = $workbook->getSheet(0);
foreach ($rit = $sheet->getRowIterator() as $row) {
foreach ($cit = $row->getCellIterator() as $cell) {
echo $cell->getCoordinate() . " - ";
@Ocramius
Ocramius / User.php
Last active July 24, 2024 14:38
Doctrine 2 ManyToMany - the correct way
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User
@erkobridee
erkobridee / npm-ntlm-proxy.md
Last active February 8, 2022 00:55
Problema: NPM atrás de um Proxy que utiliza autenticação NTLM

NPM vs NTLM PROXY

O problema: NPM atrás de um Proxy que utiliza autenticação NTLM

Ambiente do problema: Computador com Windows sem acesso administrador

Obs.: mesmo se você for administrador do computador, essa dica resolve o problema de como passar o NTLM Proxy, via linha de comando.


@BFTrick
BFTrick / woocommerce-get-product-weight.php
Created June 24, 2013 22:28
You can get a products weight using this snippet. You will need to be in the product loop to access it or on a page like content-single-product.php where you're already within the loop.
global $product;
$attributes = $product->get_attributes();
if ( $product->has_weight() ) {
echo $product->get_weight();
}
@NiklasHogefjord
NiklasHogefjord / gist:6104328
Created July 29, 2013 13:33
WooCommerce - Display cart total weight on the cart page
<?php
/**
* WooCommerce
* --------------
*
* Display cart total weight on the cart page
*
*/
add_action('woocommerce_cart_collaterals', 'myprefix_cart_extra_info');
@motin
motin / phpjavabridge-apache-poi-example-code.php
Created July 30, 2013 18:49
Example code using the Java library Apache POI (http://php-java-bridge.sourceforge.net/pjb/webapp.php) to manipulate ppt-files (PHPPowerPoint can only create, not manipulate files). Uses Java/PHP bridge (http://php-java-bridge.sourceforge.net/pjb/how_it_works.php)
<?php
require_once("http://localhost:8080/GapcmsJavaBridge/java/Java.inc");
// fake paths for gist
$sourceDataPpt = APP_PATH . "/includes/source_data.ppt";
$uploadedPpt = APP_PATH . "/upload/foo_data.ppt";
try {
@joyrexus
joyrexus / README.md
Last active June 19, 2024 09:35 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@mkdizajn
mkdizajn / function.php
Last active May 6, 2020 15:59
Wordpress Bootstrap 3 responsive images
<?php
//----------------------------------------------------------/
// responsive images [ 1) add img-responsive class 2) remove dimensions ]
//----------------------------------------------------------/
function bootstrap_responsive_images( $html ){
$classes = 'img-responsive'; // separated by spaces, e.g. 'img image-link'
// check if there are already classes assigned to the anchor
if ( preg_match('/<img.*? class="/', $html) ) {
@spigotdesign
spigotdesign / modify-theme-layout.php
Last active June 17, 2016 02:58
Theme layout mod for Hybrid Core layouts featrue
<?php
/**
* Modifies the theme layout
*
* @access public
* @param string $layout
* @return string
*/
function infusion_mod_theme_layout( $layout ) {