Skip to content

Instantly share code, notes, and snippets.

View techsin's full-sized avatar
🏠
Working from home

techsin techsin

🏠
Working from home
  • New York, NY
View GitHub Profile
@techsin
techsin / postgres-brew.md
Created January 9, 2020 21:15 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@techsin
techsin / solution.js
Last active April 17, 2020 23:45
lru cache
var LRUCache = function(capacity) {
this.hash = {};
this.capacity = capacity;
this.counter = 0;
};
LRUCache.prototype.get = function(key) {
const obj = this.hash[key];
if (typeof obj === "undefined") {
/* Setup */
class Node {
left = null;
right = null;
constructor(val) {
this.val = val;
}
}
const A = new Node('A');
@techsin
techsin / title1.js
Created May 29, 2020 16:28
animation on title
var str = '-¯-_';
var i;
var j = 0;
document.title = '‎';
setInterval(function(){
document.title = document.title + str[j++];
j = j % str.length;
i = i || 0;
i = ++i % (str.length * 5);
if (!i) document.title = '‎';
@techsin
techsin / islands.js
Created June 12, 2020 04:40
find islands leetcode
var numIslands = function(grid) {
let islands = 0;
for (let i = 0; i < grid.length; i++) {
for (let j = 0; j < grid[i].length; j++) {
if (grid[i][j] == 1) {
markRecur(i, j, grid);
islands++;
}
}
}
@techsin
techsin / download_audio.js
Created August 13, 2020 17:53
download audio recording in sms google voice
document.querySelectorAll('audio').forEach((au) => {
const url = au.currentSrc;
fetch(url).then(r => r.blob()).then(obj => downloadAudio(obj));
})
function downloadAudio(blob) {
const ele = document.createElement('a');
let counter = 0;
downloadAudio = function (blob) {
@techsin
techsin / cookie.js
Created September 10, 2020 15:51
Read and set cookie as a 3rd party
@techsin
techsin / worker.js
Last active October 18, 2020 23:16
Testing performance of service workers vs promises
function wrk() {
var blobURL = URL.createObjectURL(new Blob(['(',
function () {
for (let i = 0; i < 5000000000; i++) { } console.log(1000);
}.toString(),
')()'], { type: 'application/javascript' }));
const worker = new Worker(blobURL);
@techsin
techsin / sortEle.js
Created October 23, 2020 02:15
Sort Html Elements
// $container - css selector for nodes that need to be sorted
// $number - css selector for node with number
function sortElements($container, $number) {
const hash = new Map();
const list = Array.from(document.querySelectorAll($container));
for (let i = 0; i < list.length; i++) {
for (let j = i; j < list.length; j++) {
const element = list[i];
@techsin
techsin / cookie.js
Created January 29, 2021 00:54
cookie parser