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 / findIfSumExists.js
Last active October 20, 2017 19:44
Find if there exists two number in array that have sum equal to target.
function isThere(arr, t) {
//Usually Mergesort n log(n)
arr.sort((a,b)=> a>b?true:false);
let i = 0,
j = arr.length-1,
x = arr[i],
y = arr[j];
// O(n)
var arr = ["apple", ["apple","fix","apple"],["Apple", "apple"]];
function recurCount([...arr]) {
const WORD = 'apple';
if (arr.length === 0) {
return 0;
} else {
let tmp = arr.pop();
const crypto = require('crypto');
function hash(msg){
return crypto.createHash('sha256').update(msg).digest('hex');
}
// '24d78aedae3a0747299d9c7b93f524221aa20c73274faab1ef75f584c453fcb0'
// what did i say?
function merc(lat, lon) {
let r_major = 6378137.000,
x = r_major * toRadians(lon),
scale = x/lon,
y = 180.0/Math.PI * Math.log(Math.tan(Math.PI/4.0 + lat * (Math.PI/180.0)/2.0)) * scale;
return (x, y)
}
function toRadians (angle) {
return angle * (Math.PI / 180);
@techsin
techsin / sortAmazonWishList.js
Created October 31, 2018 18:22
Sort wish list on amazon page by reviews, simply copy paste in chrome dev console
function sortBooks() {
let books = [...document.querySelectorAll('ul#g-items li h3> a.a-link-normal')].map(el => findAncestor(el, 'g-item-sortable'));
let sorted = bubbleSort(books);
let frag = document.createDocumentFragment();
sorted.forEach(x => frag.appendChild(x));
let ul = document.querySelector("ul#g-items");
ul.innerHTML = '';
ul.append(frag);
alert('done');
return frag
@techsin
techsin / script.js
Created April 2, 2019 16:57
Scraping Angellist to csv
class Company {
name;
desc;
joined;
location;
market;
website;
employees;
stage;
constructor(...rest) {
@techsin
techsin / scrape_commerce.js
Created April 7, 2019 19:17
scrape_companies_commerce_nyc
class Company {
static fetchStack = [];
static data = [];
static fetched = 0;
static interval = 300;
static intervalVariance = 100;
constructor(tr) {
Company.fetchStack.push(tr);
}
@techsin
techsin / file.js
Created July 1, 2019 15:32
Reaction time sens clicker
var ele = document.querySelector('.test-standard.reaction-time-test');
var config = { attributes: true };
var event = new MouseEvent('mousedown', {
bubbles: true,
cancelable: true
});
var callback = function (mutationsList, observer) {
for (var mutation of mutationsList) {
@techsin
techsin / temp.js
Last active November 5, 2019 05:06
tempreature tracker
class TemperatureTracker {
constructor() {
this.records = [];
this.minV = null;
this.maxV = null;
this.freq = {};
this.sum = 0;
this.n = 0;
this.modeMax = null;
this.modeV = null;