Skip to content

Instantly share code, notes, and snippets.

@DZuz14
DZuz14 / AlarmManagerModule.js
Created May 31, 2017 19:47
Java Module that communicates JS with Native Android AlarmManager
// Android & Java
import android.widget.Toast;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.Context;
import java.util.Calendar;
// React
import com.facebook.react.bridge.NativeModule;
@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 / getCookie.js
Created June 22, 2017 12:21
Retrieve A Cookie With Javascript
function getCookie(cookieName) {
var name = cookieName + '='
var arr = document.cookie.split(';')
for (var i = 0; i < arr.length; i++) {
var str = arr[i]
while (str.charAt(0) === ' ') {
str = str.substring(1)
}
@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;
}
}