Skip to content

Instantly share code, notes, and snippets.

View toshimaru's full-sized avatar

Toshimaru toshimaru

View GitHub Profile
@gre
gre / decodeBase64.scala
Created November 15, 2012 13:43
Easy way to decode a base64 in Scala
import org.apache.commons.codec.binary.Base64
val base64 = "data:([a-z]+);base64,(.*)".r
def decodeBase64 (src: String): Option[(String, Array[Byte])] = {
src match {
case base64(mimetype, data) => Some( (mimetype, Base64.decodeBase64(data.getBytes("utf-8"))) )
case _ => None
}
}
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@mala
mala / gist:3788589
Created September 26, 2012 15:07
hostsファイルにloopbackアドレス書くのは危険か、の話
9/25にGoogle+に書いたものの転載、脅威の度合いは各々判断してください
----
補足
DNS Rebinding対策として、DNSキャッシュサーバーがプライベートアドレスを返さないようにフィルタしている、というのは
http://labs.cybozu.co.jp/blog/kazuho/archives/2007/11/djbdns_and_anti-dns_pinning.php で書かれているような対策のこと
要点は
1.別途DNSリバインディング対策をしている場合に、その穴を自分で復活させてしまうことになる
@jorilallo
jorilallo / gist:3686737
Created September 9, 2012 19:33
Google Contacts API authentication with gdata and OAuth2
import gdata
import json
import requests
# More examples:
# https://github.com/millioner/Python-contact-importer/blob/master/contact_importer/providers/google.py
# https://github.com/jtauber/django-friends/blob/master/friends/importer.py
# GData with access token
token = gdata.gauth.OAuth2Token(
@yuroyoro
yuroyoro / AwesomeReverseEngineeringCode.java
Created August 16, 2012 10:41
図2●COBOLプログラムから生成した設計書とJavaプログラムの例(富士通の発... : http://itpro.nikkeibp.co.jp/article/NEWS/20120815/416081/?SS=imgview&FD=-2096679071&ST=system
public void 計算処理(String pkt_年月日1, long pkt_通算日1){
//
/*** 前年までの「うるう年」を考慮する。 ***/
クラス_Rv作業領域.setうるう年数((クラス_Rv作業領域.get年() - 1900 - 1)/4);
//
/*** 前年までの通算日付を求める。 ***/
クラス_Rv作業領域.set合計日数((クラス_Rv作業領域.get年() - 1900) * 365 + クラス_Rv作業領域.getうるう年数());
//
/*** 入力された年がうるう年か判定する ***/
クラス_Rv作業領域.set作業用年(GlobalUtil.round(クラス_Rv作業領域.get年()/4,0,RoundingMode.DOWN));
@mattn
mattn / .classpath
Created August 8, 2012 04:51
業務プログラマがFizzBuzz書いたらどうなるか ( ref: http://d.hatena.ne.jp/irof/20120808/p1 )
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/usr/share/java/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="/usr/share/java/junit4.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@dschneider
dschneider / gist:2941985
Created June 16, 2012 17:15
RSpec - Stub Remote IP Request
ActionDispatch::Request.any_instance.stub(:remote_ip).and_return("192.168.0.1")
@paulmillr
paulmillr / active.md
Last active April 24, 2025 10:07
Most active GitHub users (by contributions). https://paulmillr.com

Most active GitHub users (git.io/top)

The list would not be updated for now. Don't write comments.

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Because of GitHub search limitations, only 1000 first users according to amount of followers are included. If you are not in the list you don't have enough followers. See raw data and source code. Algorithm in pseudocode:

githubUsers
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@oodavid
oodavid / README.md
Last active March 11, 2025 21:41 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/