Em Haskell, o equivalente a:
if let x = xOptional {
// yada yada
}
Seria:
import React from 'react'; | |
import Perf from 'react-addons-perf'; | |
/** | |
* A floating button which starts/stops React's profiler. | |
*/ | |
export default class PerfMonitor extends React.Component { | |
constructor(props) { | |
super(props); |
import Component from 'react-pure-render/component'; | |
import React from 'react'; | |
import each from 'lodash/each'; | |
import shouldPureComponentUpdate from 'react-pure-render/function'; | |
export default function logComponentUpdates(Wrapped) { | |
return class Wrapper extends Component { | |
shouldComponentUpdate(nextProps, nextState) { | |
const should = shouldPureComponentUpdate.call(this, nextProps, nextState); | |
if (should) { |
Em Haskell, o equivalente a:
if let x = xOptional {
// yada yada
}
Seria:
/* Turn on a 13x13 scrollbar */ | |
::-webkit-scrollbar { | |
width: 5px; | |
} | |
::-webkit-scrollbar-button:start:decrement, | |
::-webkit-scrollbar-button:end:increment { | |
display: block; | |
} |
(defun docker-machine-env-from-shell () | |
"Loads the docker environment from the shell" | |
(interactive) | |
(mapcar (lambda (env) (apply 'setenv env)) | |
;; This should be taken as an argument but works on my current | |
;; configurations | |
(docker-machine-env "docker-vm"))) | |
(defun docker-machine-env (machine) | |
"Reads the docker environment from the shell returns it as a list of pairs" |
#!/usr/bin/env stack | |
-- stack runghc --package ansi-terminal --package time -- -prof | |
import Control.Concurrent | |
import Control.Monad | |
import Data.List | |
import Data.Time.Clock | |
import System.Console.ANSI | |
import System.IO | |
import System.IO.Unsafe |
#!/bin/bash -e | |
if [ -t 1 ]; then | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
red=$(tput setaf 1) | |
blue=$(tput setaf 4) | |
gray=$(tput setaf 8) | |
light_white=$(tput setaf 15) | |
fi |
CREATE DATABASE jobbl; | |
CREATE ROLE jobbl; | |
GRANT ALL PRIVILEGES ON DATABASE jobbl TO jobbl; | |
ALTER ROLE jobbl WITH login; |
var ONE_WEEK = 60 * 60 * 24 * 7 | |
function updateShortCycles(collection) { | |
var query = 'this.cycle && this.cycle.cycle_seconds < ' + ONE_WEEK; | |
print('Querying ' + collection + '"' + query + '"'); | |
collection.find(query).forEach(function(doc) { | |
print('Updating ' + collection + ' ' + doc._id); | |
collection.update( | |
{ _id: doc._id}, | |
{ $set : { "cycle.cycle_seconds" : '' + ONE_WEEK } } |
module CartesianProduct where | |
import Data.List (group) | |
cprod :: [a] -> [a] -> [(a, a)] | |
cprod xs ys = [ (x, y) | x <- xs, y <- ys ] | |
cprodAll :: Eq a => [[a]] -> [(a, a)] | |
cprodAll [] = [] | |
cprodAll (x:xs) = map head $ group $ concat (map (cprod x) xs) ++ cprodAll xs |