Skip to content

Instantly share code, notes, and snippets.

View yalamber's full-sized avatar
🎯
Focusing

yalamber yalamber

🎯
Focusing
View GitHub Profile
@yalamber
yalamber / gist:4942790
Created February 13, 2013 06:59
app.js
var express = require('express')
, S = require('string')
, moment = require('moment')
, redis = require('redis')
, RedisStore = require('connect-redis')(express)
, rClient = exports.rClient = redis.createClient()
, sessionStore = exports.sessionStore = new RedisStore({client: rClient})
, app = express()
, cfg = require('./config/app_conf')
, passport = require('passport')
add_action('wp_insert_post', 'wpexpo_on_publish');
function wpexpo_on_publish($post_id){
if ( !wp_is_post_revision( $post_id ) ) {
$post_status = get_post_status($post_id);
if($post_status == 'publish' and (isset($_POST['original_publish']) and $_POST['original_publish'] == 'Publish')){
//codes here
}
}
}
function export_connect_csv(user_id, file_location){
mysqlPool.getConnection(function(err, connection){
var csv_row = "Email,First Name,Last Name,Status,Created\n";
function processRow (row) {
var csv_row = row.email+','+row.first_name+','+row.last_name+','+row.status+','+row.created+"\n";
fs.appendFile(file_location, csv_row, function (err) {
if(err){
throw err;
}
});
function export_connect_csv(user_id, res){
ConnectModel.mysqlPool.getConnection(function(err, connection){
res.header('Content-Type', 'text/csv');
var csv_header_row = "Email,First Name,Last Name,Status,Created\n";
res.write(csv_header_row);
var query = connection.query('SELECT * FROM connects where user_id = ? AND deleted = 0', [user_id]);
query
.on('error', function(err) {
function export_connect_csv(user_id, res){
ConnectModel.mysqlPool.getConnection(function(err, connection){
res.header('Content-Type', 'text/csv');
var csv_header_row = "Email,First Name,Last Name,Status,Created\n";
res.write(csv_header_row);
var query = connection.query('SELECT * FROM connects where user_id = ? AND deleted = 0', [user_id]);
query
.on('error', function(err) {
# Configuration file for varnish
#
# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK
# to be set from this shell script fragment.
#
# Should we start varnishd at boot? Set to "no" to disable.
START=yes
# Maximum number of open files (for ulimit -n)
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 800;
}
@yalamber
yalamber / Braceschecker.js
Last active March 31, 2016 04:54
This function checks for braces
function bracesChecker(str) {
if(!str) {
return true;
}
var openingBraces = [’{’, ’[’, ’(’];
var closingBraces = [’}’, ’]’, ’)’];
var stack = [];
var openIndex;
var closeIndex;
//check for opening Braces in the val
@yalamber
yalamber / .gitignore
Created January 6, 2017 11:18
WordProject gitignore
/*
.DS_Store
!.gitignore
!wp-content/
# Ignore everything in the "wp-content" directory, except the "plugins"
# and "themes" directories.
wp-content/*
!wp-content/plugins/
!wp-content/themes/
<?php
/*
Plugin Name: Taxonomy Sync
Version: 0.1
*/
 
// Taxonomies
$taxonomies_to_sync = array( 'an', 'array', 'of', 'taxonomies', 'to', 'sync' ); // Change These!
 
function ms_taxonomy_sync_add_menu() {