Skip to content

Instantly share code, notes, and snippets.

@iwek
iwek / A-Z-Category-Index.php
Created October 30, 2012 02:42
A-Z Category Index
<?php
/**
* @package A-Z Category Index
* @version 0.1
*/
/*
Plugin Name: A-Z Category Index
Plugin URI: http://wordpress.org/
Description: A-Z Category Index where each letter takes you to a page with a list of categories that start with that letter.
Version: 0.1
@iwek
iwek / AZ-Template-Page.php
Created October 30, 2012 02:43
AZ Category Index Template Page
<?php
/*
Template Name: Page Template for AZ Categories Index
Author URI: http://techslides.com/
*/
?>
<?php get_header(); ?>
<div id="content" class="widecolumn">
<?php
@iwek
iwek / typo.js
Created November 20, 2012 22:20
Typo Generator in JavaScript
function getTypos(str) {
//http://stackoverflow.com/questions/1431094/how-do-i-replace-a-character-at-a-particular-index-in-javascript
String.prototype.replaceAt=function(index, char) {
return this.substr(0, index) + char + this.substr(index+char.length);
}
//define proximity arrays
var array_prox = [];
@iwek
iwek / typo.php
Created November 20, 2012 22:21
Typo Generator in PHP
function getTypos($str) {
$typosArr = array();
$strArr = str_split($str);
//Proximity of keys on keyboard
$arr_prox = array();
$arr_prox['a'] = array('q', 'w', 'z', 'x');
$arr_prox['b'] = array('v', 'f', 'g', 'h', 'n');
@iwek
iwek / sample.log
Created November 30, 2012 18:37
sample log file
www.three.com 10.15.101.11 1353280801 TEST 345
www.one.com 10.14.101.11 1353280801 TEST 343
www.three.com 1.10.11.71 1353280801 TEST 323
www.one.com 10.15.11.61 1353280801 TEST 365
www.two.com 10.10.11.51 1353290801 TEST 55
www.two.com 10.20.13.11 1353290801 REST 435
www.one.com 10.20.14.41 1353290801 REST 65
www.two.com 10.10.11.14 1353290801 REST 345
www.three.com 10.10.11.31 1354280801 REST 34
www.one.com 10.10.13.144 1354280801 JSON 65
@iwek
iwek / html5-blank-template
Created January 19, 2013 03:50
HTML5 Blank Template with jQuery
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blank HTML5</title>
<style>
</style>
</head>
<body>
@iwek
iwek / js-nested-function-example.js
Last active May 6, 2017 03:33
JavaScript Nested Function Example
function f() {
var z = 1;
function g(y) {
alert(y + z);
}
g(2);
}
f();// calls f and alerts 3
g(2); //ReferenceError: g is not defined
@iwek
iwek / js-closure-example.js
Last active January 14, 2016 16:42
JavaScript Closure Example
function f(y) {
var z = 1;
return function g(y) {
alert(y + z);
}
}
var z=10;
f(); //returns the function: function g(y) {alert(y + z);}
f()(2); //grabs function g, assings 2 to y, knows z is 1 through closure scope and makes an alert(3)
@iwek
iwek / js-closure-better-example.js
Created January 20, 2013 05:33
JavaScript Better Closure Example
function one(y) {
var z = 1;
return function g(y) {
var all = y + z;
return all;
}
}
var z=10;
var b = one();
function two(t){
@iwek
iwek / js-variables-and-scope.js
Last active December 11, 2015 10:28
JavaScript Variables and Scope
v1 = 1; // Global Scope
var v2 = 2; // Variable defined with var keyword but not within a function: Global Scope
function f() {
v3 = 3; // No var keyword: Global Scope
var v4 = 4; // Local Scope only
var v5 = v1+v2+v3; //1+2+3=6 - Local Scope only, can access v1 and v2 variables from the Global Scope
}
v1; //1 - JavaScript can access the variable as it lives in the Global Scope