Skip to content

Instantly share code, notes, and snippets.

View lgastako's full-sized avatar

John lgastako

  • Francon & Heyer
  • Milky Way Galaxy, Third Rock from the Sun
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from cStringIO import StringIO
from UserString import MutableString
data = xrange(100000)
def test_join_way():
return ''.join([str(x) for x in data])
from __future__ import unicode_literals
def decimal_to_unicode(d, strip=True):
"""Converts a decimal to a unicode string stripping any redundant
trailing zeros to the right of the decimal place if strip is True.
>>> from decimal import Decimal
>>> decimal_to_unicode(Decimal("1.234000"))
u'1.234'
@lgastako
lgastako / tlc.lua
Created March 29, 2012 20:15 — forked from fjolnir/tlc.lua
LuaJIT ObjC bridge
-- TLC - The Tiny Lua Cocoa bridge
-- Note: Only tested with LuaJit 2 Beta 9 on x86_64 with OS X >=10.6 & iPhone 4 with iOS 5
-- Copyright (c) 2012, Fjölnir Ásgeirsson
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@lgastako
lgastako / HaskellMapsAndLists.hs
Last active January 1, 2016 08:28
Haskell implementation of https://gist.github.com/amontalenti/8114359 from a non-haskell programmer.
module Main where
import Data.Map (Map)
import qualified Data.Map as Map
main = let someItems = [1, 2, 3, 4]
someMapping = Map.fromList [ ("ST", "started")
, ("IP", "in progress")
, ("DN", "done")
]
CREATE VIEW salesforce.actual_sf_task_count AS
SELECT COUNT(*) sf_task_count
FROM salesforce.sf_task;
-- [local]:5432 salesforce@salesforce # SELECT * FROM actual_sf_task_count;
-- +---------------+
-- | sf_task_count |
-- +---------------+
-- | 8226055 |
-- +---------------+
type Branches
= Epistemology
| Ethics
| Logic
| Metaphysics
type Branches =
| Epistemology
| Ethics
@lgastako
lgastako / .ghci file
Created May 17, 2017 04:41 — forked from npezolano/.ghci file
.ghci file
:set prompt "λ: "
:set -fno-warn-unused-imports
:def hlint const . return $ ":! hlint \"src\""
:def hoogle \s -> return $ ":! hoogle --count=15 \"" ++ s ++ "\""
:def pl return . (":! pointfree \"" ++) . (++ "\"")
@lgastako
lgastako / global-local.elm
Created May 30, 2017 22:07 — forked from jeffreyrosenbluth/global-local
A Reflex app with both global and local state
{-# LANGUAGE RecursiveDo #-}
-- | A simple example of a Reflex application that uses both elm style "global"
-- state and component level "local" state. The global state is a counter that
-- can be incremented and decremented by buttons that remember how many times
-- they have been clicked.
module Main where
import Control.Applicative
@lgastako
lgastako / trees.hs
Created September 17, 2017 05:09
hustle trees
module TreeFolds where
data Tree a
= Leaf a
| Branch (Tree a) (Tree a)
deriving (Eq, Ord, Read, Show)
instance Foldable Tree where
foldMap f (Leaf a) = f a
foldMap f (Branch l r) = foldMap f l `mappend` foldMap f r
type Enum a
= Enum
{ predFn : a -> Maybe a
, succFn : a -> Maybe a
}
pred : Enum a -> a -> Maybe a
pred (Enum { predFn }) =
predFn