Skip to content

Instantly share code, notes, and snippets.

View yalamber's full-sized avatar
🎯
Focusing

yalamber yalamber

🎯
Focusing
View GitHub Profile
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) {
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;
}
});
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
}
}
}
@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')