Skip to content

Instantly share code, notes, and snippets.

@megaserg
megaserg / check.sh
Last active August 29, 2015 14:19
Ugly C++ quine
#!/bin/bash
g++ -O2 -Wall quine.cpp -o quine && ./quine > result.cpp && diff quine.cpp result.cpp
@megaserg
megaserg / setup-pants-completion.sh
Created July 15, 2015 19:06
Usage: source ~/setup-pants-completion.sh
_pants_goal_completion() {
# invoke pants to list goals
local pants_command=${COMP_WORDS[0]}
local goals_array=$(PANTS_NO_TRANSLATION=1 $pants_command -q goals | grep -v "Installed goals" | cut -d ":" -f 1 | sed -e 's/^[[:space:]]*//')
# ...or use a precomputed list
#local goals_array="autoblame bash-completion binary bootstrap builddict buildprops bundle changed check_published_deps clean-all clean-all-async compile compile-changed compute-buildprops deferred-sources dependees dependees_owners dependencies depmap detect-duplicates doc eclipse ensime export filedeps filemap filter gen goals idea invalidate jar killserver list markdown minimize ng-killall path pathdeps paths publish repl repl-dirty resolve roots run run-dirty server setup-py sort targets test test-changed thrift-linter unpack-jars"
local prefix=${COMP_WORDS[COMP_CWORD]}
if [[ $prefix == *"/"* ]]; then
@megaserg
megaserg / %13.json
Created October 21, 2015 23:38
carriage return
{
"created_at": "Wed Oct 21 19:24:31 +0000 2015",
"id": 656913977029632000,
"id_str": "656913977029632000",
"text": "@__jud4s\r> stateless\r> hello world\rSounds like a typical immigrant experience.",
"source": "<a href=\"http://www.twitter.com\" rel=\"nofollow\">Twitter for Windows Phone</a>",
"truncated": false,
"in_reply_to_status_id": 656901694811320300,
"in_reply_to_status_id_str": "656901694811320320",
"in_reply_to_user_id": 226688217,
{-# LANGUAGE FlexibleInstances, UndecidableInstances, MultiParamTypeClasses #-}
import Control.Monad.Writer
newtype CoroutineT m a = CoroutineT { runCoroutineT :: m (Either (CoroutineT m a) a) }
instance Monad m => Functor (CoroutineT m) where
fmap = liftM
instance Monad m => Applicative (CoroutineT m) where
@megaserg
megaserg / fixhg.py
Created January 26, 2019 18:39
Capitalizes your text to make it look professional.
#!/usr/bin/env python
import re
import sys
def remove_double_space_dots(s):
while " " in s:
s = s.replace(" ", " ")
while ".." in s:
s = s.replace("..", ".")