Skip to content

Instantly share code, notes, and snippets.

@elleryq
elleryq / convert_webm_mkv_to_mp3.sh
Created October 12, 2017 14:03
Convert webm/mkv to mp3
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in $(find . -regex '.*\(webm\|mkv\)$' -print)
do
fn=$(basename "${f}")
extension="${fn##*.}"
f="${fn%.*}"
ffmpeg -i "${fn}" ${f}.mp3
done
@elleryq
elleryq / jquery_click_and_hint.html
Created September 18, 2017 13:21
jQuery 1.3 click and show hint
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load jQuery
google.load("jquery", "1.3");
</script>
<script type="text/javascript">
function doHide() {
//$("#hint").hide();
@elleryq
elleryq / jquery_checkbox_demo.html
Last active September 18, 2017 13:20
jQuery 1.2 checkbox demo
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load jQuery
google.load("jquery", "1.2");
</script>
<script type="text/javascript">
google.setOnLoadCallback(function() {
$("input[name=chk]").change( function() {
@elleryq
elleryq / decorator.py
Created September 6, 2017 01:54 — forked from nealtodd/decorator.py
Python profiling decorator
from cProfile import Profile
import pstats
def profile(sort_args=['cumulative'], print_args=[10]):
profiler = Profile()
def decorator(fn):
def inner(*args, **kwargs):
result = None
@elleryq
elleryq / profile.py
Created September 6, 2017 01:54 — forked from myusuf3/profile.py
Simple little profiling decorator in python.
import cProfile
def profile_this(fn):
def profiled_fn(*args, **kwargs):
# name for profile dump
fpath = fn.__name__ + '.profile'
prof = cProfile.Profile()
ret = prof.runcall(fn, *args, **kwargs)
prof.dump_stats(fpath)
@elleryq
elleryq / gist:e5bd76c3019e7ed066e997dd2faa30a2
Created August 8, 2017 02:56
Upgrade jenkins plugins via random SSH Port. You have to enable random SSHD port in Jenkins security settings.
#!/bin/bash
JENKINS_HOST=jenkins_host
BASE_URL=http://${JENKINS_HOST}/jenkins/
SSH_ENDPOINT=$(curl -Lv ${BASE_URL}login 2>&1 | grep 'X-SSH-Endpoint')
USER=$(whoami)
echo "${SSH_ENDPOINT}"
PORT=$(echo "${SSH_ENDPOINT}" | awk -F: '{printf("%d", $3);}' | tr -d "\n")
echo "port=${PORT}"
echo "user=${USER}"
echo "host=${JENKINS_HOST}"
@elleryq
elleryq / gen_le_cert.sh
Created January 20, 2017 01:56 — forked from pahud/gen_le_cert.sh
letsencrypt cert generator with docker
#!/bin/bash
#
# 1. create a EC2 instance with public IP
# 2. create a A RR in route53 pointing your.domain.com to the public IP
# 3. make sure HTTP/HTTPS ports(80 443) are public to all in security group of this EC2 instance
# 4. make sure docker daemon is running in this EC2 instance
# 5. run this script !
# 6. keys/cert will be generated under /root/letsencrypt/etc/live/
mkdir -p /root/letsencrypt/log /root/letsencrypt/lib /root/letsencrypt/etc
@elleryq
elleryq / ubuntu_ami_locator.py
Last active August 19, 2016 07:29
ubuntu ami locator
"""
Ubuntu AMI locator
Example:
images = ubuntu_ami_locator()
images = ubuntu_ami_locator(zone=u'us-west-2', virtualization_type=u'hvm')
Reference:
* https://github.com/jspiro/node-ubuntu-ami-locator
"""
@elleryq
elleryq / jenkins-cli.sh
Created March 8, 2016 04:04
jenkins-cli.jar wrapper. Download jenkins-cli.jar automatically and wrap it as command.
#!/bin/bash
JENKINS_URL="http://localhost/jenkins"
JENKINS_JAR="/tmp/jenkins-cli.jar"
SSL_CHAR=${JENKINS_URL:4:1}
if [ ! -e $JENKINS_JAR ]; then
WGET="wget $JENKINS_URL/jnlpJars/jenkins-cli.jar -O $JENKINS_JAR"
if [ "$SSL_CHAR" == "s"]; then
@elleryq
elleryq / combine_image.c
Created February 11, 2016 14:42
Use GDI+ to combine image
VOID OnPaint_TryCombineImage(HDC hdc)
{
Graphics graphics(hdc);
Image image(L"qrcode1.bmp");
CLSID clsid;
Status status;
UINT num; // number of image encoders
UINT size; // size, in bytes, of the image encoder array
ImageCodecInfo* pImageCodecInfo;