Skip to content

Instantly share code, notes, and snippets.

View aripalo's full-sized avatar

Ari Palo aripalo

View GitHub Profile
@aripalo
aripalo / README.md
Last active August 23, 2024 08:03
Get users (and their email, first name and last name) from Slack channel

Usage

  1. You need to create a new Slack app with following scopes:

    • channels:read
    • groups:read
    • users:read
    • users:read.email
  2. Install it into a workspace

@aripalo
aripalo / README.md
Last active January 30, 2019 13:22
Download Youtube videos for offline use

Download Youtube videos for offline use

Uses wernight/docker-youtube-dl Docker image.

Usage

  1. Provide a newline (\n) separated list of Youtube video IDs (like M7XM597XO94) or URLs (like https://www.youtube.com/watch?v=M7XM597XO94) in a txt file.

  2. Allow execution for the script file:

@aripalo
aripalo / sam-deploy-user.yml
Created August 28, 2017 17:14
AWS SAM deploy IAM user & policy document
Resources:
SamDeployUser:
Type: AWS::IAM::User
Properties:
UserName: sam-deploy-user
Path: "/"
Policies:
- PolicyName: allow-sam-deploy-access
PolicyDocument:
Version: "2012-10-17"
@aripalo
aripalo / ssh-login-notify.sh
Created November 25, 2016 18:35
macOS: Notify when successful SSH login
#!/bin/bash
machine_hostname=$(hostname -s)
while read line; do
if [[ $line == *"$machine_hostname sshd:"* ]]
then
user=$(echo $line | sed -e 's/.*sshd:\(.*\)\[priv.*/\1/' | tr -d '[:space:]')
process=$(echo $line | sed -e 's/.*USER_PROCESS:\(.*\)tty.*/\1/' | tr -d '[:space:]')
logger -p 5 -t "ssh-login-notify" -s "ssh-login-notify: user \"$user\" (process: \"$process\")"
osascript -e "display notification \"user: $user\nprocess: $process\" with title \"SSH Login: $user\""
fi
@aripalo
aripalo / collect-ebignore-files.rb
Last active October 19, 2016 22:07
Parse .ebignore rules and collect included/excluded files
# get files (also hidden ones with dot prefix)
files = Dir.glob("{**/*}", File::FNM_DOTMATCH)
# Remove folders from array as (git)ignore doesn't care about empty folders
files = files.reject { |f| File.directory?(f) }
# Remove .ebignore itself
files = files.reject { |f| f == '.ebignore' }
# Read the .ebignore file
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
local italics=$'%{\e[3m%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}${italics}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@aripalo
aripalo / styles.less
Created October 6, 2016 13:25
Atom with Operator Mono Screensmart
// base styles
atom-workspace,
atom-text-editor {
font-family: "Operator Mono SSm";
font-size: 13px;
font-weight: 400;
line-height: 1.7;
}
@aripalo
aripalo / watchpack-ignore-node-modules.sh
Last active June 30, 2017 14:08
Using webpack and its polling watch feature (via watchpack) can drain CPU which is due to watchpack polling all the npm deps within node_modules folder. This is a quick hack/fix until proper fix is merged & available in watchpack.
#!/bin/bash
# Should be used until https://github.com/webpack/watchpack/pull/23 is merged and available in npm
# See https://github.com/webpack/watchpack/issues/2#issuecomment-135204573 for more info
# Ensure we have npm
if ! hash npm 2>/dev/null; then
echo 'No NPM installed!'
exit 1
fi
(function(w) {
try {
var isHttps = w.location.protocol === "https:";
var hasSniSupport = true;//we default to true
var ua = window.navigator.userAgent;
var isInternetExplorerOnWinXpOrOlder = /MSIE.*Windows\s?((NT)?\s?(([0-5]\.\d))|XP|98|95|NT;)/i.test(ua);
var isAndroid3XorOlder = /Android [0-3]\./i.test(ua);
var isSymbian = /(SymbianOS|Series40|Series60)/i.test(ua);
var isBlackBerry = /BlackBerry/i.test(ua);
@aripalo
aripalo / twitter-list-members-to-array.js
Created December 9, 2015 18:14
Get Twitter list members' usernames into array (without using the API etc)
// 1. Scroll down the list members page:
// https://twitter.com/:username/lists/:slug/members
// ProTip™: keep holding down page down button and wait until you reach the end/bottom of the list
// 2. Paste this to dev tools console
var nodeListOfUsers = document.querySelectorAll('#timeline .username');
var listOfUsernames = Array.prototype.slice.call(nodeListOfUsers).map((node) => node.innerText);
// 3. now you got the list members in array at listOfUsernames variable
// make sure it's length equals the members amount visible in Twitter website