Skip to content

Instantly share code, notes, and snippets.

@sunapi386
sunapi386 / slack-export.md
Created January 8, 2019 03:23
Guide to getting your own slack export
@sunapi386
sunapi386 / gist:c6d489c43592552d1f7c2732ac703aae
Created November 15, 2018 22:59
Clean up /boot partition

First check your kernel version, so you won't delete the in-use kernel image, running:

uname -r

Now run this command for a list of installed kernels:

dpkg --list 'linux-image*' | grep ii

and delete the kernels you don't want/need anymore by running this:

@sunapi386
sunapi386 / defaults.new
Last active September 7, 2019 21:57
Remove the WeKnow.ac Chrome newtab hijack key in defaults
{
DefaultSearchProviderEnabled = 1;
HomepageIsNewTabPage = 0;
HomepageLocation = "https://www.google.com/";
ILMediaBrowserAudioSplitViewPosition = 140;
ILMediaBrowserExpandedGroups1 = (
"com.apple.Photos.Photos",
"com.apple.Photos.TopLevelAlbums"
);
ILMediaBrowserImageSplitViewPosition = 106;
@sunapi386
sunapi386 / flush.md
Created September 6, 2018 22:56
ddclient not updating?

Flush cache and restart


sudo service ddclient stop
sudo rm /var/cache/ddclient/ddclient.cache
sudo service ddclient startsudo service ddclient stop sudo rm 
@sunapi386
sunapi386 / curl.sh
Last active July 14, 2018 01:25
Convert a base64 string from mongodb as image
# POST the images onto the server
curl --header "Content-Type: application/json" \
--request POST \
--data \
'{"name":"test-image-10","data":"'(base64 -w 0 test-image-10.jpg)'"}' \
"http://localhost:8081/images"
# Retrieve it
wget "localhost:8081/images/5b492c74de7212532da231cc" -O filename.jpg
@sunapi386
sunapi386 / storename-scraper.fish
Last active June 24, 2018 21:56
fish example web scraper tool
#! /usr/bin/fish
# Author: Jason Sun
#
# To extract and parse safeway website buyable items.
# A tutorial in fish shell script.
# I decided to do it in fish because I started playing with wget and checking out the data with vim, and
# seems gluing linux commands were pretty straight forward, quick and easy. Obviously the downside is
# this script is platform dependent. I'm using vanilla Ubuntu 16.04 Linux with the 4.4.0-127-generic kernel.
#
@sunapi386
sunapi386 / stab_and_compare_vid.sh
Created June 23, 2018 22:50
Vidstab demonstration with ffmpeg
#!/bin/bash
#stab_and_compare_vid.sh
#
# usage:
# stab_and_compare_vid.sh shakyvid starttime length
# source:
# https://www.reddit.com/r/ImageStabilization/comments/8t8pg5/simple_script_to_demonstrate_two_methods_of/
ffmpeg -ss $2 -i $1 -t $3 -c:v libx264 -crf 18 -preset slow clip.mp4
@sunapi386
sunapi386 / ifunset.yml
Created June 6, 2018 23:50
Ansible: if env var is not set prompt for value
---
- hosts: localhost
tasks:
- pause:
prompt: "What is the GitLab registration token? "
when: ( lookup('env','GITLAB_REGISTRATION_TOKEN') == "" )
register: reg_token
no_log: true
- set_fact:
gitlab_registration_token: "{{ reg_token['user_input'] }}"
@sunapi386
sunapi386 / README.md
Last active July 30, 2018 11:07 — forked from denilsonsa/README.md
traffic control: slow

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow 3G -l 600ms -p 10%   # slow network on eth0 and setup latency to 600ms packetloss to 10%
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency

slow dsl -b 1mbps # Simulate DSL with a slower speed than the default

#!/bin/bash
echo "$# arguments"
if [ $# -ne 1 ]; then
echo "illegal number of parameters"
exit -1
fi
# Generate a client certificate
export CLIENTNAME="$1"