Skip to content

Instantly share code, notes, and snippets.

View gregogalante's full-sized avatar
✌️
What's happening?

Gregorio Galante gregogalante

✌️
What's happening?
View GitHub Profile
@BadAllOff
BadAllOff / gist:06bbce913365363829e577c50d7980f0
Created June 18, 2017 09:29 — forked from WizardOfOgz/gist:1012107
Save Base64-encoded images with Paperclip
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#',
@bolderelements
bolderelements / hide-payment-based-on-shipping.php
Last active February 19, 2018 20:43
Hide Payment Gateway Based on Shipping Option Selected
/**
* 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();
@yorkxin
yorkxin / README.md
Last active October 27, 2020 12:17
Amazon S3 Redirect Rules Generator

Amazon S3 Redirect Rules Generator

A Ruby script to generate simple Amazon S3 Redirection Rules XML file.

Update: There is an app for that now! Use Amazon S3 Redirector (Web app) and you can generate the XML without any knowledge about Ruby. Thanks to @rainforestapp. BTW, It's open source too.

Dependencies

  • Nokogiri
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;
@igorbenic
igorbenic / hook.php
Created January 26, 2017 12:31
WooCommerce Stock Management with other Services | http://www.ibenic.com/woocommerce-stock-management-services
<?php
// woocommerce/includes/abstracts/abstract-wc-product.php
/**
* Returns number of items available for sale.
*
* @return int
*/
public function get_stock_quantity() {
@esamattis
esamattis / WebViewAutoHeight.js
Last active February 11, 2022 16:01
React native: Is it possible to have the height of a html content in a webview? http://stackoverflow.com/q/32952270
/*
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.
@ericchen
ericchen / gist:3081970
Created July 10, 2012 08:11
nodejs AES encrypt and decrypt
var crypto = require('crypto');
var AESCrypt = {};
AESCrypt.decrypt = function(cryptkey, iv, encryptdata) {
encryptdata = new Buffer(encryptdata, 'base64').toString('binary');
var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv),
decoded = decipher.update(encryptdata);
@ryanlecompte
ryanlecompte / gist:1283413
Created October 13, 2011 04:50
Providing an ActiveRecord-like before_filter capability to arbitrary Ruby classes
# First the end result of what we want:
class Foo
before_hook :whoa
before_hook :amazing
def test
puts "This is kinda cool!"
end
@emcmanus
emcmanus / snakeToCamelCase.js
Last active May 17, 2022 02:29 — forked from felixjung/snakeToCamelCase.js
ES6 module to recursively convert snake case keys in an object to camel case using lodash.
'use strict';
/**
* @example
* import keysToCamelCase from './snakeToCamelCase';
* keysToCamelCase({bad_key: 1}); => {badKey: 1}
* keysToCamelCase([{bad_key: 1}]); => [{badKey: 1}]
*/
function keysToCamelCase(object) {
@yacafx
yacafx / default
Last active February 9, 2023 20:07
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.
### /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;