Skip to content

Instantly share code, notes, and snippets.

View pragyanatvade's full-sized avatar
🐢
On a mission to make software development easier.

Pragyan Tripathi pragyanatvade

🐢
On a mission to make software development easier.
View GitHub Profile
@pragyanatvade
pragyanatvade / install_scrapy.md
Created August 28, 2015 13:43
Installing Scrapy
sudo apt-get install libxml2-dev libxslt1-dev
sudo apt-get install libffi-dev libssl-dev
@pragyanatvade
pragyanatvade / Vagrantfile
Last active August 29, 2015 14:16
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
domain = "example.com"
settings = {
:hostname => "adam",
:box => "ubuntu/trusty64",
@pragyanatvade
pragyanatvade / Useful Links
Last active August 29, 2015 14:16
Useful Links
@pragyanatvade
pragyanatvade / React Tutorial
Created March 17, 2015 08:34
React Unidirectional Data Flow
var FilteredList = React.createClass({
filterList: function(event){
var updatedList = this.state.initialItems;
updatedList = updatedList.filter(function(item){
return item.toLowerCase().search(
event.target.value.toLowerCase()) !== -1;
});
this.setState({items: updatedList});
},
getInitialState: function(){
@pragyanatvade
pragyanatvade / svg_component.js
Created March 19, 2015 11:05
React SVG Component
/** @jsx React.DOM */
var SVGComponent = React.createClass({
render: function() {
return this.transferPropsTo(
<svg>{this.props.children}</svg>
);
}
});
@pragyanatvade
pragyanatvade / regex.md
Created July 5, 2015 12:04
Regular Expressions

Starts with: abc Ends with: xyz Contains: 123 Doesn't contain: 456

  1. OR /^abc|xyz$|123|^(?:(?!456).)*$/

  2. AND /^(?=^abc)(?=.*xyz$)(?=.*123)(?=^(?:(?!456).)*$).*$/

@pragyanatvade
pragyanatvade / Mirror.sh
Last active August 29, 2015 14:25
Shell Script to find nearest ubuntu mirror and localtimezone
## set local/fastest mirror and local timezone
mv /etc/apt/sources.list /etc/apt/sources.list.orig
cat > /etc/apt/sources.list <<EOF
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main restricted universe multiverse
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@pragyanatvade
pragyanatvade / recursion.js
Created March 30, 2016 09:24
Recursion pattern in javascript
CategorySchema.statics.getLineage = function (categoryId, flag, done) {
var self = this;
var count1 = 0;
var count2 = 0;
var recurse = function (id, results) {
var deferred = Promise.defer();
self.findById(id, function(error, category) {
if (error) {