Skip to content

Instantly share code, notes, and snippets.

Avatar

Milan Korsos milankorsos

View GitHub Profile
@milankorsos
milankorsos / redux-actions.ts
Last active Nov 10, 2022
Correct TypeScript typing example for Redux Thunk actions
View redux-actions.ts
import {Action, ActionCreator, Dispatch} from 'redux';
import {ThunkAction} from 'redux-thunk';
// Redux action
const reduxAction: ActionCreator<Action> = (text: string) => {
return {
type: SET_TEXT,
text
};
};
@milankorsos
milankorsos / debug.js
Created Nov 24, 2011
define cookie controlled custom outputs for your modules
View debug.js
//Use $.cookie('quickbrowse-debug', true, {expires: 7, path: '/'}) to set.
// ... and $.cookie('quickbrowse-debug', null) to delete.
var qbConsole;
if(!$.cookie('quickbrowse-debug')) {
qbConsole = {};
qbConsole.log = function(){};
} else {
qbConsole = console;
}
@milankorsos
milankorsos / html
Created Nov 1, 2011
underscore templates
View html
<script type="text/template" id="something-tmpl">
<% for (var index = 0; index < items.length; index++) { %>
<% var item = items[index]; %>
<p><strong><%= item.username %></strong></p>
<% if (item.age) { %> <p>Age: <%= item.age %></p> <% } %>
<% if (item.sex) { %> <p>Sex: <%= item.sex %></p> <% } %>
<% if (item.location) { %> <p>Location: <%= item.location %></p> <% } %>
<% } %>