Skip to content

Instantly share code, notes, and snippets.

View malkafly's full-sized avatar
🏠
Working from home

d. malk malkafly

🏠
Working from home
View GitHub Profile
@malkafly
malkafly / woocommerce-custom-shipping-method.php
Created February 20, 2018 18:10 — forked from alordiel/woocommerce-custom-shipping-method.php
Adding custom shipping method for WooCommerce (v. 3.2.6)
<?php
//Works with WooCommerce 3.2.6
add_action( 'woocommerce_shipping_init', 'econt_shipping_method' );
function econt_shipping_method() {
if ( ! class_exists( 'WC_Econt_Shipping_Method' ) ) {
class WC_Econt_Shipping_Method extends WC_Shipping_Method {
public function __construct( $instance_id = 0 ) {
$this->instance_id = absint( $instance_id );
$this->id = 'econt';//this is the id of our shipping method
@malkafly
malkafly / install.sh
Created March 3, 2018 02:34
Installs LAMP with PHP 5.6 on Ubuntu 16.04
#!/bin/bash
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y apache2
sudo ufw allow in "Apache Full"
sudo apt-get install -y mysql-server
# After running this command, select (Y), option 2, then (Y) for the rest of the prompts.
sudo mysql_secure_installation
@malkafly
malkafly / guz.php
Created March 6, 2018 16:43 — forked from igoralves1/guz.php
Consuming API endpoints with Laravel 5+ AND Guzzle\Http
/*
Installation -> http://docs.guzzlephp.org/en/latest/overview.html#installation
https://www.youtube.com/watch?v=GunXVUqvO-s
https://www.udemy.com/http-clients-with-laravel-use-and-consume-services-and-apis/
add Guzzle as a dependency using the composer.phar CLI:
@malkafly
malkafly / mysql_outfile.sql
Created June 1, 2018 12:56 — forked from reyesyang/mysql_outfile.sql
Export MySQL query result to CSV file
SELECT id, username, (total_point - spent_point) AS point
FROM users
ORDER BY point DESC
LIMIT 50
INTO OUTFILE '/tmp/bbs_points_top50.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
;
@malkafly
malkafly / gist:f8f76878cc4e75900f7482354d69d3ef
Created September 19, 2018 23:14 — forked from khakimov/gist:3558086
Matrix Effect in you terminal
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
@malkafly
malkafly / bitbucket-pipelines.yml
Created November 22, 2018 10:52 — forked from mcnamee/bitbucket-pipelines.yml
Bitbucket Pipelines - Deploy via FTP to shared hosting
# Installation ---
# 1. In Bitbucket, add $FTP_USERNAME $FTP_PASSWORD and $FTP_HOST as environment variables.
# 2. Commit this file to your repo
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initial GitFTP)
#
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (from Bitbucket Cloud) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud) - if multiple deploys fail, you
@malkafly
malkafly / index.markdown
Created March 17, 2020 20:01
Integrações RD Station - PHP

Integrações RD Station

PHP

Muitos sites em PHP possuem uma página que é um script para enviar o email de contato ou tratar o preenchimento de algum formulário.

Para fazer com que essa página envie os dados para o CRM do RD Station, é só inserir nosso script de integração em seu código e fazer a chamada quando for controlar a submissão dos dados.

Script para integração

@malkafly
malkafly / group-objects-by-property.md
Created March 27, 2020 19:24 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@malkafly
malkafly / README.md
Created June 3, 2020 19:36 — forked from dalezak/README.md
Ionic Capacitor Resources Generator
  1. Run npm install cordova-res --save-dev
  2. Create 1024x1024px icon at resources/icon.png
  3. Create 2732x2732px splash at resources/splash.png
  4. Add "resources": "cordova-res ios && cordova-res android && node scripts/resources.js" to scripts in package.json
  5. Copy resources.js file to scripts/resources.js
  6. Run sudo chmod -R 777 scripts/resources.js
  7. Run npm run resources
cd /var/www/my_website_serving_dir
sudo chown -R $USER:www-data .
sudo find . -type f -exec chmod 664 {} \;
sudo find . -type d -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache