Skip to content

Instantly share code, notes, and snippets.

@kexoth
kexoth / CounLinesOfCode.hs
Last active August 29, 2015 14:02
Started this gist as comparison implementation between scripts for counting number of files & lines of code in projects in Swift (me) & Lua(@nikolamin). Added Python (@whoeverest) & Haskell (@bor0).
import System.Directory
import Control.Monad (filterM, mapM, liftM)
import System.FilePath ((</>))
getDirsRec :: FilePath -> IO [FilePath]
getDirsRec d = do
dirContents <- getDirectoryContents d
let dirContents' = [ d </> x | x <- dirContents, x /= ".", x /= ".." ]
dirs' <- mapM dirRec dirContents'
return (concat dirs' ++ [d])
import os
def generate_file_paths(path):
for dirpath, dirlist, filelist in os.walk(path):
for f in filelist:
yield os.path.join(dirpath, f)
def create_filter(extension):
def filter_f(path):
return path.endswith(extension)
@bor0
bor0 / CountLinesOfCode.hs
Last active August 29, 2015 14:02
CountLinesOfCode
import System.Directory
import Control.Monad (filterM, mapM, liftM)
import System.FilePath ((</>))
getDirsRec :: FilePath -> IO [FilePath]
getDirsRec d = do
dirContents <- getDirectoryContents d
let dirContents' = [ d </> x | x <- dirContents, x /= ".", x /= ".." ]
dirs' <- mapM dirRec dirContents'
return (concat dirs' ++ [d])
import System.Directory
import Control.Monad (filterM, mapM, liftM)
import System.FilePath ((</>))
getDirsRec :: FilePath -> IO [FilePath]
getDirsRec d = do
dirContents <- getDirectoryContents d
let dirContents' = [ d </> x | x <- dirContents, x /= ".", x /= ".." ]
dirs' <- mapM dirRec dirContents'
return (concat dirs' ++ [d])
@foca
foca / release
Last active March 31, 2023 14:15
Small shell script to create GitHub releases from the command line
#!/usr/bin/env bash
set -e
[ -z "$DEBUG" ] || set -x;
usage() {
echo "$0 <repo> <tag> [<release name>] [-- <asset>...]" >&2;
}
if [ "$1" = "-h" -o "$1" = "--help" ]; then
@MazyNoc
MazyNoc / LifecycleAwareAdapter.kt
Last active February 4, 2022 21:58
A RecyclerView adapter that respects both the RecyclerViews attach and detach view, and an external LifecycleOwner.
import android.util.Log
import android.view.View
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.recyclerview.widget.RecyclerView
import app.BuildConfig