Skip to content

Instantly share code, notes, and snippets.

@ghhv
ghhv / nginx.conf
Created April 3, 2016 09:37 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@ghhv
ghhv / gist:e5d2d4d1f23edb8f17a825f2b1cc3578
Created December 24, 2016 13:02 — forked from al3xandru/gist:1128606
nvALT Bookmarklet
javascript:(function({
var INSTAPAPER=true,w=window,d=document,pageSelectedTxt=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pageTitle=d.title,pageUri=w.location.href,tmplt="";
tmplt="From ["+pageTitle+"]("+pageUri+"):\n\n";
if(pageSelectedTxt!="") {
pageSelectedTxt=">%20"+pageSelectedTxt;
pageSelectedTxt=pageSelectedTxt.replace(/(\r\n|\n+|\r)/gm,"\n");
pageSelectedTxt=pageSelectedTxt.replace(/\n/g,"\n>%20\n>%20");
w.location.href="nvalt://make/?txt="+encodeURIComponent(tmplt+pageSelectedTxt)+"&title="+encodeURIComponent(pageTitle)
}
else {
@ghhv
ghhv / 0_reuse_code.js
Created January 6, 2017 08:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ghhv
ghhv / Vue.html
Created January 6, 2017 12:09 — forked from dengjonathan/Vue.html
Vue example by reader @thoragio
<div id="counter">
<button @click="up()">+</button>
<p id="count">{{ value }}</p>
<button @click="down()">-</button>
</div>
<script>
var counter = new Vue({
el: '#counter',
data: {
value: 0
@ghhv
ghhv / gist:fe9f0117fcdb06be6a2367bb179a67fe
Created August 6, 2017 18:53 — forked from bradleysa/gist:7d1448253097784daf94
WooCommerce: Add Continue Shopping Button on Cart Page
<?php
/**
* Add Continue Shopping Button on Cart Page
* Add to theme functions.php file or Code Snippets plugin
*/
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
function woo_add_continue_shopping_button_to_cart() {
<?php
// Geo Redirect using Cloudflare
$activepage = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
$page_from = "www.domain.tld/";
$page_to = "www.newdomain.tld/";
?>
<!-- Country Code : <?php echo $country_code; ?> -->
<!-- Active URL : <?php echo $activepage; ?> -->
@ghhv
ghhv / maintenance.php
Created March 12, 2018 07:04 — forked from bjornjohansen/maintenance.php
Custom WordPress maintenance mode page
<?php
wp_load_translations_early();
$protocol = wp_get_server_protocol();
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 30' );
?>
<!DOCTYPE html>
<html>
@ghhv
ghhv / traefik_portainer.md
Created March 21, 2020 09:14 — forked from ruanbekker/traefik_portainer.md
Traefik with SSL + Portainer on Docker Swarm Repro

Traefik and Portainer on Docker Swarm with Letsencrypt

Reproducing a Traefik with SSL and Portainer setup on a 2 Node Docker Swarm

Install Docker:

Install Docker on both nodes with a Bootstrap Script:

$ curl https://gitlab.com/rbekker87/scripts/raw/master/setup-docker-ubuntu.sh | bash
/* keep a reference to original toISOString to use it into new method */
const oldToISOString = Date.prototype.toISOString
/* Define new method */
const toISOString = function toISOString(date) {
if(!date) return date;
/* extract GTM timezone from date.toString() */
const regex = /(?:GMT)([-+]\d*)/gm;
let gtm = regex.exec(date.toString())[1];
gtm = [...gtm];
/* insert ':' in time -0500 -> -05:00*/
@ghhv
ghhv / AuthyToOtherAuthenticator.md
Created February 15, 2022 02:41 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My guess is that Brian used the