Skip to content

Instantly share code, notes, and snippets.

View mohitathwani's full-sized avatar

Mohit Athwani mohitathwani

View GitHub Profile
@mohitathwani
mohitathwani / WeavingArrays.swift
Created August 17, 2019 22:04
Weaving two arrays
func weave(left: inout [Int], right: inout [Int], temp: inout [Int], results: inout [[Int]]) {
if left.isEmpty || right.isEmpty {
var result = temp
result.append(contentsOf: left)
result.append(contentsOf: right)
results.append(result)
return
}
let leftFirst = left.removeFirst()
//We first load the express framework and make it available for our script
var express = require('express');
//We load the pi-gpio library here
var gpio = require("pi-gpio");
//Here we initialize the express framework
var app = express();
//We are going to GET the pin number and the state to set the pin to from the URL from the browser
@mohitathwani
mohitathwani / iotBlogServer_1.js
Last active August 29, 2015 13:57
Sample code for the IoT Blog post
//We first load the express framework and make it available for our script
var express = require('express');
//Here we initialize the express framework
var app = express();
//We are going to GET the pin number and the state to set the pin to from the URL from the browser
//For example http://yourdomain.com/25/1 -----> This turns the state of pin number 25 to HIGH
//Similarly: http://yourdomain.com/25/0 -----> This turns the state of pin number 25 to LOW
//NOTE: We can also send a json packet to the server as part of this request, but we won't cover that for now !
@mohitathwani
mohitathwani / mailer.js
Created March 19, 2014 06:43
Mail Bomber
var nodemailer = require("nodemailer");
for (var i= 1; i<=100; i++) {
// create reusable transport method
//(opens pool of SMTP connections)
var smtpTransport =
nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "",
pass: ""