A React component to show your gists in a slideshow
$ npm install react-gist-slideshow
// JavaScript | |
var looping = function(n) { | |
var a = 0, b = 1, f = 1; | |
for(var i = 2; i <= n; i++) { | |
f = a + b; | |
a = b; | |
b = f; | |
} | |
return f; | |
}; |
# Ruby | |
def fibonacci( n ) | |
return n if ( 0..1 ).include? n | |
( fibonacci( n - 1 ) + fibonacci( n - 2 ) ) | |
end | |
puts fibonacci( 5 ) |
# Python | |
def fib(n): | |
a,b = 1,1 | |
for i in range(n-1): | |
a,b = b,a+b | |
return a | |
print fib(5) |
// Java | |
public static int fibonacciLoop(int number){ | |
if(number == 1 || number == 2){ | |
return 1; | |
} | |
int fibo1=1, fibo2=1, fibonacci=1; | |
for(int i= 3; i<= number; i++){ | |
fibonacci = fibo1 + fibo2; //Fibonacci number is sum of previous two Fibonacci number | |
fibo1 = fibo2; | |
fibo2 = fibonacci; | |
} | |
return fibonacci; //Fibonacci number | |
} |
// Objective-C | |
-(int) fib:(int)num { | |
if (num == 0) { | |
return 0; | |
} | |
if (num == 1) { | |
return 1; | |
} | |
return [self fib:num - 1] + [self fib:num - 2]; | |
} |
The default theme is Monokai. Other themes can be added from Brace.
require('brace/themes/xcode');
...
<ReactGistSlideshow gist="https://gist.github.com/example/1234" theme="xcode" />
Set readOnly to false to allow editing of the code in the slides.
<ReactGistSlideshow gist="https://gist.github.com/example/1234" readOnly="false" />
Show line numbers on the left side of the editor.
<ReactGistSlideshow gist="https://gist.github.com/example/1234" showGutter="true" />
<ReactGistSlideshow gist="https://gist.github.com/example/1234" highlightActiveLine="true" />
// Objective-C | |
- (NSArray*) sortMyArray:(NSArray*)drinkDetails { | |
NSArray *sortedArray; | |
sortedArray = [drinkDetails sortedArrayUsingComparator:^NSComparisonResult(id a, id b) { | |
NSDate *first = [(Person*)a birthDate]; | |
NSDate *second = [(Person*)b birthDate]; | |
return [first compare:second]; | |
}]; | |
return sortedArray; | |
} |