Skip to content

Instantly share code, notes, and snippets.

Avatar

Vinícius Augusto Cunha ViniciusAugusto

View GitHub Profile
View string.md

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

View notification.js
document.addEventListener('DOMContentLoaded', function () {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
});
View js Harlen Shake
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e&&!isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}funct
@ViniciusAugusto
ViniciusAugusto / controller.js
Created Apr 21, 2016
AngularJS - cancel all $timeouts on route change
View controller.js
//Since you are doing this in a loop, every iteration will over write $scope.dataTimeout so it will only contain reference to the very last $timeout
//You would need to create an array instead to be able to access them all.
var dataTimeout=[];
//Then in the loop:
var timeOut = $timeout(function () {
fetchStatus(job);
}, 1000);
@ViniciusAugusto
ViniciusAugusto / Collection.php
Created Jan 5, 2016
Sem estoque, por ultimo na listagem de produtos - Magento 1.7.0.0 +
View Collection.php
// insira o codigo abaixo para colocar os produtos sem estoque por ultimo na listagem de produtos do magento
// depois de
if ($attribute == 'price' && $storeId != 0) {
//no arquivo app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php se a versão do Magento 1.7.0.0 +
//alteração
$this->getSelect()->joinLeft(
array('_inventory_table'=>$this->getTable('cataloginventory/stock_item')),
View Git Tutorial
Iniciando:
TERMINAL SERVIDOR:
ssh root@10.1.1.202
cd /var/www/html/sites/2015/projeto/
git init
TERMINAL HOSPEDAGEM:
ssh projeto@projeto.com.br
mkdir projeto.git
@ViniciusAugusto
ViniciusAugusto / popup.js
Last active Nov 5, 2015
Popup com cookie
View popup.js
jQuery(document).ready(function() {;
if (getCookie('popup') == "") {
beginNewsletterForm();
}
});
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
@ViniciusAugusto
ViniciusAugusto / price.phtml
Created Sep 29, 2015
Magento: Show product discount percent
View price.phtml
If you wish to show product discount percent next to product price or somewhere on a product page, here’s how you do it.
Open app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml
Find:
<?php endif; /* if ($_finalPrice == $_price): */ ?>
Past above it:
@ViniciusAugusto
ViniciusAugusto / delete.sql
Created Sep 28, 2015
Magento - Deletar todos os produtos via sql
View delete.sql
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
View Magento Add Attribute Options Programmatically
<?php
require_once('app/Mage.php'); //Path to Magento
error_reporting(E_ALL);
ini_set("display_errors", 1);
umask(0);
Mage::app();
You can’t perform that action at this time.