Skip to content

Instantly share code, notes, and snippets.

View niraj-shah's full-sized avatar
🏠
Working from home

Niraj Shah niraj-shah

🏠
Working from home
View GitHub Profile
function success(position) {
// variable to store the coordinates
var location = position.coords.latitude + ',' + position.coords.longitude;
// setup the map using user location
var mapOptions = {
center: new google.maps.LatLng( position.coords.latitude, position.coords.longitude ),
zoom: 16,
zoomControl: true,
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY_GOES_HERE&sensor=true"></script>
@niraj-shah
niraj-shah / rsync.sh
Last active December 17, 2015 18:08
Rsync from remote server to local
sudo rsync -uvzr -e 'ssh -p 2222 -l username' domain.com:/var/www/html/ /var/www/html
@niraj-shah
niraj-shah / rsync_exclude.sh
Created May 25, 2013 19:59
rsync with exclude flag
sudo rsync -rv --exclude=".svn" /from/folder/ /to/folder/
@niraj-shah
niraj-shah / config
Created July 15, 2013 16:30
Config file for SSH logins
# Example using private key
Host ServerName1
User root
HostName serverone.com
Port 2222
IdentityFile ~/servername1.pem
# Example that requires password
Host ServerName2
User ubuntu
@niraj-shah
niraj-shah / parse_user_hack.js
Created August 1, 2013 21:53
Script to get username and email addresses from a Parse website using the JavaScript SDK
var query = new Parse.Query('User');
query.find({
success: function(results) {
// cycle through the results
for ( x in results ) {
// print out the usernames and email addresses
console.log( results[x].attributes.username + ' ' + results[x].attributes.email );
}
},
error: function(myObject, error) {
@niraj-shah
niraj-shah / parse_data_count.js
Created August 1, 2013 22:20
Get the total number of registered users from Parse
var query = new Parse.Query('User');
query.count({
success: function(number) {
// print the count
console.log(number);
},
error: function(error) {
// an error occured
console.log( error );
}
@niraj-shah
niraj-shah / parse_acl.js
Created August 2, 2013 17:44
Two examples of setting ACL controls using Parse JS SDK
// ACL to restrict write to user, and public read access
var custom_acl = new Parse.ACL();
// give write access to the current user
custom_acl.setWriteAccess( Parse.User.current(), true);
// give public read access
custom_acl.setPublicReadAccess(true);
GameObject.setACL(custom_acl);
// ACL to restrict write to user, and no public access
var custom_acl = new Parse.ACL();
@niraj-shah
niraj-shah / parse_acl.php
Created August 2, 2013 17:50
An example of setting ACL controls using Parse PHP SDK
$parse = new parseObject('BlogPost');
$parse->title = "My first blog post";
$parse->story = "Welcome to my site. This is my first...";
$acl = new parseACL();
// Give the user Write access to object
$acl->setWriteAccessForId( $user_id, true );
// Give public read access
$acl->setPublicReadAccess( true );
// Disable write access for public
@niraj-shah
niraj-shah / wordpress_3.6_fix.sh
Created August 5, 2013 19:48
Find instances of $wpdb->escape in WordPress
# Go to wp-content folder
cd /path/to/wordpress/wp-content
# Find all files that have wpdb->escape
grep -ri 'wpdb->escape' *