Skip to content

Instantly share code, notes, and snippets.

View ferdinandsalis's full-sized avatar
🎯
Focusing

Ferdinand Salis ferdinandsalis

🎯
Focusing
View GitHub Profile
@jquense
jquense / app.js
Last active August 29, 2015 14:26
implementation of redux's combineReducers adding flux waitFor()
import { createStore } from 'redux';
import combineReducers from './combineReducers';
let Store = createStore(combineReducers({
reducerA(state = 0, action, waitFor){
if ( action.type === 'TEST'){
waitState = waitFor(waitFor.reducerB)
if ( waitState.reducerB === 5 )
state = 10
@mattiamanzati
mattiamanzati / handling auth in redux
Created August 25, 2015 16:27
Auth handling in redux.
Before reading:
This is a soft auth check. Auth check should always be done server side, if not, your rest api are not checking correctly for auth.
1. Auth is in the store.
You need to setup constants for AUTH_SET_TOKEN and AUTH_LOGOUT,
then create the action creators authSetToken(token) and authLogout() action creators.
Then setup a reducer that when AUTH_SET_TOKEN is dispatched, sets the internal state to {token: token},
and when logout is dispatched, clears it.
Now setup a utility function isLoggedIn(state) function, that only checks in state.auth.token exists, this is a soft check.
module DateTimeHelper
def format_date_range(date_range)
first = date_range.first
last = date_range.last
if same_day?(first, last)
"#{first.to_s(:month_day)}, #{first.year}"
elsif same_month?(first, last)
"#{first.to_s(:month_day)}-#{last.day}, #{last.year}"
else
"#{first.to_s(:month_day)}-#{last.to_s(:month_day)}, #{last.year}"
@adactio
adactio / flexboxtest.html
Created August 15, 2011 22:46
Content-first flexbox test
<!DOCTYPE html>
<html>
<head>
<title>Flexbox test</title>
<style>
@media screen and (min-width: 30em) {
body {
display: -webkit-box;
display: -moz-box;
display: -ms-box;
@miekd
miekd / css-snippet.css
Created December 27, 2011 16:02
Rounded Corner Images
.image-rounded {
border-radius: 4px;
display: inline-block;
}
.image-rounded img {
visibility: hidden;
}
@tbranyen
tbranyen / mixin-events.js
Created September 6, 2012 04:59
Mixin-able events
// Portable & reusable Events object, not too different from what is found
// in Backbone.
//
// (Credits @visionmedia) & Modified from:
// https://raw.github.com/component/emitter/master/index.js
var Events = {
// Cache all callbacks.
callbacks: {},
// Listen on the given `event` with `fn`.
@arielsalminen
arielsalminen / nav.html
Last active December 14, 2015 12:18
Simple responsive navigation toggle script without library dependencies and with touch screen support (349 bytes minified and gzipped). Live demo: http://codepen.io/viljamis/full/gAatl
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>Nav toggle</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<ol id="nav" class="closed">
<li class="active"><a href="#">Home</a></li>

Core tech

  • Java (no emoticon is sad enough)
  • Node (just for build, testing, cmd stuff at work / at home for nearly everything)
  • Ruby (only for sass/compass & Vagrant)

JS Stack (mostly used libs.)

  • Backbone
  • jQuery
@micahgodbolt
micahgodbolt / SassMeister-input.scss
Created June 24, 2013 16:08
Another stab at Filament Group's Element Query challenge.
// ---
// Sass (v3.2.9)
// ---
@mixin respond-to($queries...) {
$length: length($queries);
@for $i from 1 through $length{
@if $i % 2 == 1 {
@media screen and (min-width: nth($queries, $i)) {
@adactio
adactio / tabledisplaytest.html
Created August 16, 2011 10:36
Content-first table-display test
<!DOCTYPE html>
<html>
<head>
<title>Table Display test</title>
<style>
@media screen and (min-width: 30em) {
body {
display: table;
caption-side: top;
}