Skip to content

Instantly share code, notes, and snippets.

@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@learncodeacademy
learncodeacademy / pubsub.js
Created July 29, 2015 02:54
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@robflaherty
robflaherty / csv-to-json.php
Created September 1, 2011 02:26
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@tomazzaman
tomazzaman / class-developer-import.php
Created March 31, 2015 18:03
Import JSON into WordPress
<?php
// Published under GPL
// tutorial here: https://codeable.io/community/how-to-import-json-into-wordpress/
class Developer_Import {
public function __construct() {
add_action( 'wp_ajax_import_developer', array( $this, 'import_developer' ) );
@nola
nola / tweenmax-scroll
Last active August 5, 2018 05:47
Calculate percentage of scroll Then uses tweenmax callbacks to continue the animation
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.10.1/TweenMax.min.js"></script>
<script>
$(function(){
@nola
nola / two-objs.js
Last active December 29, 2015 14:49
The following example creates myHonda with three properties. Note that the engine property is also an object with its own properties.
var myHonda = {color: "red", wheels: 4, engine: {cylinders: 4, size: 2.2}};
//console edits and results
myHonda.color
"red"
myHonda.engine
Object {cylinders: 4, size: 2.2}
myHonda.engine.size
2.2
myHonda.engine.size = "3.3"
@nola
nola / for-in.js
Last active December 29, 2015 14:49
Enumerating over all the properties in an object. Find out whats in there.
//create the object with properties & values.
var myCar = new Object();
myCar.make = "Ford";
myCar.model = "Mustang";
myCar.year = 1969;
//then LOOP(enumerate) through all the properties of the object myCar
function showProps(obj, objName) {
var result = "";
for (var i in obj) {
@nola
nola / object-constructor.js
Last active December 29, 2015 12:28
1. Define the object type by writing a constructor FUNCTION. Use a capital letter. 2. You can create any number of Car objects by calls to new. For example, 3. mycar.year = 1993, and so on. 4. then pass in an object as a property 5. create some new Person objects 6. create some new Car objects. Pass objects rand and ken as the arguments for the …
//1
function Car(make, model, year, owner) {
this.make = make;
this.model = model;
this.year = year;
this.owner = owner;
//Notice the use of this to assign values to the object's properties based on the values passed to the function.
}
//2
@nola
nola / shortarray.js
Created November 26, 2013 01:35
Useful way of declaring small arrays on one line. Object Array Notation Shorthand
var a = new Array();
a[0] = "myString1";
a[1] = "myString2";
a[2] = "myString3";
//short hand version
var a = ["myString1", "myString2", "myString3"];