Skip to content

Instantly share code, notes, and snippets.

Somesh Mukherjee slaith

Block or report user

Report or block slaith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:d6093b66ca0fd9000f8bc34d087c8e86
var MongoClient = require('mongodb').MongoClient
, assert = rsuequire('assert');
// Connection URL
var url = 'mongodb://localhost:27017/myproject';
// Use connect method to connect to the server
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
console.log("Connected successfully to server");
@slaith
slaith / app.jsx 1
Last active Sep 25, 2016
TodoList
View app.jsx 1
var TodoItem=React.createClass({
render:function(){
return (<li className="list-group-item "> <div className="row"><div className="col-xs-8">{this.props.pos} {this.props.title}</div><div className="col-xs-2"> <button type="button" className="btn btn-danger " onClick={this.deleteMe} >X Delete</button></div></div></li>);
},
deleteMe:function(){
console.log("Delete");
}
})
var TodoList=React.createClass({
@slaith
slaith / app.jsx
Last active Sep 25, 2016
Template Code
View app.jsx
var Counter=React.createClass({
render:function(){
return (<div></div>)
}
})
@slaith
slaith / app.js
Created Sep 25, 2016
ReactWorkshop Step1
View app.js
var HelloWorld=React.createClass({
render:function(){
return React.createElement("div",{"className":"bright",id:"gello"},"HelloWorld");
}
});
ReactDOM.render(React.createElement(HelloWorld,null), document.getElementById("app"));
@slaith
slaith / environments.json
Last active Sep 23, 2016
GULP: Amazon S3 publish with git based checking
View environments.json
{
"staging":{
"uploadPath":"/reactcode"
},
"uat":{
"uploadPath":"/reactcodeuat"
},
"production":{
"dangerous":true,
"uploadPath":"/reactcodelive"
@slaith
slaith / nginx
Created Aug 3, 2015
Nginx Init script
View nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@slaith
slaith / _form.html.slim
Created Jun 9, 2015
Generator template for Bootstrap _form with error display on each field
View _form.html.slim
= form_for(@<%= singular_table_name %>, html: { class: "form-horizontal", role: "form" }) do |f|
- if @<%= singular_table_name %>.errors.any?
.alert.alert-danger.alert-dismissable role="alert"
button.close type="button" data-dismiss="alert"
span aria-hidden="true"
| &times;
span.sr-only
| Close
h4= "#{pluralize(@<%= singular_table_name %>.errors.count,"error")} prohibited this <%= singular_table_name %> from being saved:"
ul
@slaith
slaith / gist:6459693
Created Sep 6, 2013
Database singleton
View gist:6459693
<?php
class Database{
static private $_instance;
static $hostname="";
static $username="";
static $password="";
static $database="";
$conn;
static function getInstance(){
if(self::$_instance)
@slaith
slaith / item.rb
Created Sep 3, 2013
item.rb error
View item.rb
class Item < ActiveRecord::Base
attr_accessible :name, :price, :priority,:picture,:url
belongs_to :user
validates :name, presence: true
validates :price, presence: true
validates :price, length: { :maximum => 7}
has_attached_file :picture,:styles => {:small => "100x100>"}
validates_attachment_size :picture, :less_than => 5.megabytes
validates :url, format: /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix
validates_attachment_content_type :picture, :content_type => ['image/jpeg', 'image/png']
You can’t perform that action at this time.