Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name PaizaJack
// @namespace com.cielavenir
// @description PaizaJack
// @include https://paiza.jp/paizajack/*
// @run-at document-end
// @version 0.0.0.2
// ==/UserScript==
// 提出制限が設けられたので本UserScriptは事実上機能しなくなりました。
@cielavenir
cielavenir / regression.py
Last active July 6, 2017 01:58
regression
def regression(x,y):
mean_x = sum(x)/float(len(x))
mean_y = sum(y)/float(len(y))
cov = sum((a-mean_x)*(b-mean_y) for (a,b) in zip(x,y))
var_x = sum((e-mean_x)**2 for e in x)
return (cov/var_x,mean_y-mean_x*cov/var_x)
def regr(x,y):
return numpy.linalg.lstsq(numpy.array([x,numpy.ones(len(x))]).transpose(),y)
@cielavenir
cielavenir / linuxbrew_freebsd.patch
Created June 9, 2017 17:26
Linuxbrew on FreeBSD
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 0f9a00a..c2bed9e 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -299,7 +299,7 @@ module Homebrew
def symlink_ld_so
ld_so = HOMEBREW_PREFIX/"lib/ld.so"
return if ld_so.readable?
- sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3"].find do |s|
+ sys_interpreter = ['/libexec/ld-elf.so.1'].find do |s|
@cielavenir
cielavenir / chuniviewer_remove_basadv.js
Last active March 23, 2017 10:34
chuniviewerの更新リストからBAS/ADVを削除するブックマークレット
javascript:canPost=function(){return%20$('.update_diff_score').length<=30;};for(var%20diff=$('.update_diff_score'),i=diff.length-1;i>=0;i--){var%20difficulty=diff[i].children[0].children[0].children[0].textContent;if(difficulty=='BAS'||difficulty=='ADV')diff[i].remove();}
@cielavenir
cielavenir / atcoder_form.rb
Last active March 11, 2017 03:56
AtCoder 入稿スクリプト
#!/usr/bin/ruby
require 'mechanize'
ATCODER_USER=''
ATCODER_PASSWORD=''
=begin
入力は
---
コンテスト名
@cielavenir
cielavenir / counter.rb
Created February 26, 2017 18:04
Ruby collections.Counter
class Counter < Hash
def initialize(a=[])
super
self.default=0
a.each{|e|self[e]+=1}
end
def self.[](*a)
new(a)
end
end
@cielavenir
cielavenir / yenc.c
Created February 25, 2017 16:49
yenc
#include "../compat.h"
#include <stdio.h>
#include <string.h>
static const unsigned char *tbl="\0\n\r=";
//todo: header
//=ybegin line=128
static int yenc_encode(FILE *fin,FILE *fout){
unsigned int x,l=0;
@cielavenir
cielavenir / base122.c
Created February 25, 2017 16:47
base122
#include "../compat.h"
#include <stdio.h>
#include <string.h>
static const unsigned char *tbl="\0\n\r\"&\\";
static int base122_encode(FILE *fin,FILE *fout){
unsigned int x,y,z,c=0,b=0;
bool eof=false;
for(;!eof;){
#!/usr/bin/ruby
#Lobiのスタンプ吸い出し
#LobiのLibrary/Caches/stamp/1をplutilでxml形式に変換する(OSXがなければiOSのErica Utilitiesで。どうせアプリ領域閲覧にも脱獄必要ですし…)
#以下のスクリプトを食わせる
require 'mechanize'
require 'plist'
class Array
def values_rec
flat_map{|v|v.is_a?(Array)||v.is_a?(Hash) ? v.values_rec : v}
#!/usr/bin/ruby
require 'mechanize'
agent=Mechanize.new
agent.get('http://blog.sina.com.cn/')
a=agent.page.links.map{|e|e.href}.select{|e|e&&e.start_with?('http://photo.blog.sina.com.cn/showpic.html')}.map{|e|e.split('&').find{|f|f.start_with?('url=')}[4..-1]}
a.each{|e|
agent.get(e)
if agent.page.response["content-type"]=="image/jpeg"
ext='.jpg'
elsif agent.page.response["content-type"]=="image/png"