Created
February 11, 2016 10:51
-
-
Save kaz/6e9eaca707870eaacb0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db = new PDO("sqlite:deka.db"); | |
$account = [[], [], [], []]; | |
foreach($db->query("SELECT * FROM Account")->fetchAll(PDO::FETCH_ASSOC) as $deka){ | |
$account[strlen($deka["ID"]) - 5][] = $deka; | |
} | |
foreach($account as &$e){ | |
sort($e); | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>dekaこれくしょん</title> | |
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> | |
<link rel="stylesheet" href="https://code.getmdl.io/1.1.1/material.indigo-pink.min.css"> | |
<style> | |
.mdl-layout__tab-bar-button { | |
height: 64px; | |
} | |
.mdl-layout__tab-bar-container { | |
height: 64px; | |
} | |
.mdl-layout__tab-bar { | |
width: 100%; | |
} | |
.mdl-layout__tab-bar .mdl-layout__tab { | |
height: 64px; | |
line-height: 64px; | |
} | |
.mdl-layout__content { | |
padding: 40px 40px 0 80px; | |
} | |
.mdl-card { | |
width: 200px; | |
} | |
.mdl-card__title { | |
height: 200px; | |
background-size: cover; | |
background-position: center; | |
color: #FFFFFF; | |
text-shadow: 2px 2px 4px #000000; | |
cursor: pointer; | |
} | |
.mdl-card__title-text { | |
padding: 0 5px 5px 0; | |
} | |
.right { | |
float: right; | |
} | |
#cardTemplate { | |
display: none; | |
} | |
</style> | |
</head> | |
<body class="mdl-color--grey-100 mdl-color-text--grey-700 mdl-base"> | |
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header"> | |
<header class="mdl-layout__header mdl-layout__header--scroll mdl-color--primary"> | |
<div class="mdl-layout--large-screen-only mdl-layout__header-row"></div> | |
<div class="mdl-layout__header-row"><h3>dekaこれくしょん</h3></div> | |
<div class="mdl-layout--large-screen-only mdl-layout__header-row"></div> | |
<div class="mdl-layout__tab-bar mdl-js-ripple-effect mdl-color--primary-dark"> | |
<a href="javascript:" class="mdl-layout__tab">0 - 999</a> | |
<a href="javascript:" class="mdl-layout__tab is-active">0000 - 0999</a> | |
<a href="javascript:" class="mdl-layout__tab">1000 - 1999</a> | |
<a href="javascript:" class="mdl-layout__tab">2000 - 2999</a> | |
<a href="javascript:" class="mdl-layout__tab">3000 - 3999</a> | |
<a href="javascript:" class="mdl-layout__tab">4000 - 4999</a> | |
<a href="javascript:" class="mdl-layout__tab">5000 - 5999</a> | |
<a href="javascript:" class="mdl-layout__tab">6000 - 6999</a> | |
<a href="javascript:" class="mdl-layout__tab">7000 - 7999</a> | |
<a href="javascript:" class="mdl-layout__tab">8000 - 8999</a> | |
<a href="javascript:" class="mdl-layout__tab">9000 - 9999</a> | |
</div> | |
</header> | |
<main class="mdl-layout__content"> | |
<h2></h2> | |
<div class="mdl-spinner mdl-js-spinner is-active"></div> | |
<section class="mdl-grid"></section> | |
</main> | |
<footer class="demo-footer mdl-mini-footer"> | |
<div class="mdl-mini-footer--left-section"> | |
by <a href="https://twitter.com/gabalist">@gabalist</a> | |
</div> | |
</footer> | |
</div> | |
<article id="cardTemplate" class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--top"> | |
<div class="mdl-card__title mdl-card--expand template-icon"> | |
<h2 class="mdl-card__title-text template-id"></h2> | |
</div> | |
<div class="mdl-card__supporting-text"> | |
<h5 class="template-name"></h5> | |
<span class="template-bio"></span> | |
</div> | |
<div class="mdl-card__actions mdl-card--border"> | |
<button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> | |
クソリプを飛ばす | |
</button> | |
</div> | |
</article> | |
<template> | |
{{@}} | |
あ…!あのっ | |
す///す/// | |
/\ /ノ | |
//\) // | |
\\ // | |
\( ՞ةڼ◔)/すき焼き | |
| | | |
| | | |
| | | |
/ /\ \ | |
〈 〈 \\ | |
\ \ \\ | |
\) \) | |
</template> | |
<template> | |
( ^o^)☎┐<{{@}} 垢消せwwwwwwwwwwwwwww ( ^o^)Г☎ チンッ | |
</template> | |
<template> | |
{{@}} FF外から失礼するゾ~(謝罪) このツイート面白スギィ!!!!!自分、RTいいっすか? 淫夢知ってそうだから淫夢のリストにぶち込んでやるぜー いきなりリプしてすみません!許してください!なんでもしますから!(なんでもするとは言ってない | |
</template> | |
<template> | |
いないいない | |
∩(・_・)∩おるでwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww | |
そう言って{{@}}は微笑んだ。 | |
それが僕が最後に見た彼の姿だった...。 | |
</template> | |
<template> | |
(^o^)<佐川急便でぇぇぇぇすww | |
三┏( ^o^)┛キチガイお届けにまいりましたーーwww | |
<(^o^)>┌┛’,;’;≡三ドカァッ{{@}} | |
┏┗(´ิq´ิ)┓┛キェェェェェェィイイイイイイイ | |
あざっしたーーwwwww | |
┗(^o^ )┓三 | |
</template> | |
<template> | |
(´◔౪◔) 「もしもしお母さーん!」 | |
母「なにー?」 | |
( ◠‿◠ )「このマジキチなぁ~にぃ~??」 | |
___ | |
/L(՞ةڼ◔) /\ | |
/| ̄ ̄ ̄ ̄|\/ | |
| |/ | |
母「あー{{@}}か。今度燃えるゴミに出すよ。」 | |
</template> | |
<template> | |
おみくじ引いとこ | |
(^ω^)つ | ̄  ̄| | |
 ̄ ̄ ̄ | |
なに吉かな〜♪ | |
(^ω^)つ {{@}} | |
(^ω^)..... | |
__ | |
|マ| | |
|ジ| | |
|吉| | |
 ̄ ̄ | |
( ☝՞ਊ ՞)☝ファーーーーーーーーwwwwwwwwwwwwww | |
</template> | |
<template> | |
{{@}} | |
ブルブルブルブルアイ!✌(՞ਊ՞✌三✌՞ਊ՞)✌アイ!✌(՞ਊ՞✌三✌՞ਊ՞)✌ブ・ル・ベ・リ・アイ!!✌(՞ਊ՞✌三✌՞ਊ՞)✌ブルブルブルブルアイ!✌(՞ਊ՞✌三✌՞ਊ՞)✌アイ!✌(՞ਊ՞✌三✌՞ਊ՞)✌ブ・ル・ベ・リ・アイ!!✌(՞ਊ՞✌三✌՞ਊ՞)✌ | |
</template> | |
<template> | |
ニコ厨の真似しまーすww | |
※鳥肌注意※ | |
うp主ネ申ww | |
なぜ消したしww | |
↓wwww | |
ちょwwワロタww | |
タグ理解w | |
市場ww | |
{{@}} 垢消せww | |
なぜ上がったしwww | |
</template> | |
<template> | |
{{@}} | |
いけっイワーク! ミ◓ ポゥン | |
( ◠‿◠ )しまった!ボール間違えた! | |
ミ◓┗(↑o↑)┛< エゥンェゥゥゥゥゥンwwwwwwwwwwwwwwwwwwwww | |
_人人人人人人人人_ | |
>エゥンェゥゥゥゥゥンwww< | |
 ̄^Y^Y^Y^Y^Y^Y^ ̄ | |
</template> | |
<script defer src="https://code.getmdl.io/1.1.1/material.min.js"></script> | |
<script> | |
var account = <?= json_encode($account) ?>; | |
var nowProcessing = false; | |
var generate = function(digit, start, end, title, clear){ | |
if(nowProcessing) return; | |
var main = document.querySelector("main"); | |
var spinner = main.querySelector("div"); | |
var section = main.querySelector("section"); | |
nowProcessing = true; | |
spinner.style.display = "block"; | |
main.querySelector("h2").textContent = title; | |
if(clear){ | |
section.innerHTML = ""; | |
} | |
generateFragments(document.querySelector("#cardTemplate"), section, digit, start, end, 128, function(){ | |
nowProcessing = false; | |
spinner.style.display = "none"; | |
}); | |
}; | |
var generateFragments = function(original, section, digit, start, end, progress, onFinished){ | |
var curTarget = progress = progress + start <= end ? progress + start : end; | |
for(var i=start; i<=curTarget; i++){ | |
var entry = account[digit][i]; | |
var el = original.cloneNode(); | |
el.removeAttribute("id"); | |
el.innerHTML = original.innerHTML; | |
el.querySelector(".mdl-card__title").addEventListener("click", function(){ | |
window.open("https://twitter.com/" + this); | |
}.bind(entry.ID)); | |
el.querySelector(".mdl-button").addEventListener("click", function(){ | |
window.open(makeIntentURL(this)); | |
}.bind(entry.ID)); | |
el.querySelector(".template-id").textContent = "@" + entry.ID; | |
if(entry.Icon == -1){ | |
el.querySelector(".template-name").textContent = "【凍結されてる】"; | |
el.querySelector(".mdl-card__actions").style.display = "none"; | |
}else if(entry.Icon == 0){ | |
el.querySelector(".template-name").textContent = "【空いてる】"; | |
el.querySelector(".mdl-card__actions").style.display = "none"; | |
}else{ | |
el.querySelector(".template-icon").style.backgroundImage = "url('" + entry.Icon + "')"; | |
el.querySelector(".template-name").textContent = entry.Name; | |
el.querySelector(".template-bio").textContent = entry.Bio; | |
} | |
section.appendChild(el); | |
} | |
if(curTarget == end){ | |
onFinished(); | |
}else{ | |
setTimeout(generateFragments, 256, original, section, digit, curTarget, end, progress, onFinished); | |
} | |
}; | |
var makeIntentURL = function(id){ | |
var tweets = document.querySelectorAll("template"); | |
var sel = parseInt(tweets.length * Math.random()); | |
return "https://twitter.com/intent/tweet?text=" + encodeURIComponent(tweets[sel].innerHTML.trim().replace("{{@}}", "@" + id)); | |
}; | |
var links = document.querySelectorAll("a"); | |
var binds = [function(){ | |
generate(0, 0, 9, "", true); | |
generate(1, 0, 99, "", false); | |
generate(2, 0, 999, "0 - 999", false); | |
}]; | |
for(var i=0; i<10; i++){ | |
binds.push(function(){ | |
generate(3, 1000*this, 1000*this + 999, this + "000 - " + this + "999", true); | |
}.bind(i)); | |
} | |
binds.forEach(function(entry, i){ | |
links[i].addEventListener("click", entry); | |
}); | |
binds[1](); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.Statement; | |
import java.util.ArrayList; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.regex.Pattern; | |
public class Headquarters { | |
public static void main(String[] args) throws Exception { | |
Connection conn = DriverManager.getConnection("jdbc:sqlite:deka.db"); | |
Statement stat = conn.createStatement(); | |
conn.setAutoCommit(false); | |
stat.execute("CREATE TABLE IF NOT EXISTS Account (ID TEXT PRIMARY KEY, Icon TEXT, Name TEXT, Bio TEXT)"); | |
stat.execute("CREATE TABLE IF NOT EXISTS System (Name TEXT PRIMARY KEY, Value TEXT)"); | |
Pattern pat = Pattern.compile("profile-picture.+?href=\"(.*?)\".+?title=\"(.*?)\".+?Card-bio.+?>(.*?)</p>", Pattern.DOTALL); | |
AtomicInteger counter = new AtomicInteger(0); | |
ArrayList<String> ids = new ArrayList<>(); | |
for(int i=1; i<=4; i++){ | |
for(int j=0; j<Math.pow(10, i); j++){ | |
ids.add(String.format("deka%0" + i + "d", j)); | |
} | |
} | |
for(String id : ids){ | |
new Thread(new Worker(conn, pat, counter, id)).start(); | |
while(counter.get() > 256){ | |
Thread.sleep(256); | |
} | |
} | |
while(counter.get() > 0){ | |
Thread.sleep(256); | |
} | |
stat.execute("INSERT OR REPLACE INTO System VALUES('Timestamp', '" + System.currentTimeMillis() + "')"); | |
stat.close(); | |
conn.commit(); | |
conn.close(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream; | |
import java.io.InputStream; | |
import java.net.URL; | |
import java.nio.charset.StandardCharsets; | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
import java.sql.SQLException; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import javax.net.ssl.HttpsURLConnection; | |
public class Worker implements Runnable { | |
private Connection conn; | |
private Pattern pat; | |
private AtomicInteger counter; | |
private String id; | |
public Worker(Connection conn, Pattern pat, AtomicInteger counter, String id) throws Exception { | |
this.conn = conn; | |
this.pat = pat; | |
this.counter = counter; | |
this.id = id; | |
} | |
private byte[] getContent(String url) { | |
try { | |
HttpsURLConnection conn = (HttpsURLConnection) new URL(url).openConnection(); | |
conn.setInstanceFollowRedirects(true); | |
conn.setRequestMethod("GET"); | |
conn.connect(); | |
InputStream in = conn.getResponseCode()==200 ? conn.getInputStream() : conn.getErrorStream(); | |
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |
byte[] buf = new byte[2048]; | |
int readByte = 0; | |
while((readByte = in.read(buf)) > 0){ | |
out.write(buf, 0, readByte); | |
} | |
in.close(); | |
conn.disconnect(); | |
return out.toByteArray(); | |
}catch(Exception e){ | |
System.out.println("[" + e.getMessage() + "] RETRY : " + id); | |
return getContent(url); | |
} | |
} | |
private String getPageTitle(String content) { | |
for(String line : content.split("\n")){ | |
int start = line.indexOf("<title>"); | |
int end = line.indexOf("</title>"); | |
if(start > -1 && end > -1){ | |
return line.substring(start + 7, end); | |
} | |
} | |
return ""; | |
} | |
private void getInformation(PreparedStatement ps) { | |
try { | |
String content = new String(getContent("https://twitter.com/" + id), StandardCharsets.UTF_8); | |
String title = getPageTitle(content); | |
if(title.matches(".+さん \\| Twitter.*")){ | |
System.out.println(id + " - Taken"); | |
ps.setString(1, id); | |
Matcher m = pat.matcher(content); | |
if(m.find()){ | |
for(int i=0; i<3; i++){ | |
ps.setString(i+2, m.group(i+1)); | |
} | |
} | |
}else if(title.matches("Twitter / アカウント凍結")){ | |
System.out.println(id + " - Suspended"); | |
ps.setString(1, id); | |
ps.setString(2, "-1"); | |
ps.setString(3, null); | |
ps.setString(4, null); | |
}else if(title.matches("Twitter / \\?")){ | |
System.out.println(id + " - Available"); | |
ps.setString(1, id); | |
ps.setString(2, "0"); | |
ps.setString(3, null); | |
ps.setString(4, null); | |
}else{ | |
throw new Exception("Could not determine account status : " + id); | |
} | |
ps.execute(); | |
ps.close(); | |
} catch (Exception e) { | |
System.out.println("[" + e.getMessage() + "] RETRY : " + id); | |
getInformation(ps); | |
} | |
} | |
@Override | |
public void run() { | |
counter.incrementAndGet(); | |
try { | |
getInformation(conn.prepareStatement("INSERT OR REPLACE INTO Account VALUES (?, ?, ?, ?)")); | |
} catch (SQLException e) { | |
e.printStackTrace(); | |
} | |
counter.decrementAndGet(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment