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
UIImage *img = [[UIImage imageNamed:@"image.png"] _imageScaledToSize:CGSizeMake(32.0f, 32.0f) interpolationQuality:1]; |
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
def a(ss: String*) = ss.toList.foreach(println(_)) | |
// Error!! | |
// def b(ss: String*) = a(ss) | |
// Success | |
def b(ss: String*) = a(ss:_*) |
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
a = ["foo", 1, "bar", 2, "hoge", 100] | |
h = Hash[*a] # {"hoge"=>100, "foo"=>1, "bar"=>2} |
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.net.Authenticator; | |
import java.net.PasswordAuthentication; | |
// Basic認証のAuthenticatorを作成 | |
class HttpAuthenticator extends Authenticator { | |
public String username; | |
public String password; | |
public HttpAuthenticator(String username, String password) { | |
this.username = username; | |
this.password = password; |
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
# MongoDBに格納するためのModelクラス | |
class PEntry | |
include MongoMapper::Document | |
end |
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
require 'tempfile' | |
Dir.mkdir('tmp') unless FileTest.exist?('tmp') | |
tempfile = Tempfile.new(['xx', '.txt'], 'tmp') | |
puts tempfile.path | |
# => /Users/iwazawa/tmp/xx20110527-4157-1cev5di.txt |
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
function terminalColor(msg, fg, bg, dc) { | |
if (!fg && !bg && !dc) return msg; | |
var m = {black:"0",red:"1",green:"2",yellow:"3",blue:"4",magenta:"5",cyan:"6",white:"7", | |
uline:"4",bold:"1"}; | |
if (m[fg]) msg = "\u001b[3"+m[fg]+"m"+msg+"\u001b[39m"; | |
if (m[bg]) msg = "\u001b[4"+m[bg]+"m"+msg+"\u001b[49m"; | |
if (dc) { | |
var decos = dc.split(','); | |
for (var i=0; i<decos.length; i++) { | |
if (m[decos[i]]) msg = "\u001b["+m[decos[i]]+"m"+msg+"\u001b[0m"; |
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
# 固定数のループ | |
for i in {1..100}; do | |
echo $i | |
done |
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.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.security.KeyManagementException; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.cert.X509Certificate; |
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 play._ | |
import play.test._ | |
import org.scalatest._ | |
import org.scalatest.junit._ | |
import org.scalatest.matchers._ | |
class BasicTests extends UnitFlatSpec with ShouldMatchers with BeforeAndAfterEach { | |
override def beforeEach() { |
OlderNewer