Skip to content

Instantly share code, notes, and snippets.

View maisnamraju's full-sized avatar

Maisnam Raju Singh maisnamraju

View GitHub Profile
@maisnamraju
maisnamraju / Database Model Content
Last active August 29, 2015 14:05
Uploading csv data to mysql database in codeigniter with Timestamp
$file_path = FCPATH.'/uploads/'. $current_user.'.csv'; //It should always be set to FCPATH to make sure that the path is absolute
$query_name = "LOAD DATA LOCAL INFILE '"
. $file_path .
"' INTO TABLE `"
. $this->table_name .
"` FIELDS TERMINATED BY ','
LINES TERMINATED BY '\\n'
IGNORE 1 LINES
(time_stamp,curr_property,curr_property_cost,day_property,day_property_cost,curr_solar_generating,curr_solar_export,day_solar_generated,day_solar_export,curr_chan1,curr_chan2,curr_chan3,day_chan1,day_chan2,day_chan3)

If you are using vagrant, you probably-statistically are using git. Make sure you have its binary folder on your path, because that path contains 'ssh.exe'.

Now, modify C:\vagrant\vagrant\embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\ssh.rb to comment out the faulty Windows check and add a real SSH check:

# if Util::Platform.windows?
  # raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],
                                       # :port => ssh_info[:port],
                                       # :username => ssh_info[:username],
 # :key_path => ssh_info[:private_key_path]
@maisnamraju
maisnamraju / passport-config.js
Created November 27, 2014 07:17
passport local authentication in express
var config = require('./config');
var passport = require('passport');
var User = require('./models/user');
var LocalStrategy = require('passport-local').Strategy;
var isValidPassword = function(user, password){
return bCrypt.compareSync(password, user.password);
};
// Generates hash using bCrypt
@maisnamraju
maisnamraju / Calling the file
Created March 26, 2015 16:50
setting state of component in reactjs
var renderTabsContent = function(content){
if(typeof content === 'object') {
return(
<span dangerouslySetInnerHTML={{__html: content.text }} />
class Header extends React.Component{
constructor(props, context) {
super(props);
}
toggleAdvancedSearch() {
React.render(
@maisnamraju
maisnamraju / gist:c64a767d3a420946ce02
Created August 3, 2015 14:45
nginx config to proxy ghost blog
server {
listen 80;
server_name site_name;
location / {
proxy_pass http://127.0.0.1:2368;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
@maisnamraju
maisnamraju / closure.js
Created August 11, 2015 13:31
Example of a closure
var counter = (function() {
var privateCounter = 0;
function changeBy(val) {
privateCounter += val;
}
return {
increment: function() {
changeBy(1);
},
decrement: function() {
@maisnamraju
maisnamraju / mail.js
Last active October 10, 2018 15:38
Nodemailer with Mailgun to send email templates
"use strict";
let nodemailer = require('nodemailer');
let jade = require('jade');
let mailgunTransport = require('nodemailer-mailgun-transport');
let nodeTemplates = require('email-templates');
let path = require('path');
let nconf = require('nconf');
let co = require('co');
@maisnamraju
maisnamraju / logger.js
Created May 5, 2016 13:38 — forked from rtgibbons/logger.js
Logger Library with winston
var app = require(process.cwd() + '/app');
var winston = require('winston');
var _ = require('lodash');
// Set up logger
var customColors = {
trace: 'white',
debug: 'green',
info: 'green',
warn: 'yellow',
@maisnamraju
maisnamraju / pub-sub.js
Created August 1, 2016 12:19 — forked from reu/pub-sub.js
node.js redis pub-sub example
var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");