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
scala> case class InvalidData(i: Int) | |
defined class InvalidData | |
scala> def firstProcess(i: Int): Either[InvalidData, Int] = try{ Right(10 / i) } catch { case _: Throwable => Left(InvalidData(i)) } | |
firstProcess: (i: Int)Either[InvalidData,Int] | |
scala> def secondProcess(d: InvalidData): Either[InvalidData, Int] = try{ Right(10 + d.i) } catch { case _: Throwable => Left(InvalidData(d.i)) } | |
secondProcess: (d: InvalidData)Either[InvalidData,Int] | |
scala> for { a <- firstProcess(2).left; b <- secondProcess(a).right } yield b |
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
# -*- coding: utf-8 -*- | |
############################## | |
##### Working with lists ##### | |
############################## | |
def last(ls) | |
ls[-1] | |
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
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. |
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
package main | |
import "fmt" | |
func rec(depth int, ch chan int) { | |
if depth > 3 { | |
return | |
} else { | |
ch <- depth | |
rec(depth+1, ch) // cannot be gorouting |
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
#!/usr/bin/env perl | |
use strict; | |
use utf8; | |
use Data::Dumper::Concise; | |
sub hoge(&;$) { | |
my $a = shift; | |
warn Dumper($a); | |
return $a->(); |
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
#!/usr/bin/env bash | |
# Copyright (c) 2011 Tomohito Ozaki(yuroyoro) | |
# 2014 Ken Kaizu(krrrr38) | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: | |
# |
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
update | |
upgrade | |
tap homebrew/binary || true | |
tap phinze/homebrew-cask || true | |
install brew-cask | |
install ack | |
install android-sdk | |
install autoconf |
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
$self->write_file("$base/js/xsrf-token.js", <<'...'); | |
var <% $module %> = <% $module %> || {}; | |
<% $module %>.getXSRFToken = function() { | |
var token; | |
return function() { | |
if(token === undefined) { | |
var cookies = document.cookie.split(/\s*;\s*/); | |
for (var i=0,l=cookies.length; i<l; i++) { | |
var matched = cookies[i].match(/^XSRF-TOKEN=(.*)$/); |
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 com.android.volley.toolbox.HurlStack; | |
import oauth.signpost.OAuthConsumer; | |
import oauth.signpost.exception.OAuthCommunicationException; | |
import oauth.signpost.exception.OAuthExpectationFailedException; | |
import oauth.signpost.exception.OAuthMessageSignerException; | |
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; |
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
package com.example.external; | |
import java.io.UnsupportedEncodingException; | |
import java.util.Map; | |
import com.android.volley.AuthFailureError; | |
import com.android.volley.NetworkResponse; | |
import com.android.volley.ParseError; | |
import com.android.volley.Request; | |
import com.android.volley.Response; |