Skip to content

Instantly share code, notes, and snippets.

View liuyix's full-sized avatar

Yi Liu liuyix

  • Shanghai
  • 17:18 (UTC +08:00)
View GitHub Profile
@davidpelfree
davidpelfree / Util.java
Created May 25, 2017 18:29
Java 8 retry pattern
package util;
import java.util.Arrays;
import java.util.function.Supplier;
public final class Util {
/**
* Retry to run a function a few times, retry if specific exceptions occur.
*

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@takeshixx
takeshixx / hb-test.py
Last active March 9, 2024 13:37
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <takeshix@adversec.com>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@liuyix
liuyix / python-tips.md
Last active December 30, 2015 16:09
python best practise!
@panzi
panzi / mandelbrot.c
Created November 10, 2013 04:40
gcc -lm -Wall -Werror -Wextra -pedantic -std=c99 -O3 -o mandelbrot mandelbrot.c original: http://preshing.com/20110926/high-resolution-mandelbrot-in-obfuscated-python/
#include <stdio.h>
#include <complex.h>
#define dc double complex
dc
Y(dc
V,
dc B,dc c){
return
(cabs (V)<6)?(c?Y(V *V+
B,B,c-1):c):(2+c-4*cpow
@davidcrawford
davidcrawford / unzip.py
Created October 1, 2013 06:16
Python UnzipStream — A file-like wrapper around a gzipped stream that uncompresses as it reads.
import os
import zlib
from StringIO import StringIO
ESTIMATED_COMPRESSION_FACTOR = 2
class UnzipStream(object):
'''
@liuyix
liuyix / shell-script-dir.sh
Last active December 22, 2015 06:39
shell script: 返回当前script所在路径,即使是symlink也可以。
#!/bin/bash
# http://stackoverflow.com/a/422123
# http://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides
dir=$(dirname $(readlink -f "$BASH_SOURCE"))
@mrchief
mrchief / LICENSE.md
Last active March 23, 2024 12:28
Add "Open with Sublime Text 2" to Windows Explorer Context Menu (including folders)

MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@liuyix
liuyix / 0.python_tips_index.md
Last active December 15, 2015 17:59
Python学习备忘

#Python Tips

调用外部命令

detect function type

read large file

@ppmotskula
ppmotskula / remote-unlock-ubuntu-fde.sh
Created April 2, 2013 19:54
Enable remote unlocking of a fully encrypted (dm-crypt/LUKS) Ubuntu 12.10 server via SSH.
#!/bin/bash
cat << ENDMSG
This script enables you to remotely unlock a fully encrypted (dm-crypt/LUKS) Ubuntu 12.10 server via SSH.
The script must be run as root (via sudo).
Contains bits gratefully taken from
http://hacksr.blogspot.com/2012/05/ssh-unlock-with-fully-encrypted-ubuntu.html and
http://blog.nguyenvq.com/2011/09/13/remote-unlocking-luks-encrypted-lvm-using-dropbear-ssh-in-ubuntu/