Skip to content

Instantly share code, notes, and snippets.

View laserpants's full-sized avatar

Heikki Johannes Hildén laserpants

View GitHub Profile
@laserpants
laserpants / gist:779472892c1b39088135
Last active September 15, 2016 09:27
Griddle paginator component (React.js) adapted for Bootstrap
/*
http://griddlegriddle.github.io/Griddle/index.html
<Griddle useGriddleStyles={false} tableClassName="table" showFilter={true} useCustomPagerComponent="true" customPagerComponent={BootstrapPager} results={this.state.data} />
*/
var BootstrapPager = React.createClass({
getDefaultProps: function() {
return {
"maxPage": 0,
@laserpants
laserpants / gist:6622810035445a88c570
Created July 11, 2015 20:09
Form validation with react-bootstrap
var React = require('react');
var Bootstrap = require('react-bootstrap');
var Input = Bootstrap.Input;
var NameInput = React.createClass({
getInitialState: function() {
return {
value: '',
hint: null,
@laserpants
laserpants / FocusInputExample.jsx
Created July 25, 2015 13:25
React: Set focus on input element
var Hello = React.createClass({
getInitialState: function() {
return {
value: 1,
editMode: false
};
},
edit: function() {
this.setState({editMode: true});
},
@laserpants
laserpants / gist:9f3a77c1d24c0ca23cd3
Created August 20, 2015 22:05
React-bootstrap paging component for Griddle
const BootstrapPager = React.createClass({
getDefaultProps() {
return {
currentPage : 0,
maxPage : 0,
maxButtons : 10
}
},
handleSelect(event, selectedEvent) {
let page = selectedEvent.eventKey
@laserpants
laserpants / list_view_item.xml
Last active January 20, 2016 09:30
ListView layout for FessBox channel list adapter items.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="1"
@laserpants
laserpants / WebSocketMessageListener.java
Created January 20, 2016 09:32
WebSocketMessageListener interface.
package org.farmradio.fessbox;
public interface WebSocketMessageListener {
void onMessage(String message);
}
@laserpants
laserpants / WebSocketService.java
Last active January 20, 2016 09:44
WebSocket service class.
package org.farmradio.fessbox;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import de.tavendo.autobahn.WebSocketConnection;
@laserpants
laserpants / Main.hs
Last active October 19, 2017 06:46
Haskell ternary operator.
module Main where
(.?.) :: Bool -> (a, a) -> a
(.?.) True = fst
(.?.) False = snd
infixl 3 .?.
(>:<) :: a -> b -> (a, b)
(>:<) = (,)
module Main
import Prelude.Functor
total ap : Applicative f => f (a -> b) -> f a -> f b
ap = (<*>)
total maybeAdd1 : Num a => Maybe a -> Maybe a -> Maybe a
maybeAdd1 x y = do x' <- x
y' <- y
@laserpants
laserpants / keymap.cson
Created November 20, 2017 21:16
Keymap binding to toggle IDE-Haskell output pane in Atom editor
'atom-workspace':
'ctrl-shift-0': 'ide-haskell:toggle-output'