Skip to content

Instantly share code, notes, and snippets.

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

Rituparna sonowal eagleyed

🏠
Working from home
  • Individual
  • Kolkata, India
View GitHub Profile
@eagleyed
eagleyed / gist:6a448125aaa1fb49b791ad7cde8162c4
Created May 15, 2019 13:25 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@eagleyed
eagleyed / docker-help.md
Created May 4, 2020 21:28 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@eagleyed
eagleyed / scrapy.md
Created May 5, 2020 10:00 — forked from bradtraversy/scrapy.md
Scrapy commands and code
@eagleyed
eagleyed / node_nginx_ssl.md
Created May 5, 2020 10:03 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@eagleyed
eagleyed / python_heroku.MD
Created May 5, 2020 10:12 — forked from bradtraversy/python_heroku.MD
Python & Postgres Heroku Deployment

Python Heroku Deployment

Steps to create a postgres database and deply a Python app to Heroku

Install guinicorn locally

pipenv install gunicorn
or
pip install gunicorn

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@eagleyed
eagleyed / docker_wordpress.md
Created May 5, 2020 12:05 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@eagleyed
eagleyed / webpack.config.js
Created June 10, 2020 10:24 — forked from wpscholar/webpack.config.js
Get started with WebPack in WordPress today!
'use strict';
const autoprefixer = require('autoprefixer');
const browsers = require('@wordpress/browserslist-config');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const webpack = require('webpack');
module.exports = function (env, options) {
@eagleyed
eagleyed / wc-automatically-complete-orders.php
Created August 7, 2020 10:58
[Frontend Snippets] Automatically complete all orders
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );