Skip to content

Instantly share code, notes, and snippets.

@aquasmit
aquasmit / javascript-getelements
Last active August 29, 2015 14:21
JavaScript - getElements
(function(){
console.log(document.getElementById('mainHeading'));
console.log(document.getElementsByClassName('heading'));
console.log(document.getElementsByTagName('p'));
console.log(document.getElementsByName('txtName'));
//get first <p> element
console.log(document.getElementsByTagName('p')[0]);
@aquasmit
aquasmit / wamp-server-network-access
Last active August 29, 2015 14:21
Apache 2.4.x - Allow wamp server access from any machine in network using http://
Open httpd.conf and replace line
Require local
by
Require all granted
That's all. After you restart Wamp server, you will be able to access your machine frm any machine in network using URL like http://aquasmit (assuming that aquasmit is your machine name)
@aquasmit
aquasmit / file uploading checklist - php.ini
Created May 27, 2015 20:23
file uploading checklist - php.ini
file_uploads on (or true or 1)
upload_tmp_dir NULL
post_max_size 8M
upload_max_filesize 2M
max_execution_time 30 (in seconds)
max_input_time -1 (no limit)
memory_limit 128M
@aquasmit
aquasmit / php-superglobals
Created May 27, 2015 20:32
PHP Superglobals
$_GET
$_POST
$_SERVER
$_COOKIE
$_SESSION
$_FILES
@aquasmit
aquasmit / mysqli-cheal-list
Last active August 29, 2015 14:22
mysqli - Cheat List
//Resource: http://www.pontikis.net/blog/how-to-use-php-improved-mysqli-extension-and-why-you-should
/*MySQLi supports two tpe of APIs
1. Procedural (NOT RECOMMENDED)
2. Object Oriented API
*/
/********************connecting to database******************************/
//Procedural
$conn = mysqli_connect($dbServer,$database, $username, $password);
if(mysqli_connect_errno()){
@aquasmit
aquasmit / git-commands.md
Last active April 9, 2017 10:49
git commands
  • Git Initialization

git init

  • Git commit

git commit -m "Intial commit"

  • Add Remote repository
@aquasmit
aquasmit / .gitignore
Created March 13, 2016 10:10
Some common gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@aquasmit
aquasmit / tripadvisor-scraping.js
Created April 6, 2016 16:28
TripAdvisor Reviews Scraping using X-Ray (Node.js)
var Xray = require('x-ray');
var x = Xray();
x('https://www.tripadvisor.com/Hotel_Review-g60763-d93545-Reviews-The_Manhattan_at_Times_Square_Hotel-New_York_City_New_York.html', '#REVIEWS .reviewSelector', [{
reviewer: '.username.mo span',
//ajax_link:'div#most_recent_pager div .pam.uiBoxWhite.noborder.uiMorePagerPrimary@href'
reviewer_location: '.location',
//review_rating: '.rating-very-large meta[content]@content',
//review_date: '.rating-qualifier [content]@content',
@aquasmit
aquasmit / yelp_reviews_scraping.js
Created April 6, 2016 16:30
Yelp Reviews scraping using X-Ray (Node js)
var Xray = require('x-ray');
var x = Xray();
x('https://www.yelp.com/biz/bottega-louie-los-angeles', 'ul.ylist li .review--with-sidebar', [{
reviewer: '.user-name .user-display-name',
reviewer_location: '.user-location b',
review_rating: '.rating-very-large meta[content]@content',
review_date: '.rating-qualifier [content]@content',
review_content:'.review-content p'
}])

###Using node.js as a simple web server that will serve static files

You can use Connect and ServeStatic with Node.js for this:

Step 1: Install connect & serve-static packages npm install connect serve-static

Step 2: Create server.js file with content

var connect = require('connect');