Skip to content

Instantly share code, notes, and snippets.

View anticlergygang's full-sized avatar

setHacked anticlergygang

View GitHub Profile
@anticlergygang
anticlergygang / basicPromiseExample.js
Created December 17, 2019 03:59
Here is a simple example of a promise in js
let addPromise = (a, b) => new Promise((resolve, reject) => {
if (isNaN(a) === false && isNaN(b) === false) {
resolve(a + b)
} else {
reject('a or b, is not a number')
}
})
addPromise(1, 2).then(resolved => {
console.log(`promise resolved with ${resolved}`)
return addPromise(1, 3)
@anticlergygang
anticlergygang / sw.js
Created August 4, 2019 00:54
This service worker basicly pre caches the whole app if it has connection to the backend, with every reload, it requests and stores a fresh index.html into cache. This way if the user has connection, code linked to the html document could be updated and cached just by changing the file names of the linked code. If the file names are the same fro…
let cacheObject = {
name: '1',
precache: [
'./html/index.html',
'./css/index.css',
'./js/index.js',
'./',
'./robots.txt',
'./manifest.webmanifest',
'./favicon.ico',
@anticlergygang
anticlergygang / sw-fetch.js
Created August 4, 2019 00:45
If the service worker can hit the backend, it requests a fresh index.html, else it goes to the version stored in cache. This is nice because if you update any code that's linked to the html, all you have to do is change the file name to something that's not already in the cache, and it will be stored and used for future requests.
this.addEventListener('fetch', event => {
console.log(`fetch event request url: ${event.request.url}`)
event.respondWith(
caches.match(event.request).then(cacheResponse => {
if (event.request.url.indexOf('.html') !== -1 || event.request.url === `https://www.${domainName}.${tld}/`) {
return fetch(event.request.url).then(response => {
return caches.open(cacheObject.name).then(cache => {
cache.put(event.request, response.clone()).catch(error => {
console.log('Could not add to cache!' + error)
})
const https = require('https')
const colors = require('colors')
let gthreads = []
let polthreads = []
let bizthreads = []
const catalogPromise = (board) => {
return new Promise((resolve, reject) => {
let path = `/${board}/catalog.json`
@anticlergygang
anticlergygang / binanceRichterScale.js
Last active October 25, 2018 01:12
This loops through BTC markets on Binance 24/7 and checks how fast the last 500 trades came in. green = +1 trades a sec, red = -1 trades a sec
const fs = require('fs')
const https = require('https')
const colors = require('colors')
const moment = require('moment-timezone')
const querystring = require('querystring')
const util = require('util')
const crypto = require('crypto')
const percentOf = (per, num) => {
return (num / 100) * per
@anticlergygang
anticlergygang / traillingProfit.js
Last active December 17, 2018 23:57
If you want to get it to work, you need to npm install all of the modules required at the top and change all occurances of process.env. BINANCEAPIKEY and process.env.BINANCESECRET with your apikey and secret. After this just run 'node scalpBot.js "SYMBOL" "PERCENT_TRAIL"'
const fs = require('fs')
const https = require('https')
const colors = require('colors')
const moment = require('moment-timezone')
const querystring = require('querystring')
const util = require('util')
const crypto = require('crypto')
const percentOf = (per, num) => {
return (num / 100) * per
@anticlergygang
anticlergygang / scalpBot.js
Created October 17, 2018 09:59
npm i all the modules and run it
const fs = require('fs')
const https = require('https')
const colors = require('colors')
const moment = require('moment-timezone')
const querystring = require('querystring')
const percentOf = (per, num) => {
return (num / 100) * per
}
const percentChange = (v1, v2) => {
@anticlergygang
anticlergygang / DOM.js
Created October 8, 2018 02:53
Literally some of the worst code I have every written, gonna condense this to like 200 lines soon.
const colors = require('colors')
const binanceAPI = options => {
return new Promise((resolve, reject) => {
try {
let requestObject = {
host: 'api.binance.com',
port: 443,
method: options.method
}
switch (`${options.method} ${options.endpoint}`) {
const https = require('https')
const binanceAPI = options => {
return new Promise((resolve, reject) => {
try {
let requestObject = {
host: 'api.binance.com',
port: 443,
method: options.method
}
switch (`${options.method} ${options.endpoint}`) {
@anticlergygang
anticlergygang / 4chanActivityTracker.js
Created September 26, 2018 02:26
Change 'currentBoard' for whatever board you want to parse, you can run this script concurrently in other child processes, just make sure the intervals don't line up exactly and that you are not making more than 1 request a second.
const https = require('https'),
colors = require('colors'),
moment = require('moment')
const catalogPromise = (board) => {
return new Promise((resolve, reject) => {
let path = `/${board}/catalog.json`
let url = `https://a.4cdn.org${path}`
let req = https.request({
host: 'a.4cdn.org',