Skip to content

Instantly share code, notes, and snippets.

View neophyt3's full-sized avatar
🎯
Focusing

Pradeep Chauhan neophyt3

🎯
Focusing
  • Mumbai, India
View GitHub Profile
convert the below clojure language to javascript
(= gravity* 1.8 timebase* 120 front-threshold* 1
nourl-factor* .4 lightweight-factor* .17 gag-factor* .1)
(def frontpage-rank (s (o scorefn realscore) (o gravity gravity*))
(* (/ (let base (- (scorefn s) 1)
(if (> base 0) (expt base .8) base))
(expt (/ (+ (item-age s) timebase*) 60) gravity))
(if (no (in s!type 'story 'poll)) .8
(blank s!url) nourl-factor*
// works on Edge and Chrome Devtools
$$(".app .wrapper").forEach(el => { el.style.maxWidth = 'none' })
$$(".app .container .container-right").pop().style.maxWidth = 'none'
// HOW-TO
// Paste the above script in devtools console and press enter to apply changes
// Note:
# Error handling
Links:
- https://fettblog.eu/rust-enums-wrapping-errors/
- https://www.lpalmieri.com/posts/error-handling-rust/
Cookbook on error scenarios
- https://rust-lang-nursery.github.io/rust-cookbook/errors/handle.html
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
https://stackoverflow.com/questions/3455625/linux-command-to-print-directory-structure-in-the-form-of-a-tree
@neophyt3
neophyt3 / generateUPC.js
Created April 1, 2018 18:54
Aircel UPC generator incase you dont have sim number
//https://ekyc.aircel.com:444/ekyc/genUPC.html
//this site uses angularjs
//let take advantage of developer tools console tab
//lets grab the http service of anugular js
$http = angular.element(document.body).injector().get('$http')
//so now, lets have a handy function to send post request
//returns promise
function sendPost(simnum){ return $http.post('https://ekyc.aircel.com:444/ekyc/rest/genUPC', {"service_id":"WEB_UPC","msisdn":"919768XXXXXX","sim":simnum})}
@neophyt3
neophyt3 / concurrency.go
Created February 11, 2018 20:14 — forked from montanaflynn/concurrency.go
A simple example of bounded concurrency and wait groups in Golang
package main
import (
"fmt"
"sync"
"time"
)
func main() {
@neophyt3
neophyt3 / irctc.py
Created June 26, 2017 19:42 — forked from avamsi/irctc.py
Python script to semi-automate tatkal ticket booking.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep, strftime
def waituntil(s):
while strftime('%H:%M:%S') < s:
print strftime('%H:%M:%S')
sleep(1)
@neophyt3
neophyt3 / encrypt_decrypt_example.js
Created May 10, 2017 07:00 — forked from erans/encrypt_decrypt_example.js
Example of encryption and decryption in node.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(text, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
}