Skip to content

Instantly share code, notes, and snippets.

@DZuz14
DZuz14 / createCookie.js
Last active June 22, 2017 15:31
Create Cookie With Javascript
function createCookie(name, value, expdays) {
var date, expires, serializedValue;
// Set Expiration date in the future
date = new Date();
date.setTime(date.getTime() + expdays * 86400000);
expires = 'expires=' + date.toUTCString();
// JSON stringify the object
serializedValue = JSON.stringify(value);
@DZuz14
DZuz14 / package.json
Created June 27, 2017 17:22
Jest/Enzyme Dependencies
{
"name": "dz-jest-boiler",
"version": "0.1.0",
"description": "Test React Component with Jest and Enzyme",
"main": "server.js",
"scripts": {
"test": "jest --verbose",
"dev": "webpack-dev-server"
},
"author": "Daniel Zuzevich",
@DZuz14
DZuz14 / mailchimp-dz.php
Last active June 28, 2017 02:13
Mailchimp API
<?php
$MailChimp = new MailChimp('insert api key here');
$list_id = 'gmj87s22'; // Mailchimp List Id
$email = $_POST['email'];
$first_name = $_POST['firstName'];
$last_name = $_POST['lastName'];
$result = $MailChimp->post("lists/$list_id/members", [
@DZuz14
DZuz14 / urlExtractor.js
Last active June 30, 2017 13:40
Query string value extraction
function urlExtractor(url) {
url = decodeURIComponent(url);
var charIndex = url.indexOf('=');
if(charIndex < 0) {
return;
}
var sliced = url.slice(charIndex).substring(1).replace(/_/g, ' ');
var inputField = document.getElementById('lead_source');
@DZuz14
DZuz14 / BattleShip.py
Created June 30, 2017 18:15
Python Battleship
from random import randint
board = []
# create the 5 x 5 board
for x in range(0, 5):
board.append(["O"] * 5)
board_index = len(board) - 1
@DZuz14
DZuz14 / SitemapGenerator.php
Created July 10, 2017 12:48
XML Sitemap Generator
<?php
/**
* Generate the sitemap_index file
*/
function generate_main() {
$main_xml = '<?xml version="1.0" encoding="UTF-8"?>';
$main_xml .= "\n";
$main_xml .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$main_xml .= "\n\n";
@DZuz14
DZuz14 / Header.php
Last active July 19, 2017 02:21
header
<!-- DZ Was Here -->
<div style="float: right;">
<a style="color: #9ABF93 !important;cursor: pointer;font-size:16px;" href="tel:8772714218">(877) 271-4218</a>
<?php echo do_shortcode('[aps-social id="2"]')?>
</div>
<!-- DZ Was Here -->
@DZuz14
DZuz14 / location-example.sh
Created July 24, 2017 16:16
Well Known Directory Lets Encrypt
server {
# Other config data will usually fill up this area
location ~ /.well-known {
allow all;
}
}
@DZuz14
DZuz14 / command.sh
Created July 24, 2017 16:25
Certbot SSL Cert Generation
sudo certbot certonly --webroot --webroot-path=/var/www/html -d example.com -d www.example.com
@DZuz14
DZuz14 / sheets.php
Created August 4, 2017 15:05
Accessing the Google Sheets API
<?php
// Insert into the sheet
$options = array('valueInputOption' => 'RAW');
$values = [
["$email","$first_name","$last_name","$zip_code"]
];
$body = new Google_Service_Sheets_ValueRange(['values' => $values]);
$result = $service->spreadsheets_values->append(SHEET_ID, 'A1:D', $body, $options);