Skip to content

Instantly share code, notes, and snippets.

View matriphe's full-sized avatar

Muhammad Zamroni matriphe

View GitHub Profile
@matriphe
matriphe / aws-s3-glacier-restore.sh
Created May 5, 2024 10:08
Restore AWS S3 Object from Glacier Type
#!/bin/sh
# Original: https://stackoverflow.com/a/55499152
BUCKET=bucket # Replace with your actual bucket name
BPATH=path # Replace with the path within the bucket
DAYS=5 # Number of days to keep in the Standard type
S3BUCKET="s3://$BUCKET$BPATH"
@matriphe
matriphe / git-config-alias.md
Last active May 16, 2022 10:37
Git Hide / Unhide

Based on https://stackoverflow.com/a/25387310

git config --global alias.hide 'update-index --assume-unchanged'
git config --global alias.unhide 'update-index --no-assume-unchanged'
git config --global alias.hidden '! git ls-files -v | grep '^h' | cut -c3-'

Usage

Keybase proof

I hereby claim:

  • I am matriphe on github.
  • I am matriphe (https://keybase.io/matriphe) on keybase.
  • I have a public key ASD-YZEOxh6jNzeWvspqDVh9_E6gseTzN0PAdc-ray852wo

To claim this, I am signing this object:

@matriphe
matriphe / brew-install-kubectl-cli-1.11.3.md
Created July 9, 2019 15:08
Brew Install kubectl-cli version 1.11.3
@matriphe
matriphe / composer
Last active March 5, 2023 03:41
Composer shell alias to run Composer Docker
#!/bin/bash
docker run \
--interactive \
--rm \
--user $(id -u):$(id -g) \
--volume ~/.composer:/tmp \
--volume /etc/passwd:/etc/passwd:ro \
--volume /etc/group:/etc/group:ro \
--volume $(pwd):/app \
composer "$@"
@matriphe
matriphe / parse_raw_http_request.php
Created February 25, 2018 22:16
Parse raw HTTP request data (get PUT/PATCH data)
<?php
/**
* Parse raw HTTP request data
*
* Pass in $a_data as an array. This is done by reference to avoid copying
* the data around too much.
*
* Any files found in the request will be added by their field name to the
* $data['files'] array.
@matriphe
matriphe / redis.service
Last active September 22, 2020 11:01
Redis Systemd Service (Debian Based)
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
Type=forking
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/local/bin/redis-cli shutdown
<?php
$examples = [
// kendaraan umum
'B 1',
'B 1234 ABC',
'B-1234-ABC',
'AD-1234 - XYZ',
'AB1234LD',
'D1',
@matriphe
matriphe / ssh-telegram.sh
Last active May 7, 2023 15:00
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use jq to parse JSON from ipinfo.io
# get jq from here http://stedolan.github.io/jq/
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ]; then

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter