Skip to content

Instantly share code, notes, and snippets.

View divsbhalala's full-sized avatar

Divyesh Bhalala divsbhalala

View GitHub Profile
@divsbhalala
divsbhalala / aws_import.sh
Created August 29, 2022 13:38 — forked from radiofrequency/aws_import.sh
Import lets encrypt cert to aws certificate manager in renew hook
#place in /etc/letsencrypt/renewal-hooks/post
export AWS_ACCESS_KEY_ID=XXX
export AWS_SECRET_ACCESS_KEY=XXX
#certs must be in us-east-1 to use with cloudfront
export AWS_DEFAULT_REGION=us-east-1
#run without --certificate-arn first time then specify arn for updates
aws acm import-certificate --certificate file:///etc/letsencrypt/live/site.com/cert.pem --private-key file:///etc/letsencrypt/live/site.com/privkey.pem --certificate-chain file:///etc/letsencrypt/live/site.com/chain.pem --certificate-arn specifyarnforupdate
@divsbhalala
divsbhalala / getdates.js
Created July 26, 2019 14:24 — forked from miguelmota/getDates.js
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
var getDates = function(startDate, endDate) {
var dates = [],
currentDate = startDate,
addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
while (currentDate <= endDate) {
@divsbhalala
divsbhalala / bot.json
Created January 3, 2019 13:23 — forked from abhivijay96/bot.json
Bot compiler todo bot demo
{
"intents": [
{
"name": "addTodo",
"utterances": [],
"parameters": [],
"response": {
"type": "mb",
"value": "add"
}
@divsbhalala
divsbhalala / fix-homebrew-npm.md
Created October 9, 2018 17:21 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@divsbhalala
divsbhalala / js.js
Created October 8, 2018 18:26 — forked from GaryJones/js.js
Gravity Forms Countries dropdown with country codes
var countryCodes = {
'Afghanistan': '93',
'Albania': '355',
'Algeria': '213',
'American Samoa': '684',
'Andorra': '376',
'Angola': '244',
'Antigua and Barbuda': '1-268',
'Argentina': '54',
'Armenia': '374',
@divsbhalala
divsbhalala / save_upload_field_to_custom_field.php
Created August 22, 2018 08:33 — forked from saltnpixels/save_upload_field_to_custom_field.php
gravity form upload file to media library and use attachment ID in custom field
add_action( 'gform_after_create_post', 'gf_add_to_media_library', 10, 3 );
/**
* Save file upload fields under custom post field to the library
*
* @param $post_id The post identifier
* @param $entry The entry
* @param $form The form
*/
@divsbhalala
divsbhalala / countiesIreland.json
Created August 20, 2018 06:33 — forked from kanejoe/countiesIreland.json
Counties of Ireland in JSON format
[
"Antrim",
"Armagh",
"Carlow",
"Cavan",
"Clare",
"Cork",
"Derry",
"Donegal",
"Down",
@divsbhalala
divsbhalala / ubuntu-install-nodejs-npm.sh
Created July 27, 2018 08:00 — forked from kolosek/ubuntu-install-nodejs-npm.sh
Install node.js version 6.x Ubuntu 16.04
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
echo "Installing NodeJS 6.x"
sudo apt-get install nodejs
echo "Install webpack globally"
sudo npm install webpack -g
echo "Install nightwatch globally"
sudo npm install webpack -g
@divsbhalala
divsbhalala / delete-all-woocommerce-products.php
Created June 23, 2018 15:13 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@divsbhalala
divsbhalala / latest-ffmpeg-centos6.sh
Created February 26, 2017 05:26 — forked from mustafaturan/latest-ffmpeg-centos6.sh
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0