Skip to content

Instantly share code, notes, and snippets.

View esgy's full-sized avatar
🏠
Working from home

Sorin Gitlan esgy

🏠
Working from home
View GitHub Profile
@esgy
esgy / angular-slick-directive
Created August 4, 2014 07:23
Angular SlickJs directive with reinit support
'use strict';
angular.module('app')
.directive('sgSlick', ['$timeout', function ($timeout) {
return {
restrict: 'AE',
scope: {
images: '=',
@esgy
esgy / post_types.php
Created November 13, 2012 17:28
create new post types wordpress
// Using JW_Post_Type.php
$product = new PostType("movie");
$product->add_taxonomy('Actor');
$product->add_taxonomy('Director');
$product->add_meta_box('Movie Info', array(
'name' => 'text',
'rating' => 'text',
'review' => 'textarea',
'Profile Image' => 'file'
@esgy
esgy / JW_Post_Type.php
Created November 13, 2012 17:29
JW_Post_Type.php for Wordpress
<?php
// include this JW_Post_Type.php into function.php
session_start();
/**
* JW Post Types
* @author Jeffrey Way
* @link http://jeffrey-way.com
*/
@esgy
esgy / move_wordpress.php
Created November 13, 2012 17:32
MOVING WORDPRESS
// Details here: http://codex.wordpress.org/Moving_WordPress
// For safe database changes:
// 1. Only perform a search and replace on the wp_posts table to not break the serialized data.
// 2. OR Use a utility script: https://github.com/interconnectit/Search-Replace-DB
@esgy
esgy / gist:4110083
Created November 19, 2012 10:51
javascript typeof helper
Object.toType = (function toType(global) {
return function(obj) {
if (obj === global) {
return "global";
}
return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
}
})(this)
@esgy
esgy / module.js
Created November 20, 2012 16:08
js: module pattern
var someModule = function(){
//private attributes
var privateVar = 5;
//private methods
var privateMethod = function(){
return 'Private Test';
};
return {
//public attributes
@esgy
esgy / singleton.js
Created November 20, 2012 16:01
js: Singleton pattern
var SingletonTester = (function()
{
//args: an object containing arguments for the singleton
function Singleton(args) {
//set args variable to args passed or empty object if none provided.
var args = args || {};
//set the name parameter
this.name = 'SingletonTester';
//set the value of pointX
this.pointX = args.pointX || 6; //get parameter from arguments or set default
@esgy
esgy / revealingmodule.js
Last active October 13, 2015 01:38
js: revealing module
/*
The idea here is that you have private methods
which you want to expose as public methods.
What are are doing below is effectively defining
a self-executing function and immediately returning
the object.
*/
var myRevealingModule = function(){
var name = 'John Smith';
@esgy
esgy / protopatern.js
Created November 20, 2012 16:09
js: prototype pattern
// No need for capitalization as it's not a constructor
var someCar = {
drive: function() {};
name: 'Mazda 3'
};
// Use Object.create to generate a new car
var anotherCar = Object.create(someCar);
anotherCar.name = 'Toyota Camry';
@esgy
esgy / wp-post-meta.php
Created November 26, 2012 15:06
wordpress get post meta - custom fields
$heading_image = get_post_meta($post->ID,"pageThumb",true);