Skip to content

Instantly share code, notes, and snippets.

@jgonera
jgonera / gist:781722
Created January 16, 2011 12:01
JS for file upload progress with gp.fileupload and Nginx module
function pollGp() {
$.ajax({
type: 'GET',
url: '/gp.fileupload.stat/${c.upload_id}',
cache: false,
dataType: 'json',
timeout: 5000,
success: function(response) {
if (response.state == 1) {
$('#progressbar div').css('width', response.percent + '%');
@mattratleph
mattratleph / vimdiff.md
Last active July 18, 2024 15:03 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@pascalpoitras
pascalpoitras / config.md
Last active July 18, 2024 22:34
My WeeChat configuration

WeeChat Screenshot

Mouse


enable


@AlainODea
AlainODea / bootstrap.sh
Last active January 26, 2019 17:34
WIP: SmartOS installing Haskell Cabal 1.16.1.0 (look at install_cabal.sh)
#!/bin/sh
set -o xtrace
# A script to bootstrap cabal-install.
# It works by downloading and installing the Cabal, zlib and
# HTTP packages. It then installs cabal-install itself.
# It expects to be run inside the cabal-install directory.
# install settings, you can override these by setting environment vars
@tel
tel / PipeLog.hs
Last active January 13, 2018 10:03
Pipes-based logger
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module PipeLog where
import Control.Applicative
import Data.Functor.Identity
import Pipes
import qualified Pipes.Prelude as P
newtype LogT l m a =
@prestonp
prestonp / query.sql
Created October 16, 2014 17:21
postgres update return new values and old values
-- returning updated values and old values by using a sub-expression
update orders
set type = 'delivery'
where id = 3767
returning id, type, (
select type from orders where id = 3767
) as old_type;
@bdha
bdha / gist:c456cf6e5484ea5ad256
Last active August 29, 2015 14:15
Building Haskell on SmartOS
@djspiewak
djspiewak / streams-tutorial.md
Created March 22, 2015 19:55
Introduction to scalaz-stream

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

import Control.Monad.Logic
import Control.Monad.Trans.Maybe
zipLogic :: (MonadLogic m) => m a -> m b -> m (a, b)
zipLogic gx gy =
maybe mzero return <=< runMaybeT $ do
(x, rx) <- MaybeT (msplit gx)
(y, ry) <- MaybeT (msplit gy)
lift $ return (x, y) `mplus` zipLogic rx ry
@olivierlacan
olivierlacan / migrate_postgresql_database.md
Last active March 24, 2022 20:30
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X. See upgraded version of this guide: http://olivierlacan.com/posts/migrating-homebrew-postgres-to-a-new-version/

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important: