Skip to content

Instantly share code, notes, and snippets.

View jonathansampson's full-sized avatar
🦁
*roar*

Sampson jonathansampson

🦁
*roar*
View GitHub Profile
@jonathansampson
jonathansampson / getRetweeters.js
Last active June 9, 2023 17:36
When viewing a list of users who retweeted a Tweet, these functions can extract that list from the global React state, making it easier to analyze the accounts for commonalities and other patterns.
const SELECTORS = {
RT_ROOT: "div[aria-label='Timeline: Retweeted by']",
REACT_ROOT: "#react-root > div > div",
};
/**
* Retrieve the properties of a React element.
* @param {Object} element - The target React element.
* @returns {Object} The properties of the given React element.
* @throws Will throw an error if React props are not found.
<dl class="messages">
<dt>u/cokechan: Can you talk about the machine learning model that serves ads? What features is the model trained on?</dt>
<dd>Currently betting on ELPH: Entropy Learning Pruned Hypothesis but all the Bayesian tools in the kit work. For proof of humanity (see last answer) we know of potential partners using RNNs. The key with machine learning is data feed quality. Browsers are juicy: navigation, tab clusters, opener/openee relations, scrolling of content, and (bigger) search query log, ecommerce log, form fill data. Plus info you volunteer when onboarding about demographics, brand loyalty, that stays on device and is encrypted with client key if you sync. We can do cross-device attribution via encrypted sync + blind tokens, without any data in clear on servers. This will be huge!</dd>
</dl>
<style>
dl.messages {
max-width: 85%;
font-family: tahoma;
font-size: 16px;

##Pocket Doesn't Work in the Brave Browser

###Windows Users

Open Brave, and navigate to the about:preferences#advanced page. Ensure that Pocket is turned off, and close Brave.

Press Win+E to open Explorer, and navigate to %AppData%\Roaming\brave\Extensions. At this point, you should see numerous folders; delete niloccemoadcdkdjlinkgdfekeahmflj.

Open Brave, and navigate to the about:preferences#advanced page. Turn on Pocket.

@jonathansampson
jonathansampson / intersectsNode.js
Created June 3, 2016 00:40
A polyfill for Range.prototype.intersectsNode
if ( !Range.prototype.intersectsNode ) {
Range.prototype.intersectsNode = function ( node ) {
let range = document.createRange();
range.selectNode( node );
return 0 > this.compareBoundaryPoints( Range.END_TO_START, range )
&& 0 < this.compareBoundaryPoints( Range.START_TO_END, range );
};
}
ul {
padding-left: 0;
list-style: none;
line-height: 1.5em;
font-family: Tahoma;
}
ul::before {
font-weight: 700;
content: "\53\68\2a\74\20\4c\69\73\74\3a";
@jonathansampson
jonathansampson / ebola.sample.html
Created October 17, 2014 00:05
Alternative implementation for http://apps.washingtonpost.com/g/page/politics/the-scale-of-american-ebola-infections/1381/?template=iframe which will avoid Stack size limitations in some browsers
<style>
#people {
margin-top: 20px;
}
#people img {
width: 100%;
display: block;
}
</style>
@jonathansampson
jonathansampson / valueAsNumber.js
Created August 4, 2014 15:48
`valueAsNumber` shim for Internet Explorer 11
(function () {
/* Internet Explorer 11 may have trouble retrieving the number type
of an input value. This short script performs a quick test, and repairs
the functionality if necessary. Load before attempting to use the
`valueAsNumber` property on input elements. */
"use strict";
var a = document.createElement( "input" );
// based on https://snipt.net/gregwhitworth/w3c-keyword-colors-90c153dd/
// adds alphabetical index, hex, and rgb values
var colors = {
"a": [
[
"aliceblue",
"#F0F8FF",
"rgb(240, 248, 255)"
],
[
@jonathansampson
jonathansampson / Object-Crawler.js
Last active August 29, 2015 14:01
Creates an object that reveals browser features and functionality
/*global document, prompt */
(function( global ) {
"use strict";
var response = {
browser: {
name: prompt( "Browser Name? (Chrome, IExplorer, etc)" ),
version: prompt( "Browser Version? (34, 11, etc)" )
},
@jonathansampson
jonathansampson / Proto-Crawler.js
Last active August 29, 2015 13:57
Enumerates all properties of an object, including those found along the prototype chain.
var output = (function ( object ) {
"use strict";
function getProperties ( object ) {
return object ? Object.getOwnPropertyNames( object )
.concat( getProperties( Object.getPrototypeOf( object ) ) ) : [] ;
}
function getUnique ( array ) {