public int fibonacci(int x) {
if (x == 1) {
return 1;
} else if (x == 2) {
return 1;
} else {
return fibonacci(x - 1) + fibonacci(x - 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
private static void setLookAndFeel() | |
{ | |
// Well, let's try to set Nimbus explicitly first. | |
try | |
{ | |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); | |
System.out.println("LaF: com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); | |
return; // success | |
} | |
catch(Throwable ex) |
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
{ | |
"node": true, | |
"undef": true, | |
"bitwise": true, | |
"latedef": true, | |
"trailing": true, | |
"maxlen": 120 | |
} |
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 getURLParameter(name) { | |
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; | |
} |
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
travis_retry() { | |
local result=0 | |
local count=3 | |
while [ $count -gt 0 ]; do | |
"$@" | |
result=$? | |
[[ "$result" == "0" ]] && break | |
count=$(($count - 1)) | |
echo "Command ($@) failed. Retrying: $((3 - $count))" >&2 | |
sleep 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
// не моё | |
function plural_str(i, str1, str2, str3) { | |
if (i % 10 === 1 && i % 100 !== 11) return str1; | |
if (i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 10 || i % 100 >= 20)) return str2; | |
return str3; | |
} |
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
request = require 'request' | |
rand = Math.floor(Math.random()*100000000).toString() | |
request( | |
method: 'PUT' | |
uri: 'http://mikeal.iriscouch.com/testjs/' + rand | |
multipart: [ | |
'content-type': 'application/json' | |
'body': JSON.stringify( | |
foo: 'bar' |
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.prototype.arrowise = function(){ | |
// удаляем комментарии, выделяем префикс "function...", аргументы и тело | |
var parsed = this.toString() | |
.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/mg, '') | |
.match(/(function.*?)\((.*?)\)\s*\{([\s\S]*)\}.*/); | |
var prefix = parsed[1], args = parsed[2], code = parsed[3]; | |
// если аргументы есть, добавляется запятая перед аргументом __cb | |
if(!/^\s*$/.test(args)) args += ','; |
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 ( | |
"time" | |
"github.com/micro/go-micro" | |
_ "github.com/micro/go-micro/broker" | |
"github.com/micro/go-micro/server" | |
brokerNats "github.com/micro/go-plugins/broker/nats" | |
transportNats "github.com/micro/go-plugins/transport/nats" | |
) |
OlderNewer