Skip to content

Instantly share code, notes, and snippets.

View koyanloshe's full-sized avatar
👁️
Focusing

Alok Shenoy koyanloshe

👁️
Focusing
View GitHub Profile
@koyanloshe
koyanloshe / Google-Sheet-Form-Post.md
Last active April 17, 2020 08:32 — forked from willpatera/Google-Sheet-Form-Post.md
Post to google spreadsheet from html form #HTML

Overview

This collection of files serves as a simple static demonstration of how to post to a google spreadsheet from an external html <form> following the example by Martin Hawksey

Run example

You should be able to just open index.html in your browser and test locally.

However if there are some permissions errors you can make a quick html server with python. Open terminal and cd to the directory where the gist files are located and enter python -m SimpleHTTPServer. By default this creates a local server at localhost:8000

@koyanloshe
koyanloshe / app.js
Last active April 17, 2020 08:29
nodeJS server #Javascript
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
@koyanloshe
koyanloshe / killall.sh
Last active April 17, 2020 08:30
Kill a node server process that wont terminate #Unix
//primary attempt
killall node
//secondary attempt
kill -9 $(ps aux | grep '\snode\s' | awk '{print $2}')
@koyanloshe
koyanloshe / telnet setup
Last active April 17, 2020 08:29
Chat Server #Javascript
var net = require('net')
var chatServer = net.createServer(), clientList = []
chatServer.on('connection', function(client) {
client.name = client.remoteAddress + ':' + client.remotePort client.write('Hi ' + client.name + '!\n');
clientList.push(client)
client.on('data', function(data) { broadcast(data, client)
}) })
function broadcast(message, client) { for(var i=0;i<clientList.length;i+=1) {
if(client !== clientList[i]) { clientList[i].write(client.name + " says " + message)
} }
# clone repo
git clone https://github.com/Microsoft/vscode-react-sample.git react-todo
# navigate to repo
cd appFolderName
# install deps
npm install
# Run in terminal backend
@koyanloshe
koyanloshe / beforeIntersectionObeserver.js
Last active April 17, 2020 08:32
Check if a certain element in the viewport #Javascript
function onVisibilityChange(el, callback) {
var old_visible;
return function () {
var visible = isElementInViewport(el);
if (visible != old_visible) {
old_visible = visible;
if (typeof callback == 'function') {
callback();
}
}
@koyanloshe
koyanloshe / path issue Babel
Created November 23, 2018 07:34
Babel #Path #npm
export PATH=$PATH:/Users/koyanloshe/.npm-packages/bin
@koyanloshe
koyanloshe / boilerplate.html
Last active April 17, 2020 08:30
Emailer boilerplate interactive demo by Litmus #HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
lang="en" xml:lang="en">
<head>
<title>Interactive Email Elements</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@koyanloshe
koyanloshe / function for trigger event
Last active December 13, 2018 07:08
Trigger an event in plain.JS #Javascript
function triggerEvent(el, type) {
if ('createEvent' in document) {
// modern browsers, IE9+
var e = document.createEvent('HTMLEvents');
e.initEvent(type, false, true);
el.dispatchEvent(e);
} else {
// IE 8
var e = document.createEventObject();
e.eventType = type;
@koyanloshe
koyanloshe / smooth scroll jQuery snippet
Last active April 17, 2020 08:28
smoothScroll.js #Javascript #jQuery
$("a").on('click', function (event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function () {
window.location.hash = hash;
});
};