Skip to content

Instantly share code, notes, and snippets.

@jamesrr39
jamesrr39 / find-unused-requirejs-imports.sh
Last active August 29, 2015 14:21
Find unused resources
#!/bin/bash
# a script to find any javascripts that may not be used anywhere anymore.
base_directory="."
all_files=$(find "$base_directory" -type f)
for file in $all_files
do
import_name=$(echo "$file" | rev | cut -d "/" -f 1 | rev | sed -e 's/\.js$//')
@jamesrr39
jamesrr39 / memory-notifier.py
Last active August 29, 2015 14:22
Notify how much swap space is available (Linux)
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import re
from gi.repository import Notify
def send_message(summary, message):
Notify.init (summary)
notification = Notify.Notification.new (summary,message,"dialog-information")
@jamesrr39
jamesrr39 / get-process-working-directory
Created June 1, 2015 18:31
Get working directory of a searched for process
#!/bin/bash
# get the working directory of processes
search_term="$1"
pgrep "$search_term" | xargs -I {} readlink -f /proc/{}/cwd
@jamesrr39
jamesrr39 / find-duplicate-filenames.py
Last active August 29, 2015 14:23
Find duplicate filenames within a path
#!/usr/bin/python
'''
Tool to find files with the same name within a directory.
Developed to help with detection of unused files that weren't being detected as unused by require.js as they had the same names as other files that were being imported.
usage:
python find-duplicate-filenames.py [path]
options:
path: path on which to look. Defaults to the current working directory.
@jamesrr39
jamesrr39 / me.md
Last active September 13, 2015 20:12
About me

I'm a developer living/working in Malmö, Sweden. I mostly write in Javascript, some Java and increasingly more Go and Python, and bash when it's needed.

My main interests technologically include web technologies, automation and image processing.

You can find my PGP key on pgp.mit.edu. I try and remember to PGP sign when I tag. You can use git verify-tag to verify the tag! My key ID is 83868A38.

@jamesrr39
jamesrr39 / media-workflow.sh
Last active September 15, 2015 08:34
pre-commit githook to make sure files are always added in master and only deleted in feature branches
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m' # No Color
# pre-commit hook to check new files are always added to the master branch and deletions are always made in feature branches.
# useful when master should contain all the files ever added (eg. in a media project), and the feature branches can offer 'views' of parts of them
branch_name=$(git rev-parse --abbrev-ref HEAD)
@jamesrr39
jamesrr39 / Golang program stdin stdout interaction.md
Last active July 12, 2023 18:21
Using stdout and stdin from other programs in Golang

Go program interaction

Example of how to use stdout and stdin from other programs in golang

Requires go

Run

go run parentprocess.go
@jamesrr39
jamesrr39 / Cgo practice
Last active February 25, 2016 21:26
Cgo practice
Some Go/Cgo code
go run cgo.go
@jamesrr39
jamesrr39 / Go Pointers.md
Last active February 19, 2019 04:05
Go Pointers

Go pointers

This gist demonstrates the use of pointers in go (and other similar languages)

Use &x to get the address of x

Use *x to get a value from an address x

When should I use a pointer?

@jamesrr39
jamesrr39 / Installing libgit2.md
Last active February 13, 2024 13:41
Installing libgit2

Remove any libgit2 packages you already have, otherwise these will be included first and they do not necessarily have everything needed that you need for pygit2/git2go.

sudo apt-get purge libgit2-0 libgit2-dev

From http://www.pygit2.org/install.html

wget https://github.com/libgit2/libgit2/archive/v0.23.4.tar.gz
tar xzf v0.23.4.tar.gz
cd libgit2-0.23.4/

cmake .