Skip to content

Instantly share code, notes, and snippets.

View sreejith-ms's full-sized avatar
:octocat:
Focusing

Sreejith MS sreejith-ms

:octocat:
Focusing
View GitHub Profile
@sreejith-ms
sreejith-ms / Dockerfile
Last active February 25, 2019 12:08
puppeteer-headful
FROM node:8
# Install dependencies
RUN apt-get update &&\
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \
xvfb x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps
bot.on('trigger', function (message) {
// handle message from trigger function
var queuedMessage = message.value;
var botAdapter = botPatch.patch(bot);
var callBackFn = function (dat, session) {
session.userData.foo = {};
};
botAdapter.loadSession(queuedMessage.address, {}, callBackFn);
});
@sreejith-ms
sreejith-ms / ByteArrayToListOfObjects
Created June 4, 2017 17:06
ByteArrayToListOfObjects
List<TestObject> convertedResult = new List<TestObject>(resultByteArray.Length/sizeOfObject);
for (index = 0; index < resultByteArray.Length; )
{
var testObject = new TestObject();
testObject.A = BitConverter.ToInt32(resultByteArray, index);
index += 4;
testObject.B = BitConverter.ToUInt32(resultByteArray, index);
index += 4;
testObject.C = resultByteArray[index++];
testObject.D = BitConverter.ToUInt16(resultByteArray, index);
List<TestObject> listOfTestObjects = new List<TestObject>{ new TestObject { A = 12356, B = 23455, C = 45, D = 4500} };
int index = 0, sizeOfObject = 11;
byte[] resultByteArray = new byte[sizeOfObject * listOfTestObjects.Count];
foreach(var testObject in listOfTestObjects)
{
Buffer.BlockCopy(BitConverter.GetBytes(testObject.A), 0, resultByteArray, index, 4);
index += 4;
Buffer.BlockCopy(BitConverter.GetBytes(testObject.B), 0, resultByteArray, index, 4);
index += 4;
Buffer.SetByte(resultByteArray, index++, testObject.C);
@sreejith-ms
sreejith-ms / pocketarticlescount
Created May 21, 2017 18:11
Pocket unread articles count
document.getElementsByClassName("item_type_normal").length
@sreejith-ms
sreejith-ms / quorafollowedquestions
Created May 21, 2017 16:16
Get Quora followed questions url
var urls = [];
[].forEach.call(document.querySelectorAll('.layout_3col_center .pagedlist_item'), function (el) {
urls.push("https://www.quora.com/" + el.querySelectorAll(".question_link")[0].getAttribute("href"));
});
console.log(JSON.stringify(urls))
@sreejith-ms
sreejith-ms / 1_primitive_comparison.js
Created April 12, 2017 08:53 — forked from nicbell/1_primitive_comparison.js
JavaScript object deep comparison. Comparing x === y, where x and y are values, return true or false. Comparing x === y, where x and y are objects, returns true if x and y refer to the same object. Otherwise, returns false even if the objects appear identical. Here is a solution to check if two objects are the same.
//Primitive Type Comparison
var a = 1;
var b = 1;
var c = a;
console.log(a == b); //true
console.log(a === b); //true
console.log(a == c); //true
console.log(a === c); //true
@sreejith-ms
sreejith-ms / README.md
Created February 4, 2017 08:18 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})