Skip to content

Instantly share code, notes, and snippets.

@gsscoder
gsscoder / alive.go
Last active December 17, 2019 05:19
Go goroutine and channel to monitor process end
// compile: go build -o alive
// usage:
// $ ps -A | rg firefox
// 35761 ?? 0:23.28 /Applications/Firefox.app/Contents/MacOS/firefox
// ./alive 35761
package main
import (
"fmt"
@gsscoder
gsscoder / pickall_count_words.fsx
Last active December 19, 2019 06:25
F# script that searches the web using PickAll and counts the words of results descriptions
(*
* pickall_count_words.fsx
* - F# Script that demonstrates the use of PickAll (github.com/gsscoder/pickall)
* - Searches the web and counts the words of results descriptions
* - Requires PickAll.dll (0.8.0) and AngleSharp.dll (0.14.0-alpha-787)
* in the script directory
*)
#r "PickAll.dll"
open System
open Microsoft.FSharp.Control
@gsscoder
gsscoder / Facebook_PickAll_Searcher.cs
Last active December 18, 2019 16:16
Facebook searcher temporarily removed from PickAll source
/*
* Facebook_PickAll_Searcher.cs
* Facebook searcher for PickAll (github.com/gsscoder/pickall)
* Removed from repository, still pluggable as external service
*/
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
@gsscoder
gsscoder / pickall_search_of_searches.fsx
Last active December 19, 2019 06:41
F# scripts that uses output of a first search to perform the second
(*
* pickall_search_of_searches.fsx
* - F# Script that demonstrates the use of PickAll (github.com/gsscoder/pickall)
* - Searches the web adding the first two more used words in initial results
* - descriptions for a subsequent query
* - Requires PickAll.dll (0.8.0) and AngleSharp.dll (0.14.0-alpha-787)
* in the script directory
*)
#r "PickAll.dll"
open System
@gsscoder
gsscoder / buger_jsonparser.go
Last active December 21, 2019 13:37
Go program that parses JSON with buger/jsonparser
package main
import (
"fmt"
"github.com/buger/jsonparser"
)
var data = []byte(`
{
@gsscoder
gsscoder / tidwall_gjson.go
Last active December 21, 2019 14:11
Go program that parses JSON with tidwall/gjson
package main
import (
"fmt"
"github.com/tidwall/gjson"
)
var data = `
{
@gsscoder
gsscoder / rebar3_getdeps_yfinance.out
Created December 22, 2019 15:01
YFinance-LFE actual rebar3 get-deps output
===> Verifying dependencies...
===> Fetching clj (from {git,"git://github.com/lfex/clj.git"})
===> WARNING: It is recommended to use {branch, Name}, {tag, Tag} or {ref, Ref}, otherwise updating the dep may not work as expected.
===> Fetching lfe-compile (from {git,"https://github.com/lfe-rebar3/compile.git",
{tag,"0.5.0"}})
===> Fetching lfe (from {git,"https://github.com/rvirding/lfe.git",
{ref,"697e9b4996fa843f4c6a9edea25005d30a9b8a14"}})
===> Compiling lfe
_build/default/plugins/lfe/src/lfe_macro_include.erl:28: Warning: export_all flag enabled - all functions will be exported
@gsscoder
gsscoder / factorial.csx
Last active December 29, 2019 06:19
C# script to calculate factorial of a number
// $ dotnet script factorial.csx 10
// 3628800
var n = long.Parse(Args.ElementAt(0));
Console.WriteLine($"{factorial(n)}");
long factorial(long n)
{
if (n == 0) {
@gsscoder
gsscoder / factorial.hs
Last active December 28, 2019 20:39
Haskell program to calculate factorial of a number
-- $ ./factorial 10
-- 3628800
import System.Environment
main = do
args <- getArgs
let n = args !! 0
putStrLn (show (factorial (read n)))
factorial :: (Integral a) => a -> a
@gsscoder
gsscoder / Factorial.scala
Created December 29, 2019 05:41
Scala program to calculate factorial of a number
// $ sbt
// sbt:factorial> ~run 10
// [info] running sample.Sample 10
// 3628800
package sample
object Sample extends App {
println(factorial(args(0).toLong).toString)
def factorial (num: Long) : Long = {