Skip to content

Instantly share code, notes, and snippets.

View musale's full-sized avatar
Breaking Things 😜

Musale Martin musale

Breaking Things 😜
View GitHub Profile
@musale
musale / docker-destroy-all.sh
Created September 11, 2016 12:37 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@musale
musale / renameFile.py
Last active February 7, 2017 10:23
This is a script that I use to rename my youtube-dl downloaded files. I just remove the extra ids at the end and rename with appropriate extension
# /usr/bin/env python
# ensure that you run the script in the folder containing
# the files to be renamed
import os
for filename in os.listdir("."):
# split the file name into 3 parts
# normal filename looks like this for mp3
# 'Born Again - Third Day-4m_dP2n-5W8.mp3'
@musale
musale / 001.py
Created February 15, 2017 15:05
Sample file for Euler Problem
"""
Project Euler Problem 1
=======================
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
@musale
musale / fix.md
Last active May 31, 2024 19:41
How to fix and recover a “corrupt history file” in zsh
# move to home directory
cd ~

# move the .zsh_history file into another .zsh_history_bad file
mv .zsh_history .zsh_history_bad

# write all printable strings into a new .zsh_history file
strings .zsh_history_bad > .zsh_history
@musale
musale / decode.go
Created March 30, 2017 12:37
Decode SOAP response in golang. Working playground https://play.golang.org/p/4qDLIMhl8A
package main
import (
"encoding/xml"
"fmt"
)
var payload = `
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c2b="http://cps.huawei.com/cpsinterface/c2bpayment">
<soapenv:Header/>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js"></script>
</head>
<body>
@musale
musale / letsencrypt.sh
Created April 13, 2017 07:25
letsencrypt.com commands to setup and renew certificates
# clone the repo for letsencrypt from github
git clone https://github.com/letsencrypt/letsencrypt
# stop nginx
systemctl stop nginx
# get the cert
./letsencrypt-auto certonly --standalone --email your@email.co --agree-tos -d www.yoursite.com
# renewing your cert
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">