Skip to content

Instantly share code, notes, and snippets.

View navdeepsingh's full-sized avatar
🎯
Focusing

Navdeep Singh navdeepsingh

🎯
Focusing
View GitHub Profile
@navdeepsingh
navdeepsingh / parse-file.js
Created March 18, 2016 08:17
Upload file using FormData
$('#file').val('');
$("#file").change(function () {
readFile($(this), this);
});
$('.js-action').click(function (e) {
e.preventDefault();
var $this = $(this);
var $parent = $this.parent().parent();
@navdeepsingh
navdeepsingh / ssh
Created March 23, 2016 10:52
Clear Drupal site cache
drush cc all
@navdeepsingh
navdeepsingh / modal.js
Last active July 28, 2016 12:51
Load Dynamic (AJAX) modal in Bootstrap 3, remove from DOM after timeout
$('[data-toggle="modal"]').click(function () {
var url = $(this).attr('href');
$.get(url, function (data) {
var modal = $('<div id="clue-modal" class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog"><div class="modal-content">' + data + '</div></div></div>').modal();
modal.on("hidden.bs.modal", function () {
$(this).remove();
});
setTimeout(function(){
modal.modal('hide');
},5000);
'use strict'
const Config = use('Config')
var twitterAPI = require('node-twitter-api')
const promisify = require("es6-promisify")
const twitter = new twitterAPI({
consumerKey: Config.get('auth.twitterAuth.consumerKey'),
consumerSecret: Config.get('auth.twitterAuth.consumerSecret'),
@navdeepsingh
navdeepsingh / TwitterController.js
Last active November 16, 2016 06:20
Adonisjs Twitter Controller
'use strict'
const Config = use('Config')
var twitterAPI = require('node-twitter-api')
const promisify = require("es6-promisify")
const twitter = new twitterAPI({
consumerKey: Config.get('auth.twitterAuth.consumerKey'),
consumerSecret: Config.get('auth.twitterAuth.consumerSecret'),
@navdeepsingh
navdeepsingh / d3-barChart.js
Last active March 24, 2017 10:10
D3 : Basic start with Bar Chart
var w = 300;
var h = 250;
var padding = 5;
var dataset = [5, 10, 15, 20, 25,
11, 45, 21, 3, 21];
var svg = d3.select("body").append("svg")
.attr("width", w)
.attr("height", h);
function colorPicker(v) {
@navdeepsingh
navdeepsingh / d3-LineChart.js
Last active March 24, 2017 12:24
D3-LineChart
var w = 350;
var h = 200;
var monthlySales = [
{ 'month': 10, 'sales': 12 },
{ 'month': 20, 'sales': 8 },
{ 'month': 30, 'sales': 85 },
{ 'month': 40, 'sales': 10 },
{ 'month': 50, 'sales': 23 },
{ 'month': 60, 'sales': 85 },
@navdeepsingh
navdeepsingh / countries.json
Last active August 22, 2017 05:27
Countries Data
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Åland Islands",
"code": "AX"
},
{
@navdeepsingh
navdeepsingh / index.html
Last active December 6, 2017 07:49
HTML5 PWA Template Ref: https://paymentrequest.show/
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="A site that demonstrates the Payment Request API.">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>Payment Request API | Demo &amp; Info</title>
<link rel="manifest" href="/manifest.json">
@navdeepsingh
navdeepsingh / serviceworker.js
Last active May 11, 2018 05:27
Service Worker Script
// At index.html
if (navigator.serviceWorker) {
navigator.serviceWorker.register('/serviceworker.js')
}
// Main file serviceworker.js
const staticCacheName = 'cacheFile-v.0';
self.addEventListener('install', installEvent => {
installEvent.waitUntil(
caches.open(staticCacheName)