Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/php
<?php
function get_ssl_domain_expiration($ssl_domain){
$i = 0;
$ssl_domain_data = array();
$domain = parse_url($ssl_domain, PHP_URL_HOST);
$g = stream_context_create (array("ssl" => array("capture_peer_cert" => true)));
$r = stream_socket_client("ssl://${domain}:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $g);
$cert = stream_context_get_params($r);
# Block WordPress xmlrpc.php requests
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
# END protect xmlrpc.php
@facelordgists
facelordgists / sed
Created January 30, 2019 22:35
how to use sed to search and replace strings inside files
#Standalone command
sed -i 's/old string/new string/g' /home/dude/text-file.txt
## use a custom separator
sed -i 's:old/folder/path:new/folder/path:g' /home/dude/text-file.txt
## dry run
sed 's/old string/new string/g' | less
@facelordgists
facelordgists / JS: How to find the sum of an array of numbers using reduce() function.js
Last active November 2, 2018 17:32
JS: How to find the sum of an array of numbers using reduce() function.js #javascript #js #reduce
// -----------------------------------
// Method #1
var sum = [1, 2, 3].reduce(add, 0);
function add(a, b) {
return a + b;
}
console.log(sum); // 6
@facelordgists
facelordgists / Angular HTML Button
Created November 1, 2018 00:02
Angular: How to toggle a variable back and forth between two strings
a(ng-click="") toggle
@facelordgists
facelordgists / Angular Scope Testing.md
Created November 1, 2018 00:02
This example shows the order that controllers, directives and properties get their scope.
@facelordgists
facelordgists / JS: How to reduce boil down arrays with reduce().txt
Last active November 2, 2018 17:32
JS: How to reduce boil down arrays with reduce().txt
http://adripofjavascript.com/blog/drips/boiling-down-arrays-with-array-reduce.html
// ===========================================================
// Simple toggle
// ----------------------------------
var bool = true;
bool = !bool;
// ===========================================================
// Function to toggle
// ----------------------------------
$scope.form_state.showing = false;
.row.row-eq-height(ng-repeat='product in productsFiltered=(products | filter:{name: filterQuery} | orderBy: sortTerm)' ng-if='$index % 3 == 0')
.col-xs-4(ng-repeat='i in [0, 1, 2]', ng-init='product = productsFiltered[$parent.$parent.$index + i]', ng-if='$parent.$index + i < productsFiltered.length')
.panel.b.product-list-block.mb-sm
.panel-heading
span.product-type-icon
div {{product.name}}
table.product-list-block-table.mt-lg.mb-lg
tbody
tr
th Price
@facelordgists
facelordgists / How to get the "Added" date of a file on a Mac.sh
Created November 1, 2018 00:00
When you download a file or add it to your system, it stamps it with that date and time.
#!/bin/sh
filepath="test.txt"
added_date__year_month_day=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "$filepath" | awk '{print $1}')
echo $added_date__year_month_day
#2017-12-10
added_date__year_month=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "$filepath" | awk '{print $1}' | cut -c1-7)
echo $added_date__year_month
# 2017-12