Skip to content

Instantly share code, notes, and snippets.

@ohanhi
ohanhi / joy-of-composition.md
Last active May 6, 2024 05:21
The Joy of Composition - Why stateless rendering is pure bliss

This is a proposal for a lightning talk at the Reactive 2015 conference.

NOTE: If you like this, star ⭐ the Gist - the amount of stars decides whether it makes the cut!

The Joy of Composition

Why stateless rendering is pure bliss

React just got stateless components, meaning that they are in essence pure functions for rendering. Pure functions make it dead simple - even fun - to refactor your views

@kpuputti
kpuputti / fold.js
Last active May 6, 2024 05:20
Functional acrobatics using folds in JavaScript.
/*eslint-env es6 */
// Inspired by the paper "A tutorial on the universality and
// expressiveness of fold" by Graham Hutton (available at
// http://www.cs.nott.ac.uk/~gmh/fold.pdf), implementing some generic
// list handling functions in JavaScript in terms of `fold`.
// Personally I had an enlightnening moment when I realised the
// beautiful interplay of cons lists and foldr during the FP101x
// Haskell course. JavaScript's syntax doesn't make this very apparent
@axefrog
axefrog / scope.js
Last active May 6, 2024 05:20
An idea for scoping Cycle.js child components/dialogues in the context of their parent. Any driver can optionally supply a scope() function, which returns a scoped instance of itself. A driver can also supply an unscope() function which returns a transformed instance of its associated sink. Anything that is scope-unaware is preserved.
function runInScope(main, sources, context, ...args) {
if(!main) {
throw new Error('A "main" function must be supplied, which will be called in scope and from which a (sinks) object will be returned');
}
if(!sources) {
throw new Error('A source drivers object must be supplied, to which scoping can be applied');
}
if(!context) {
throw new Error('A scope context object must be supplied, either as a string, or as an object of key/value pairs');
}
@KarthickSudhakar
KarthickSudhakar / kvm_export_import.sh
Last active May 6, 2024 05:20
Bash script to import and export KVM virtual machine
#!/usr/bin/env bash
# ----------------------------------------------------------------------------------------------------
# AUTHOR : KARTHICK S
# PURPOSE : THIS SCRIPT WILL EXPORT/IMPORT THE CONFIG AND VM DISK.
#
# usage:
# export function will take care of exporting the necessary for all VM. Run as "<scriptname.sh> export"
# import function will take care of importing the necessary for all VM. Run as "<scriptname.sh> import"
#
@attilaking
attilaking / emailValidate.js
Created May 20, 2020 10:39
[Validate email] email validations #email #validate
function ValidateEmail(mail) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) {
return (true)
}
//alert("You have entered an invalid email address!")
return (false)
}
@balupton
balupton / README.md
Last active May 6, 2024 05:19
DocPad: Minify your assets with Grunt

DocPad: Minify your assets with Grunt

The following will minify your assets with grunt each time a generation write completes.

Installation

  1. Install Dependencies
@allanwhite
allanwhite / Iterate text layer, save to png
Last active May 6, 2024 05:19
This is a Photoshop .jsx script that will iterate & change a number in a text layer, and save-to-web files in a preset path.
function sfwPNG24(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}
@allanwhite
allanwhite / HSQ-brand-colors-2015.markdown
Last active May 6, 2024 05:19
HSQ Brand colors, 2015

HSQ Brand colors, 2015

Current as of Dec. 29 2014. These colors are going to drive the new healthsparq.com, which will be launched in early 2015.

A Pen by Allan White on CodePen.

License.

@allanwhite
allanwhite / share.html
Last active May 6, 2024 05:19
Lean Share Icons (a partial for Statamic CMS)
<h2 class="subhead">Share this!</h2>
<p class="icons"><!-- there's some styling for icons here; lots of ways to solve this. See font-awesome for icons -->
<a href="https://twitter.com/intent/tweet?text={{ site_name }}: {{ title|truncate:100 }}&url={{ permalink }}&related={{ twitteruser }}" target="_blank"><i class="icon-twitter"></i> </a>
<a href="http://www.facebook.com/sharer.php?s=100
&p[url]={{ permalink }}
{{ if image_featured_thumb }}&p[images][0]={{ image_featured_thumb }}{{ endif }}
&p[title]={{ site_name }}: {{ title }}
&p[summary]={{ summary|truncate:200 }}"><i class="icon-facebook"></i> </a>
<a href="https://plus.google.com/share?url={{ permalink }}"><i class="icon-google-plus"></i></a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url={{ permalink }}&title={{ title }}|{{ site_name }}&summary={{ summary|truncate:100 }}" title="_blank"><i class="icon-linkedin"></i> </a>
@allanwhite
allanwhite / SassMeister-input-HTML.html
Created February 18, 2016 01:35
Generated by SassMeister.com.
<div class="flex flex-center">
<img class="client" src="https://catalyze.io/assets/img/customer-logos/zipnosis-logo.png" alt="logo"/>
<img class="client" src="https://catalyze.io/assets/img/customer-logos/zipnosis-logo.png" alt="logo"/>
<img class="client" src="https://catalyze.io/assets/img/customer-logos/zipnosis-logo.png" alt="logo"/>
<img class="client" src="https://catalyze.io/assets/img/customer-logos/zipnosis-logo.png" alt="logo"/>
<img class="client" src="https://catalyze.io/assets/img/customer-logos/zipnosis-logo.png" alt="logo"/>
<img class="client" src="https://catalyze.io/assets/img/customer-logos/zipnosis-logo.png" alt="logo"/>
</div>