This file contains hidden or 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
| package net.firsp.mods; | |
| import cpw.mods.fml.common.FMLCommonHandler; | |
| import cpw.mods.fml.common.Mod; | |
| import cpw.mods.fml.common.event.FMLInitializationEvent; | |
| import cpw.mods.fml.common.eventhandler.SubscribeEvent; | |
| import cpw.mods.fml.common.gameevent.TickEvent; | |
| import net.minecraft.entity.Entity; | |
| import net.minecraft.entity.boss.IBossDisplayData; | |
| import net.minecraft.entity.monster.IMob; |
This file contains hidden or 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
| \$N | |
| ex: \[(.*?)\] -> (\$1) | |
| => [test] -> (test) |
This file contains hidden or 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
| (defun take (n list) | |
| (if (= n 0) nil (cons (car list) (take (- n 1) (cdr list))))) | |
| (defun slice (n list) | |
| (if (null list) nil (cons (take n list) (slice n (nthcdr n list))))) | |
| (defun msort(list pred) | |
| (cond ((not (consp (car list))) | |
| (msort (slice 1 list) pred)) | |
| ((equal (cdr list) NIL) |
This file contains hidden or 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
| class Array | |
| def merge(arr) | |
| org = self.reverse | |
| arr = arr.reverse | |
| new = [] | |
| loop{ | |
| if org == [] | |
| return new.concat(arr.reverse) | |
| end | |
| if arr == [] |
This file contains hidden or 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
| (defun msort (list pred) | |
| (cond ((not (consp (car list))) | |
| (msort (mapcar (lambda (x) (cons x NIL)) list) pred)) | |
| ((equal (cdr list) NIL) | |
| (car list)) | |
| (t | |
| (let (merged) | |
| (loop | |
| (push (merge 'list (pop list) (pop list) pred) merged) | |
| (if (not list) (return (msort merged pred)))))))) |
This file contains hidden or 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
| def downheap!(arr, i, mnode) | |
| a = [i, i*2+1, i*2+2] | |
| b = arr[a[0]] | |
| c = arr[a[1]] | |
| d = a[2] <= mnode ? arr[a[2]] : nil | |
| e = [b,c,d] | |
| e.delete(nil) | |
| f = e.index(e.max) | |
This file contains hidden or 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
| class Service | |
| def streaming(method = :userstream, *args, &proc) | |
| p = lambda{|q| | |
| if q and not q.empty? | |
| Plugin.call(:json, q) end | |
| proc.call(q) | |
| } | |
| twitter.__send__(method, *args, &p) | |
| end | |
| end |
This file contains hidden or 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
| server = WEBrick::HTTPServer.new({:Port => 8000}) | |
| server.mount_proc('/'){|req,res| | |
| q = Hash[*(req.query_string.split('&').map{|s|s.split('=')}.flatten)] | |
| if q.include?('message') | |
| Service.primary.post(:message => q['message']) | |
| end | |
| } | |
| Thread.new{server.start} |
This file contains hidden or 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 random | |
| f = open('a.bmp','rb').read() | |
| f = list(f) | |
| for i in range(0x36, len(f)): | |
| if random.random() < 0.5: | |
| f[i] = 255 | |
| else: | |
| f[i] = 192 | |
| open('b.bmp','wb').write(bytes(f)) |
This file contains hidden or 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 threading | |
| import os | |
| import urllib.request | |
| def status(j,d): | |
| if 'extended_entities' in d and 'media' in d['extended_entities']: | |
| p = 'images/' + d['user']['screen_name'] | |
| if not os.path.exists(p): | |
| os.makedirs(p) | |
| for m in d['extended_entities']['media']: |