Skip to content

Instantly share code, notes, and snippets.

@Globegitter
Globegitter / gist:9d724b14342763f042ea
Last active August 29, 2015 14:15
Install node-sass on iojs
#This sets the environment variable for Fish shell (http://fishshell.com/). Change for bash/zsh.
set -g -x SKIP_SASS_BINARY_DOWNLOAD_FOR_CI true
cd node_modules
#If you are using ember-cli-sass first change your package.json to
#"ember-cli-sass": "git+https://github.com/aexmachina/ember-cli-sass#sources-content"
#and cd node_modules/ember-cli-sass/node_modules/broccoli-sass/node_modules/
rm -rf node-sass
git clone --recursive https://github.com/sass/node-sass.git
cd node-sass
@sebmarkbage
sebmarkbage / Enhance.js
Last active July 8, 2026 08:56
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@yelouafi
yelouafi / adt.js
Created April 24, 2015 11:31
Algebraic Data Types in javascript (see http://tech.pro/blog/6885/javascript-and-type-thinking)
function eachKey(obj, f) {
for(var key in obj) {
if( obj.hasOwnProperty(key) )
f(key, obj[key]);
}
}
function adtcase (base, proto, key) {
return (...args) => {
var inst = new base();
@DrBoolean
DrBoolean / falg.js
Created December 15, 2015 18:19
F-algebra es2015
const daggy = require('daggy')
const {compose, curry, map, prop, identity, intersection, union} = require('ramda');
const inspect = (x) => { if(!x) return x; return x.inspect ? x.inspect() : x; }
// F-algebras
// Fix
// ============
// Fx is a simple wrapper that does almost nothing. It's much more useful in typed languages to check that we have a recursive f (Fix f)
//https://gist.github.com/quelgar/4661081
const daggy = require('daggy');
const {range} = require('ramda');
// type to hold an index and the array
const Pointer = daggy.tagged('i', 'a')
// Comonad instance
Pointer.prototype.extract = function() { return this.a[this.i] }
@DrBoolean
DrBoolean / comonads-are-objects.js
Created December 23, 2015 19:55
Comonads are objects js style.
// http://www.haskellforall.com/2013/02/you-could-have-invented-comonads.html
const daggy = require('daggy');
const {toUpper, prop, identity, range, curry, compose} = require('ramda');
const Config = daggy.tagged("opts")
Config.prototype.inspect = function() {
return `Config(${this.opts})`
}
@davisml
davisml / draftToHTML.js
Last active March 9, 2017 12:47
DraftJS block data to HTML
// AttributedString class from https://github.com/cohitre/attributedString.js
// Modifications made to support html tags & remove span wrapper from unstyled blocks
var AttributedString = (function () {
var aString
, StringRange
, RangesList
, HtmlSerializer
, plainStringSerializer
, _ = {}
, entityMap = {
@alexeygolev
alexeygolev / convert.js
Last active May 17, 2016 09:10
convertFromHtml in node
const jsdom = require('jsdom').jsdom
const fs = require('fs')
const path = require('path')
const {
ContentState,
convertToRaw,
convertFromRaw,
} = require('draft-js')
const React = fs.readFileSync(path.join(__dirname, '../node_modules/react/dist/react.js'))
const http = require('http');
// Swagger-like API description
const api = {
'/users': {
'get': {
'parameters': {
'role': {
'in': 'query'
},
@alexandru
alexandru / web-crawler.ts
Last active January 7, 2021 12:42
Web crawler that downloads HTML content (for analysis) from a list of websites, exporting content as JSON lines
#!/usr/bin/env node
import { IO, Try, Success, Failure, Either, Left, Right, Cancelable, Duration } from "funfix"
import { RequestResponse } from "request"
import * as fs from "fs"
import * as request from "request"
import * as Url from "url"
import * as cheerio from "cheerio"
import * as minimist from "minimist"