Skip to content

Instantly share code, notes, and snippets.

@drocta
drocta / removeBadStyles.php
Created September 16, 2015 04:28
removes bad styles. incomplete.
$xpath = new DOMXpath($doc);
$elements = $xpath->query("//*[@style]");//things with a style
$withBadStyles=Array();
foreach($elements as $element){
echo $element->getAttribute("style");
echo "\n";
$elementStyle=$element->getAttribute("style");
if(strpos($elementStyle,"position")!==False){
$withBadStyles[]=$element;
}
@drocta
drocta / removeBadIframes.php
Created September 11, 2015 04:56
example of using DOMDocument to remove iframes to unapproved locations
<?PHP
$myhtml= <<< HTML
<HTML>
<p><br><iframe scrolling="no" src="https://w.soundcloud.com/player/?AAA=https%3A//api.soundcloud.com/tracks/147305734&color=ff5500&&hide_related=false&show_comments=true&show_user=true&show_reposts=false" frameborder="no" height="166" width="100%">fsdgds</iframe></p><p>This is the first audio post on the site<br></p>
<a href="exumple.com">Zoo</a>
<iframe scrolling="no" src="https://w.soundcloud.com/player/?BBB=https%3A//api.soundcloud.com/tracks/147305734&color=ff5500&&hide_related=false&show_comments=true&show_user=true&show_reposts=false" frameborder="no" height="166" width="100%">fsdgds</iframe>
<a href="example.com">moo</a>
<iframe scrolling="no" src="http://www.yeutube.com/embedr/?CCC=https%3A//api.soundcloud.com/tracks/147305734&color=ff5500&&hide_related=false&show_comments=true&show_user=true&show_reposts=false" frameborder="no" height="166" width="100%">fsdgds</iframe>
@drocta
drocta / homestuckKidsStatistics.r
Created August 8, 2015 05:21
regression analysis with the human kids and similarities in word usages and gender and dream moon
kids = c("john","jade","dave","rose","jane","jake","dirk","roxy")
gender = c(1,0,1,0,0,1,1,0)
moon = c(1,1,0,0,1,1,0,0)
#1 codes for male, 0 codes for female
#1 codes for prospit, 0 codes for derse
#the pairs of kids are ordered in the same order as in http://pastebin.com/QCpBgTxD
@drocta
drocta / wordUseSimilarity.py
Created August 7, 2015 17:54
Similarity between word uses of different characters
import re
import operator
import math
removeApostr=re.compile(r"'")#to remove apostrophes.
removeDigits=re.compile(r"[0-9]")#to remove digits
removeNonAlpha=re.compile(r"[^\w]")#to remove digits
removeNull=re.compile(r"\x00")
@drocta
drocta / tumblr theme system.
Created April 29, 2015 22:42
This is a description of tumblr's theme system.
(most of the stuff before paragraph 8 might not be neccesary. Maybe just skip to paragraph 8 or 7? This is paragraph 0.)
Ok, so, this document is meant to be a general description of what sort of things each post will need to store in order
for it to be compatible with tumblr's theme system. (note to you: maybe double check the legality of using their system? I suspect it is legal to support their theme system, but you should probably check)
There are a fair number of things on here, and some of them aren't things you probably need to store per post, because I got a little carried away when making this list.
Due to the large number of things on here, it might be a bit daunting to try to implement them all when making themes render. However, it so happens that much of it is set up such that if you roll out some features later than others, it shouldn't make parts of the theme that are not supported yet have problems!
This is because of the {block:<something>}{/block:<something>} system.
Play this game by pasting the script in http://www.puzzlescript.net/editor.html