Skip to content

Instantly share code, notes, and snippets.

Suraj N. Kurapati sunaku

Block or report user

Report or block sunaku

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am sunaku on github.
  • I am sunaku (https://keybase.io/sunaku) on keybase.
  • I have a public key ASBP3INxz9p7lkGtL5u-P-wMRaZ4oyRVNY3u3NHrizZVXwo

To claim this, I am signing this object:

@sunaku
sunaku / gist:6a043d726b46a9bfaeb3
Created Oct 21, 2015
Elixir's Logger to stderr
View gist:6a043d726b46a9bfaeb3
$ mix new foo
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/foo.ex
* creating test
* creating test/test_helper.exs
@sunaku
sunaku / interleave.exs
Created Sep 15, 2015
Persistent zipping (interleaving) in Elixir.
View interleave.exs
defmodule Interleave do
def interleave(a, b, result \\ [])
def interleave([], [], result), do: result |> Enum.reverse
def interleave([], b, result), do: interleave(b, [], result)
def interleave([h|t], b, result), do: interleave(b, t, [h | result])
end
iex(1)> split = Regex.split(~r/x/, "fooxbar")
["foo", "bar"]
iex(2)> scan = Regex.scan(~r/x/, "fooxbar")
View issue-315.sozi.html
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
@sunaku
sunaku / fizzbuzz.exs
Last active May 14, 2017
A functional FizzBuzz (without any integer modulus or division) in Elixir. See https://pragprog.com/magazines/2012-08/thinking-functionally-with-haskell
View fizzbuzz.exs
# A functional FizzBuzz (without any integer modulus or division) in Elixir
# https://pragprog.com/magazines/2012-08/thinking-functionally-with-haskell
nums = Stream.iterate(1, &(&1 + 1))
fizz = Stream.cycle ["", "", "Fizz"]
buzz = Stream.cycle ["", "", "", "", "Buzz"]
fizzbuzz = Stream.zip(fizz, buzz) |> Stream.zip(nums) |> Stream.map(fn
{{"", "" }, number} -> number
{{fizzword, buzzword}, _number} -> fizzword <> buzzword
end)
fizzbuzz |> Stream.take(100) |> Enum.each(&IO.puts/1)
@sunaku
sunaku / shed
Last active Sep 7, 2016
POSIX shell script equivalent of https://github.com/mplewis/shed
View shed
#!/bin/sh -e
#
# POSIX shell script equivalent of:
# <https://github.com/mplewis/shed>
#
# Usage: shed [SHELL_ARGUMENTS...]
#
# Executes stdin after you edit it.
# If $EDITOR is unset, uses $PAGER.
# If $PAGER is unset, uses cat(1).
@sunaku
sunaku / stay.log
Last active Aug 29, 2015
vim-fetch issue #7
View stay.log
calling function fetch#visual(1)
line 1: " get text between last visual selection marks
line 2: " adapted from http://stackoverflow.com/a/6271254/990363
line 3: let [l:startline, l:startcol] = getpos("'<")[1:2]
line 4: let [l:endline, l:endcol] = getpos("'>")[1:2]
line 5: let l:endcol = min([l:endcol, col([l:endline, '$'])]) " 'V' col nr. bug
line 6: let l:endcol -= &selection is 'inclusive' ? 0 : 1
line 7: let l:lines = getline(l:startline, l:endline)
line 8: if visualmode() isnot? 'v' " block-wise selection
@sunaku
sunaku / sjsu-course-prereqs.rb
Last active Aug 29, 2015
Dumps course prerequisites for the given SJSU (San Jose State University http://www.sjsu.edu/) degree program as a DOT (Graphviz http://www.graphviz.org/) graph. You can play with the resulting graph by pasting it into the Vis.js playground (http://visjs.org/examples/graph/15_dot_language_playground.html) or you can convert it into a PDF with cl…
View sjsu-course-prereqs.rb
#!/usr/bin/env ruby
#
# Usage: ruby sjsu-course-prereqs.rb [PROGRAM_INFO_URL]
#
# Dumps course prerequisites for the given SJSU degree program as a DOT graph.
# If no PROGRAM_INFO_URL is given, the M.S. Computer Science program is used:
#
# http://www.sjsu.edu/cs/programs/mscs/program-info/
#
# You can convert the graph into a PDF with clickable course links like this:
View csd-wrapper.sh
#!/bin/sh
ARGS=$( echo "$*" | sed 's/ -url / -host /; s/ -langselen\>//' )
$HOME/.cisco/hostscan/bin/cstub -log error $ARGS
@sunaku
sunaku / chromeos-vpn
Created Apr 9, 2014
chromeos-scripts
View chromeos-vpn
#!/bin/bash
#
# Connects to the VPN specified by the given vpnc(1) configuration file and
# then waits for you to interrupt or kill this process, at which time it
# disconnects the VPN. See https://github.com/dnschneid/crouton/wiki/VPNC
#
# Usage: chromeos-vpn VPNC_CONFIGURATION_FILE [OPTIONS_FOR_VPNC...]
#
# Setup: apt-get install vpnc wireless-tools
#
You can’t perform that action at this time.