Skip to content

Instantly share code, notes, and snippets.

View sunyang713's full-sized avatar

Jonathan Sun sunyang713

  • New York, New York
View GitHub Profile
;(function(){[].slice.call({length: window.setTimeout(function(){},0)}).forEach(function(_,i){clearTimeout(i+1);});})()
div {
--shf: 4.9406564584124654e-322;
width: calc(((100% / 11) - 9.09px) * var(--shf) / var(--shf));
}
/*
What this does: it multiplies the value to be rounded by a really small value
that underflows the value starting at the third decimal point. Then, it divides
the truncated value back, resulting in a rounded version of the value. This
// https://github.com/justjavac/proxy-www
export default new Proxy(new URL('https://www'), {
get(target, prop) {
let o = Reflect.get(target, prop)
if (typeof o === 'function') return o.bind(target)
if (typeof prop !== 'string') return o
if (prop === 'then') return Promise.prototype.then.bind(fetch(target))
target = new URL(target)
target.hostname += `.${prop}`
return new Proxy(target, { get })
@sunyang713
sunyang713 / remove-likes.md
Created January 2, 2021 04:56 — forked from aelk00/remove-likes.md
Remove all your facebook likes

1- Go to: https://www.facebook.com/{your_id_or_username}/allactivity/?category_key=LIKEDPOSTS&filter_hidden=ALL&filter_privacy=NONE You can use Filter to choose year or month.
or go to https://www.facebook.com/me/allactivity/?category_key=LIKEDPOSTS&filter_hidden=ALL&filter_privacy=NONE ""@michelep""
2- Open the console and run the following JavaScript code and wait:

setInterval(() => {
  for (const Button of document.querySelectorAll('div[aria-label="Action options"]')) {
    Button.click()
for (const remove of document.querySelectorAll('div[role="menuitem"]')) {
 remove.click() 
// fuck off facebook
Array(99)
.fill()
.forEach(() => window.document.getElementsByClassName("_45yr")[0].click());
Object
.values(window.document.getElementsByTagName("button"))
.filter(x => x.getAttribute("data-tooltip-content") === "Remove")
.forEach(x => x.click());
@sunyang713
sunyang713 / introrx.md
Created September 15, 2018 06:44 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@sunyang713
sunyang713 / reducers.js
Created August 20, 2018 04:31 — forked from gaearon/reducers.js
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
export default function googleSpreadsheetValuesToObject(spreadsheet) {
const fields = spreadsheet[0]
return spreadsheet.slice(1).map(
row => fields.reduce(
(obj, field, index) => {
obj[field] = row[index]
return obj
}
, {}
)
@sunyang713
sunyang713 / pick.js
Created February 8, 2016 08:27
Copy a subset of an object based on an array of keys
/**
* Copy a subset of an object based on an array of keys
*/
const pick = (keys, object) => keys.reduce(
(result, key) => Object.assign(
result,
{ [key]: object[key] }
), {}
)
@sunyang713
sunyang713 / apply.js
Last active February 8, 2016 08:28
Object Apply
/**
* Return a new object with a function applied on each element of the original object
*/
const apply = (object, callback) => Object.keys(object).reduce(
(result, key) => Object.assign(
result,
{ [key]: callback(object[key]) }
), {}
)