Skip to content

Instantly share code, notes, and snippets.

View stefanolaru's full-sized avatar

Ștefan Olaru stefanolaru

View GitHub Profile
@stefanolaru
stefanolaru / gist:e282805f8a3d027e18964810eea050be
Created June 8, 2021 05:52
Block bots scanning for WordPress URLs in a LAMP env
# block WP requests
RewriteCond %{THE_REQUEST} /(wp-content|wp-admin|wp-includes|wp-login) [NC]
RewriteRule ^(.*)$ - [F,L]
@stefanolaru
stefanolaru / view.vue
Created January 23, 2021 03:10
sample template
<template>
<div class="p-4 bg-gray-900">Hello from Gist!</div>
</template>
@stefanolaru
stefanolaru / product-1.js
Last active December 10, 2020 06:42
GumCart code samples
// A simple product with maximum available quantity.
GumCart.addItem({
id: "HEADPHONES", // optional
name: "Wireless Headphones", // required
price: 89, // required
max_quantity: 2,
image:
"https://gumcart.com/images/products/product-1.jpg",
});
// open the cart
@stefanolaru
stefanolaru / haversine.js
Created May 8, 2020 05:57
calculate distance between 2 map points
'use strict';
const toRadians = degrees => (Math.PI / 180) * degrees;
const toDegrees = radians => (180 * radians) / Math.PI;
const earthRadius = 6371e3; // metres
module.exports.getDistance = (ne_lat, sw_lat, ne_lng, sw_lng) => {
var lat1 = toRadians(ne_lat);
var lat2 = toRadians(sw_lat);
var lat_diff = toRadians(sw_lat - ne_lat);
for bucket in $(aws s3api list-buckets --query "Buckets[].Name" --output text); do echo $bucket
aws s3api list-objects --bucket $bucket --output json --query "[sum(Contents[].Size), length(Contents[])]"; done
@stefanolaru
stefanolaru / css_path.js
Last active February 11, 2020 05:13 — forked from asfaltboy/css_path.js
Get Element CSS Selector
/*
* Copyright (C) 2015 Pavel Savshenko
* Copyright (C) 2011 Google Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Matt Lilek <[email protected]>
* Copyright (C) 2009 Joseph Pecoraro
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
<?php
array (
'sitemap.xml' => 'index.php?aiosp_sitemap_path=root',
'(.+)-sitemap(\\d+).xml' => 'index.php?aiosp_sitemap_path=$matches[1]&aiosp_sitemap_page=$matches[2]',
'(.+)-sitemap.xml' => 'index.php?aiosp_sitemap_path=$matches[1]',
'^wp-json/?$' => 'index.php?rest_route=/',
'^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
'^index.php/wp-json/?$' => 'index.php?rest_route=/',
'^index.php/wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]',
'listings/?$' => 'index.php?post_type=property',
@stefanolaru
stefanolaru / puppeteer_test.js
Created January 30, 2019 14:34
Puppeteer Screenshot Test
'use strict';
var puppeteer = require('puppeteer');
module.exports.pptr = async (event, context) => {
puppeteer.launch().then(async browser => {
const page = await browser.newPage();
@stefanolaru
stefanolaru / dropzones3.js
Created January 15, 2019 18:34
Dropzone get signed request and upload to S3
var dz = new Dropzone('#dropzone-uploader', {
url: '/admin/media/upload',
acceptedFiles: 'image/jpeg',
method: 'put',
maxFilesize: 2,
parallelUploads: 1,
uploadMultiple: false,
createImageThumbnails: false,
autoProcessQueue: false,
previewTemplate: $('#preview-template').html(),
@stefanolaru
stefanolaru / axios.oauth.js
Last active January 2, 2019 17:02
OAuth1.0 signing request to interact with Woocommerce API / Axios /NodeJS
'use strict';
var axios = require('axios'),
oauth = require('oauth-sign'),
qs = require('querystring'),
config = require('./config.json');
// read config
var $woo = config.woo;
module.exports.woo = async (event, context) => {