Skip to content

Instantly share code, notes, and snippets.

✌️
What's happening?

Gregorio Galante gregogalante

✌️
What's happening?
Block or report user

Report or block gregogalante

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bolderelements
bolderelements / hide-payment-based-on-shipping.php
Last active Feb 19, 2018
Hide Payment Gateway Based on Shipping Option Selected
View hide-payment-based-on-shipping.php
/**
* Hide the PayPal payment option when the customer selects a specific Table Rate option
* Code snippets should be added to the functions.php file of your child theme
*
* @return array
*/
function alter_payment_gateways( $list ){
// Retrieve chosen shipping options from all possible packages
$chosen_rates = ( isset( WC()->session ) ) ? WC()->session->get( 'chosen_shipping_methods' ) : array();
@yacafx
yacafx / default
Last active Jul 16, 2019
NGNIX configuration for run node app and php app at the same same time - This configuration made Node and Wordpress working at the same time on two different routes.
View default
### /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.php;
@BadAllOff
BadAllOff / gist:06bbce913365363829e577c50d7980f0
Created Jun 18, 2017 — forked from WizardOfOgz/gist:1012107
Save Base64-encoded images with Paperclip
View gist:06bbce913365363829e577c50d7980f0
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@emcmanus
emcmanus / snakeToCamelCase.js
Last active Aug 31, 2018 — forked from felixjung/snakeToCamelCase.js
ES6 module to recursively convert snake case keys in an object to camel case using lodash.
View snakeToCamelCase.js
'use strict';
/**
* @example
* import keysToCamelCase from './snakeToCamelCase';
* keysToCamelCase({bad_key: 1}); => {badKey: 1}
* keysToCamelCase([{bad_key: 1}]); => [{badKey: 1}]
*/
function keysToCamelCase(object) {
View hook.php
<?php
// woocommerce/includes/abstracts/abstract-wc-product.php
/**
* Returns number of items available for sale.
*
* @return int
*/
public function get_stock_quantity() {
@0x263b
0x263b / colors.md
Last active Oct 1, 2019
Random color from string in javascript
View colors.md

Random color from string in javascript

Consider a list of strings you need to permanently assign a random color.

First you should turn the string into a hash.

var string = "string"
var hash = 0
@jarretmoses
jarretmoses / React Native Clear Cache
Last active Nov 11, 2019
Clearing the Cache of your React Native Project
View React Native Clear Cache
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
View NavigationBarAndroid.java
package com.yourapp.navbar;
import android.app.Activity;
import android.view.View;
import com.facebook.react.ReactActivity;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@epeli
epeli / WebViewAutoHeight.js
Last active Nov 8, 2019
React native: Is it possible to have the height of a html content in a webview? http://stackoverflow.com/q/32952270
View WebViewAutoHeight.js
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Esa-Matti Suuronen <esa-matti@suuronen.org>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
You can’t perform that action at this time.