Skip to content

Instantly share code, notes, and snippets.

@codygman
codygman / gist:7984368
Created December 16, 2013 09:23
How to get the length of a webpage in haskell imperatively, using Network.HTTP, and using Network.HTTP.Conduit
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Lazy.Char8 as BCL
import qualified Network.HTTP.Conduit as C
import Network.HTTP
pageCountShort :: IO ()
-- prints word count of a page using Network.HTTP.Conduit
pageCountShort = getLine >>= C.simpleHttp >>= print . length . words . BCL.unpack
main :: IO ()
Running tests for ruby1.8 using debian/ruby-tests.rb...
./common.rb:5:in `require': no such file to load -- mocha/setup (LoadError)
from ./common.rb:5
from ./test_buffered_io.rb:1:in `require'
from ./test_buffered_io.rb:1
from ./test/test_all.rb:10:in `require'
from ./test/test_all.rb:10
from ./test/test_all.rb:10:in `each'
from ./test/test_all.rb:10
from ./test/test_all.rb:5:in `chdir'
cody@zentop:~/backports/vagrant/ruby-net-ssh/ruby-net-ssh-2.6.8$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.3"
irb(main):002:0>
cody@zentop:~/backports/vagrant/ruby-net-ssh/ruby-net-ssh-2.6.8$ apt-cache policy ruby
ruby:
Installed: 1:1.9.3
Candidate: 1:1.9.3
Version table:
*** 1:1.9.3 0
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
module FizzBuzzC
%default total
-- Dependently typed FizzBuzz, constructively
-- A number is fizzy if it is evenly divisible by 3
data Fizzy : Nat -> Type where
ZeroFizzy : Fizzy 0
Fizz : Fizzy n -> Fizzy (3 + n)
* Go
** Martini/gorp/go-sql-driver
*** results
Running 5s test @ http://127.0.0.1:8080/api/v1/test/1
4 threads and 150 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.52ms 2.24ms 24.20ms 63.46%
Req/Sec 8.26k 684.06 8.87k 96.00%
164388 requests in 5.01s, 19.91MB read
Non-2xx or 3xx responses: 164388
@codygman
codygman / gist:d81e747cf7db1c849a23
Last active August 29, 2015 14:24
0 to Haskell web development on Windows in 10 minutes
1. Download https://github.com/commercialhaskell/stack/releases/download/v0.1.2.0/stack-0.1.2.0-x86_64-windows.zip
2. Create the folder %APPDATA%\local\bin (e.g. "c:\Users\Michael\AppData\Roaming\local\bin") if it doesn't exist
3. Extract the zip file above there
4. Append the folder location where stack installs user applications on your path: C:\Users\%user%\AppData\Roaming\local\bin\ (e.g. "C:\Users\Michael\AppData\Roaming\local\bin")
5. WARNING: Be sure that the paths you added don't have any spaces or you'll run into problems.
7. Create a folder (e.g. C:\Users\Michael\my-spock-project) for your project
8. Open a cmd.exe and navigate (e.g. cd C:\Users\Michael\my-spock-project) to your projects folder
9. stack setup
10. stack new
11. Open new-template.cabal and find the section called library. Go to the section called build-depends and on the next line put ", Spock" without the quotes.
@codygman
codygman / x.elisp
Last active July 18, 2018 04:02
fixed evil insert subheading/insert subheading todo and use more sane (for me) keybinds
;; not the first iteration, but since =, i h= and =, i s= didn't work and inserting a subitem above doesn't make sense I made the capitalized versions insert a todo
;; we can just rely upon =, s j= to move a heading up if need be
(defun my-org-insert-subheading (arg)
"Insert a new subheading and demote it.
Works for outline headings and for plain lists alike."
(interactive "P")
(evil-org-end-of-line) ;; go to end of line first
(org-insert-heading arg)
(cond
((org-at-heading-p) (org-do-demote))
* TODO tryout spacemacs-ish addon
** cloned per instructions in readme
** now adding to init.el :private
** don't see errors in the messages buffer
** don't have spacemacsy keybinds
** not sure what was wrong, I did:
*** clone doom-emacs to ~/.emacs.d
*** checkout develop
*** make quickstart
*** follow spaceemacs-ish instructions
;; Package configs
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(package-initialize)
;; Bootstrap `use-package`
(unless (package-installed-p 'use-package)