Skip to content

Instantly share code, notes, and snippets.

View napsternxg's full-sized avatar
🎯
Focusing

Shubhanshu Mishra napsternxg

🎯
Focusing
View GitHub Profile
@napsternxg
napsternxg / ShaderToy-Render.ipynb
Last active August 15, 2022 05:45
RenderShaderToy Example in Google Colab
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@napsternxg
napsternxg / grid_dist.py
Created January 19, 2022 20:55
Grid Distance Function
"""
# Grid Dist
what's a loss function that incorporates spatial distance?
e.g. i want...
loss(y..., y...) == 0
0 < loss(yt, y1) < loss(yt, y2)
loss(yt, y2) == loss(yt, y2.T)
Tweet: https://twitter.com/TheShubhanshu/status/1482132766607265796
"""
@napsternxg
napsternxg / Wordle_Solution.md
Last active January 14, 2022 00:51
Wordle One Shot Solution (Hack)

Wordle One Shot Solution (Hack)

NOTE: This is a hack to get the wordle solution

NOTE: Use it only when you are frustrated and just want to see the solution. It will ruin the fun of the game for you.

I am not doing anything fancy. It is just that the solution is always available on the page and I am reading it and firing the keypresses to get answer.

Be reminded that you should not copy JS from strangers on your pages, it can be used to steal your passwords or other sensitive information. You can read the full code used here and more details at: https://gist.github.com/napsternxg/a80021d6aec9d362db8c736bc2f9a888 Learn about internet security from A PROJECT OF THE ELECTRONIC FRONTIER FOUNDATION: SURVEILLANCE SELF-DEFENSE: TIPS, TOOLS AND HOW-TOS FOR SAFER ONLINE COMMUNICATIONS course from https://ssd.eff.org/en

@napsternxg
napsternxg / string_diff_using_difflib.py
Last active January 12, 2022 18:33
Python difflib for string diffs
# Using python difflib
from difflib import Differ, ndiff, SequenceMatcher, HtmlDiff
from pprint import pprint
from IPython.display import display_html, HTML, display
css_style = """
<style>
del {
text-decoration: line-through;
@napsternxg
napsternxg / tensorboard_hparam_logging.py
Created October 20, 2021 18:35
Tensorboard HParam logging
import tensorflow as tf
from tensorboard.plugins.hparams import api as hp
import numpy as np
N, d = 100, 5
x_train = np.random.randn(N, d)
y_train = np.random.randint(0, 2, size=[N, 1])
HP_NUM_UNITS = hp.HParam('num_units', hp.Discrete([16, 32]))
{
"data": [
{
"id": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011\/04\/25",
"office": "Edinburgh",
"extn": "5421"
@napsternxg
napsternxg / Smooth Sigmoids.ipynb
Created September 2, 2021 23:22
Smooth Sigmoids
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@napsternxg
napsternxg / wikidata_celeb_images.sparql
Created July 15, 2021 19:37
Wikidata Select Celeb Image Demographics
#defaultView:ImageGrid
SELECT ?human
#(SAMPLE(?humanLabel) AS ?humanLabel)
(SAMPLE(?image) AS ?image)
(SAMPLE(?sex_or_gender) AS ?sex_or_gender)
#(SAMPLE(?sex_or_genderLabel) AS ?sex_or_genderLabel)
(SAMPLE(?ethnic_group) AS ?ethnic_group)
#(SAMPLE(?ethnic_groupLabel) AS ?ethnic_groupLabel)
(SAMPLE(?date_of_birth) AS ?date_of_birth)
(SAMPLE(?occupation) AS ?occupation)
@napsternxg
napsternxg / google_scholar_info.js
Last active July 8, 2021 05:05
Google Scholar Info Extractor
function getCitationInfo() {
t = document.querySelector("table#gsc_rsb_st")
cite_hist = document.querySelector("div.gsc_md_hist_b")
overall = Array.from(t.querySelectorAll("tr")).map((tr, i) => {
selector = i == 0 ? "th" : "td";
row = Array.from(tr.querySelectorAll(selector))
return row.map(td => td.innerText)
})
temporal = {
years: Array.from(cite_hist.querySelectorAll("span.gsc_g_t")).map(s => +s.innerText),
@napsternxg
napsternxg / gsutil_folder_copy.py
Created June 8, 2021 16:59
GS Util Python Copy Folder
import tensorflow as tf
base_path = "gs://bucket/some_folder"
target_folder = Path("./localfolder").resolve()
for folder, subfolders, files in tf.io.gfile.walk(base_path):
# print(folder, subfolders, files)
local_folder = target_folder.joinpath(*Path(folder).parts[4:])
# print(folder, local_folder)
local_folder.mkdir(parents=True, exist_ok=True)
for from_file in files: