Skip to content

Instantly share code, notes, and snippets.

View 2jacobtan's full-sized avatar

Jacob Tan En 2jacobtan

View GitHub Profile
@2jacobtan
2jacobtan / Hide webpage floating elements (alt ver).js
Last active June 10, 2020 02:11
JavaScript bookmarklet: removes annoying floating elements on a webpage
/*
This alternate version works by appending a CSS rule to "document.head",
then appends the given class name to each floating element.
Overcomes the problem of child nodes having "visibility:visible", faced by the original version.
*/
javascript:
if (typeof aoeuToggle != "number"){
/* declare global variables for toggle functionality */
# API example:
# http://fg-69c8cbcd.herokuapp.com/user/1
# {"id":1, "name":"Austin", "friends":[2,5]}
import requests
import json
retrievedUsers = {} #Python dict (hash table), to keep track of users for whom data has been retrieved through the API. {id:User object}
#user ID => User object
@2jacobtan
2jacobtan / concise if-elif using 2-D tuple and eval().py
Last active October 15, 2019 12:09
concise if-elif using 2-D tuple and eval()
def calculate(self):
average = mean(self.scores)
a = average
grading = (
("a < 40", 'F'),
("a < 55", 'E'),
("a < 70", 'D'),
("a < 80", 'C'),
("a < 90", 'B'),
("a <= 100", 'A')
@2jacobtan
2jacobtan / remove duplicates from an unsorted linked list.py
Created October 15, 2019 11:57
remove duplicates from an unsorted linked list
def removeDuplicates(self,head):
if head == None:
pass
else:
encountered_values = set()
encountered_values.add(head.data)
last_unique = current = head
while current.next:
current = current.next
if current.data in encountered_values:
@2jacobtan
2jacobtan / FizzBuzz_func.hs
Last active June 10, 2020 02:11
FizzBuzz via function composition
-- from https://www.youtube.com/watch?v=FyCYva9DhsI&t=21m03s
-- NDC conference talk: Clean Coders Hate What Happens to Your Code When You Use These Enterprise Programming Tricks
import Data.List (foldl')
import Data.List (intersperse)
import Data.Function ((&))
fizzbuzz :: Integer -> String
fizzbuzz n = fizz (buzz id) $ show n
where
//try at https://dotnetfiddle.net/KvNhXi
#nullable enable
using System;
using System.Linq;
using System.Numerics;
using System.Globalization;
using static MyNamespace.ConsoleOutputHelpers;
#nullable enable
using System;
using System.IO;
namespace jt2.debug_helper_extensions
{
static class To_json_extensions
{
static string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
import Data.Function ( (&), fix )
import Data.List (foldl')
-- top-down
fib n = snd $ go n
where
-- go :: Int -> (Int,Int)
go 0 = (0,0)
go 1 = (0,1)
go x = (b,a+b)
@2jacobtan
2jacobtan / emotions.md
Created March 20, 2021 16:51 — forked from Gabriella439/emotions.md
How to get in touch with your emotions

How to get in touch with your emotions

I wanted to share something I've learned in the course of therapy that I felt might benefit others. Specifically, I'd like to share how to better listen to one's emotions.

Why should we do this?

You might wonder why would we want to be in better touch with our emotions. One reason why is that everybody builds a metaphor or narrative for themselves

@2jacobtan
2jacobtan / trolling_haskell
Last active July 2, 2021 21:12 — forked from quchen/trolling_haskell
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now