Skip to content

Instantly share code, notes, and snippets.

@andrewjmeier
Last active August 29, 2015 14:23
Show Gist options
  • Save andrewjmeier/9486b899f1b2114c267e to your computer and use it in GitHub Desktop.
Save andrewjmeier/9486b899f1b2114c267e to your computer and use it in GitHub Desktop.

React-Gist-Slideshow

A React component to show your gists in a slideshow

$ npm install react-gist-slideshow

Supported File Types

  • JavaScript
  • HTML
  • Markdown
  • Objective-C
  • Ruby
  • Java
  • Python
// 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];
}

Change Text Editor Style

Theme

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" />

Read-Only

Set readOnly to false to allow editing of the code in the slides.

<ReactGistSlideshow gist="https://gist.github.com/example/1234" readOnly="false" />

Show Gutter

Show line numbers on the left side of the editor.

<ReactGistSlideshow gist="https://gist.github.com/example/1234" showGutter="true" />

Highlight Active Line

<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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment