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 / 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");
@maisnamraju
maisnamraju / gist:c7d4ad274c1f6159b96dbee0180ee358
Created March 2, 2017 10:52
Check for 44371900569F and 15 days
{"unit":"d","values":[[1487100600000,822013.9236842105,1086926.1736842105,1707292.2578947367,68708414.75],[1487187000000,1299176.7805555556,1654508.4868055556,2365664.8548611114,127664402.93333334],[1487273400000,1465469.411111111,1811391.7770833336,2567056.5868055555,140254026.6],[1487359800000,1143490.0770833332,1427996.865972222,2045996.1194444445,110819593.5],[1487446200000,1556465.7798611112,1883760.5184027776,2782667.3233796298,167502893.51666665],[1487532600000,1474878.972222222,1827149.161111111,2669417.353472222,143314691.68333334],[1487619000000,791752.6909722221,914076.6395833333,1387845.9701388888,74248207.21666665],[1487705400000,1191156.1541666666,1649674.4493055556,2250951.9291666667,122202780.78333333],[1487791800000,1893747.81517094,2338579.518910256,3271600.866559829,163601690.30000004],[1487878200000,1150275.370138889,1430092.6847222224,2121428.8520833333,112843125.76666665],[1487964600000,1380634.4347222222,1730927.4999999998,2443052.826388889,133310754.26666667],[1488051000000,1610405.220