View git-ipfs
set -e
TMP="$(mktemp -d)"
git clone -q --bare . "$TMP"
cd "$TMP"
git update-server-info
if [ objects/pack/*.pack != 'objects/pack/*.pack' ]; then
cat objects/pack/*.pack | git unpack-objects
View stanza.xml
<message type='chat'>
<reference xmlns='urn:xmpp:reference:0' type='data'>
<media-sharing xmlns='urn:xmpp:sims:1'>
<file xmlns='urn:xmpp:jingle:apps:file-transfer:4'>
View rosterAdd.rb
require 'blather/client'
require 'vcard'
# USAGE: ruby rosterAdd.rb jid@server.tld password paths/to/vcards
tels = ARGV.slice!(2..-1).flat_map do |file|
Vcard::Vcard.decode(open(file).read).flat_map do |vcard| {|tel| tel.location.include?('cell') }.map { |tel|
tel = tel.to_s.gsub(/[^0-9\+]/, '')
tel = "+1#{tel}" if tel.length == 10 && tel[0] != '+'
View SqlSimpleHelpers.hs
module SqlSimpleHelpers where
import Prelude hiding (all)
import Control.Applicative ((<*>))
import Data.Tagged (Tagged(..), asTaggedTypeOf)
import Data.Text (Text)
import qualified Data.Text as T
class SqlColumns a where
columns :: Tagged a [Text] -- ^ Columns representend in the Haskell data, in order used in ToRow/FromRow
View http-stream-file.hs
module Main (main) where
import Control.Monad (forever, when)
import System.Environment (getArgs)
import System.IO (withBinaryFile, hIsEOF, IOMode(ReadMode), hSetBuffering, BufferMode(BlockBuffering))
import Control.Concurrent (threadDelay)
import Blaze.ByteString.Builder.ByteString (fromByteString)
import Data.ByteString (ByteString)
import Data.ByteString as BS
import Data.Text as T
View html2text.rb
require 'nokogiri'
def content_text(nodes) do |el|
if el.text? || el.attributes['class'].to_s.match(/\b(?:h\-card|vcard|h\-x\-username)\b/) || el.attributes['rel'].to_s.match(/\btag\b/)
elsif == 'a'
href = el.attributes['href'].to_s
if el.text.strip == ''
// This allows you to consume a variable ane replace it with a new value
fn option_map_mut<T, F: FnOnce(T) -> T>(x: &mut Option<T>, f: F) {
match *x {
Some(_) => {
*x = Some(f(x.take().unwrap()));
None => {}
set -e
x="$(cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw)"
y="$(cat /sys/bus/iio/devices/iio:device0/in_accel_y_raw)"
[ "$x" -lt 0 ] && abs_x=$(( $x * -1 ))
View TDD.hs
module TDD (add) where
import qualified Data.Text as T
data ArgumentError = ArgumentError deriving (Show)
add :: String -> Integer
add s = sum $ map toI $ T.split (\d -> d == ',' || d == '\n') (T.pack s)
toI :: T.Text -> Integer
View TDD.hs
module TDD (add, ArgumentError(..)) where
import Data.Either
import Data.Monoid
import qualified Data.Text as T
newtype ArgumentError = ArgumentError [Integer] deriving (Show, Eq)
instance Monoid ArgumentError where
mempty = ArgumentError []