Skip to content

Instantly share code, notes, and snippets.

View gpampara's full-sized avatar

Gary Pamparà gpampara

  • Pretoria, South Africa
View GitHub Profile
@cdown
cdown / gist:1163649
Last active July 1, 2024 03:35
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
package pl.irc
import org.jibble.pircbot.PircBot
import dispatch._
import Http._
import net.liftweb.json._
import net.liftweb.json.JsonDSL._
import net.liftweb.json.Printer.{compact}
import java.io.{PrintStream, ByteArrayOutputStream}
@kofemann
kofemann / adler32.py
Last active October 15, 2021 07:57
A script to calculate adler32 checksum of given files
#!/usr/bin/env python
'''A script to calculate adler32 checksum of given files'''
BLOCKSIZE=256*1024*1024
import sys
from zlib import adler32
for fname in sys.argv[1:]:
asum = 1
with open(fname,"rb") as f:
@mpilquist
mpilquist / gist:3679896
Created September 8, 2012 21:26
Template approach to avoiding explicit type annotations
import scalaz._
/**
* Provides type aliases and utilities for working with state disjunctions.
*
* A state disjunction is a function `S => F[(S, L \/ R)]` wrapped in the StateT and EitherT monad
* transformers.
*
* See `StateDisjunctionT` and `StateDisjunction` for more information.
@wsargent
wsargent / gist:5860224
Created June 25, 2013 16:58
Using ning async http client
import play.api.libs.ws.Response
import scala.concurrent.{Future, Promise}
import com.ning.http.client._
import com.ning.http.client.{Response => AHCResponse}
import com.ning.http.client.AsyncCompletionHandler
val url = "http://google.com"
val config = new AsyncHttpClientConfig.Builder()
@ms-tg
ms-tg / scala_try_monad_axioms.scala
Last active May 28, 2022 03:48
Scala Try: monad axioms
import scala.util.{Try, Success, Failure}
def f(s: String): Try[Int] = Try { s.toInt }
def g(i: Int): Try[Int] = Try { i * 2 }
def unit[T](v: T): Try[T] = Success(v)
//val v = "1"
val v = "bad"
val m = Success(v)
@shajra
shajra / Task.scala
Created August 23, 2013 03:34
integration code between Scalaz and Scala standard concurrency libraries.
import concurrent.{ExecutionContext, Future => SFuture, Promise}
import util.Try
import _root_.scalaz.\/
import _root_.scalaz.concurrent.{Task => ZTask}
object Task {
def fromScala[A]
@pchiusano
pchiusano / retries.scala
Last active December 30, 2015 22:29
Combinator for retrying a `Process` multiple times, delaying between attempts
// FYI: some comments below refer to old version of this gist: https://gist.github.com/pchiusano/7894696/12201b92db57dff8ed6689fc55c15c3f1a136f86
package scalaz.stream
import scalaz.\/
import scalaz.concurrent.Task
object retries {
def dropWhileUnlessAtEnd[I](f: I => Boolean): Process1[I,I] = {
def go(prev: Option[I]): Process1[I,I] =
@markhibberd
markhibberd / argonaut.scala
Created January 3, 2014 03:05
argonaut union type example
package argonaut.example
import argonaut._, Argonaut._
import scalaz._, Scalaz._
object UnionExample extends {
sealed trait Thing
final case class One(n: String, i: Int) extends Thing
final case class Two(n: String) extends Thing
@donovanh
donovanh / gulpfile.js
Created July 28, 2014 21:01
Gulp file for Jekyll, with Sass, Autoprefixer, and browsersync
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),