Skip to content

Instantly share code, notes, and snippets.

View slaith's full-sized avatar

someonenew slaith

  • India
View GitHub Profile
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 September 25, 2016 12:32
TodoList
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 September 25, 2016 10:09
Template Code
var Counter=React.createClass({
render:function(){
return (<div></div>)
}
})
@slaith
slaith / app.js
Created September 25, 2016 09:27
ReactWorkshop Step1
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 September 23, 2016 10:29
GULP: Amazon S3 publish with git based checking
{
"staging":{
"uploadPath":"/reactcode"
},
"uat":{
"uploadPath":"/reactcodeuat"
},
"production":{
"dangerous":true,
"uploadPath":"/reactcodelive"
@slaith
slaith / nginx
Created August 3, 2015 10:34
Nginx Init script
#! /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 June 9, 2015 13:52
Generator template for Bootstrap _form with error display on each field
= 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 September 6, 2013 04:52
Database singleton
<?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 September 3, 2013 14:57
item.rb error
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']