Skip to content

Instantly share code, notes, and snippets.

View iporsut's full-sized avatar
🏠
Working from home

Weerasak Chongnguluam iporsut

🏠
Working from home
View GitHub Profile
@iporsut
iporsut / concurrent-get.hs
Last active November 7, 2017 03:04
Concurrent HTTP Get using Haskell
#!/usr/bin/env stack
-- stack --resolver lts-9.12 script --package http-conduit,stm,bytestring
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy.Char8 as L8
import Control.Concurrent
import Control.Monad
import Control.Concurrent.STM
import Network.HTTP.Simple
@iporsut
iporsut / gist:4eb8564acf78e83d3312e559a16b5075
Last active July 26, 2017 08:27
modify from c-j-s/ruby-ssh-safety/Example.rb
#!/usr/bin/env ruby
# WARNING! Everything described in this file was checked against
# Net::SSH v3.2.0, https://github.com/net-ssh/net-ssh/tree/v3.2.0
# (commit e279c5e). Other versions may be apropriately different.
# Some of the things here appear to dig into the Net::SSH internals a
# little more than may be comfortable for some.
#
require 'net/ssh'
#!/usr/bin/env stack
-- stack script --resolver lts-8.20 --package time,haskeline
module Main where
import Control.Monad.IO.Class
import Control.Monad
import Control.Exception
import System.Console.Haskeline
import Data.Time
import Data.Maybe
@iporsut
iporsut / roof.go
Created May 24, 2017 05:38
Refactor from P' Roof Go Presentation
package main
import (
"fmt"
"log"
"os"
"time"
)
func export(i int) {
#!/usr/bin/env bash
go get -u github.com/alecthomas/gometalinter
go get -u github.com/haya14busa/go-typeconv/cmd/gotypeconv
go get -u github.com/haya14busa/gosum/cmd/gosumcheck
go get -u github.com/haya14busa/goverage
go get -u github.com/motemen/gofind/cmd/gofind
go get -u github.com/nsf/gocode
go get -u github.com/rogpeppe/godef
go get -u github.com/sqs/goreturns
go get -u github.com/zmb3/gogetdoc
@iporsut
iporsut / map-flatten.clj
Created April 9, 2017 09:23
map-flatten
(defn map-flatten
([params]
(into {} (map-flatten params nil)))
([params prefix]
(mapcat (fn [[k v]]
(let [prefix (if (nil? prefix) (name k) (str prefix "[" (name k) "]"))]
(if (map? v)
(map-flatten v prefix)
[{prefix v}])))
params)))
@iporsut
iporsut / .emacs
Last active October 3, 2020 04:29
dot emacs
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
@iporsut
iporsut / Replicate.java
Last active August 18, 2016 17:42
Generate power print
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Replicate {
public static void main(String []args) throws IOException, InterruptedException {
@iporsut
iporsut / Replicate.java
Created August 18, 2016 16:43
BigInteger power print
import java.math.BigInteger;
public class Replicate {
public static void main(String []args) {
Integer n = 100;
BigInteger bn = new BigInteger(n.toString()).pow(n);
while (!bn.equals(BigInteger.ZERO)) {
System.out.print('A');
bn = bn.subtract(BigInteger.ONE);
}
System.out.println();