Skip to content

Instantly share code, notes, and snippets.

View kmod-midori's full-sized avatar
🏳️‍⚧️
It works!

Midori Kochiya kmod-midori

🏳️‍⚧️
It works!
  • Beijing University of Posts and Telecommunications
  • Chengdu,China
  • 16:39 (UTC +08:00)
  • X @enp39s0
View GitHub Profile
var roll=function(max,min,count){
var i=0;
var ret=[];
while(i<count){
ret.push(parseInt(Math.random()*(max-min+1)+min));
i++;
}
return ret;
}
var sm=function(s){
if(typeof s !='object'||s==null)var s=[];
if(typeof s.length =='undefined')s=[s];
return {
segments:s,
addText:function(text){
this.segments.push({
text:text,
type:'TEXT'
});
@kmod-midori
kmod-midori / Moe Dice(Node ver.) Command Parser&Runner.js
Created February 16, 2013 16:08
Moe Dice's command runner. Known issue:If I send too many segments to Google,the API will return 500.
var Segment=require('./classes/segment');
function buildContent(content,bot_id,user_id,user_name){
var ret=new Segment();
ret.addMention(user_name,user_id);
for(var i in content){
if(content[i].type=='USER_MENTION'&&content[i].user.userId==bot_id){
console.log('Command detected.');
var command=content[parseInt(i)+1].text.trim();
var rest=content;
rest.splice(0,parseInt(i)+2);
get_tags = (raw)->
return '' if raw is ''
return '' if !raw?
raw = raw.replace /☪|★|☆/g,''
pattern = /\[(.+?)\]|【(.+?)\】|\((.+?)\)|『(.+?)\』|~(.+?)\~|◆(.+?)◇/g
// Generated by CoffeeScript 1.6.1
(function() {
var cur_page, flowless, fs, get_tags, jquery, jsdom, keywords, start, _;
fs = require('fs');
jsdom = require('jsdom');
flowless = require('flowless');
fs = require 'fs'
jsdom = require 'jsdom'
flowless = require 'flowless'
mysql = require 'mysql'
jquery = fs.readFileSync('../jquery.js').toString()
_ = require 'underscore'
strip_html = require 'strip_html'
serialize = require 'serialize'
cur_page = 1
var request=require('request');
exports.client_secret='q-tA1vMJhkoeoucVH7NfvryX';
exports.client_id='545553600905.apps.googleusercontent.com';
exports.app_version=13196;
exports.request=function(access,data,uid,callback){
if(typeof data == 'string'){
//refresh token
var qs=require('querystring');
var option={
url:'https://accounts.google.com/o/oauth2/token',
<?php
function detect() {
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
// Identify the browser. Check Opera and Safari first in case of spoof. Let Google Chrome be identified as Safari.
if (preg_match('/opera/', $userAgent)) {
$name = 'opera';
}
elseif (preg_match('/webkit/', $userAgent)) {
$name = 'safari';
<?php
/**
* Step 1: Require the Slim Framework
*
* If you are not using Composer, you need to require the
* Slim Framework and register its PSR-0 autoloader.
*
* If you are using Composer, you can skip this step.
*/
require 'Slim/Slim.php';
chrome.cookies.onChanged.addListener(function(ci){
if(ci.cookie.name=="oauth_code"&&ci.cookie.domain=="accounts.google.com"&&ci.cookie.path=="/o/oauth2/programmatic_auth"&&ci.removed==false){
chrome.extension.sendMessage(null,{oauth:ci.cookie.value});
}
});